füge grundlegende rohrmodelle hinzu
This commit is contained in:
parent
96674df391
commit
90c25e5fd7
6 changed files with 119 additions and 140 deletions
BIN
client/src/main/resources/textures/blocks/pipe.png
Executable file
BIN
client/src/main/resources/textures/blocks/pipe.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 172 B |
Binary file not shown.
Before Width: | Height: | Size: 422 B |
Binary file not shown.
Before Width: | Height: | Size: 531 B |
BIN
client/src/main/resources/textures/blocks/pipe_selected.png
Normal file
BIN
client/src/main/resources/textures/blocks/pipe_selected.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 178 B |
Binary file not shown.
Before Width: | Height: | Size: 406 B |
|
@ -12,8 +12,8 @@ import common.entity.types.EntityLiving;
|
|||
import common.item.CheatTab;
|
||||
import common.model.Model;
|
||||
import common.model.Model.ModelProvider;
|
||||
import common.model.ModelRotation;
|
||||
import common.properties.Property;
|
||||
import common.properties.PropertyBool;
|
||||
import common.tileentity.TileEntity;
|
||||
import common.tileentity.TileEntityPipe;
|
||||
import common.util.BlockPos;
|
||||
|
@ -26,31 +26,77 @@ import common.world.World;
|
|||
import common.world.AWorldServer;
|
||||
|
||||
public class BlockPipe extends Block implements ITileEntityProvider, Directional {
|
||||
public static final PropertyBool DOWN = PropertyBool.create("down");
|
||||
public static final PropertyBool UP = PropertyBool.create("up");
|
||||
public static final PropertyBool NORTH = PropertyBool.create("north");
|
||||
public static final PropertyBool EAST = PropertyBool.create("east");
|
||||
public static final PropertyBool SOUTH = PropertyBool.create("south");
|
||||
public static final PropertyBool WEST = PropertyBool.create("west");
|
||||
|
||||
private static boolean keepInventory;
|
||||
|
||||
public BlockPipe() {
|
||||
super(Material.SOLID);
|
||||
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.DOWN));
|
||||
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.DOWN).withProperty(DOWN, false).withProperty(UP, false).withProperty(NORTH, false).withProperty(EAST, false).withProperty(SOUTH, false).withProperty(WEST, false));
|
||||
this.setTab(CheatTab.TECHNOLOGY);
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.setBlockBounds(0.25f, 0.25f, 0.25f, 0.75f, 0.75f, 0.75f);
|
||||
}
|
||||
|
||||
public void setBlockBounds(IWorldAccess worldIn, BlockPos pos) {
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
public boolean canConnectTo(Block block) {
|
||||
return block instanceof BlockMachine || block instanceof BlockPipe || block instanceof BlockChest;
|
||||
}
|
||||
|
||||
public void getCollisionBoxes(World worldIn, BlockPos pos, State state, BoundingBox mask, List<BoundingBox> list, Entity collidingEntity) {
|
||||
boolean flip = state.getBlock() == this && state.getValue(FACING) == Facing.UP;
|
||||
this.setBlockBounds(0.0F, flip ? 0.375f : 0.0F, 0.0F, 1.0F, flip ? 1.0f : 0.625F, 1.0F);
|
||||
super.getCollisionBoxes(worldIn, pos, state, mask, list, collidingEntity);
|
||||
float f = 0.125F;
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
|
||||
super.getCollisionBoxes(worldIn, pos, state, mask, list, collidingEntity);
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
|
||||
super.getCollisionBoxes(worldIn, pos, state, mask, list, collidingEntity);
|
||||
this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
super.getCollisionBoxes(worldIn, pos, state, mask, list, collidingEntity);
|
||||
this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
|
||||
super.getCollisionBoxes(worldIn, pos, state, mask, list, collidingEntity);
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
public State getState(State state, IWorldAccess world, BlockPos pos) {
|
||||
return state.withProperty(DOWN, this.canConnectTo(world.getState(pos.down()).getBlock()))
|
||||
.withProperty(UP, this.canConnectTo(world.getState(pos.up()).getBlock()))
|
||||
.withProperty(NORTH, this.canConnectTo(world.getState(pos.north()).getBlock()))
|
||||
.withProperty(EAST, this.canConnectTo(world.getState(pos.east()).getBlock()))
|
||||
.withProperty(SOUTH, this.canConnectTo(world.getState(pos.south()).getBlock()))
|
||||
.withProperty(WEST, this.canConnectTo(world.getState(pos.west()).getBlock()));
|
||||
}
|
||||
|
||||
public State getItemState() {
|
||||
return this.getState().withProperty(FACING, Facing.EAST).withProperty(DOWN, false).withProperty(UP, false).withProperty(NORTH, false).withProperty(EAST, true).withProperty(SOUTH, false).withProperty(WEST, true);
|
||||
}
|
||||
|
||||
protected Property[] getUnsavedProperties() {
|
||||
return new Property[] {NORTH, SOUTH, DOWN, UP, WEST, EAST};
|
||||
}
|
||||
|
||||
public void setBlockBounds(IWorldAccess world, BlockPos pos) {
|
||||
this.setBlockBounds(this.canConnectTo(world.getState(pos.west()).getBlock()) ? 0.0f : 0.25f, this.canConnectTo(world.getState(pos.down()).getBlock()) ? 0.0f : 0.25f,
|
||||
this.canConnectTo(world.getState(pos.north()).getBlock()) ? 0.0f : 0.25f, this.canConnectTo(world.getState(pos.east()).getBlock()) ? 1.0f : 0.75f,
|
||||
this.canConnectTo(world.getState(pos.up()).getBlock()) ? 1.0f : 0.75f, this.canConnectTo(world.getState(pos.south()).getBlock()) ? 1.0f : 0.75f);
|
||||
}
|
||||
|
||||
public void getCollisionBoxes(World world, BlockPos pos, State state, BoundingBox mask, List<BoundingBox> list, Entity collidingEntity) {
|
||||
this.setBlockBounds(0.25f, 0.25f, 0.25f, 0.75f, 0.75f, 0.75f);
|
||||
super.getCollisionBoxes(world, pos, state, mask, list, collidingEntity);
|
||||
if(this.canConnectTo(world.getState(pos.west()).getBlock())) {
|
||||
this.setBlockBounds(0.0f, 0.25f, 0.25f, 0.25f, 0.75f, 0.75f);
|
||||
super.getCollisionBoxes(world, pos, state, mask, list, collidingEntity);
|
||||
}
|
||||
if(this.canConnectTo(world.getState(pos.down()).getBlock())) {
|
||||
this.setBlockBounds(0.25f, 0.0f, 0.25f, 0.75f, 0.25f, 0.75f);
|
||||
super.getCollisionBoxes(world, pos, state, mask, list, collidingEntity);
|
||||
}
|
||||
if(this.canConnectTo(world.getState(pos.north()).getBlock())) {
|
||||
this.setBlockBounds(0.25f, 0.25f, 0.0f, 0.75f, 0.75f, 0.25f);
|
||||
super.getCollisionBoxes(world, pos, state, mask, list, collidingEntity);
|
||||
}
|
||||
if(this.canConnectTo(world.getState(pos.east()).getBlock())) {
|
||||
this.setBlockBounds(0.75f, 0.25f, 0.25f, 1.0f, 0.75f, 0.75f);
|
||||
super.getCollisionBoxes(world, pos, state, mask, list, collidingEntity);
|
||||
}
|
||||
if(this.canConnectTo(world.getState(pos.up()).getBlock())) {
|
||||
this.setBlockBounds(0.25f, 0.75f, 0.25f, 0.75f, 1.0f, 0.75f);
|
||||
super.getCollisionBoxes(world, pos, state, mask, list, collidingEntity);
|
||||
}
|
||||
if(this.canConnectTo(world.getState(pos.south()).getBlock())) {
|
||||
this.setBlockBounds(0.25f, 0.25f, 0.75f, 0.75f, 0.75f, 1.0f);
|
||||
super.getCollisionBoxes(world, pos, state, mask, list, collidingEntity);
|
||||
}
|
||||
this.setBlockBounds(0.25f, 0.25f, 0.25f, 0.75f, 0.75f, 0.75f);
|
||||
}
|
||||
|
||||
public State getPlacedState(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer) {
|
||||
|
@ -61,29 +107,28 @@ public class BlockPipe extends Block implements ITileEntityProvider, Directional
|
|||
return new TileEntityPipe();
|
||||
}
|
||||
|
||||
public boolean onUse(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ) {
|
||||
if(worldIn.client) {
|
||||
public boolean onUse(World world, BlockPos pos, State state, EntityNPC player, Facing side, float hitX, float hitY, float hitZ) {
|
||||
if(world.client)
|
||||
return true;
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if(te instanceof TileEntityPipe) {
|
||||
state = state.cycleProperty(FACING);
|
||||
keepInventory = true;
|
||||
world.setState(pos, state, 3);
|
||||
world.setState(pos, state, 3);
|
||||
keepInventory = false;
|
||||
te.validate();
|
||||
world.setTileEntity(pos, te);
|
||||
}
|
||||
else {
|
||||
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||
|
||||
if(tileentity instanceof TileEntityPipe) {
|
||||
// TODO: edit direction
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void onRemoved(AWorldServer worldIn, BlockPos pos, State state) {
|
||||
if(!keepInventory) {
|
||||
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||
|
||||
if(tileentity instanceof TileEntityPipe) {
|
||||
if(tileentity instanceof TileEntityPipe)
|
||||
dropItems(worldIn, pos, (TileEntityPipe)tileentity);
|
||||
}
|
||||
|
||||
super.onRemoved(worldIn, pos, state);
|
||||
}
|
||||
|
||||
public boolean isFullCube() {
|
||||
|
@ -105,7 +150,7 @@ public class BlockPipe extends Block implements ITileEntityProvider, Directional
|
|||
}
|
||||
|
||||
protected Property[] getProperties() {
|
||||
return new Property[] {FACING};
|
||||
return new Property[] {FACING, DOWN, UP, NORTH, EAST, WEST, SOUTH};
|
||||
}
|
||||
|
||||
public boolean isMagnetic() {
|
||||
|
@ -114,108 +159,42 @@ public class BlockPipe extends Block implements ITileEntityProvider, Directional
|
|||
|
||||
@Clientside
|
||||
public Model getModel(ModelProvider provider, String name, State state) {
|
||||
if(state.getValue(FACING).getAxis().isVertical())
|
||||
return provider.getModel("pipe_outside")
|
||||
.add(0, 10, 0, 16, 11, 16)
|
||||
.d().uv(0, 0, 16, 16).noCull()
|
||||
.u("pipe_inside").uv(0, 0, 16, 16).noCull()
|
||||
.n().uv(0, 5, 16, 6).noCull()
|
||||
.s().uv(0, 5, 16, 6).noCull()
|
||||
.w().uv(0, 5, 16, 6).noCull()
|
||||
.e().uv(0, 5, 16, 6).noCull()
|
||||
.add(0, 11, 0, 2, 16, 16)
|
||||
.d().uv(0, 0, 2, 16).noCull()
|
||||
.u("pipe_top").uv(0, 0, 2, 16).noCull()
|
||||
.n().uv(0, 0, 2, 5).noCull()
|
||||
.s().uv(0, 0, 2, 5).noCull()
|
||||
.w().uv(0, 0, 16, 5).noCull()
|
||||
.e().uv(0, 0, 16, 5).noCull()
|
||||
.add(14, 11, 0, 16, 16, 16)
|
||||
.d().uv(14, 0, 16, 16).noCull()
|
||||
.u("pipe_top").uv(14, 0, 16, 16).noCull()
|
||||
.n().uv(14, 0, 16, 5).noCull()
|
||||
.s().uv(14, 0, 16, 5).noCull()
|
||||
.w().uv(0, 0, 16, 5).noCull()
|
||||
.e().uv(0, 0, 16, 5).noCull()
|
||||
.add(2, 11, 0, 14, 16, 2)
|
||||
.d().uv(2, 0, 14, 2).noCull()
|
||||
.u("pipe_top").uv(2, 0, 14, 2).noCull()
|
||||
.n().uv(2, 0, 14, 5).noCull()
|
||||
.s().uv(2, 0, 14, 5).noCull()
|
||||
.w().uv(0, 0, 2, 5).noCull()
|
||||
.e().uv(0, 0, 2, 5).noCull()
|
||||
.add(2, 11, 14, 14, 16, 16)
|
||||
.d().uv(2, 14, 14, 16).noCull()
|
||||
.u("pipe_top").uv(2, 14, 14, 16).noCull()
|
||||
.n().uv(2, 0, 14, 5).noCull()
|
||||
.s().uv(2, 0, 14, 5).noCull()
|
||||
.w().uv(14, 0, 16, 5).noCull()
|
||||
.e().uv(14, 0, 16, 5).noCull()
|
||||
.add(4, 4, 4, 12, 10, 12)
|
||||
.d().uv(4, 4, 12, 12).noCull()
|
||||
.u().uv(4, 4, 12, 12).noCull()
|
||||
.n().uv(4, 6, 12, 12).noCull()
|
||||
.s().uv(4, 6, 12, 12).noCull()
|
||||
.w().uv(4, 6, 12, 12).noCull()
|
||||
.e().uv(4, 6, 12, 12).noCull()
|
||||
.add(6, 0, 6, 10, 4, 10)
|
||||
.d().uv(6, 6, 10, 10).noCull()
|
||||
.u().uv(6, 6, 10, 10).noCull()
|
||||
.n().uv(6, 12, 10, 16).noCull()
|
||||
.s().uv(6, 12, 10, 16).noCull()
|
||||
.w().uv(6, 12, 10, 16).noCull()
|
||||
.e().uv(6, 12, 10, 16).noCull().rotate(state.getValue(FACING) == Facing.UP ? ModelRotation.X180_Y0 : ModelRotation.X0_Y0);
|
||||
else
|
||||
return provider.getModel("pipe_outside")
|
||||
.add(0, 10, 0, 16, 11, 16)
|
||||
.d().uv(0, 0, 16, 16).noCull()
|
||||
.u("pipe_inside").uv(0, 0, 16, 16).noCull()
|
||||
.n().uv(0, 5, 16, 6).noCull()
|
||||
.s().uv(0, 5, 16, 6).noCull()
|
||||
.w().uv(0, 5, 16, 6).noCull()
|
||||
.e().uv(0, 5, 16, 6).noCull()
|
||||
.add(0, 11, 0, 2, 16, 16)
|
||||
.d().uv(0, 0, 2, 16).noCull()
|
||||
.u("pipe_top").uv(0, 0, 2, 16).noCull()
|
||||
.n().uv(0, 0, 2, 5).noCull()
|
||||
.s().uv(0, 0, 2, 5).noCull()
|
||||
.w().uv(0, 0, 16, 5).noCull()
|
||||
.e().uv(0, 0, 16, 5).noCull()
|
||||
.add(14, 11, 0, 16, 16, 16)
|
||||
.d().uv(14, 0, 16, 16).noCull()
|
||||
.u("pipe_top").uv(14, 0, 16, 16).noCull()
|
||||
.n().uv(14, 0, 16, 5).noCull()
|
||||
.s().uv(14, 0, 16, 5).noCull()
|
||||
.w().uv(0, 0, 16, 5).noCull()
|
||||
.e().uv(0, 0, 16, 5).noCull()
|
||||
.add(2, 11, 0, 14, 16, 2)
|
||||
.d().uv(2, 0, 14, 2).noCull()
|
||||
.u("pipe_top").uv(2, 0, 14, 2).noCull()
|
||||
.n().uv(2, 0, 14, 5).noCull()
|
||||
.s().uv(2, 0, 14, 5).noCull()
|
||||
.w().uv(0, 0, 2, 5).noCull()
|
||||
.e().uv(0, 0, 2, 5).noCull()
|
||||
.add(2, 11, 14, 14, 16, 16)
|
||||
.d().uv(2, 14, 14, 16).noCull()
|
||||
.u("pipe_top").uv(2, 14, 14, 16).noCull()
|
||||
.n().uv(2, 0, 14, 5).noCull()
|
||||
.s().uv(2, 0, 14, 5).noCull()
|
||||
.w().uv(14, 0, 16, 5).noCull()
|
||||
.e().uv(14, 0, 16, 5).noCull()
|
||||
.add(4, 4, 4, 12, 10, 12)
|
||||
.d().uv(4, 4, 12, 12).noCull()
|
||||
.u().uv(4, 4, 12, 12).noCull()
|
||||
.n().uv(4, 6, 12, 12).noCull()
|
||||
.s().uv(4, 6, 12, 12).noCull()
|
||||
.w().uv(4, 6, 12, 12).noCull()
|
||||
.e().uv(4, 6, 12, 12).noCull()
|
||||
.add(6, 4, 0, 10, 8, 4)
|
||||
.d().uv(6, 0, 10, 4).noCull()
|
||||
.u().uv(6, 0, 10, 4).noCull()
|
||||
.n().uv(6, 8, 10, 12).noCull()
|
||||
.s().uv(6, 8, 10, 12).noCull()
|
||||
.w().uv(0, 8, 4, 12).noCull()
|
||||
.e().uv(0, 8, 4, 12).noCull()
|
||||
.rotate(ModelRotation.getNorthRot(state.getValue(FACING)));
|
||||
Facing dir = state.getValue(FACING);
|
||||
boolean down = state.getValue(DOWN);
|
||||
boolean up = state.getValue(UP);
|
||||
boolean north = state.getValue(NORTH);
|
||||
boolean south = state.getValue(SOUTH);
|
||||
boolean west = state.getValue(WEST);
|
||||
boolean east = state.getValue(EAST);
|
||||
String sel = name + "_selected";
|
||||
Model model = provider.getModel(name);
|
||||
if(!down || !up || !north || !south || !west || !east) {
|
||||
model.add(4, 4, 4, 12, 12, 12);
|
||||
if(!down)
|
||||
model.d(dir == Facing.DOWN ? sel : name).noCull();
|
||||
if(!up)
|
||||
model.u(dir == Facing.UP ? sel : name).noCull();
|
||||
if(!north)
|
||||
model.n(dir == Facing.NORTH ? sel : name).noCull();
|
||||
if(!south)
|
||||
model.s(dir == Facing.SOUTH ? sel : name).noCull();
|
||||
if(!west)
|
||||
model.w(dir == Facing.WEST ? sel : name).noCull();
|
||||
if(!east)
|
||||
model.e(dir == Facing.EAST ? sel : name).noCull();
|
||||
}
|
||||
if(down)
|
||||
model.add(4, 0, 4, 12, 4, 12).nswe(dir == Facing.DOWN ? sel : name).uv(4, 4, 12, 8).noCull();
|
||||
if(up)
|
||||
model.add(4, 12, 4, 12, 16, 12).nswe(dir == Facing.UP ? sel : name).uv(4, 8, 12, 12).noCull();
|
||||
if(north)
|
||||
model.add(4, 4, 0, 12, 12, 4).d(dir == Facing.NORTH ? sel : name).uv(4, 4, 12, 8).noCull().u(dir == Facing.NORTH ? sel : name).uv(4, 8, 12, 12).noCull().w(dir == Facing.NORTH ? sel : name).uv(8, 4, 12, 12).noCull().e(dir == Facing.NORTH ? sel : name).uv(4, 4, 8, 12).noCull();
|
||||
if(south)
|
||||
model.add(4, 4, 12, 12, 12, 16).d(dir == Facing.SOUTH ? sel : name).uv(4, 8, 12, 12).noCull().u(dir == Facing.SOUTH ? sel : name).uv(4, 4, 12, 8).noCull().w(dir == Facing.SOUTH ? sel : name).uv(4, 4, 8, 12).noCull().e(dir == Facing.SOUTH ? sel : name).uv(8, 4, 12, 12).noCull();
|
||||
if(west)
|
||||
model.add(0, 4, 4, 4, 12, 12).du(dir == Facing.WEST ? sel : name).uv(8, 4, 12, 12).noCull().n(dir == Facing.WEST ? sel : name).uv(4, 4, 8, 12).noCull().s(dir == Facing.WEST ? sel : name).uv(8, 4, 12, 12).noCull();
|
||||
if(east)
|
||||
model.add(12, 4, 4, 16, 12, 12).du(dir == Facing.EAST ? sel : name).uv(4, 4, 8, 12).noCull().n(dir == Facing.EAST ? sel : name).uv(8, 4, 12, 12).noCull().s(dir == Facing.EAST ? sel : name).uv(4, 4, 8, 12).noCull();
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue