From 0e4a65354f7a5514d2ceb73eb6234ee7df6a4ade Mon Sep 17 00:00:00 2001 From: Michael Hillcox Date: Mon, 1 Mar 2021 17:46:12 +0000 Subject: [PATCH] chore: some blocks ported and INamedProviders added to tiles --- .../mod/blocks/BlockFarmer.java | 86 ++--- .../mod/blocks/BlockFeeder.java | 31 +- .../mod/blocks/BlockFermentingBarrel.java | 41 +-- .../mod/blocks/BlockFireworkBox.java | 35 +- .../mod/blocks/BlockFluidCollector.java | 99 ++--- .../mod/blocks/BlockFurnaceDouble.java | 150 +++----- .../actuallyadditions/mod/blocks/Shapes.java | 341 ++++++++++++++++++ .../mod/inventory/ContainerGrinder.java | 6 +- .../mod/inventory/ContainerInputter.java | 14 +- .../mod/tile/TileEntityFarmer.java | 21 +- .../mod/tile/TileEntityFeeder.java | 21 +- .../mod/tile/TileEntityFermentingBarrel.java | 22 +- .../mod/tile/TileEntityFireworkBox.java | 20 +- .../mod/tile/TileEntityFluidCollector.java | 21 +- .../mod/tile/TileEntityFurnaceDouble.java | 21 +- .../mod/tile/TileEntityGiantChestLarge.java | 37 +- .../mod/tile/TileEntityGiantChestMedium.java | 37 +- .../mod/tile/TileEntityGrinder.java | 21 +- .../mod/tile/TileEntityInputter.java | 20 +- .../TileEntityLaserRelayItemWhitelist.java | 27 +- .../mod/tile/TileEntityMiner.java | 22 +- .../mod/tile/TileEntityOilGenerator.java | 21 +- .../mod/tile/TileEntityPhantomPlacer.java | 20 +- .../mod/tile/TileEntityRangedCollector.java | 20 +- .../mod/tile/TileEntitySmileyCloud.java | 121 ++++--- .../mod/tile/TileEntityXPSolidifier.java | 28 +- 26 files changed, 875 insertions(+), 428 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFarmer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFarmer.java index 192969d55..1e3d21a20 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFarmer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFarmer.java @@ -10,34 +10,24 @@ package de.ellpeck.actuallyadditions.mod.blocks; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; -import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; +import de.ellpeck.actuallyadditions.mod.blocks.base.DirectionalBlock; import de.ellpeck.actuallyadditions.mod.tile.TileEntityFarmer; -import net.minecraft.block.BlockHorizontal; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.entity.EntityLivingBase; +import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; +import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.world.IBlockReader; import net.minecraft.world.World; -public class BlockFarmer extends BlockContainerBase { +public class BlockFarmer extends DirectionalBlock.Container { public BlockFarmer() { - super(Material.ROCK, this.name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); + super(ActuallyBlocks.defaultPickProps(0)); } @Override @@ -47,50 +37,20 @@ public class BlockFarmer extends BlockContainerBase { @Override public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - if (!world.isRemote) { - TileEntityFarmer farmer = (TileEntityFarmer) world.getTileEntity(pos); - if (farmer != null) { - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FARMER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } - return true; + return this.openGui(worldIn, player, pos, TileEntityFarmer.class); + } + + @Override + public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + switch (state.get(FACING)) { + case EAST: + return Shapes.FarmerShapes.SHAPE_E; + case SOUTH: + return Shapes.FarmerShapes.SHAPE_S; + case WEST: + return Shapes.FarmerShapes.SHAPE_W; + default: + return Shapes.FarmerShapes.SHAPE_N; } - return true; - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.RARE; - } - - @Override - public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, EntityLivingBase player, ItemStack stack) { - world.setBlockState(pos, state.withProperty(BlockHorizontal.FACING, player.getHorizontalFacing().getOpposite()), 2); - - super.onBlockPlacedBy(world, pos, state, player, stack); - } - - @Override - public BlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(BlockHorizontal.FACING, Direction.byHorizontalIndex(meta)); - } - - @Override - public int getMetaFromState(BlockState state) { - return state.getValue(BlockHorizontal.FACING).getHorizontalIndex(); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, BlockHorizontal.FACING); - } - - @Override - public BlockState withRotation(BlockState state, Rotation rot) { - return state.withProperty(BlockHorizontal.FACING, rot.rotate(state.getValue(BlockHorizontal.FACING))); - } - - @Override - public BlockState withMirror(BlockState state, Mirror mirror) { - return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING))); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFeeder.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFeeder.java index d7039cc84..c47aeb693 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFeeder.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFeeder.java @@ -10,28 +10,24 @@ package de.ellpeck.actuallyadditions.mod.blocks; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; -import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.tile.TileEntityFeeder; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; +import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.world.IBlockReader; import net.minecraft.world.World; public class BlockFeeder extends BlockContainerBase { public BlockFeeder() { - super(Material.ROCK, this.name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(0.5F); - this.setResistance(6.0F); - this.setSoundType(SoundType.STONE); + super(ActuallyBlocks.defaultPickProps(0, 0.5F, 6.0F)); } @Override @@ -41,18 +37,11 @@ public class BlockFeeder extends BlockContainerBase { @Override public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - if (!world.isRemote) { - TileEntityFeeder feeder = (TileEntityFeeder) world.getTileEntity(pos); - if (feeder != null) { - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FEEDER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } - return true; - } - return true; + return this.openGui(worldIn, player, pos, TileEntityFeeder.class); } @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.UNCOMMON; + public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + return Shapes.FEEDER_SHAPE; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFermentingBarrel.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFermentingBarrel.java index 7b03e04e3..d3fcaf857 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFermentingBarrel.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFermentingBarrel.java @@ -10,38 +10,29 @@ package de.ellpeck.actuallyadditions.mod.blocks; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; -import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.tile.TileEntityFermentingBarrel; +import net.minecraft.block.BlockState; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; +import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import net.minecraftforge.common.ToolType; +import net.minecraftforge.fml.network.NetworkHooks; public class BlockFermentingBarrel extends BlockContainerBase { public BlockFermentingBarrel() { - super(Material.WOOD, this.name); - this.setHarvestLevel("axe", 0); - this.setHardness(0.5F); - this.setResistance(5.0F); - this.setSoundType(SoundType.WOOD); - } - - @Override - public boolean isFullCube(BlockState state) { - return false; - } - - @Override - public boolean isOpaqueCube(BlockState state) { - return false; + super(Properties.create(Material.WOOD).harvestTool(ToolType.AXE).harvestLevel(0).hardnessAndResistance(0.5F, 5.0F).sound(SoundType.WOOD)); } @Override @@ -50,21 +41,21 @@ public class BlockFermentingBarrel extends BlockContainerBase { } @Override - public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { + public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { if (!world.isRemote) { TileEntityFermentingBarrel press = (TileEntityFermentingBarrel) world.getTileEntity(pos); if (press != null) { if (!this.tryUseItemOnTank(player, hand, press.canolaTank) && !this.tryUseItemOnTank(player, hand, press.oilTank)) { - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FERMENTING_BARREL.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); + NetworkHooks.openGui((ServerPlayerEntity) player, press, pos); } } - return true; + return ActionResultType.PASS; } - return true; + return ActionResultType.PASS; } @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.RARE; + public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + return Shapes.BARREL_SHAPE; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFireworkBox.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFireworkBox.java index 6d89679c8..f83fc884e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFireworkBox.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFireworkBox.java @@ -10,41 +10,32 @@ package de.ellpeck.actuallyadditions.mod.blocks; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; -import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.tile.TileEntityFireworkBox; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; +import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.world.IBlockReader; import net.minecraft.world.World; public class BlockFireworkBox extends BlockContainerBase { - public BlockFireworkBox() { - super(Material.ROCK, this.name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); + super(ActuallyBlocks.defaultPickProps(0)); } @Override - public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { + public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { if (this.tryToggleRedstone(world, pos, player)) { - return true; - } else if (!world.isRemote) { - TileEntityFireworkBox grinder = (TileEntityFireworkBox) world.getTileEntity(pos); - if (grinder != null) { - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FIREWORK_BOX.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } + return ActionResultType.PASS; } - return true; + + return this.openGui(world, player, pos, TileEntityFireworkBox.class); } @Override @@ -53,7 +44,7 @@ public class BlockFireworkBox extends BlockContainerBase { } @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.RARE; + public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + return Shapes.FIREWORKS_BOX_SHAPE; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFluidCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFluidCollector.java index 412e659b4..d0f5a5824 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFluidCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFluidCollector.java @@ -10,38 +10,27 @@ package de.ellpeck.actuallyadditions.mod.blocks; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; -import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; +import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock; import de.ellpeck.actuallyadditions.mod.tile.TileEntityFluidCollector; import de.ellpeck.actuallyadditions.mod.tile.TileEntityFluidPlacer; -import net.minecraft.block.BlockDirectional; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.entity.EntityLivingBase; +import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; +import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.world.IBlockReader; import net.minecraft.world.World; -public class BlockFluidCollector extends BlockContainerBase { - +public class BlockFluidCollector extends FullyDirectionalBlock.Container { private final boolean isPlacer; public BlockFluidCollector(boolean isPlacer) { - super(Material.ROCK, this.name); + super(ActuallyBlocks.defaultPickProps(0)); this.isPlacer = isPlacer; - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); } @Override @@ -52,57 +41,29 @@ public class BlockFluidCollector extends BlockContainerBase { } @Override - public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { + public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { if (this.tryToggleRedstone(world, pos, player)) { - return true; + return ActionResultType.PASS; } - if (!world.isRemote) { - TileEntityFluidCollector collector = (TileEntityFluidCollector) world.getTileEntity(pos); - if (collector != null) { - if (!this.tryUseItemOnTank(player, hand, collector.tank)) { - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FLUID_COLLECTOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } - } - return true; + + return this.openGui(world, player, pos, TileEntityFluidCollector.class); + } + + @Override + public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + switch (state.get(FACING)) { + case UP: + return Shapes.FluidCollectorShapes.SHAPE_U; + case DOWN: + return Shapes.FluidCollectorShapes.SHAPE_D; + case EAST: + return Shapes.FluidCollectorShapes.SHAPE_E; + case SOUTH: + return Shapes.FluidCollectorShapes.SHAPE_S; + case WEST: + return Shapes.FluidCollectorShapes.SHAPE_W; + default: + return Shapes.FluidCollectorShapes.SHAPE_N; } - return true; - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.RARE; - } - - @Override - public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, EntityLivingBase player, ItemStack stack) { - int rotation = Direction.getDirectionFromEntityLiving(pos, player).ordinal(); - world.setBlockState(pos, this.getStateFromMeta(rotation), 2); - - super.onBlockPlacedBy(world, pos, state, player, stack); - } - - @Override - public BlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(BlockDirectional.FACING, Direction.byIndex(meta)); - } - - @Override - public int getMetaFromState(BlockState state) { - return state.getValue(BlockDirectional.FACING).getIndex(); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, BlockDirectional.FACING); - } - - @Override - public BlockState withRotation(BlockState state, Rotation rot) { - return state.withProperty(BlockDirectional.FACING, rot.rotate(state.getValue(BlockDirectional.FACING))); - } - - @Override - public BlockState withMirror(BlockState state, Mirror mirror) { - return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING))); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceDouble.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceDouble.java index 7cf4bca67..dcbc23629 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceDouble.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceDouble.java @@ -10,48 +10,39 @@ package de.ellpeck.actuallyadditions.mod.blocks; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING; +import static net.minecraft.state.properties.BlockStateProperties.LIT; + import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; -import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase; -import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.tile.TileEntityFurnaceDouble; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; import net.minecraft.block.Block; -import net.minecraft.block.BlockHorizontal; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.properties.PropertyBool; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.EntityLivingBase; +import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.particles.ParticleTypes; +import net.minecraft.state.StateContainer; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Hand; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.IBlockAccess; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.world.IBlockReader; import net.minecraft.world.World; -import net.minecraftforge.api.distmarker.Dist; +import net.minecraft.world.server.ServerWorld; -import java.util.List; import java.util.Random; public class BlockFurnaceDouble extends BlockContainerBase { - - public static final PropertyBool IS_ON = PropertyBool.create("on"); - public BlockFurnaceDouble() { - super(Material.ROCK, this.name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - this.setTickRandomly(true); + // TODO: [port] confirm this is correct for light level... Might not be reactive. + super(ActuallyBlocks.defaultPickProps(0).tickRandomly().setLightLevel(state -> state.get(LIT) + ? 12 + : 0)); + + this.setDefaultState(this.stateContainer.getBaseState().with(HORIZONTAL_FACING, Direction.NORTH).with(LIT, false)); } @Override @@ -60,92 +51,55 @@ public class BlockFurnaceDouble extends BlockContainerBase { } @Override - @OnlyIn(Dist.CLIENT) - public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random rand) { - if (state.getValue(IS_ON)) { + public void randomTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) { + if (state.get(LIT)) { for (int i = 0; i < 5; i++) { - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double) pos.getX() + 0.5F, (double) pos.getY() + 1.0F, (double) pos.getZ() + 0.5F, 0.0D, 0.0D, 0.0D); + worldIn.addParticle(ParticleTypes.SMOKE, (double) pos.getX() + 0.5F, (double) pos.getY() + 1.0F, (double) pos.getZ() + 0.5F, 0.0D, 0.0D, 0.0D); } } } @Override public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - if (!world.isRemote) { - TileEntityFurnaceDouble furnace = (TileEntityFurnaceDouble) world.getTileEntity(pos); - if (furnace != null) { - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FURNACE_DOUBLE.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } - return true; - } - return true; + return this.openGui(worldIn, player, pos, TileEntityFurnaceDouble.class); } @Override - public int getLightValue(BlockState state, IBlockAccess world, BlockPos pos) { - return state.getValue(IS_ON) - ? 12 - : 0; + public BlockState getStateForPlacement(BlockItemUseContext context) { + return this.getDefaultState().with(HORIZONTAL_FACING, context.getNearestLookingDirection().getOpposite()).with(LIT, false); } @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.UNCOMMON; + protected void fillStateContainer(StateContainer.Builder builder) { + builder.add(LIT).add(HORIZONTAL_FACING); } + // TODO: [port] add back + + // public static class TheItemBlock extends ItemBlockBase { + // + // public TheItemBlock(Block block) { + // super(block); + // } + // + // @Override + // public void addInformation(ItemStack stack, World playerIn, List tooltip, ITooltipFlag advanced) { + // tooltip.add(TextFormatting.ITALIC + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".previouslyDoubleFurnace")); + // } + // } + + @Override - public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, EntityLivingBase player, ItemStack stack) { - world.setBlockState(pos, state.withProperty(BlockHorizontal.FACING, player.getHorizontalFacing().getOpposite()), 2); - - super.onBlockPlacedBy(world, pos, state, player, stack); - } - - @Override - public BlockState getStateFromMeta(int meta) { - boolean isOn = meta >= 4; - Direction facing = Direction.byHorizontalIndex(isOn - ? meta - 4 - : meta); - return this.getDefaultState().withProperty(BlockHorizontal.FACING, facing).withProperty(IS_ON, isOn); - } - - @Override - public int getMetaFromState(BlockState state) { - int meta = state.getValue(BlockHorizontal.FACING).getHorizontalIndex(); - return state.getValue(IS_ON) - ? meta + 4 - : meta; - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, BlockHorizontal.FACING, IS_ON); - } - - @Override - public BlockState withRotation(BlockState state, Rotation rot) { - return state.withProperty(BlockHorizontal.FACING, rot.rotate(state.getValue(BlockHorizontal.FACING))); - } - - @Override - public BlockState withMirror(BlockState state, Mirror mirror) { - return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING))); - } - - @Override - protected ItemBlockBase getItemBlock() { - return new TheItemBlock(this); - } - - public static class TheItemBlock extends ItemBlockBase { - - public TheItemBlock(Block block) { - super(block); - } - - @Override - public void addInformation(ItemStack stack, World playerIn, List tooltip, ITooltipFlag advanced) { - tooltip.add(TextFormatting.ITALIC + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".previouslyDoubleFurnace")); + public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + switch (state.get(HORIZONTAL_FACING)) { + case EAST: + return Shapes.FurnaceDoubleShapes.SHAPE_E; + case SOUTH: + return Shapes.FurnaceDoubleShapes.SHAPE_S; + case WEST: + return Shapes.FurnaceDoubleShapes.SHAPE_W; + default: + return Shapes.FurnaceDoubleShapes.SHAPE_N; } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/Shapes.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/Shapes.java index 34c61a2a8..7b269ae4c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/Shapes.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/Shapes.java @@ -5,6 +5,7 @@ import net.minecraft.util.math.shapes.IBooleanFunction; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShapes; +import java.util.Optional; import java.util.stream.Stream; public class Shapes { @@ -79,6 +80,47 @@ public class Shapes { Block.makeCuboidShape(0, 4, 4, 1, 12, 6), Block.makeCuboidShape(15, 4, 10, 16, 12, 12) ).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get(); + static final VoxelShape BARREL_SHAPE = Stream.of( + Block.makeCuboidShape(0, 12, 0, 16, 14, 1), Block.makeCuboidShape(1, 0.5, 1, 15, 15, 15), + Block.makeCuboidShape(0, 2, 15, 16, 4, 16), Block.makeCuboidShape(0, 7, 15, 16, 9, 16), + Block.makeCuboidShape(0, 12, 15, 16, 14, 16), Block.makeCuboidShape(0, 2, 0, 16, 4, 1), + Block.makeCuboidShape(0, 7, 0, 16, 9, 1), Block.makeCuboidShape(0, 2, 1, 1, 4, 15), + Block.makeCuboidShape(0, 7, 1, 1, 9, 15), Block.makeCuboidShape(0, 12, 1, 1, 14, 15), + Block.makeCuboidShape(15, 12, 1, 16, 14, 15), Block.makeCuboidShape(15, 7, 1, 16, 9, 15), + Block.makeCuboidShape(15, 2, 1, 16, 4, 15), Block.makeCuboidShape(7, 0, 0.5, 9, 16, 1.5), + Block.makeCuboidShape(0.5, 0, 7, 1.5, 16, 9), Block.makeCuboidShape(7, 0, 14.5, 9, 16, 15.5), + Block.makeCuboidShape(14.5, 0, 7, 15.5, 16, 9), Block.makeCuboidShape(2, 0, 0.5, 5, 16, 1.5), + Block.makeCuboidShape(0.5, 0, 11, 1.5, 16, 14), Block.makeCuboidShape(2, 0, 14.5, 5, 16, 15.5), + Block.makeCuboidShape(14.5, 0, 11, 15.5, 16, 14), Block.makeCuboidShape(11, 0, 0.5, 14, 16, 1.5), + Block.makeCuboidShape(0.5, 0, 2, 1.5, 16, 5), Block.makeCuboidShape(11, 0, 14.5, 14, 16, 15.5), + Block.makeCuboidShape(14.5, 0, 2, 15.5, 16, 5), Block.makeCuboidShape(4, 15, 7, 6, 15.3, 9), + Block.makeCuboidShape(2, 15, 4, 3, 15.3, 12), Block.makeCuboidShape(4, 15, 13, 12, 15.3, 14), + Block.makeCuboidShape(4, 15, 2, 12, 15.3, 3), Block.makeCuboidShape(13, 15, 4, 14, 15.3, 12), + Block.makeCuboidShape(3, 15, 3, 4, 15.3, 4), Block.makeCuboidShape(3, 15, 12, 4, 15.3, 13), + Block.makeCuboidShape(12, 15, 3, 13, 15.3, 4), Block.makeCuboidShape(12, 15, 12, 13, 15.3, 13) + ).reduce((v1, v2) -> { + return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR); + }).get(); + static final VoxelShape FIREWORKS_BOX_SHAPE = Stream.of( + Block.makeCuboidShape(0, 0, 0, 1, 1, 16), Block.makeCuboidShape(1, 0, 15, 15, 1, 16), + Block.makeCuboidShape(15, 0, 0, 16, 1, 16), Block.makeCuboidShape(1, 0, 0, 15, 1, 1), + Block.makeCuboidShape(0, 15, 0, 1, 16, 16), Block.makeCuboidShape(15, 15, 0, 16, 16, 16), + Block.makeCuboidShape(1, 15, 0, 15, 16, 1), Block.makeCuboidShape(1, 15, 15, 15, 16, 16), + Block.makeCuboidShape(0, 1, 15, 1, 15, 16), Block.makeCuboidShape(15, 1, 15, 16, 15, 16), + Block.makeCuboidShape(15, 1, 0, 16, 15, 1), Block.makeCuboidShape(0, 1, 0, 1, 15, 1), + Block.makeCuboidShape(10, 14, 9, 12, 15, 10), Block.makeCuboidShape(7, 14, 9, 9, 15, 10), + Block.makeCuboidShape(4, 14, 9, 6, 15, 10), Block.makeCuboidShape(10, 14, 6, 12, 15, 7), + Block.makeCuboidShape(7, 14, 6, 9, 15, 7), Block.makeCuboidShape(4, 14, 6, 6, 15, 7), + Block.makeCuboidShape(6, 14, 4, 7, 15, 12), Block.makeCuboidShape(9, 14, 4, 10, 15, 12), + Block.makeCuboidShape(4, 14, 12, 12, 15, 14), Block.makeCuboidShape(4, 14, 2, 12, 15, 4), + Block.makeCuboidShape(12, 14, 2, 14, 15, 14), Block.makeCuboidShape(2, 14, 2, 4, 15, 14), + Block.makeCuboidShape(2, 13, 2, 14, 14, 14), Block.makeCuboidShape(2, 0, 2, 14, 1, 14), + Block.makeCuboidShape(1, 0, 2, 2, 15, 14), Block.makeCuboidShape(14, 0, 2, 15, 15, 14), + Block.makeCuboidShape(1, 0, 1, 15, 15, 2), Block.makeCuboidShape(1, 0, 14, 15, 15, 15) + ).reduce((v1, v2) -> { + return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR); + }).get(); + static final class CoalGeneratorShapes { static final VoxelShape NORTH = Stream.of( @@ -320,4 +362,303 @@ public class Shapes { Block.makeCuboidShape(0, 6, 11, 1, 10, 13), Block.makeCuboidShape(0, 6, 3, 1, 10, 5) ).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get(); } + + static class FarmerShapes { + static final VoxelShape SHAPE_N = Stream.of( + Block.makeCuboidShape(11, 14, 4, 12, 15, 5), Block.makeCuboidShape(0, 0, 0, 1, 1, 16), + Block.makeCuboidShape(1, 0, 15, 15, 1, 16), Block.makeCuboidShape(15, 0, 0, 16, 1, 16), + Block.makeCuboidShape(1, 0, 0, 15, 1, 1), Block.makeCuboidShape(0, 15, 0, 1, 16, 16), + Block.makeCuboidShape(15, 15, 0, 16, 16, 16), Block.makeCuboidShape(1, 15, 0, 15, 16, 1), + Block.makeCuboidShape(1, 15, 15, 15, 16, 16), Block.makeCuboidShape(0, 1, 15, 1, 15, 16), + Block.makeCuboidShape(15, 1, 15, 16, 15, 16), Block.makeCuboidShape(15, 1, 0, 16, 15, 1), + Block.makeCuboidShape(0, 1, 0, 1, 15, 1), Block.makeCuboidShape(4, 11, 4, 12, 12, 12), + Block.makeCuboidShape(4, 14, 4, 5, 15, 5), Block.makeCuboidShape(3, 12, 5, 4, 14, 11), + Block.makeCuboidShape(12, 12, 5, 13, 14, 11), Block.makeCuboidShape(5, 12, 3, 11, 14, 4), + Block.makeCuboidShape(5, 12, 12, 11, 14, 13), Block.makeCuboidShape(11, 12, 11, 12, 14, 12), + Block.makeCuboidShape(11, 12, 4, 12, 14, 5), Block.makeCuboidShape(4, 12, 4, 5, 14, 5), + Block.makeCuboidShape(4, 12, 11, 5, 14, 12), Block.makeCuboidShape(4, 14, 11, 5, 15, 12), + Block.makeCuboidShape(11, 14, 11, 12, 15, 12), Block.makeCuboidShape(2, 14, 2, 4, 15, 14), + Block.makeCuboidShape(4, 14, 2, 12, 15, 4), Block.makeCuboidShape(4, 14, 12, 12, 15, 14), + Block.makeCuboidShape(12, 14, 2, 14, 15, 14), Block.makeCuboidShape(2, 0, 2, 14, 1, 14), + Block.makeCuboidShape(1, 0, 2, 2, 15, 14), Block.makeCuboidShape(14, 0, 2, 15, 15, 14), + Block.makeCuboidShape(1, 0, 1, 5, 15, 2), Block.makeCuboidShape(5, 5, 2, 11, 11, 3), + Block.makeCuboidShape(5, 0, 1, 11, 5, 2), Block.makeCuboidShape(5, 11, 1, 11, 15, 2), + Block.makeCuboidShape(11, 0, 1, 15, 15, 2), Block.makeCuboidShape(1, 0, 14, 15, 15, 15) + ).reduce((v1, v2) -> { + return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR); + }).get(); + + static final VoxelShape SHAPE_E = Stream.of( + Block.makeCuboidShape(11, 14, 11, 12, 15, 12), Block.makeCuboidShape(0, 0, 0, 16, 1, 1), + Block.makeCuboidShape(0, 0, 1, 1, 1, 15), Block.makeCuboidShape(0, 0, 15, 16, 1, 16), + Block.makeCuboidShape(15, 0, 1, 16, 1, 15), Block.makeCuboidShape(0, 15, 0, 16, 16, 1), + Block.makeCuboidShape(0, 15, 15, 16, 16, 16), Block.makeCuboidShape(15, 15, 1, 16, 16, 15), + Block.makeCuboidShape(0, 15, 1, 1, 16, 15), Block.makeCuboidShape(0, 1, 0, 1, 15, 1), + Block.makeCuboidShape(0, 1, 15, 1, 15, 16), Block.makeCuboidShape(15, 1, 15, 16, 15, 16), + Block.makeCuboidShape(15, 1, 0, 16, 15, 1), Block.makeCuboidShape(4, 11, 4, 12, 12, 12), + Block.makeCuboidShape(11, 14, 4, 12, 15, 5), Block.makeCuboidShape(5, 12, 3, 11, 14, 4), + Block.makeCuboidShape(5, 12, 12, 11, 14, 13), Block.makeCuboidShape(12, 12, 5, 13, 14, 11), + Block.makeCuboidShape(3, 12, 5, 4, 14, 11), Block.makeCuboidShape(4, 12, 11, 5, 14, 12), + Block.makeCuboidShape(11, 12, 11, 12, 14, 12), Block.makeCuboidShape(11, 12, 4, 12, 14, 5), + Block.makeCuboidShape(4, 12, 4, 5, 14, 5), Block.makeCuboidShape(4, 14, 4, 5, 15, 5), + Block.makeCuboidShape(4, 14, 11, 5, 15, 12), Block.makeCuboidShape(2, 14, 2, 14, 15, 4), + Block.makeCuboidShape(12, 14, 4, 14, 15, 12), Block.makeCuboidShape(2, 14, 4, 4, 15, 12), + Block.makeCuboidShape(2, 14, 12, 14, 15, 14), Block.makeCuboidShape(2, 0, 2, 14, 1, 14), + Block.makeCuboidShape(2, 0, 1, 14, 15, 2), Block.makeCuboidShape(2, 0, 14, 14, 15, 15), + Block.makeCuboidShape(14, 0, 1, 15, 15, 5), Block.makeCuboidShape(13, 5, 5, 14, 11, 11), + Block.makeCuboidShape(14, 0, 5, 15, 5, 11), Block.makeCuboidShape(14, 11, 5, 15, 15, 11), + Block.makeCuboidShape(14, 0, 11, 15, 15, 15), Block.makeCuboidShape(1, 0, 1, 2, 15, 15) + ).reduce((v1, v2) -> { + return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR); + }).get(); + + static final VoxelShape SHAPE_S = Stream.of( + Block.makeCuboidShape(4, 14, 11, 5, 15, 12), Block.makeCuboidShape(15, 0, 0, 16, 1, 16), + Block.makeCuboidShape(1, 0, 0, 15, 1, 1), Block.makeCuboidShape(0, 0, 0, 1, 1, 16), + Block.makeCuboidShape(1, 0, 15, 15, 1, 16), Block.makeCuboidShape(15, 15, 0, 16, 16, 16), + Block.makeCuboidShape(0, 15, 0, 1, 16, 16), Block.makeCuboidShape(1, 15, 15, 15, 16, 16), + Block.makeCuboidShape(1, 15, 0, 15, 16, 1), Block.makeCuboidShape(15, 1, 0, 16, 15, 1), + Block.makeCuboidShape(0, 1, 0, 1, 15, 1), Block.makeCuboidShape(0, 1, 15, 1, 15, 16), + Block.makeCuboidShape(15, 1, 15, 16, 15, 16), Block.makeCuboidShape(4, 11, 4, 12, 12, 12), + Block.makeCuboidShape(11, 14, 11, 12, 15, 12), Block.makeCuboidShape(12, 12, 5, 13, 14, 11), + Block.makeCuboidShape(3, 12, 5, 4, 14, 11), Block.makeCuboidShape(5, 12, 12, 11, 14, 13), + Block.makeCuboidShape(5, 12, 3, 11, 14, 4), Block.makeCuboidShape(4, 12, 4, 5, 14, 5), + Block.makeCuboidShape(4, 12, 11, 5, 14, 12), Block.makeCuboidShape(11, 12, 11, 12, 14, 12), + Block.makeCuboidShape(11, 12, 4, 12, 14, 5), Block.makeCuboidShape(11, 14, 4, 12, 15, 5), + Block.makeCuboidShape(4, 14, 4, 5, 15, 5), Block.makeCuboidShape(12, 14, 2, 14, 15, 14), + Block.makeCuboidShape(4, 14, 12, 12, 15, 14), Block.makeCuboidShape(4, 14, 2, 12, 15, 4), + Block.makeCuboidShape(2, 14, 2, 4, 15, 14), Block.makeCuboidShape(2, 0, 2, 14, 1, 14), + Block.makeCuboidShape(14, 0, 2, 15, 15, 14), Block.makeCuboidShape(1, 0, 2, 2, 15, 14), + Block.makeCuboidShape(11, 0, 14, 15, 15, 15), Block.makeCuboidShape(5, 5, 13, 11, 11, 14), + Block.makeCuboidShape(5, 0, 14, 11, 5, 15), Block.makeCuboidShape(5, 11, 14, 11, 15, 15), + Block.makeCuboidShape(1, 0, 14, 5, 15, 15), Block.makeCuboidShape(1, 0, 1, 15, 15, 2) + ).reduce((v1, v2) -> { + return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR); + }).get(); + + static final VoxelShape SHAPE_W = Stream.of( + Block.makeCuboidShape(4, 14, 4, 5, 15, 5), Block.makeCuboidShape(0, 0, 15, 16, 1, 16), + Block.makeCuboidShape(15, 0, 1, 16, 1, 15), Block.makeCuboidShape(0, 0, 0, 16, 1, 1), + Block.makeCuboidShape(0, 0, 1, 1, 1, 15), Block.makeCuboidShape(0, 15, 15, 16, 16, 16), + Block.makeCuboidShape(0, 15, 0, 16, 16, 1), Block.makeCuboidShape(0, 15, 1, 1, 16, 15), + Block.makeCuboidShape(15, 15, 1, 16, 16, 15), Block.makeCuboidShape(15, 1, 15, 16, 15, 16), + Block.makeCuboidShape(15, 1, 0, 16, 15, 1), Block.makeCuboidShape(0, 1, 0, 1, 15, 1), + Block.makeCuboidShape(0, 1, 15, 1, 15, 16), Block.makeCuboidShape(4, 11, 4, 12, 12, 12), + Block.makeCuboidShape(4, 14, 11, 5, 15, 12), Block.makeCuboidShape(5, 12, 12, 11, 14, 13), + Block.makeCuboidShape(5, 12, 3, 11, 14, 4), Block.makeCuboidShape(3, 12, 5, 4, 14, 11), + Block.makeCuboidShape(12, 12, 5, 13, 14, 11), Block.makeCuboidShape(11, 12, 4, 12, 14, 5), + Block.makeCuboidShape(4, 12, 4, 5, 14, 5), Block.makeCuboidShape(4, 12, 11, 5, 14, 12), + Block.makeCuboidShape(11, 12, 11, 12, 14, 12), Block.makeCuboidShape(11, 14, 11, 12, 15, 12), + Block.makeCuboidShape(11, 14, 4, 12, 15, 5), Block.makeCuboidShape(2, 14, 12, 14, 15, 14), + Block.makeCuboidShape(2, 14, 4, 4, 15, 12), Block.makeCuboidShape(12, 14, 4, 14, 15, 12), + Block.makeCuboidShape(2, 14, 2, 14, 15, 4), Block.makeCuboidShape(2, 0, 2, 14, 1, 14), + Block.makeCuboidShape(2, 0, 14, 14, 15, 15), Block.makeCuboidShape(2, 0, 1, 14, 15, 2), + Block.makeCuboidShape(1, 0, 11, 2, 15, 15), Block.makeCuboidShape(2, 5, 5, 3, 11, 11), + Block.makeCuboidShape(1, 0, 5, 2, 5, 11), Block.makeCuboidShape(1, 11, 5, 2, 15, 11), + Block.makeCuboidShape(1, 0, 1, 2, 15, 5), Block.makeCuboidShape(14, 0, 1, 15, 15, 15) + ).reduce((v1, v2) -> { + return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR); + }).get(); + } + + static class FluidCollectorShapes { + static final VoxelShape SHAPE_U = Stream.of( + Block.makeCuboidShape(1, 1, 1, 15, 15, 15), Block.makeCuboidShape(0, 15, 15, 16, 16, 16), + Block.makeCuboidShape(0, 15, 0, 16, 16, 1), Block.makeCuboidShape(0, 0, 15, 16, 1, 16), + Block.makeCuboidShape(0, 0, 0, 16, 1, 1), Block.makeCuboidShape(0, 1, 15, 1, 15, 16), + Block.makeCuboidShape(0, 1, 0, 1, 15, 1), Block.makeCuboidShape(15, 1, 15, 16, 15, 16), + Block.makeCuboidShape(15, 1, 0, 16, 15, 1), Block.makeCuboidShape(0, 15, 1, 1, 16, 15), + Block.makeCuboidShape(0, 0, 1, 1, 1, 15), Block.makeCuboidShape(15, 0, 1, 16, 1, 15), + Block.makeCuboidShape(15, 15, 1, 16, 16, 15), Block.makeCuboidShape(15, 3, 6, 16, 13, 10), + Block.makeCuboidShape(0, 3, 6, 1, 13, 10), Block.makeCuboidShape(5, 15, 5, 11, 16, 11), + Block.makeCuboidShape(3, 15, 6, 5, 16, 10), Block.makeCuboidShape(11, 15, 6, 13, 16, 10), + Block.makeCuboidShape(6, 15, 11, 10, 16, 13), Block.makeCuboidShape(6, 15, 3, 10, 16, 5) + ).reduce((v1, v2) -> { + return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR); + }).get(); + + static final VoxelShape SHAPE_D = Stream.of( + Block.makeCuboidShape(1, 1, 1, 15, 15, 15), Block.makeCuboidShape(0, 0, 0, 16, 1, 1), + Block.makeCuboidShape(0, 0, 15, 16, 1, 16), Block.makeCuboidShape(0, 15, 0, 16, 16, 1), + Block.makeCuboidShape(0, 15, 15, 16, 16, 16), Block.makeCuboidShape(0, 1, 0, 1, 15, 1), + Block.makeCuboidShape(0, 1, 15, 1, 15, 16), Block.makeCuboidShape(15, 1, 0, 16, 15, 1), + Block.makeCuboidShape(15, 1, 15, 16, 15, 16), Block.makeCuboidShape(0, 0, 1, 1, 1, 15), + Block.makeCuboidShape(0, 15, 1, 1, 16, 15), Block.makeCuboidShape(15, 15, 1, 16, 16, 15), + Block.makeCuboidShape(15, 0, 1, 16, 1, 15), Block.makeCuboidShape(15, 3, 6, 16, 13, 10), + Block.makeCuboidShape(0, 3, 6, 1, 13, 10), Block.makeCuboidShape(5, 0, 5, 11, 1, 11), + Block.makeCuboidShape(3, 0, 6, 5, 1, 10), Block.makeCuboidShape(11, 0, 6, 13, 1, 10), + Block.makeCuboidShape(6, 0, 3, 10, 1, 5), Block.makeCuboidShape(6, 0, 11, 10, 1, 13) + ).reduce((v1, v2) -> { + return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR); + }).get(); + + static final VoxelShape SHAPE_N = Stream.of( + Block.makeCuboidShape(1, 1, 1, 15, 15, 15), Block.makeCuboidShape(0, 15, 0, 16, 16, 1), + Block.makeCuboidShape(0, 0, 0, 16, 1, 1), Block.makeCuboidShape(0, 15, 15, 16, 16, 16), + Block.makeCuboidShape(0, 0, 15, 16, 1, 16), Block.makeCuboidShape(0, 15, 1, 1, 16, 15), + Block.makeCuboidShape(0, 0, 1, 1, 1, 15), Block.makeCuboidShape(15, 15, 1, 16, 16, 15), + Block.makeCuboidShape(15, 0, 1, 16, 1, 15), Block.makeCuboidShape(0, 1, 0, 1, 15, 1), + Block.makeCuboidShape(0, 1, 15, 1, 15, 16), Block.makeCuboidShape(15, 1, 15, 16, 15, 16), + Block.makeCuboidShape(15, 1, 0, 16, 15, 1), Block.makeCuboidShape(15, 6, 3, 16, 10, 13), + Block.makeCuboidShape(0, 6, 3, 1, 10, 13), Block.makeCuboidShape(5, 5, 0, 11, 11, 1), + Block.makeCuboidShape(3, 6, 0, 5, 10, 1), Block.makeCuboidShape(11, 6, 0, 13, 10, 1), + Block.makeCuboidShape(6, 11, 0, 10, 13, 1), Block.makeCuboidShape(6, 3, 0, 10, 5, 1) + ).reduce((v1, v2) -> { + return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR); + }).get(); + + + static final VoxelShape SHAPE_E = Stream.of( + Block.makeCuboidShape(1, 1, 1, 15, 15, 15), Block.makeCuboidShape(15, 15, 0, 16, 16, 16), + Block.makeCuboidShape(15, 0, 0, 16, 1, 16), Block.makeCuboidShape(0, 15, 0, 1, 16, 16), + Block.makeCuboidShape(0, 0, 0, 1, 1, 16), Block.makeCuboidShape(1, 15, 0, 15, 16, 1), + Block.makeCuboidShape(1, 0, 0, 15, 1, 1), Block.makeCuboidShape(1, 15, 15, 15, 16, 16), + Block.makeCuboidShape(1, 0, 15, 15, 1, 16), Block.makeCuboidShape(15, 1, 0, 16, 15, 1), + Block.makeCuboidShape(0, 1, 0, 1, 15, 1), Block.makeCuboidShape(0, 1, 15, 1, 15, 16), + Block.makeCuboidShape(15, 1, 15, 16, 15, 16), Block.makeCuboidShape(3, 6, 15, 13, 10, 16), + Block.makeCuboidShape(3, 6, 0, 13, 10, 1), Block.makeCuboidShape(15, 5, 5, 16, 11, 11), + Block.makeCuboidShape(15, 6, 3, 16, 10, 5), Block.makeCuboidShape(15, 6, 11, 16, 10, 13), + Block.makeCuboidShape(15, 11, 6, 16, 13, 10), Block.makeCuboidShape(15, 3, 6, 16, 5, 10) + ).reduce((v1, v2) -> { + return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR); + }).get(); + + static final VoxelShape SHAPE_S = Stream.of( + Block.makeCuboidShape(1, 1, 1, 15, 15, 15), Block.makeCuboidShape(0, 15, 15, 16, 16, 16), + Block.makeCuboidShape(0, 0, 15, 16, 1, 16), Block.makeCuboidShape(0, 15, 0, 16, 16, 1), + Block.makeCuboidShape(0, 0, 0, 16, 1, 1), Block.makeCuboidShape(15, 15, 1, 16, 16, 15), + Block.makeCuboidShape(15, 0, 1, 16, 1, 15), Block.makeCuboidShape(0, 15, 1, 1, 16, 15), + Block.makeCuboidShape(0, 0, 1, 1, 1, 15), Block.makeCuboidShape(15, 1, 15, 16, 15, 16), + Block.makeCuboidShape(15, 1, 0, 16, 15, 1), Block.makeCuboidShape(0, 1, 0, 1, 15, 1), + Block.makeCuboidShape(0, 1, 15, 1, 15, 16), Block.makeCuboidShape(0, 6, 3, 1, 10, 13), + Block.makeCuboidShape(15, 6, 3, 16, 10, 13), Block.makeCuboidShape(5, 5, 15, 11, 11, 16), + Block.makeCuboidShape(11, 6, 15, 13, 10, 16), Block.makeCuboidShape(3, 6, 15, 5, 10, 16), + Block.makeCuboidShape(6, 11, 15, 10, 13, 16), Block.makeCuboidShape(6, 3, 15, 10, 5, 16) + ).reduce((v1, v2) -> { + return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR); + }).get(); + + static final VoxelShape SHAPE_W = Stream.of( + Block.makeCuboidShape(1, 1, 1, 15, 15, 15), Block.makeCuboidShape(0, 15, 0, 1, 16, 16), + Block.makeCuboidShape(0, 0, 0, 1, 1, 16), Block.makeCuboidShape(15, 15, 0, 16, 16, 16), + Block.makeCuboidShape(15, 0, 0, 16, 1, 16), Block.makeCuboidShape(1, 15, 15, 15, 16, 16), + Block.makeCuboidShape(1, 0, 15, 15, 1, 16), Block.makeCuboidShape(1, 15, 0, 15, 16, 1), + Block.makeCuboidShape(1, 0, 0, 15, 1, 1), Block.makeCuboidShape(0, 1, 15, 1, 15, 16), + Block.makeCuboidShape(15, 1, 15, 16, 15, 16), Block.makeCuboidShape(15, 1, 0, 16, 15, 1), + Block.makeCuboidShape(0, 1, 0, 1, 15, 1), Block.makeCuboidShape(3, 6, 0, 13, 10, 1), + Block.makeCuboidShape(3, 6, 15, 13, 10, 16), Block.makeCuboidShape(0, 5, 5, 1, 11, 11), + Block.makeCuboidShape(0, 6, 11, 1, 10, 13), Block.makeCuboidShape(0, 6, 3, 1, 10, 5), + Block.makeCuboidShape(0, 11, 6, 1, 13, 10), Block.makeCuboidShape(0, 3, 6, 1, 5, 10) + ).reduce((v1, v2) -> { + return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR); + }).get(); + } + + static class FurnaceDoubleShapes { + static final VoxelShape SHAPE_N = Stream.of( + Block.makeCuboidShape(15, 15, 0, 16, 16, 16), Block.makeCuboidShape(0, 15, 0, 1, 16, 16), + Block.makeCuboidShape(1, 15, 0, 15, 16, 1), Block.makeCuboidShape(1, 15, 15, 15, 16, 16), + Block.makeCuboidShape(0, 1, 15, 1, 15, 16), Block.makeCuboidShape(15, 1, 15, 16, 15, 16), + Block.makeCuboidShape(15, 1, 0, 16, 15, 1), Block.makeCuboidShape(0, 1, 0, 1, 15, 1), + Block.makeCuboidShape(0, 0, 0, 16, 1, 16), Block.makeCuboidShape(5, 14, 6, 11, 15, 7), + Block.makeCuboidShape(5, 14, 8, 11, 15, 9), Block.makeCuboidShape(5, 14, 10, 11, 15, 14), + Block.makeCuboidShape(5, 14, 2, 11, 15, 5), Block.makeCuboidShape(11, 14, 2, 14, 15, 14), + Block.makeCuboidShape(2, 14, 2, 5, 15, 14), Block.makeCuboidShape(1, 1, 2, 2, 15, 14), + Block.makeCuboidShape(14, 1, 2, 15, 15, 14), Block.makeCuboidShape(1, 1, 14, 15, 15, 15), + Block.makeCuboidShape(7, 3, 1, 9, 7, 2), Block.makeCuboidShape(3, 7, 1, 13, 15, 2), + Block.makeCuboidShape(3, 1, 1, 13, 3, 2), Block.makeCuboidShape(1, 1, 1, 3, 15, 2), + Block.makeCuboidShape(13, 1, 1, 15, 15, 2), Block.makeCuboidShape(5, 13, 5, 11, 14, 10), + Block.makeCuboidShape(2, 3, 2, 14, 8, 3) + ).reduce((v1, v2) -> { + return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR); + }).get(); + + static final VoxelShape SHAPE_E = Stream.of( + Block.makeCuboidShape(0, 15, 15, 16, 16, 16), Block.makeCuboidShape(0, 15, 0, 16, 16, 1), + Block.makeCuboidShape(15, 15, 1, 16, 16, 15), Block.makeCuboidShape(0, 15, 1, 1, 16, 15), + Block.makeCuboidShape(0, 1, 0, 1, 15, 1), Block.makeCuboidShape(0, 1, 15, 1, 15, 16), + Block.makeCuboidShape(15, 1, 15, 16, 15, 16), Block.makeCuboidShape(15, 1, 0, 16, 15, 1), + Block.makeCuboidShape(0, 0, 0, 16, 1, 16), Block.makeCuboidShape(9, 14, 5, 10, 15, 11), + Block.makeCuboidShape(7, 14, 5, 8, 15, 11), Block.makeCuboidShape(2, 14, 5, 6, 15, 11), + Block.makeCuboidShape(11, 14, 5, 14, 15, 11), Block.makeCuboidShape(2, 14, 11, 14, 15, 14), + Block.makeCuboidShape(2, 14, 2, 14, 15, 5), Block.makeCuboidShape(2, 1, 1, 14, 15, 2), + Block.makeCuboidShape(2, 1, 14, 14, 15, 15), Block.makeCuboidShape(1, 1, 1, 2, 15, 15), + Block.makeCuboidShape(14, 3, 7, 15, 7, 9), Block.makeCuboidShape(14, 7, 3, 15, 15, 13), + Block.makeCuboidShape(14, 1, 3, 15, 3, 13), Block.makeCuboidShape(14, 1, 1, 15, 15, 3), + Block.makeCuboidShape(14, 1, 13, 15, 15, 15), Block.makeCuboidShape(6, 13, 5, 11, 14, 11), + Block.makeCuboidShape(13, 3, 2, 14, 8, 14) + ).reduce((v1, v2) -> { + return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR); + }).get(); + + static final VoxelShape SHAPE_S = Stream.of( + Block.makeCuboidShape(0, 15, 0, 1, 16, 16), Block.makeCuboidShape(15, 15, 0, 16, 16, 16), + Block.makeCuboidShape(1, 15, 15, 15, 16, 16), Block.makeCuboidShape(1, 15, 0, 15, 16, 1), + Block.makeCuboidShape(15, 1, 0, 16, 15, 1), Block.makeCuboidShape(0, 1, 0, 1, 15, 1), + Block.makeCuboidShape(0, 1, 15, 1, 15, 16), Block.makeCuboidShape(15, 1, 15, 16, 15, 16), + Block.makeCuboidShape(0, 0, 0, 16, 1, 16), Block.makeCuboidShape(5, 14, 9, 11, 15, 10), + Block.makeCuboidShape(5, 14, 7, 11, 15, 8), Block.makeCuboidShape(5, 14, 2, 11, 15, 6), + Block.makeCuboidShape(5, 14, 11, 11, 15, 14), Block.makeCuboidShape(2, 14, 2, 5, 15, 14), + Block.makeCuboidShape(11, 14, 2, 14, 15, 14), Block.makeCuboidShape(14, 1, 2, 15, 15, 14), + Block.makeCuboidShape(1, 1, 2, 2, 15, 14), Block.makeCuboidShape(1, 1, 1, 15, 15, 2), + Block.makeCuboidShape(7, 3, 14, 9, 7, 15), Block.makeCuboidShape(3, 7, 14, 13, 15, 15), + Block.makeCuboidShape(3, 1, 14, 13, 3, 15), Block.makeCuboidShape(13, 1, 14, 15, 15, 15), + Block.makeCuboidShape(1, 1, 14, 3, 15, 15), Block.makeCuboidShape(5, 13, 6, 11, 14, 11), + Block.makeCuboidShape(2, 3, 13, 14, 8, 14) + ).reduce((v1, v2) -> { + return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR); + }).get(); + + static final VoxelShape SHAPE_W = Stream.of( + Block.makeCuboidShape(0, 15, 0, 16, 16, 1), Block.makeCuboidShape(0, 15, 15, 16, 16, 16), + Block.makeCuboidShape(0, 15, 1, 1, 16, 15), Block.makeCuboidShape(15, 15, 1, 16, 16, 15), + Block.makeCuboidShape(15, 1, 15, 16, 15, 16), Block.makeCuboidShape(15, 1, 0, 16, 15, 1), + Block.makeCuboidShape(0, 1, 0, 1, 15, 1), Block.makeCuboidShape(0, 1, 15, 1, 15, 16), + Block.makeCuboidShape(0, 0, 0, 16, 1, 16), Block.makeCuboidShape(6, 14, 5, 7, 15, 11), + Block.makeCuboidShape(8, 14, 5, 9, 15, 11), Block.makeCuboidShape(10, 14, 5, 14, 15, 11), + Block.makeCuboidShape(2, 14, 5, 5, 15, 11), Block.makeCuboidShape(2, 14, 2, 14, 15, 5), + Block.makeCuboidShape(2, 14, 11, 14, 15, 14), Block.makeCuboidShape(2, 1, 14, 14, 15, 15), + Block.makeCuboidShape(2, 1, 1, 14, 15, 2), Block.makeCuboidShape(14, 1, 1, 15, 15, 15), + Block.makeCuboidShape(1, 3, 7, 2, 7, 9), Block.makeCuboidShape(1, 7, 3, 2, 15, 13), + Block.makeCuboidShape(1, 1, 3, 2, 3, 13), Block.makeCuboidShape(1, 1, 13, 2, 15, 15), + Block.makeCuboidShape(1, 1, 1, 2, 15, 3), Block.makeCuboidShape(5, 13, 5, 10, 14, 11), + Block.makeCuboidShape(2, 3, 2, 3, 8, 14) + ).reduce((v1, v2) -> { + return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR); + }).get(); + } + + public static final VoxelShape FEEDER_SHAPE = ShapeBuilder.get() + .add(0, 15, 0, 1, 16, 16).add(15, 15, 0, 16, 16, 16) + .add(1, 15, 0, 15, 16, 1).add(1, 15, 15, 15, 16, 16).add(1, 0, 15, 15, 1, 16) + .add(1, 0, 0, 15, 1, 1).add(15, 0, 0, 16, 1, 16).add(0, 0, 0, 1, 1, 16) + .add(0, 1, 15, 1, 15, 16).add(15, 1, 15, 16, 15, 16).add(15, 1, 0, 16, 15, 1) + .add(0, 1, 0, 1, 15, 1).add(11, 14, 11, 12, 15, 12).add(11, 14, 4, 12, 15, 5) + .add(4, 14, 11, 5, 15, 12).add(4, 14, 4, 5, 15, 5).add(4, 13, 4, 12, 14, 12) + .add(4, 14, 12, 12, 15, 15).add(4, 14, 1, 12, 15, 4).add(1, 14, 1, 4, 15, 15) + .add(12, 14, 1, 15, 15, 15).add(1, 1, 1, 15, 2, 15).add(14, 2, 1, 15, 14, 15) + .add(1, 2, 1, 2, 14, 15).add(2, 2, 14, 14, 14, 15).add(2, 2, 1, 14, 14, 2) + .standardReduceBuild().get(); + + public static class ShapeBuilder { + Stream.Builder shapes = Stream.builder(); + + public ShapeBuilder add(double x1, double y1, double z1, double x2, double y2, double z2) { + this.shapes.add(Block.makeCuboidShape(x1, y1, z1, x2, y2, z2)); + return this; + } + + public Stream build() { + return this.shapes.build(); + } + + public Optional standardReduceBuild() { + return this.shapes.build().reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)); + } + + public static ShapeBuilder get() { + return new ShapeBuilder(); + } + } + } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerGrinder.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerGrinder.java index 90375c48d..d56a777ac 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerGrinder.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerGrinder.java @@ -29,13 +29,13 @@ public class ContainerGrinder extends Container { public final boolean isDouble; public static ContainerGrinder fromNetwork(int windowId, PlayerInventory inv, PacketBuffer data) { - return new ContainerGrinder(windowId, inv, data.readBoolean(), (TileEntityGrinder) Objects.requireNonNull(inv.player.world.getTileEntity(data.readBlockPos()))); + return new ContainerGrinder(windowId, inv, (TileEntityGrinder) Objects.requireNonNull(inv.player.world.getTileEntity(data.readBlockPos()))); } - public ContainerGrinder(int windowId, PlayerInventory inventory, boolean isDouble, TileEntityGrinder tile) { + public ContainerGrinder(int windowId, PlayerInventory inventory, TileEntityGrinder tile) { super(ActuallyContainers.GRINDER_CONTAINER.get(), windowId); this.tileGrinder = tile; - this.isDouble = isDouble; + this.isDouble = tile.isDouble; this.addSlot(new SlotItemHandlerUnconditioned(this.tileGrinder.inv, TileEntityGrinder.SLOT_INPUT_1, this.isDouble ? 51 diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerInputter.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerInputter.java index 87a8a0c5c..6e67ecdce 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerInputter.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerInputter.java @@ -30,19 +30,19 @@ public class ContainerInputter extends Container { public final boolean isAdvanced; public static ContainerInputter fromNetwork(int windowId, PlayerInventory inv, PacketBuffer data) { - return new ContainerInputter(windowId, inv, data.readBoolean(), (TileEntityInputter) Objects.requireNonNull(inv.player.world.getTileEntity(data.readBlockPos()))); + return new ContainerInputter(windowId, inv, (TileEntityInputter) Objects.requireNonNull(inv.player.world.getTileEntity(data.readBlockPos()))); } - public ContainerInputter(int windowId, PlayerInventory inventory, boolean isAdvanced, TileEntityInputter tile) { + public ContainerInputter(int windowId, PlayerInventory inventory, TileEntityInputter tile) { super(ActuallyContainers.INPUTTER_CONTAINER.get(), windowId); this.tileInputter = tile; - this.isAdvanced = isAdvanced; + this.isAdvanced = tile.isAdvanced; - this.addSlot(new SlotItemHandlerUnconditioned(this.tileInputter.inv, 0, 80, 21 + (isAdvanced + this.addSlot(new SlotItemHandlerUnconditioned(this.tileInputter.inv, 0, 80, 21 + (this.isAdvanced ? 12 : 0))); - if (isAdvanced) { + if (this.isAdvanced) { for (int i = 0; i < 2; i++) { for (int x = 0; x < 3; x++) { for (int y = 0; y < 4; y++) { @@ -56,13 +56,13 @@ public class ContainerInputter extends Container { for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { - this.addSlot(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 101 + i * 18 + (isAdvanced + this.addSlot(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 101 + i * 18 + (this.isAdvanced ? GuiInputter.OFFSET_ADVANCED : 0))); } } for (int i = 0; i < 9; i++) { - this.addSlot(new Slot(inventory, i, 8 + i * 18, 159 + (isAdvanced + this.addSlot(new Slot(inventory, i, 8 + i * 18, 159 + (this.isAdvanced ? GuiInputter.OFFSET_ADVANCED : 0))); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFarmer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFarmer.java index 8be0624d3..ec4768ddf 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFarmer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFarmer.java @@ -15,25 +15,33 @@ import de.ellpeck.actuallyadditions.api.farmer.FarmerResult; import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior; import de.ellpeck.actuallyadditions.api.internal.IFarmer; import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; +import de.ellpeck.actuallyadditions.mod.inventory.ContainerFarmer; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.Container; +import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.World; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.Collections; import java.util.List; -public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer { +public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer, INamedContainerProvider { private static final List SORTED_FARMER_BEHAVIORS = new ArrayList<>(); public final CustomEnergyStorage storage = new CustomEnergyStorage(100000, 1000, 0); @@ -225,4 +233,15 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer public void addToOutput(List stacks) { StackUtil.addAll(this.inv, stacks, 6, 12, false); } + + @Override + public ITextComponent getDisplayName() { + return StringTextComponent.EMPTY; + } + + @Nullable + @Override + public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity p_createMenu_3_) { + return new ContainerFarmer(windowId, playerInventory, this); + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFeeder.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFeeder.java index 9a9785d43..30a05421f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFeeder.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFeeder.java @@ -10,9 +10,14 @@ package de.ellpeck.actuallyadditions.mod.tile; +import de.ellpeck.actuallyadditions.mod.inventory.ContainerFeeder; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; import net.minecraft.entity.passive.AnimalEntity; import net.minecraft.entity.passive.horse.HorseEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.Container; +import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; @@ -20,11 +25,14 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.particles.ParticleTypes; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.MathHelper; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; +import javax.annotation.Nullable; import java.util.List; import java.util.Optional; -public class TileEntityFeeder extends TileEntityInventoryBase { +public class TileEntityFeeder extends TileEntityInventoryBase implements INamedContainerProvider { public static final int THRESHOLD = 30; private static final int TIME = 100; @@ -109,4 +117,15 @@ public class TileEntityFeeder extends TileEntityInventoryBase { } return animal.getGrowingAge() == 0 && !animal.isInLove() && animal.isBreedingItem(stack); } + + @Override + public ITextComponent getDisplayName() { + return StringTextComponent.EMPTY; + } + + @Nullable + @Override + public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity p_createMenu_3_) { + return new ContainerFeeder(windowId, playerInventory, this); + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java index 32452d6bb..f5cb55820 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java @@ -11,16 +11,25 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; +import de.ellpeck.actuallyadditions.mod.inventory.ContainerFermentingBarrel; import de.ellpeck.actuallyadditions.mod.util.Util; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.Container; +import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Direction; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.templates.FluidTank; -public class TileEntityFermentingBarrel extends TileEntityBase implements ISharingFluidHandler { +import javax.annotation.Nullable; + +public class TileEntityFermentingBarrel extends TileEntityBase implements ISharingFluidHandler, INamedContainerProvider { private static final int PROCESS_TIME = 100; public final FluidTank canolaTank = new FluidTank(2 * Util.BUCKET) { @@ -149,4 +158,15 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari public Direction[] getFluidShareSides() { return Direction.values(); } + + @Override + public ITextComponent getDisplayName() { + return StringTextComponent.EMPTY; + } + + @Nullable + @Override + public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity p_createMenu_3_) { + return new ContainerFermentingBarrel(windowId, playerInventory, this); + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFireworkBox.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFireworkBox.java index d2e44c960..94f748e34 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFireworkBox.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFireworkBox.java @@ -10,9 +10,13 @@ package de.ellpeck.actuallyadditions.mod.tile; +import de.ellpeck.actuallyadditions.mod.inventory.ContainerFireworkBox; import de.ellpeck.actuallyadditions.mod.network.gui.INumberReactor; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.projectile.FireworkRocketEntity; +import net.minecraft.inventory.container.Container; +import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.item.DyeColor; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; @@ -22,14 +26,17 @@ import net.minecraft.util.Direction; import net.minecraft.util.WeightedRandom; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.World; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; -public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisplay, INumberReactor { +public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisplay, INumberReactor, INamedContainerProvider { public static final int USE_PER_SHOT = 500; public final CustomEnergyStorage storage = new CustomEnergyStorage(20000, 200, 0); @@ -277,6 +284,17 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisp return this.lazyEnergy; } + @Override + public ITextComponent getDisplayName() { + return StringTextComponent.EMPTY; + } + + @Nullable + @Override + public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity p_createMenu_3_) { + return new ContainerFireworkBox(windowId, playerInventory); + } + private static class WeightedFireworkType extends WeightedRandom.Item { public final int type; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java index 4c8b66d0a..018b78036 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java @@ -10,13 +10,18 @@ package de.ellpeck.actuallyadditions.mod.tile; +import de.ellpeck.actuallyadditions.mod.inventory.ContainerFluidCollector; import de.ellpeck.actuallyadditions.mod.util.Util; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.material.Material; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; import net.minecraft.fluid.Fluids; +import net.minecraft.inventory.container.Container; +import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.nbt.CompoundNBT; import net.minecraft.particles.ParticleTypes; import net.minecraft.tileentity.TileEntityType; @@ -24,6 +29,8 @@ import net.minecraft.util.Direction; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.FluidStack; @@ -32,8 +39,9 @@ import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.templates.FluidTank; import javax.annotation.Nonnull; +import javax.annotation.Nullable; -public class TileEntityFluidCollector extends TileEntityBase implements ISharingFluidHandler { +public class TileEntityFluidCollector extends TileEntityBase implements ISharingFluidHandler, INamedContainerProvider { public boolean isPlacer; public final FluidTank tank = new FluidTank(8 * Util.BUCKET) { @@ -209,4 +217,15 @@ public class TileEntityFluidCollector extends TileEntityBase implements ISharing public Direction[] getFluidShareSides() { return Direction.values(); } + + @Override + public ITextComponent getDisplayName() { + return StringTextComponent.EMPTY; + } + + @Nullable + @Override + public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity player) { + return new ContainerFluidCollector(windowId, playerInventory, this); + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceDouble.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceDouble.java index 079a5af7f..7f3940ce2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceDouble.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceDouble.java @@ -11,6 +11,7 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.mod.blocks.BlockFurnaceDouble; +import de.ellpeck.actuallyadditions.mod.inventory.ContainerFurnaceDouble; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; @@ -19,15 +20,22 @@ import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.Container; +import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipe; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Direction; import net.minecraft.util.datafix.fixes.FurnaceRecipes; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; -public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements IButtonReactor { +import javax.annotation.Nullable; + +public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements IButtonReactor, INamedContainerProvider { public static final int SLOT_INPUT_1 = 0; public static final int SLOT_OUTPUT_1 = 1; @@ -223,4 +231,15 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements public LazyOptional getEnergyStorage(Direction facing) { return this.lazyEnergy; } + + @Override + public ITextComponent getDisplayName() { + return StringTextComponent.EMPTY; + } + + @Nullable + @Override + public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity player) { + return new ContainerFurnaceDouble(windowId, playerInventory, this); + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChestLarge.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChestLarge.java index d1107b3bd..ebd0a6bbd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChestLarge.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChestLarge.java @@ -1,18 +1,19 @@ -/* - * This file ("TileEntityGiantChestLarge.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -public class TileEntityGiantChestLarge extends TileEntityGiantChest { - - public TileEntityGiantChestLarge() { - super(9 * 13 * 3, "giantChestLarge"); - } -} +// TODO: [port][note] not used +///* +// * This file ("TileEntityGiantChestLarge.java") is part of the Actually Additions mod for Minecraft. +// * It is created and owned by Ellpeck and distributed +// * under the Actually Additions License to be found at +// * http://ellpeck.de/actaddlicense +// * View the source code at https://github.com/Ellpeck/ActuallyAdditions +// * +// * © 2015-2017 Ellpeck +// */ +// +//package de.ellpeck.actuallyadditions.mod.tile; +// +//public class TileEntityGiantChestLarge extends TileEntityGiantChest { +// +// public TileEntityGiantChestLarge() { +// super(9 * 13 * 3, "giantChestLarge"); +// } +//} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChestMedium.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChestMedium.java index 4ee048b31..600665a96 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChestMedium.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChestMedium.java @@ -1,18 +1,19 @@ -/* - * This file ("TileEntityGiantChestMedium.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -public class TileEntityGiantChestMedium extends TileEntityGiantChest { - - public TileEntityGiantChestMedium() { - super(9 * 13 * 2, "giantChestMedium"); - } -} +// TODO: [port][note] not used +///* +// * This file ("TileEntityGiantChestMedium.java") is part of the Actually Additions mod for Minecraft. +// * It is created and owned by Ellpeck and distributed +// * under the Actually Additions License to be found at +// * http://ellpeck.de/actaddlicense +// * View the source code at https://github.com/Ellpeck/ActuallyAdditions +// * +// * © 2015-2017 Ellpeck +// */ +// +//package de.ellpeck.actuallyadditions.mod.tile; +// +//public class TileEntityGiantChestMedium extends TileEntityGiantChest { +// +// public TileEntityGiantChestMedium() { +// super(9 * 13 * 2, "giantChestMedium"); +// } +//} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGrinder.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGrinder.java index 9ded5420c..cd1bb4cc8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGrinder.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGrinder.java @@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe; import de.ellpeck.actuallyadditions.mod.blocks.BlockFurnaceDouble; +import de.ellpeck.actuallyadditions.mod.inventory.ContainerGrinder; import de.ellpeck.actuallyadditions.mod.misc.SoundHandler; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry; @@ -21,15 +22,22 @@ import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.Util; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.Container; +import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.SoundCategory; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; -public class TileEntityGrinder extends TileEntityInventoryBase implements IButtonReactor { +import javax.annotation.Nullable; + +public class TileEntityGrinder extends TileEntityInventoryBase implements IButtonReactor, INamedContainerProvider { public static final int SLOT_INPUT_1 = 0; public static final int SLOT_OUTPUT_1_1 = 1; @@ -265,4 +273,15 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IButto public LazyOptional getEnergyStorage(Direction facing) { return this.lazyEnergy; } + + @Override + public ITextComponent getDisplayName() { + return StringTextComponent.EMPTY; + } + + @Nullable + @Override + public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity player) { + return new ContainerGrinder(windowId, playerInventory, this); + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputter.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputter.java index 69f85e25f..1fccea4f6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputter.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputter.java @@ -10,6 +10,7 @@ package de.ellpeck.actuallyadditions.mod.tile; +import de.ellpeck.actuallyadditions.mod.inventory.ContainerInputter; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.network.gui.INumberReactor; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; @@ -18,20 +19,26 @@ import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.Container; +import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.AbstractFurnaceTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; +import javax.annotation.Nullable; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -public class TileEntityInputter extends TileEntityInventoryBase implements IButtonReactor, INumberReactor { +public class TileEntityInputter extends TileEntityInventoryBase implements IButtonReactor, INumberReactor, INamedContainerProvider { public static final int OKAY_BUTTON_ID = 133; private final SlotlessableItemHandlerWrapper wrapper = new SlotlessableItemHandlerWrapper(this.lazyInv, null); @@ -309,4 +316,15 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt public IRemover getRemover() { return (slot, automation) -> !automation || slot == 0; } + + @Override + public ITextComponent getDisplayName() { + return StringTextComponent.EMPTY; + } + + @Nullable + @Override + public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity player) { + return new ContainerInputter(windowId, playerInventory, this); + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemWhitelist.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemWhitelist.java index df510eb14..1667af7bb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemWhitelist.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemWhitelist.java @@ -11,6 +11,7 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.mod.inventory.ContainerFilter; +import de.ellpeck.actuallyadditions.mod.inventory.ContainerLaserRelayItemWhitelist; import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotFilter; import de.ellpeck.actuallyadditions.mod.items.ItemDrill; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; @@ -18,11 +19,17 @@ import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.Container; +import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; -import net.minecraftforge.items.IItemHandler; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; -public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem implements IButtonReactor { +import javax.annotation.Nullable; + +public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem implements IButtonReactor, INamedContainerProvider { public FilterSettings leftFilter = new FilterSettings(12, true, true, false, false, 0, -1000); public FilterSettings rightFilter = new FilterSettings(12, true, true, false, false, 0, -2000); @@ -72,15 +79,14 @@ public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem private void addWhitelistSmart(boolean output) { for (SlotlessableItemHandlerWrapper handler : this.handlersAround.values()) { - IItemHandler itemHandler = handler.getNormalHandler(); - if (itemHandler != null) { + handler.getNormalHandler().ifPresent(itemHandler -> { for (int i = 0; i < itemHandler.getSlots(); i++) { ItemStack stack = itemHandler.getStackInSlot(i); if (StackUtil.isValid(stack)) { this.addWhitelistSmart(output, stack); } } - } + }); } } @@ -132,4 +138,15 @@ public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem } } } + + @Override + public ITextComponent getDisplayName() { + return StringTextComponent.EMPTY; + } + + @Nullable + @Override + public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity player) { + return new ContainerLaserRelayItemWhitelist(windowId, playerInventory, this); + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityMiner.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityMiner.java index a6c2634a7..cf43c5ed1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityMiner.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityMiner.java @@ -11,6 +11,7 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues; +import de.ellpeck.actuallyadditions.mod.inventory.ContainerMiner; import de.ellpeck.actuallyadditions.mod.items.ItemDrill; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.util.AssetUtil; @@ -21,21 +22,27 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.Container; +import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.common.util.FakePlayerFactory; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; import net.minecraftforge.fluids.IFluidBlock; +import javax.annotation.Nullable; import java.util.List; -public class TileEntityMiner extends TileEntityInventoryBase implements IButtonReactor, IEnergyDisplay { +public class TileEntityMiner extends TileEntityInventoryBase implements IButtonReactor, IEnergyDisplay, INamedContainerProvider { public static final int ENERGY_USE_PER_BLOCK = 650; public static final int DEFAULT_RANGE = 2; @@ -163,7 +170,7 @@ public class TileEntityMiner extends TileEntityInventoryBase implements IButtonR } else { if (StackUtil.isValid(stack)) { // TODO: [port] come back and see if there is a tag for this - + // int[] ids = OreDictionary.getOreIDs(stack); // for (int id : ids) { // String name = OreDictionary.getOreName(id); @@ -235,4 +242,15 @@ public class TileEntityMiner extends TileEntityInventoryBase implements IButtonR public LazyOptional getEnergyStorage(Direction facing) { return this.lazyEnergy; } + + @Override + public ITextComponent getDisplayName() { + return StringTextComponent.EMPTY; + } + + @Nullable + @Override + public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity player) { + return new ContainerMiner(windowId, playerInventory, this); + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java index 7949b467c..45ed5d2bb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java @@ -13,11 +13,18 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.recipe.OilGenRecipe; import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntListValues; +import de.ellpeck.actuallyadditions.mod.inventory.ContainerOilGenerator; import de.ellpeck.actuallyadditions.mod.util.Util; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; import net.minecraft.fluid.Fluid; +import net.minecraft.inventory.container.Container; +import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.util.LazyOptional; @@ -27,8 +34,9 @@ import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.templates.FluidTank; import javax.annotation.Nonnull; +import javax.annotation.Nullable; -public class TileEntityOilGenerator extends TileEntityBase implements ISharingEnergyProvider, ISharingFluidHandler { +public class TileEntityOilGenerator extends TileEntityBase implements ISharingEnergyProvider, ISharingFluidHandler, INamedContainerProvider { int[] i = ConfigIntListValues.OIL_POWER.getValue(); @@ -214,4 +222,15 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn public LazyOptional getEnergyStorage(Direction facing) { return this.lazyEnergy; } + + @Override + public ITextComponent getDisplayName() { + return StringTextComponent.EMPTY; + } + + @Nullable + @Override + public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity player) { + return new ContainerOilGenerator(windowId, playerInventory, this); + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomPlacer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomPlacer.java index 022642eda..3dc3269a2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomPlacer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomPlacer.java @@ -11,6 +11,7 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.api.tile.IPhantomTile; +import de.ellpeck.actuallyadditions.mod.inventory.ContainerPhantomPlacer; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; @@ -21,17 +22,23 @@ import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.Container; +import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.particles.ParticleTypes; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.server.ServerWorld; +import javax.annotation.Nullable; import java.util.List; -public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements IPhantomTile, IButtonReactor { +public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements IPhantomTile, IButtonReactor, INamedContainerProvider { public static final int RANGE = 3; public BlockPos boundPosition; @@ -225,4 +232,15 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements this.sendUpdate(); } + + @Override + public ITextComponent getDisplayName() { + return StringTextComponent.EMPTY; + } + + @Nullable + @Override + public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity player) { + return new ContainerPhantomPlacer(windowId, playerInventory, this); + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java index 97a5ca1d5..e6e7afc40 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java @@ -10,21 +10,28 @@ package de.ellpeck.actuallyadditions.mod.tile; +import de.ellpeck.actuallyadditions.mod.inventory.ContainerRangedCollector; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.Container; +import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.particles.ParticleTypes; import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.server.ServerWorld; +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; -public class TileEntityRangedCollector extends TileEntityInventoryBase implements IButtonReactor { +public class TileEntityRangedCollector extends TileEntityInventoryBase implements IButtonReactor, INamedContainerProvider { public static final int RANGE = 6; public FilterSettings filter = new FilterSettings(12, true, true, false, false, 0, -1000); @@ -96,4 +103,15 @@ public class TileEntityRangedCollector extends TileEntityInventoryBase implement public void onButtonPressed(int buttonID, PlayerEntity player) { this.filter.onButtonPressed(buttonID); } + + @Override + public ITextComponent getDisplayName() { + return StringTextComponent.EMPTY; + } + + @Nullable + @Override + public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity player) { + return new ContainerRangedCollector(windowId, playerInventory, this); + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntitySmileyCloud.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntitySmileyCloud.java index 70d39d002..97b08750e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntitySmileyCloud.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntitySmileyCloud.java @@ -1,60 +1,61 @@ -/* - * This file ("TileEntitySmileyCloud.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.mod.network.gui.IStringReactor; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.nbt.CompoundNBT; - -public class TileEntitySmileyCloud extends TileEntityBase implements IStringReactor { - - public String name; - private String nameBefore; - - public TileEntitySmileyCloud() { - super("smileyCloud"); - } - - @Override - public void writeSyncableNBT(CompoundNBT compound, NBTType type) { - super.writeSyncableNBT(compound, type); - if (this.name != null && type != NBTType.SAVE_BLOCK) { - compound.setString("Name", this.name); - } - } - - @Override - public void readSyncableNBT(CompoundNBT compound, NBTType type) { - super.readSyncableNBT(compound, type); - if (type != NBTType.SAVE_BLOCK) { - this.name = compound.getString("Name"); - } - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - boolean nameChanged = this.name != null - ? !this.name.equals(this.nameBefore) - : this.nameBefore != null; - if (nameChanged && this.sendUpdateWithInterval()) { - this.nameBefore = this.name; - this.markDirty(); - } - } - } - - @Override - public void onTextReceived(String text, int textID, PlayerEntity player) { - this.name = text; - } -} +// TODO: [port][note]: Not used +///* +// * This file ("TileEntitySmileyCloud.java") is part of the Actually Additions mod for Minecraft. +// * It is created and owned by Ellpeck and distributed +// * under the Actually Additions License to be found at +// * http://ellpeck.de/actaddlicense +// * View the source code at https://github.com/Ellpeck/ActuallyAdditions +// * +// * © 2015-2017 Ellpeck +// */ +// +//package de.ellpeck.actuallyadditions.mod.tile; +// +//import de.ellpeck.actuallyadditions.mod.network.gui.IStringReactor; +//import net.minecraft.entity.player.PlayerEntity; +//import net.minecraft.nbt.CompoundNBT; +// +//public class TileEntitySmileyCloud extends TileEntityBase implements IStringReactor { +// +// public String name; +// private String nameBefore; +// +// public TileEntitySmileyCloud() { +// super("smileyCloud"); +// } +// +// @Override +// public void writeSyncableNBT(CompoundNBT compound, NBTType type) { +// super.writeSyncableNBT(compound, type); +// if (this.name != null && type != NBTType.SAVE_BLOCK) { +// compound.setString("Name", this.name); +// } +// } +// +// @Override +// public void readSyncableNBT(CompoundNBT compound, NBTType type) { +// super.readSyncableNBT(compound, type); +// if (type != NBTType.SAVE_BLOCK) { +// this.name = compound.getString("Name"); +// } +// } +// +// @Override +// public void updateEntity() { +// super.updateEntity(); +// if (!this.world.isRemote) { +// boolean nameChanged = this.name != null +// ? !this.name.equals(this.nameBefore) +// : this.nameBefore != null; +// if (nameChanged && this.sendUpdateWithInterval()) { +// this.nameBefore = this.name; +// this.markDirty(); +// } +// } +// } +// +// @Override +// public void onTextReceived(String text, int textID, PlayerEntity player) { +// this.name = text; +// } +//} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java index 530675000..5ca5acee7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java @@ -11,6 +11,7 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +import de.ellpeck.actuallyadditions.mod.inventory.ContainerXPSolidifier; import de.ellpeck.actuallyadditions.mod.items.InitItems; import de.ellpeck.actuallyadditions.mod.items.ItemSolidifiedExperience; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; @@ -18,14 +19,20 @@ import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.entity.item.ExperienceOrbEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.Container; +import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.MathHelper; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; +import javax.annotation.Nullable; import java.util.List; -public class TileEntityXPSolidifier extends TileEntityInventoryBase implements IButtonReactor { +public class TileEntityXPSolidifier extends TileEntityInventoryBase implements IButtonReactor, INamedContainerProvider { private static final int[] XP_MAP = new int[256]; @@ -124,10 +131,8 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I if (this.amount > 0) { ItemStack stack = this.inv.getStackInSlot(0); if (stack.isEmpty()) { - int toSet = this.amount > 64 - ? 64 - : this.amount; - this.inv.setStackInSlot(0, new ItemStack(InitItems.itemSolidifiedExperience, toSet)); + int toSet = Math.min(this.amount, 64); + this.inv.setStackInSlot(0, new ItemStack(InitItems.itemSolidifiedExperience.get(), toSet)); this.amount -= toSet; this.markDirty(); } else if (stack.getCount() < 64) { @@ -177,7 +182,7 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I @Override public IAcceptor getAcceptor() { - return (slot, stack, automation) -> slot == 1 && stack.getItem() == InitItems.itemSolidifiedExperience; + return (slot, stack, automation) -> slot == 1 && stack.getItem() == InitItems.itemSolidifiedExperience.get(); } @Override @@ -205,4 +210,15 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I } } } + + @Override + public ITextComponent getDisplayName() { + return StringTextComponent.EMPTY; + } + + @Nullable + @Override + public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity player) { + return new ContainerXPSolidifier(windowId, playerInventory, this); + } }