From 90c25e5fd7f56229766bd149a3a9bbf98798f988 Mon Sep 17 00:00:00 2001 From: Sen Date: Wed, 13 Aug 2025 13:23:11 +0200 Subject: [PATCH] =?UTF-8?q?f=C3=BCge=20grundlegende=20rohrmodelle=20hinzu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/textures/blocks/pipe.png | Bin 0 -> 172 bytes .../resources/textures/blocks/pipe_inside.png | Bin 422 -> 0 bytes .../textures/blocks/pipe_outside.png | Bin 531 -> 0 bytes .../textures/blocks/pipe_selected.png | Bin 0 -> 178 bytes .../resources/textures/blocks/pipe_top.png | Bin 406 -> 0 bytes .../java/common/block/tech/BlockPipe.java | 259 ++++++++---------- 6 files changed, 119 insertions(+), 140 deletions(-) create mode 100755 client/src/main/resources/textures/blocks/pipe.png delete mode 100755 client/src/main/resources/textures/blocks/pipe_inside.png delete mode 100755 client/src/main/resources/textures/blocks/pipe_outside.png create mode 100644 client/src/main/resources/textures/blocks/pipe_selected.png delete mode 100755 client/src/main/resources/textures/blocks/pipe_top.png diff --git a/client/src/main/resources/textures/blocks/pipe.png b/client/src/main/resources/textures/blocks/pipe.png new file mode 100755 index 0000000000000000000000000000000000000000..46f6f94e24cd443841e913b8e505587fd696fbd1 GIT binary patch literal 172 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkEbHUgGKN%KnmrmrIX*d12Oippd1fi(`nz>Er|n)}DwX|Jqwx5<>T+ zot28I5>QZ4c~bA;aiTuy=te1rE*asai3T3L2Shu*bRHArV5qYdf9!EZSqEqcgQu&X J%Q~loCIC0)F8Kfe literal 0 HcmV?d00001 diff --git a/client/src/main/resources/textures/blocks/pipe_inside.png b/client/src/main/resources/textures/blocks/pipe_inside.png deleted file mode 100755 index 24e8eae30680b1b44c1cf5704f366d920e6a4436..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 422 zcmV;X0a^ZuP)JgNPtAi3sMLL~K`%v^-(K&LXu%&&zp2JXH{bg5D%E4Y9D z&5R~5RYhhl@J=9$5|Sl%$2CH!=-k1;>P~{P!#w4|h9Hu*%(OQdX+hb*+t*_Z_If_1!dAt>}54oagxy+D?y)dZ>={_qqGe7WUq0t$nTR8Aw?>zXzy{cA=``59XP)00FZ}L_t(I%XO2@ZsRZvgg?=;l)7ny zUivl~$5lShjD$_JEjw2xiM1+I2i$Hq z&gV0m&F0smloIQ@VrJA@ky@*F?KO_0pOI3LM+&VqR26`nvzwN4b~95- zPMCB4GxK}_w%e@}^jPP4=5o3CC@(KBlu{o1)4}iW z@4qr0hJo|>%skJ85PXD=8HVAZFoeK7&mLuW{_X9}4eLriK0e&wzSi=SHOBZ)_Ay4L zX<}IxVvLkhevK-f?Ql3aQ7OfD;%9t+uemGepm7{I9*^Fof2>}8U*>t{dcC5md;?in VG5*`OQ8fSn002ovPDHLkV1gB(^Hu-= diff --git a/client/src/main/resources/textures/blocks/pipe_selected.png b/client/src/main/resources/textures/blocks/pipe_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..e78f65af9fe77f7a80a963fa4e10c3d6a8f77a7e GIT binary patch literal 178 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkEbHUgGKN%KnmrmrGYS{P~AnKp}fi7sn8b)5!@EtUWK7{!2>yYj0~w z2;Eb4R*KC{rz*g~!{fyN2@@v#Khl+K+8|=7=5;t>f>eXHz)Rs?WuQCOW=cM8a%(sb PG>XB~)z4*}Q$iB})X_6A literal 0 HcmV?d00001 diff --git a/client/src/main/resources/textures/blocks/pipe_top.png b/client/src/main/resources/textures/blocks/pipe_top.png deleted file mode 100755 index e0dbe96acb75ac539a45387910c82145bcf3fcb7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 406 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL8%hgh?3y^w370~qEv=}#LT=BJwMkFg)(D3 zQ$0gN_s>q|Kx0`wT^vI!{HIQi+;l{N!}V^M)#m`ovvdCDw}!V*`}ehV)$9cdheYpK z^cBrpo^xC6vyJ!dZAJID$6Qx^z3bE_onPj%^K0*iKJQ`kxE!)-)g+zMOEkEyezuvu zNoVP6tF4QZx7Xe-zE{2S^{-NfKYfn{+_Q8VelMS4|MZU$!$CPwBZdzT6k4`8Y;afg z6k^=Zb8i}hdxAt;K7$7nQ1%3iz#2xo`Ta^a79VnS__^-=@9U~JT7UJ_ys#5^6Sz_6 z#J$Mh`#3L{^fK@|$R5ku;C|F-#xl=4pKX3IZOim!QonX-+2x!yJLlTws#LdbXWTKx yuwaR!fS5^JukK?Wd$Vh1hkiU_|9P+aC$r8Qu`8GJi}iuQ#^CAd=d#Wzp$PyhXQk}` diff --git a/common/src/main/java/common/block/tech/BlockPipe.java b/common/src/main/java/common/block/tech/BlockPipe.java index ec498e20..e01ce372 100755 --- a/common/src/main/java/common/block/tech/BlockPipe.java +++ b/common/src/main/java/common/block/tech/BlockPipe.java @@ -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 boolean canConnectTo(Block block) { + return block instanceof BlockMachine || block instanceof BlockPipe || block instanceof BlockChest; + } + + 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 void setBlockBounds(IWorldAccess worldIn, BlockPos pos) { - this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + 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 getCollisionBoxes(World worldIn, BlockPos pos, State state, BoundingBox mask, List 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 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 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) { - return true; - } - else { - TileEntity tileentity = worldIn.getTileEntity(pos); - - if(tileentity instanceof TileEntityPipe) { - // TODO: edit direction - } - + 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); } + return true; } public void onRemoved(AWorldServer worldIn, BlockPos pos, State state) { - TileEntity tileentity = worldIn.getTileEntity(pos); - - if(tileentity instanceof TileEntityPipe) { - dropItems(worldIn, pos, (TileEntityPipe)tileentity); + if(!keepInventory) { + TileEntity tileentity = worldIn.getTileEntity(pos); + 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; } }