From 552acd6baa635ce5bc4b7bbf72fdf81f13256016 Mon Sep 17 00:00:00 2001 From: stfwi Date: Sat, 5 Dec 2020 13:45:19 +0100 Subject: [PATCH] Pole and T-Support directional auto placement added (issue #139). Door shapes improved. Crafting Table JEI slot count fixed. Window placement handling improved. --- gradle.properties | 4 +- meta/update.json | 5 +- readme.md | 7 +++ .../java/wile/engineersdecor/ModContent.java | 44 +++++++++++++----- .../wile/engineersdecor/blocks/EdBreaker.java | 3 +- .../wile/engineersdecor/blocks/EdChair.java | 5 +- .../engineersdecor/blocks/EdChimneyBlock.java | 2 +- .../blocks/EdCraftingTable.java | 6 +-- .../engineersdecor/blocks/EdDoorBlock.java | 8 ++++ .../blocks/EdDoubleGateBlock.java | 4 +- .../wile/engineersdecor/blocks/EdDropper.java | 6 +-- .../blocks/EdElectricalFurnace.java | 4 +- .../engineersdecor/blocks/EdFluidBarrel.java | 4 +- .../engineersdecor/blocks/EdFluidFunnel.java | 2 +- .../wile/engineersdecor/blocks/EdFreezer.java | 8 ++-- .../wile/engineersdecor/blocks/EdFurnace.java | 6 +-- .../engineersdecor/blocks/EdHatchBlock.java | 4 +- .../wile/engineersdecor/blocks/EdHopper.java | 16 ++++--- .../blocks/EdHorizontalSupportBlock.java | 30 ++++++++++-- .../engineersdecor/blocks/EdLabeledCrate.java | 10 ++-- .../wile/engineersdecor/blocks/EdMilker.java | 8 ++-- .../blocks/EdMineralSmelter.java | 6 +-- .../wile/engineersdecor/blocks/EdPlacer.java | 6 +-- .../engineersdecor/blocks/EdRailingBlock.java | 4 +- .../engineersdecor/blocks/EdSolarPanel.java | 3 +- .../blocks/EdStraightPoleBlock.java | 46 +++++++++++++++++-- .../engineersdecor/blocks/EdTestBlock.java | 5 +- .../engineersdecor/blocks/EdTreeCutter.java | 3 +- .../blocks/EdWasteIncinerator.java | 6 +-- .../engineersdecor/blocks/EdWindowBlock.java | 29 +++++++++++- .../engineersdecor/eapi/jei/JEIPlugin.java | 4 +- .../libmc/blocks/StandardDoorBlock.java | 38 ++++++++++----- .../libmc/detail/Inventories.java | 1 + 33 files changed, 244 insertions(+), 93 deletions(-) diff --git a/gradle.properties b/gradle.properties index 4ce95e5..a9fd8e5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.daemon=false org.gradle.jvmargs=-Xmx8G version_minecraft=1.16.4 -version_forge_minecraft=1.16.4-35.0.2 +version_forge_minecraft=1.16.4-35.1.10 version_fml_mappings=20201028-1.16.3 version_jei=1.16.4:7.6.0.58 -version_engineersdecor=1.1.4 +version_engineersdecor=1.1.5 diff --git a/meta/update.json b/meta/update.json index 58fd1e1..3bedf87 100644 --- a/meta/update.json +++ b/meta/update.json @@ -1,6 +1,7 @@ { "homepage": "https://www.curseforge.com/minecraft/mc-mods/engineers-decor/", "1.16.4": { + "1.1.5": "[F] Fixed Crafting Table JEI storage slot count.\n[F] Fixed Factory Hopper removed item collection dupe bug (issue #146, thx FatheredPuma81).\n[F] Increased device GUI access ranges beyond the player block selection range.\n[A] Window placement handling improved.\n[M] Steel/Wood Pole and Double-T support placement improved (issue #139, thx Biviho).\n[M] Metal Sliding Door bottom/top shape when opened added.", "1.1.4": "[R] Release build v1.1.4.\n[F] Solar Panel balancing threshold tuned.\n[F] Fixed Catwalk default state (issue #140, thx hvdklauw).\n[M] Updated lang ru_ru file (PR#137, Smollet777).\n[M] Factory Dropper: Added Ignore-External-Redstone mode.", "1.1.4-b2": "[A] Steel Catwalks added (top and bottom aligned).\n[A] Steel Railings added.\n[F] Fixed Empty Fluid Barrel crafting crash (ty inflamedsebi).\n[A] Added Solar Panel power balancing.\n[M] GUI Button tooltip delay reduced to 800ms.\n[M] Hopper and Placer: Added \"Redstone ignored\" mode, changed icons from signal-like to Redstone-Torch-like.\n[M] Treated Wood Ladder now crafted from Old Industrial Wood, as Treated Wood Sticks now count as normal Sticks.", "1.1.4-b1": "[U] Ported to 1.16.4.", @@ -19,7 +20,7 @@ "1.1.2-b1": "[U] Ported to MC1.16.2." }, "promos": { - "1.16.4-recommended": "1.1.4", - "1.16.4-latest": "1.1.4" + "1.16.4-recommended": "1.1.5", + "1.16.4-latest": "1.1.5" } } \ No newline at end of file diff --git a/readme.md b/readme.md index e997e81..a4d09c8 100644 --- a/readme.md +++ b/readme.md @@ -11,6 +11,13 @@ Mod sources for Minecraft version 1.16.x. ## Version history + - v1.1.5 [F] Fixed Crafting Table JEI storage slot count. + [F] Fixed Factory Hopper removed item collection dupe bug (issue #146, thx FatheredPuma81). + [F] Increased device GUI access ranges beyond the player block selection range. + [A] Window placement handling improved. + [M] Steel/Wood Pole and Double-T support placement improved (issue #139, thx Biviho). + [M] Metal Sliding Door bottom/top shape when opened added. + - v1.1.4 [R] Release build v1.1.4. [F] Solar Panel balancing threshold tuned. [F] Fixed Catwalk default state (issue #140, thx hvdklauw). diff --git a/src/main/java/wile/engineersdecor/ModContent.java b/src/main/java/wile/engineersdecor/ModContent.java index 9b38a52..688bf58 100644 --- a/src/main/java/wile/engineersdecor/ModContent.java +++ b/src/main/java/wile/engineersdecor/ModContent.java @@ -311,8 +311,20 @@ public class ModContent public static final EdDoorBlock METAL_SLIDING_DOOR = (EdDoorBlock)(new EdDoorBlock( DecorBlock.CFG_TRANSLUCENT|DecorBlock.CFG_HORIZIONTAL, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(1.5f, 12f).sound(SoundType.METAL).notSolid(), - Auxiliaries.getPixeledAABB(15,0,7, 16,16,9), - Auxiliaries.getPixeledAABB( 0,0,7, 16,16,9), + new AxisAlignedBB[]{ + Auxiliaries.getPixeledAABB(15, 0.0,6, 16,16.0,10), + Auxiliaries.getPixeledAABB( 0,15.5,6, 16,16.0,10), + }, + new AxisAlignedBB[]{ + Auxiliaries.getPixeledAABB(15, 0.0,6, 16,16.0,10), + Auxiliaries.getPixeledAABB( 0, 0.0,6, 16, 0.3,10), + }, + new AxisAlignedBB[]{ + Auxiliaries.getPixeledAABB( 0,0,7, 16,16,9) + }, + new AxisAlignedBB[]{ + Auxiliaries.getPixeledAABB( 0,0,7, 16,16,9) + }, SoundEvents.BLOCK_IRON_DOOR_OPEN, SoundEvents.BLOCK_IRON_DOOR_CLOSE )).setRegistryName(new ResourceLocation(MODID, "metal_sliding_door")); @@ -342,6 +354,8 @@ public class ModContent public static final EdDoorBlock OLD_INDUSTRIAL_WOOD_DOOR = (EdDoorBlock)(new EdDoorBlock( DecorBlock.CFG_DEFAULT, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1.5f, 12f).sound(SoundType.WOOD).notSolid(), + Auxiliaries.getPixeledAABB(15,0, 0, 16,16,16), + Auxiliaries.getPixeledAABB( 0,0,13, 16,16,16), SoundEvents.BLOCK_WOODEN_DOOR_OPEN, SoundEvents.BLOCK_WOODEN_DOOR_CLOSE )).setRegistryName(new ResourceLocation(MODID, "old_industrial_wood_door")); @@ -444,14 +458,13 @@ public class ModContent public static final EdWindowBlock TREATED_WOOD_WINDOW = (EdWindowBlock)(new EdWindowBlock( DecorBlock.CFG_LOOK_PLACEMENT, - Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f) - .sound(SoundType.GLASS).notSolid().setBlocksVision((s,w,p)->false), + Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD).notSolid(), Auxiliaries.getPixeledAABB(0,0,7, 16,16,9) )).setRegistryName(new ResourceLocation(MODID, "treated_wood_window")); public static final EdWindowBlock STEEL_FRAMED_WINDOW = (EdWindowBlock)(new EdWindowBlock( DecorBlock.CFG_LOOK_PLACEMENT, - Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.GLASS).notSolid(), + Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), Auxiliaries.getPixeledAABB(0,0,7.5, 16,16,8.5) )).setRegistryName(new ResourceLocation(MODID, "steel_framed_window")); @@ -460,43 +473,50 @@ public class ModContent public static final EdStraightPoleBlock TREATED_WOOD_POLE = (EdStraightPoleBlock)(new EdStraightPoleBlock( DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_FLIP_PLACEMENT_IF_SAME, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD).notSolid(), - Auxiliaries.getPixeledAABB(5.8,5.8,0, 10.2,10.2,16) + Auxiliaries.getPixeledAABB(5.8,5.8,0, 10.2,10.2,16), + null )).setRegistryName(new ResourceLocation(MODID, "treated_wood_pole")); public static final EdStraightPoleBlock TREATED_WOOD_POLE_HEAD = (EdStraightPoleBlock)(new EdStraightPoleBlock( DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_FLIP_PLACEMENT_IF_SAME, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD).notSolid(), - Auxiliaries.getPixeledAABB(5.8,5.8,0, 10.2,10.2,16) + Auxiliaries.getPixeledAABB(5.8,5.8,0, 10.2,10.2,16), + TREATED_WOOD_POLE )).setRegistryName(new ResourceLocation(MODID, "treated_wood_pole_head")); public static final EdStraightPoleBlock TREATED_WOOD_POLE_SUPPORT = (EdStraightPoleBlock)(new EdStraightPoleBlock( DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_FLIP_PLACEMENT_IF_SAME, Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD).notSolid(), - Auxiliaries.getPixeledAABB(5.8,5.8,0, 10.2,10.2,16) + Auxiliaries.getPixeledAABB(5.8,5.8,0, 10.2,10.2,16), + TREATED_WOOD_POLE )).setRegistryName(new ResourceLocation(MODID, "treated_wood_pole_support")); public static final EdStraightPoleBlock THIN_STEEL_POLE = (EdStraightPoleBlock)(new EdStraightPoleBlock( DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), - Auxiliaries.getPixeledAABB(6,6,0, 10,10,16) + Auxiliaries.getPixeledAABB(6,6,0, 10,10,16), + null )).setRegistryName(new ResourceLocation(MODID, "thin_steel_pole")); public static final EdStraightPoleBlock THIN_STEEL_POLE_HEAD = (EdStraightPoleBlock)(new EdStraightPoleBlock( DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_FLIP_PLACEMENT_IF_SAME, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), - Auxiliaries.getPixeledAABB(6,6,0, 10,10,16) + Auxiliaries.getPixeledAABB(6,6,0, 10,10,16), + THIN_STEEL_POLE )).setRegistryName(new ResourceLocation(MODID, "thin_steel_pole_head")); public static final EdStraightPoleBlock THICK_STEEL_POLE = (EdStraightPoleBlock)(new EdStraightPoleBlock( DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), - Auxiliaries.getPixeledAABB(5,5,0, 11,11,16) + Auxiliaries.getPixeledAABB(5,5,0, 11,11,16), + null )).setRegistryName(new ResourceLocation(MODID, "thick_steel_pole")); public static final EdStraightPoleBlock THICK_STEEL_POLE_HEAD = (EdStraightPoleBlock)(new EdStraightPoleBlock( DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_FLIP_PLACEMENT_IF_SAME, Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).notSolid(), - Auxiliaries.getPixeledAABB(5,5,0, 11,11,16) + Auxiliaries.getPixeledAABB(5,5,0, 11,11,16), + THICK_STEEL_POLE )).setRegistryName(new ResourceLocation(MODID, "thick_steel_pole_head")); public static final EdHorizontalSupportBlock STEEL_DOUBLE_T_SUPPORT = (EdHorizontalSupportBlock)(new EdHorizontalSupportBlock( diff --git a/src/main/java/wile/engineersdecor/blocks/EdBreaker.java b/src/main/java/wile/engineersdecor/blocks/EdBreaker.java index 1684e9b..07751dd 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdBreaker.java +++ b/src/main/java/wile/engineersdecor/blocks/EdBreaker.java @@ -124,9 +124,10 @@ public class EdBreaker @SuppressWarnings("deprecation") public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { + if(world.isRemote()) return ActionResultType.SUCCESS; TileEntity te = world.getTileEntity(pos); if(te instanceof BreakerTileEntity) ((BreakerTileEntity)te).state_message(player); - return ActionResultType.SUCCESS; + return ActionResultType.CONSUME; } } diff --git a/src/main/java/wile/engineersdecor/blocks/EdChair.java b/src/main/java/wile/engineersdecor/blocks/EdChair.java index b48785f..3e58836 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdChair.java +++ b/src/main/java/wile/engineersdecor/blocks/EdChair.java @@ -57,8 +57,9 @@ public class EdChair public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) { if(!sitting_enabled) return ActionResultType.PASS; - if(!world.isRemote) EntityChair.sit(world, player, pos); - return ActionResultType.SUCCESS; + if(world.isRemote()) return ActionResultType.SUCCESS; + EntityChair.sit(world, player, pos); + return ActionResultType.CONSUME; } @Override diff --git a/src/main/java/wile/engineersdecor/blocks/EdChimneyBlock.java b/src/main/java/wile/engineersdecor/blocks/EdChimneyBlock.java index 4e92b65..67456d2 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdChimneyBlock.java +++ b/src/main/java/wile/engineersdecor/blocks/EdChimneyBlock.java @@ -57,7 +57,7 @@ public class EdChimneyBlock extends DecorBlock.Normal implements IDecorBlock @Override @SuppressWarnings("deprecation") public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) - { world.setBlockState(pos, state.with(POWER, (state.get(POWER)+1) & 0xf), 1|2); return ActionResultType.SUCCESS; } + { world.setBlockState(pos, state.with(POWER, (state.get(POWER)+1) & 0xf), 1|2); return ActionResultType.func_233537_a_(world.isRemote()); } @Override @SuppressWarnings("deprecation") diff --git a/src/main/java/wile/engineersdecor/blocks/EdCraftingTable.java b/src/main/java/wile/engineersdecor/blocks/EdCraftingTable.java index 1542276..f5487cb 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdCraftingTable.java +++ b/src/main/java/wile/engineersdecor/blocks/EdCraftingTable.java @@ -99,12 +99,12 @@ public class EdCraftingTable @Override public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) { - if(world.isRemote) return ActionResultType.SUCCESS; + if(world.isRemote()) return ActionResultType.SUCCESS; final TileEntity te = world.getTileEntity(pos); if(!(te instanceof CraftingTableTileEntity)) return ActionResultType.FAIL; if((!(player instanceof ServerPlayerEntity) && (!(player instanceof FakePlayer)))) return ActionResultType.FAIL; NetworkHooks.openGui((ServerPlayerEntity)player,(INamedContainerProvider)te); - return ActionResultType.SUCCESS; + return ActionResultType.CONSUME; } @Override @@ -283,7 +283,7 @@ public class EdCraftingTable @Override public boolean isUsableByPlayer(PlayerEntity player) - { return getPos().distanceSq(player.getPosition()) < 36; } + { return ((getWorld().getTileEntity(getPos()) == this)) && (getPos().distanceSq(player.getPosition()) < 64); } @Override public void openInventory(PlayerEntity player) diff --git a/src/main/java/wile/engineersdecor/blocks/EdDoorBlock.java b/src/main/java/wile/engineersdecor/blocks/EdDoorBlock.java index bd893ce..72f63f8 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdDoorBlock.java +++ b/src/main/java/wile/engineersdecor/blocks/EdDoorBlock.java @@ -16,6 +16,9 @@ import wile.engineersdecor.libmc.blocks.StandardDoorBlock; public class EdDoorBlock extends StandardDoorBlock implements IDecorBlock { + public EdDoorBlock(long config, Block.Properties properties, AxisAlignedBB[] open_aabbs_top, AxisAlignedBB[] open_aabbs_bottom, AxisAlignedBB[] closed_aabbs_top, AxisAlignedBB[] closed_aabbs_bottom, SoundEvent open_sound, SoundEvent close_sound) + { super(config, properties, open_aabbs_top, open_aabbs_bottom, closed_aabbs_top, closed_aabbs_bottom, open_sound, close_sound); } + public EdDoorBlock(long config, Block.Properties properties, AxisAlignedBB open_aabb, AxisAlignedBB closed_aabb, SoundEvent open_sound, SoundEvent close_sound) { super(config, properties, open_aabb, closed_aabb, open_sound, close_sound); } @@ -24,4 +27,9 @@ public class EdDoorBlock extends StandardDoorBlock implements IDecorBlock public EdDoorBlock(long config, Block.Properties properties) { super(config, properties); } + + //@Override + //@SuppressWarnings("deprecation") + //public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) + //{ return state.get(OPEN) ? VoxelShapes.empty() : super.getCollisionShape(state, world, pos, context); } } diff --git a/src/main/java/wile/engineersdecor/blocks/EdDoubleGateBlock.java b/src/main/java/wile/engineersdecor/blocks/EdDoubleGateBlock.java index b9d3bd1..fea9498 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdDoubleGateBlock.java +++ b/src/main/java/wile/engineersdecor/blocks/EdDoubleGateBlock.java @@ -81,7 +81,7 @@ public class EdDoubleGateBlock extends DecorBlock.HorizontalWaterLoggable implem public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) { if((rayTraceResult.getFace()==Direction.UP) || (rayTraceResult.getFace()==Direction.DOWN) && (player.getHeldItem(hand).getItem()==this.asItem())) return ActionResultType.PASS; - if(world.isRemote) return ActionResultType.SUCCESS; + if(world.isRemote()) return ActionResultType.SUCCESS; final boolean open = !state.get(OPEN); world.setBlockState(pos, state.with(OPEN, open),2|8|16); if(state.get(SEGMENT) == SEGMENT_UPPER) { @@ -92,7 +92,7 @@ public class EdDoubleGateBlock extends DecorBlock.HorizontalWaterLoggable implem if(adjacent.getBlock()==this) world.setBlockState(pos.up(), adjacent.with(OPEN, open), 2|8|16); } world.playSound(null, pos, open?SoundEvents.BLOCK_IRON_DOOR_OPEN:SoundEvents.BLOCK_IRON_DOOR_CLOSE, SoundCategory.BLOCKS, 0.7f, 1.4f); - return ActionResultType.SUCCESS; + return ActionResultType.CONSUME; } @Override diff --git a/src/main/java/wile/engineersdecor/blocks/EdDropper.java b/src/main/java/wile/engineersdecor/blocks/EdDropper.java index 623cfa9..3e0356f 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdDropper.java +++ b/src/main/java/wile/engineersdecor/blocks/EdDropper.java @@ -169,12 +169,12 @@ public class EdDropper @Override public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) { - if(world.isRemote) return ActionResultType.SUCCESS; + if(world.isRemote()) return ActionResultType.SUCCESS; final TileEntity te = world.getTileEntity(pos); if(!(te instanceof EdDropper.DropperTileEntity)) return ActionResultType.FAIL; if((!(player instanceof ServerPlayerEntity) && (!(player instanceof FakePlayer)))) return ActionResultType.FAIL; NetworkHooks.openGui((ServerPlayerEntity)player,(INamedContainerProvider)te); - return ActionResultType.SUCCESS; + return ActionResultType.CONSUME; } @Override @@ -405,7 +405,7 @@ public class EdDropper @Override public boolean isUsableByPlayer(PlayerEntity player) - { return getPos().distanceSq(player.getPosition()) < 36; } + { return ((getWorld().getTileEntity(getPos()) == this)) && (getPos().distanceSq(player.getPosition()) < 64); } @Override public void openInventory(PlayerEntity player) diff --git a/src/main/java/wile/engineersdecor/blocks/EdElectricalFurnace.java b/src/main/java/wile/engineersdecor/blocks/EdElectricalFurnace.java index fe97b94..ff37873 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdElectricalFurnace.java +++ b/src/main/java/wile/engineersdecor/blocks/EdElectricalFurnace.java @@ -81,13 +81,13 @@ public class EdElectricalFurnace @Override public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) { - if(world.isRemote) return ActionResultType.SUCCESS; + if(world.isRemote()) return ActionResultType.SUCCESS; final TileEntity te = world.getTileEntity(pos); if(!(te instanceof EdElectricalFurnace.ElectricalFurnaceTileEntity)) return ActionResultType.FAIL; if((!(player instanceof ServerPlayerEntity) && (!(player instanceof FakePlayer)))) return ActionResultType.FAIL; NetworkHooks.openGui((ServerPlayerEntity)player,(INamedContainerProvider)te); player.addStat(Stats.INTERACT_WITH_FURNACE); - return ActionResultType.SUCCESS; + return ActionResultType.CONSUME; } @Override diff --git a/src/main/java/wile/engineersdecor/blocks/EdFluidBarrel.java b/src/main/java/wile/engineersdecor/blocks/EdFluidBarrel.java index e4996b4..605ab32 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdFluidBarrel.java +++ b/src/main/java/wile/engineersdecor/blocks/EdFluidBarrel.java @@ -187,12 +187,12 @@ public class EdFluidBarrel public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) { if(player.getHeldItem(hand).getItem() == asItem()) return ActionResultType.PASS; // Pass that to block placement. - if(world.isRemote) return ActionResultType.SUCCESS; + if(world.isRemote()) return ActionResultType.SUCCESS; TileEntity te = world.getTileEntity(pos); if(!(te instanceof FluidBarrelTileEntity)) return ActionResultType.FAIL; if(!((FluidBarrelTileEntity)te).handlePlayerInteraction(state, world, pos, player, hand)) return ActionResultType.PASS; world.getPendingBlockTicks().scheduleTick(pos, this, 4); - return ActionResultType.SUCCESS; + return ActionResultType.CONSUME; } @Override diff --git a/src/main/java/wile/engineersdecor/blocks/EdFluidFunnel.java b/src/main/java/wile/engineersdecor/blocks/EdFluidFunnel.java index 7a0566e..778d3fe 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdFluidFunnel.java +++ b/src/main/java/wile/engineersdecor/blocks/EdFluidFunnel.java @@ -146,7 +146,7 @@ public class EdFluidFunnel if(world.isRemote) return ActionResultType.SUCCESS; TileEntity te = world.getTileEntity(pos); if(!(te instanceof FluidFunnelTileEntity)) return ActionResultType.FAIL; - return FluidUtil.interactWithFluidHandler(player, hand, world, pos, rayTraceResult.getFace()) ? ActionResultType.SUCCESS : ActionResultType.FAIL; + return FluidUtil.interactWithFluidHandler(player, hand, world, pos, rayTraceResult.getFace()) ? ActionResultType.CONSUME : ActionResultType.FAIL; } @Override diff --git a/src/main/java/wile/engineersdecor/blocks/EdFreezer.java b/src/main/java/wile/engineersdecor/blocks/EdFreezer.java index 982de1d..6758673 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdFreezer.java +++ b/src/main/java/wile/engineersdecor/blocks/EdFreezer.java @@ -110,17 +110,17 @@ public class EdFreezer public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) { if(player.isSneaking()) return ActionResultType.PASS; - if(world.isRemote) return ActionResultType.SUCCESS; + if(world.isRemote()) return ActionResultType.SUCCESS; FreezerTileEntity te = getTe(world, pos); if(te==null) return ActionResultType.FAIL; final ItemStack stack = player.getHeldItem(hand); boolean dirty = false; if(Fluidics.manualFluidHandlerInteraction(world, pos, null, player, hand)) { world.playSound(null, pos, SoundEvents.ITEM_BUCKET_EMPTY, SoundCategory.BLOCKS, 0.5f, 1.4f); - return ActionResultType.SUCCESS; + return ActionResultType.CONSUME; } if(stack.getItem()==Items.WATER_BUCKET) { - return ActionResultType.SUCCESS; // would be already handled + return ActionResultType.CONSUME; // would be already handled } else if(stack.isEmpty()) { ItemStack ice = te.getIceItem(true); if(!ice.isEmpty()) { @@ -129,7 +129,7 @@ public class EdFreezer } else { world.playSound(null, pos, SoundEvents.BLOCK_IRON_TRAPDOOR_OPEN, SoundCategory.BLOCKS, 0.2f, 0.02f); } - return ActionResultType.SUCCESS; + return ActionResultType.CONSUME; } else { return ActionResultType.PASS; } diff --git a/src/main/java/wile/engineersdecor/blocks/EdFurnace.java b/src/main/java/wile/engineersdecor/blocks/EdFurnace.java index 94eaec5..f947da7 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdFurnace.java +++ b/src/main/java/wile/engineersdecor/blocks/EdFurnace.java @@ -157,13 +157,13 @@ public class EdFurnace @Override public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) { - if(world.isRemote) return ActionResultType.SUCCESS; + if(world.isRemote()) return ActionResultType.SUCCESS; final TileEntity te = world.getTileEntity(pos); if(!(te instanceof FurnaceTileEntity)) return ActionResultType.FAIL; if((!(player instanceof ServerPlayerEntity) && (!(player instanceof FakePlayer)))) return ActionResultType.FAIL; NetworkHooks.openGui((ServerPlayerEntity)player,(INamedContainerProvider)te); player.addStat(Stats.INTERACT_WITH_FURNACE); - return ActionResultType.SUCCESS; + return ActionResultType.CONSUME; } @Override @@ -398,7 +398,7 @@ public class EdFurnace @Override public boolean isUsableByPlayer(PlayerEntity player) - { return getPos().distanceSq(player.getPosition()) < 36; } + { return ((getWorld().getTileEntity(getPos()) == this)) && (getPos().distanceSq(player.getPosition()) < 64); } @Override public void openInventory(PlayerEntity player) diff --git a/src/main/java/wile/engineersdecor/blocks/EdHatchBlock.java b/src/main/java/wile/engineersdecor/blocks/EdHatchBlock.java index 9a59d55..ad05d1e 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdHatchBlock.java +++ b/src/main/java/wile/engineersdecor/blocks/EdHatchBlock.java @@ -78,11 +78,11 @@ public class EdHatchBlock extends DecorBlock.HorizontalWaterLoggable implements @Override public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) { - if(world.isRemote) return ActionResultType.CONSUME; + if(world.isRemote()) return ActionResultType.SUCCESS; boolean open = !state.get(OPEN); world.setBlockState(pos, state.with(OPEN, open), 1|2); world.playSound(null, pos, open?SoundEvents.BLOCK_IRON_DOOR_OPEN:SoundEvents.BLOCK_IRON_DOOR_CLOSE, SoundCategory.BLOCKS, 0.7f, 1.4f); - return ActionResultType.SUCCESS; + return ActionResultType.CONSUME; } @Override diff --git a/src/main/java/wile/engineersdecor/blocks/EdHopper.java b/src/main/java/wile/engineersdecor/blocks/EdHopper.java index edb4d74..8b6879d 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdHopper.java +++ b/src/main/java/wile/engineersdecor/blocks/EdHopper.java @@ -146,12 +146,12 @@ public class EdHopper @Override public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) { - if(world.isRemote) return ActionResultType.SUCCESS; + if(world.isRemote()) return ActionResultType.SUCCESS; final TileEntity te = world.getTileEntity(pos); if(!(te instanceof HopperTileEntity)) return ActionResultType.FAIL; if((!(player instanceof ServerPlayerEntity) && (!(player instanceof FakePlayer)))) return ActionResultType.FAIL; NetworkHooks.openGui((ServerPlayerEntity)player,(INamedContainerProvider)te); - return ActionResultType.SUCCESS; + return ActionResultType.CONSUME; } @Override @@ -377,7 +377,7 @@ public class EdHopper @Override public boolean isUsableByPlayer(PlayerEntity player) - { return getPos().distanceSq(player.getPosition()) < 36; } + { return ((getWorld().getTileEntity(getPos()) == this)) && (getPos().distanceSq(player.getPosition()) < 64); } @Override public void openInventory(PlayerEntity player) @@ -616,20 +616,24 @@ public class EdHopper rpos = new Vector3d(0.5+pos.getX(),-1.5+pos.getY(),0.5+pos.getZ()); collection_volume = (new AxisAlignedBB(pos.down(2))).grow(0.1+collection_range_, 1, 0.1+collection_range_); } - final List items = world.getEntitiesWithinAABB(ItemEntity.class, collection_volume); + final List items = world.getEntitiesWithinAABB(ItemEntity.class, collection_volume, e->(e.isAlive() && e.isOnGround())); if(items.size() <= 0) return false; final int max_to_collect = 3; int n_collected = 0; for(ItemEntity ie:items) { boolean is_direct_collection_tange = ie.getDistanceSq(rpos)<0.7; - if(!is_direct_collection_tange && (ie.cannotPickup() || (!ie.isOnGround()))) continue; + if(!is_direct_collection_tange && (ie.cannotPickup())) continue; ItemStack stack = ie.getItem(); + if(stack.isEmpty()) continue; int n_accepted = try_insert_into_hopper(stack); if(n_accepted <= 0) continue; - if(n_accepted == stack.getCount()) { + if(n_accepted >= stack.getCount()) { + stack.setCount(0); + ie.setItem(stack); ie.remove(); } else { stack.shrink(n_accepted); + ie.setItem(stack); } if((!is_direct_collection_tange) && (++n_collected >= max_to_collect)) break; } diff --git a/src/main/java/wile/engineersdecor/blocks/EdHorizontalSupportBlock.java b/src/main/java/wile/engineersdecor/blocks/EdHorizontalSupportBlock.java index ed96794..4b8e629 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdHorizontalSupportBlock.java +++ b/src/main/java/wile/engineersdecor/blocks/EdHorizontalSupportBlock.java @@ -12,11 +12,15 @@ package wile.engineersdecor.blocks; import net.minecraft.block.Block; import net.minecraft.entity.EntitySpawnPlacementRegistry; import net.minecraft.entity.EntityType; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.BlockItemUseContext; +import net.minecraft.item.DirectionalPlaceContext; +import net.minecraft.item.ItemStack; import net.minecraft.state.BooleanProperty; import net.minecraft.state.IntegerProperty; import net.minecraft.state.StateContainer; import net.minecraft.util.*; +import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.util.math.shapes.IBooleanFunction; @@ -29,6 +33,7 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import wile.engineersdecor.ModContent; import wile.engineersdecor.libmc.detail.Auxiliaries; +import wile.engineersdecor.libmc.detail.Inventories; import javax.annotation.Nullable; import java.util.HashMap; @@ -123,10 +128,27 @@ public class EdHorizontalSupportBlock extends DecorBlock.WaterLoggable implement public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld world, BlockPos pos, BlockPos facingPos) { return temp_block_update_until_better(state, world, pos); } - @Deprecated - @SuppressWarnings("deprecation") - public void neighborChanged(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos) - { world.setBlockState(pos, temp_block_update_until_better(state, world, pos)); } + @Override + public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) + { + ItemStack held_stack = player.getHeldItem(hand); + if((held_stack.isEmpty()) || (held_stack.getItem() != this.asItem())) return ActionResultType.PASS; + if(!(hit.getFace().getAxis().isVertical())) return ActionResultType.PASS; + final Direction placement_direction = player.getHorizontalFacing(); + final BlockPos adjacent_pos = pos.offset(placement_direction); + final BlockState adjacent = world.getBlockState(adjacent_pos); + final BlockItemUseContext ctx = new DirectionalPlaceContext(world, adjacent_pos, placement_direction, player.getHeldItem(hand), placement_direction.getOpposite()); + if(!adjacent.isReplaceable(ctx)) return ActionResultType.func_233537_a_(world.isRemote()); + final BlockState new_state = getStateForPlacement(ctx); + if(new_state == null) return ActionResultType.FAIL; + if(!world.setBlockState(adjacent_pos, new_state, 1|2)) return ActionResultType.FAIL; + world.playSound(player, pos, SoundEvents.BLOCK_METAL_PLACE, SoundCategory.BLOCKS, 1f, 1f); + if(!player.isCreative()) { + held_stack.shrink(1); + Inventories.setItemInPlayerHand(player, hand, held_stack); + } + return ActionResultType.func_233537_a_(world.isRemote()); + } @Override @SuppressWarnings("deprecation") diff --git a/src/main/java/wile/engineersdecor/blocks/EdLabeledCrate.java b/src/main/java/wile/engineersdecor/blocks/EdLabeledCrate.java index 81ebd11..bf4f2ac 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdLabeledCrate.java +++ b/src/main/java/wile/engineersdecor/blocks/EdLabeledCrate.java @@ -149,12 +149,12 @@ public class EdLabeledCrate @SuppressWarnings("deprecation") public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) { - if(world.isRemote) return ActionResultType.SUCCESS; + if(world.isRemote()) return ActionResultType.SUCCESS; final TileEntity te = world.getTileEntity(pos); - if(!(te instanceof LabeledCrateTileEntity)) return ActionResultType.SUCCESS; - if((!(player instanceof ServerPlayerEntity) && (!(player instanceof FakePlayer)))) return ActionResultType.SUCCESS; + if(!(te instanceof LabeledCrateTileEntity)) return ActionResultType.FAIL; + if((!(player instanceof ServerPlayerEntity) && (!(player instanceof FakePlayer)))) return ActionResultType.FAIL; NetworkHooks.openGui((ServerPlayerEntity)player,(INamedContainerProvider)te); - return ActionResultType.SUCCESS; + return ActionResultType.CONSUME; } @Override @@ -373,7 +373,7 @@ public class EdLabeledCrate @Override public boolean isUsableByPlayer(PlayerEntity player) - { return getPos().distanceSq(player.getPosition()) < 36; } + { return ((getWorld().getTileEntity(getPos()) == this)) && (getPos().distanceSq(player.getPosition()) < 64); } @Override public void openInventory(PlayerEntity player) diff --git a/src/main/java/wile/engineersdecor/blocks/EdMilker.java b/src/main/java/wile/engineersdecor/blocks/EdMilker.java index 94683e7..c1705dc 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdMilker.java +++ b/src/main/java/wile/engineersdecor/blocks/EdMilker.java @@ -109,16 +109,16 @@ public class EdMilker @Override public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { - if(world.isRemote) return ActionResultType.SUCCESS; + if(world.isRemote()) return ActionResultType.SUCCESS; MilkerTileEntity te = getTe(world, pos); if(te==null) return ActionResultType.FAIL; final ItemStack in_stack = player.getHeldItem(hand); final ItemStack out_stack = MilkerTileEntity.milk_filled_container_item(in_stack); if(in_stack.isEmpty()) { te.state_message(player); - return ActionResultType.SUCCESS; + return ActionResultType.CONSUME; } else if(out_stack.isEmpty() && (te.fluid_handler()!=null)) { - return FluidUtil.interactWithFluidHandler(player, hand, te.fluid_handler()) ? ActionResultType.SUCCESS : ActionResultType.FAIL; + return FluidUtil.interactWithFluidHandler(player, hand, te.fluid_handler()) ? ActionResultType.CONSUME : ActionResultType.FAIL; } else { boolean drained = false; IItemHandler player_inventory = new PlayerMainInvWrapper(player.inventory); @@ -141,7 +141,7 @@ public class EdMilker world.playSound(null, pos, SoundEvents.ITEM_BUCKET_FILL, SoundCategory.BLOCKS, 0.8f, 1f); } } - return ActionResultType.SUCCESS; + return ActionResultType.CONSUME; } @Nullable diff --git a/src/main/java/wile/engineersdecor/blocks/EdMineralSmelter.java b/src/main/java/wile/engineersdecor/blocks/EdMineralSmelter.java index 2f09046..10ef605 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdMineralSmelter.java +++ b/src/main/java/wile/engineersdecor/blocks/EdMineralSmelter.java @@ -117,7 +117,7 @@ public class EdMineralSmelter public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) { if(player.isSneaking()) return ActionResultType.PASS; - if(world.isRemote) return ActionResultType.SUCCESS; + if(world.isRemote()) return ActionResultType.SUCCESS; MineralSmelterTileEntity te = getTe(world, pos); if(te==null) return ActionResultType.FAIL; final ItemStack stack = player.getHeldItem(hand); @@ -163,7 +163,7 @@ public class EdMineralSmelter dirty = true; } if(dirty) player.inventory.markDirty(); - return ActionResultType.SUCCESS; + return ActionResultType.CONSUME; } @Override @@ -398,7 +398,7 @@ public class EdMineralSmelter @Override public boolean isUsableByPlayer(PlayerEntity player) - { return ((world.getTileEntity(pos) == this) && (player.getDistanceSq(pos.getX()+0.5d, pos.getY()+0.5d, pos.getZ()+0.5d) <= 64.0d)); } + { return ((getWorld().getTileEntity(getPos()) == this)) && (getPos().distanceSq(player.getPosition()) < 64); } @Override public void openInventory(PlayerEntity player) diff --git a/src/main/java/wile/engineersdecor/blocks/EdPlacer.java b/src/main/java/wile/engineersdecor/blocks/EdPlacer.java index 371955b..53c4bf3 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdPlacer.java +++ b/src/main/java/wile/engineersdecor/blocks/EdPlacer.java @@ -143,12 +143,12 @@ public class EdPlacer @Override public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) { - if(world.isRemote) return ActionResultType.SUCCESS; + if(world.isRemote()) return ActionResultType.SUCCESS; final TileEntity te = world.getTileEntity(pos); if(!(te instanceof PlacerTileEntity)) return ActionResultType.FAIL; if((!(player instanceof ServerPlayerEntity) && (!(player instanceof FakePlayer)))) return ActionResultType.FAIL; NetworkHooks.openGui((ServerPlayerEntity)player,(INamedContainerProvider)te); - return ActionResultType.SUCCESS; + return ActionResultType.CONSUME; } @Override @@ -346,7 +346,7 @@ public class EdPlacer @Override public boolean isUsableByPlayer(PlayerEntity player) - { return getPos().distanceSq(player.getPosition()) < 36; } + { return ((getWorld().getTileEntity(getPos()) == this)) && (getPos().distanceSq(player.getPosition()) < 64); } @Override public void openInventory(PlayerEntity player) diff --git a/src/main/java/wile/engineersdecor/blocks/EdRailingBlock.java b/src/main/java/wile/engineersdecor/blocks/EdRailingBlock.java index 967d4ee..130cc97 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdRailingBlock.java +++ b/src/main/java/wile/engineersdecor/blocks/EdRailingBlock.java @@ -60,7 +60,7 @@ public class EdRailingBlock extends DecorBlock.HorizontalFourWayWaterLoggable im { if(player.getHeldItem(hand).getItem() != asItem()) return ActionResultType.PASS; Direction face = hit.getFace(); - if(!face.getAxis().isHorizontal()) return world.isRemote() ? ActionResultType.SUCCESS : ActionResultType.CONSUME; + if(!face.getAxis().isHorizontal()) return ActionResultType.func_233537_a_(world.isRemote()); final Vector3d rhv = hit.getHitVec().subtract(Vector3d.copyCentered(hit.getPos())); if(rhv.mul(Vector3d.copy(face.getDirectionVec())).scale(2).lengthSquared() < 0.99) face = face.getOpposite(); // click on railing, not the outer side. BooleanProperty railing = getDirectionProperty(face); @@ -72,7 +72,7 @@ public class EdRailingBlock extends DecorBlock.HorizontalFourWayWaterLoggable im } else { EdCatwalkBlock.place_consume(state, world, pos, player, hand, add ? 1 : -1); } - return world.isRemote() ? ActionResultType.SUCCESS : ActionResultType.CONSUME; + return ActionResultType.func_233537_a_(world.isRemote()); } // -- IDecorBlock diff --git a/src/main/java/wile/engineersdecor/blocks/EdSolarPanel.java b/src/main/java/wile/engineersdecor/blocks/EdSolarPanel.java index bdeb8c5..efc195d 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdSolarPanel.java +++ b/src/main/java/wile/engineersdecor/blocks/EdSolarPanel.java @@ -72,9 +72,10 @@ public class EdSolarPanel @Override public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { + if(world.isRemote()) return ActionResultType.SUCCESS; TileEntity te = world.getTileEntity(pos); if(te instanceof SolarPanelTileEntity) ((SolarPanelTileEntity)te).state_message(player); - return ActionResultType.SUCCESS; + return ActionResultType.CONSUME; } } diff --git a/src/main/java/wile/engineersdecor/blocks/EdStraightPoleBlock.java b/src/main/java/wile/engineersdecor/blocks/EdStraightPoleBlock.java index 0c6fd9e..9b3432a 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdStraightPoleBlock.java +++ b/src/main/java/wile/engineersdecor/blocks/EdStraightPoleBlock.java @@ -10,18 +10,29 @@ package wile.engineersdecor.blocks; import net.minecraft.block.Block; import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItemUseContext; +import net.minecraft.item.DirectionalPlaceContext; +import net.minecraft.item.ItemStack; +import net.minecraft.util.*; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; -import net.minecraft.util.Direction; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; +import wile.engineersdecor.libmc.detail.Inventories; + import javax.annotation.Nullable; +import java.util.Arrays; public class EdStraightPoleBlock extends DecorBlock.DirectedWaterLoggable implements IDecorBlock { - public EdStraightPoleBlock(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB) - { super(config, builder, unrotatedAABB); } + private final EdStraightPoleBlock default_pole; + + public EdStraightPoleBlock(long config, Block.Properties builder, final AxisAlignedBB unrotatedAABB, @Nullable EdStraightPoleBlock defaultPole) + { super(config, builder, unrotatedAABB); default_pole=(defaultPole==null) ? (this) : (defaultPole); } @Override @Nullable @@ -38,4 +49,33 @@ public class EdStraightPoleBlock extends DecorBlock.DirectedWaterLoggable implem } return state; } + + @Override + public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) + { + if((hit.getFace().getAxis() == state.get(FACING).getAxis())) return ActionResultType.PASS; + final ItemStack held_stack = player.getHeldItem(hand); + if((held_stack.isEmpty()) || (!(held_stack.getItem() instanceof BlockItem))) return ActionResultType.PASS; + if(!(((BlockItem)(held_stack.getItem())).getBlock() instanceof EdStraightPoleBlock)) return ActionResultType.PASS; + if(held_stack.getItem() != default_pole.asItem()) return ActionResultType.func_233537_a_(world.isRemote()); + final Block held_block = ((BlockItem)(held_stack.getItem())).getBlock(); + final Direction block_direction = state.get(FACING); + final Vector3d block_vec = Vector3d.copy(state.get(FACING).getDirectionVec()); + final double colinearity = 1.0-block_vec.crossProduct(player.getLookVec()).length(); + final Direction placement_direction = Arrays.stream(Direction.getFacingDirections(player)).filter(d->d.getAxis()==block_direction.getAxis()).findFirst().orElse(Direction.NORTH); + final BlockPos adjacent_pos = pos.offset(placement_direction); + final BlockState adjacent = world.getBlockState(adjacent_pos); + final BlockItemUseContext ctx = new DirectionalPlaceContext(world, adjacent_pos, placement_direction, player.getHeldItem(hand), placement_direction.getOpposite()); + if(!adjacent.isReplaceable(ctx)) return ActionResultType.func_233537_a_(world.isRemote()); + final BlockState new_state = held_block.getStateForPlacement(ctx); + if(new_state == null) return ActionResultType.FAIL; + if(!world.setBlockState(adjacent_pos, new_state, 1|2)) return ActionResultType.FAIL; + world.playSound(player, pos, SoundEvents.BLOCK_METAL_PLACE, SoundCategory.BLOCKS, 1f, 1f); + if(!player.isCreative()) { + held_stack.shrink(1); + Inventories.setItemInPlayerHand(player, hand, held_stack); + } + return ActionResultType.func_233537_a_(world.isRemote()); + } + } diff --git a/src/main/java/wile/engineersdecor/blocks/EdTestBlock.java b/src/main/java/wile/engineersdecor/blocks/EdTestBlock.java index 63f317c..edc4228 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdTestBlock.java +++ b/src/main/java/wile/engineersdecor/blocks/EdTestBlock.java @@ -78,10 +78,11 @@ public class EdTestBlock @SuppressWarnings("deprecation") public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { + if(world.isRemote()) return ActionResultType.SUCCESS; TileEntity te = world.getTileEntity(pos); - if(!(te instanceof TestTileEntity)) return ActionResultType.SUCCESS; + if(!(te instanceof TestTileEntity)) return ActionResultType.FAIL; ((TestTileEntity)te).activated(player, hand, hit); - return ActionResultType.SUCCESS; + return ActionResultType.CONSUME; } } diff --git a/src/main/java/wile/engineersdecor/blocks/EdTreeCutter.java b/src/main/java/wile/engineersdecor/blocks/EdTreeCutter.java index b0fb762..b3eb930 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdTreeCutter.java +++ b/src/main/java/wile/engineersdecor/blocks/EdTreeCutter.java @@ -90,9 +90,10 @@ public class EdTreeCutter @Override public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { + if(world.isRemote()) return ActionResultType.SUCCESS; TileEntity te = world.getTileEntity(pos); if(te instanceof TreeCutterTileEntity) ((TreeCutterTileEntity)te).state_message(player); - return ActionResultType.SUCCESS; + return ActionResultType.CONSUME; } } diff --git a/src/main/java/wile/engineersdecor/blocks/EdWasteIncinerator.java b/src/main/java/wile/engineersdecor/blocks/EdWasteIncinerator.java index 05ccd28..7f1c052 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdWasteIncinerator.java +++ b/src/main/java/wile/engineersdecor/blocks/EdWasteIncinerator.java @@ -144,12 +144,12 @@ public class EdWasteIncinerator @Override public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) { - if(world.isRemote) return ActionResultType.SUCCESS; + if(world.isRemote()) return ActionResultType.SUCCESS; final TileEntity te = world.getTileEntity(pos); if(!(te instanceof WasteIncineratorTileEntity)) return ActionResultType.FAIL; if((!(player instanceof ServerPlayerEntity) && (!(player instanceof FakePlayer)))) return ActionResultType.FAIL; NetworkHooks.openGui((ServerPlayerEntity)player,(INamedContainerProvider)te); - return ActionResultType.SUCCESS; + return ActionResultType.CONSUME; } @Override @@ -317,7 +317,7 @@ public class EdWasteIncinerator @Override public boolean isUsableByPlayer(PlayerEntity player) - { return getPos().distanceSq(player.getPosition()) < 36; } + { return ((getWorld().getTileEntity(getPos()) == this)) && (getPos().distanceSq(player.getPosition()) < 64); } @Override public void openInventory(PlayerEntity player) diff --git a/src/main/java/wile/engineersdecor/blocks/EdWindowBlock.java b/src/main/java/wile/engineersdecor/blocks/EdWindowBlock.java index 68ef8e6..2ad116a 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdWindowBlock.java +++ b/src/main/java/wile/engineersdecor/blocks/EdWindowBlock.java @@ -10,13 +10,19 @@ package wile.engineersdecor.blocks; import net.minecraft.block.Block; import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.fluid.Fluids; import net.minecraft.item.BlockItemUseContext; -import net.minecraft.util.Direction; +import net.minecraft.item.DirectionalPlaceContext; +import net.minecraft.util.*; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; import javax.annotation.Nullable; +import java.util.Arrays; public class EdWindowBlock extends DecorBlock.DirectedWaterLoggable implements IDecorBlock @@ -47,6 +53,27 @@ public class EdWindowBlock extends DecorBlock.DirectedWaterLoggable implements I return super.getStateForPlacement(context).with(FACING, facing); } + @Override + @SuppressWarnings("deprecation") + public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) + { + if(player.getHeldItem(hand).getItem() != asItem()) return ActionResultType.PASS; + final Direction facing = state.get(FACING); + if(facing.getAxis() != hit.getFace().getAxis()) return ActionResultType.PASS; + Arrays.stream(Direction.getFacingDirections(player)) + .filter(d->d.getAxis() != facing.getAxis()) + .filter(d->world.getBlockState(pos.offset(d)).isReplaceable((new DirectionalPlaceContext(world, pos.offset(d), facing.getOpposite(), player.getHeldItem(hand), facing)))) + .findFirst().ifPresent((d)->{ + BlockState st = getDefaultState() + .with(FACING, facing) + .with(WATERLOGGED,world.getBlockState(pos.offset(d)).getFluidState().getFluid()==Fluids.WATER); + world.setBlockState(pos.offset(d), st, 1|2); + world.playSound(player, pos, SoundEvents.BLOCK_METAL_PLACE, SoundCategory.BLOCKS, 1f, 1f); + } + ); + return ActionResultType.func_233537_a_(world.isRemote()); + } + @Override public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) { return true; } diff --git a/src/main/java/wile/engineersdecor/eapi/jei/JEIPlugin.java b/src/main/java/wile/engineersdecor/eapi/jei/JEIPlugin.java index 21557e3..4683b5a 100644 --- a/src/main/java/wile/engineersdecor/eapi/jei/JEIPlugin.java +++ b/src/main/java/wile/engineersdecor/eapi/jei/JEIPlugin.java @@ -22,6 +22,8 @@ import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import wile.engineersdecor.blocks.EdCraftingTable.CraftingTableTileEntity; + import java.util.HashSet; import java.util.List; import java.util.stream.Collectors; @@ -42,7 +44,7 @@ public class JEIPlugin implements mezz.jei.api.IModPlugin registration.addRecipeTransferHandler( EdCraftingTable.CraftingTableContainer.class, VanillaRecipeCategoryUid.CRAFTING, - 1, 9, 10, 44 + 1, 9, 10, 36+CraftingTableTileEntity.NUM_OF_STORAGE_SLOTS ); } catch(Throwable e) { ModEngineersDecor.logger().warn("Exception in JEI crafting table handler registration: '" + e.getMessage() + "'."); diff --git a/src/main/java/wile/engineersdecor/libmc/blocks/StandardDoorBlock.java b/src/main/java/wile/engineersdecor/libmc/blocks/StandardDoorBlock.java index 33d44ab..6fe3a32 100644 --- a/src/main/java/wile/engineersdecor/libmc/blocks/StandardDoorBlock.java +++ b/src/main/java/wile/engineersdecor/libmc/blocks/StandardDoorBlock.java @@ -22,6 +22,7 @@ import net.minecraft.block.BlockState; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.shapes.IBooleanFunction; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShapes; @@ -39,23 +40,30 @@ import java.util.List; public class StandardDoorBlock extends DoorBlock implements StandardBlocks.IStandardBlock { private final long config_; - protected final VoxelShape shapes_[][][]; + protected final VoxelShape shapes_[][][][]; protected final SoundEvent open_sound_; protected final SoundEvent close_sound_; - public StandardDoorBlock(long config, Block.Properties properties, AxisAlignedBB open_aabb, AxisAlignedBB closed_aabb, SoundEvent open_sound, SoundEvent close_sound) + public StandardDoorBlock(long config, Block.Properties properties, AxisAlignedBB[] open_aabbs_top, AxisAlignedBB[] open_aabbs_bottom, AxisAlignedBB[] closed_aabbs_top, AxisAlignedBB[] closed_aabbs_bottom, SoundEvent open_sound, SoundEvent close_sound) { super(properties); - VoxelShape shapes[][][] = new VoxelShape[Direction.values().length][2][2]; + VoxelShape shapes[][][][] = new VoxelShape[Direction.values().length][2][2][2]; for(Direction facing: Direction.values()) { for(boolean open: new boolean[]{false,true}) { - for(boolean hinge_right: new boolean[]{false,true}) { - if(facing.getAxis() == Axis.Y) { - shapes[facing.ordinal()][open?1:0][hinge_right?1:0] = VoxelShapes.fullCube(); - } else { - AxisAlignedBB aabb = Auxiliaries.getRotatedAABB(open ? open_aabb : closed_aabb, facing, true); - if(!hinge_right) aabb = Auxiliaries.getMirroredAABB(aabb, facing.rotateY().getAxis()); - shapes[facing.ordinal()][open?1:0][hinge_right?1:0] = VoxelShapes.create(aabb); + for(DoubleBlockHalf half: new DoubleBlockHalf[]{DoubleBlockHalf.UPPER,DoubleBlockHalf.LOWER}) { + for(boolean hinge_right: new boolean[]{false,true}) { + VoxelShape shape = VoxelShapes.empty(); + if(facing.getAxis() == Axis.Y) { + shape = VoxelShapes.fullCube(); + } else { + final AxisAlignedBB[] aabbs = (open)?((half==DoubleBlockHalf.UPPER) ? open_aabbs_top : open_aabbs_bottom) : ((half==DoubleBlockHalf.UPPER) ? closed_aabbs_top : closed_aabbs_bottom); + for(AxisAlignedBB e:aabbs) { + AxisAlignedBB aabb = Auxiliaries.getRotatedAABB(e, facing, true); + if(!hinge_right) aabb = Auxiliaries.getMirroredAABB(aabb, facing.rotateY().getAxis()); + shape = VoxelShapes.combineAndSimplify(shape, VoxelShapes.create(aabb), IBooleanFunction.OR); + } + } + shapes[facing.ordinal()][open?1:0][hinge_right?1:0][half==DoubleBlockHalf.UPPER?0:1] = shape; } } } @@ -66,6 +74,9 @@ public class StandardDoorBlock extends DoorBlock implements StandardBlocks.IStan close_sound_ = close_sound; } + public StandardDoorBlock(long config, Block.Properties properties, AxisAlignedBB open_aabb, AxisAlignedBB closed_aabb, SoundEvent open_sound, SoundEvent close_sound) + { this(config, properties, new AxisAlignedBB[]{open_aabb}, new AxisAlignedBB[]{open_aabb}, new AxisAlignedBB[]{closed_aabb}, new AxisAlignedBB[]{closed_aabb}, open_sound, close_sound); } + public StandardDoorBlock(long config, Block.Properties properties, SoundEvent open_sound, SoundEvent close_sound) { this( @@ -120,9 +131,11 @@ public class StandardDoorBlock extends DoorBlock implements StandardBlocks.IStan public boolean canCreatureSpawn(BlockState state, IBlockReader world, BlockPos pos, EntitySpawnPlacementRegistry.PlacementType type, @Nullable EntityType entityType) { return false; } + @Override public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) - { return shapes_[state.get(FACING).ordinal()][state.get(OPEN)?1:0][state.get(HINGE)==DoorHingeSide.RIGHT?1:0]; } + { return shapes_[state.get(FACING).ordinal()][state.get(OPEN)?1:0][state.get(HINGE)==DoorHingeSide.RIGHT?1:0][state.get(HALF)==DoubleBlockHalf.UPPER?0:1]; } + @Override public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { boolean open = !state.get(OPEN); @@ -130,9 +143,10 @@ public class StandardDoorBlock extends DoorBlock implements StandardBlocks.IStan world.setBlockState(pos, state, 2|8); sound(world, pos, open); actuate_adjacent_wing(state, world, pos, open); - return world.isRemote ? ActionResultType.SUCCESS : ActionResultType.CONSUME; + return ActionResultType.func_233537_a_(world.isRemote()); } + @Override public void neighborChanged(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean isMoving) { boolean powered = world.isBlockPowered(pos) || world.isBlockPowered(pos.offset(state.get(HALF) == DoubleBlockHalf.LOWER ? Direction.UP : Direction.DOWN)); diff --git a/src/main/java/wile/engineersdecor/libmc/detail/Inventories.java b/src/main/java/wile/engineersdecor/libmc/detail/Inventories.java index a092ce3..67d2934 100644 --- a/src/main/java/wile/engineersdecor/libmc/detail/Inventories.java +++ b/src/main/java/wile/engineersdecor/libmc/detail/Inventories.java @@ -393,6 +393,7 @@ public class Inventories { ItemHandlerHelper.giveItemToPlayer(entity, stack); } public static void setItemInPlayerHand(PlayerEntity player, Hand hand, ItemStack stack) { + if(stack.isEmpty()) stack = ItemStack.EMPTY; if(hand == Hand.MAIN_HAND) { player.inventory.mainInventory.set(player.inventory.currentItem, stack); } else {