From e1e140a62d2314bfe4e4fccd0d7b3fa6110b97da Mon Sep 17 00:00:00 2001 From: KnightMiner Date: Sat, 14 Dec 2019 22:45:44 -0600 Subject: [PATCH] Clean up deprecation warnings and add a few comments --- .../building/block/BlockBookshelf.java | 45 +++++++++------- .../building/block/BlockEnlightenedBush.java | 9 ++-- .../building/block/BlockFlower.java | 16 +++--- .../building/block/BlockGlassDoor.java | 12 ++--- .../building/block/BlockGlassTrapdoor.java | 5 +- .../building/block/BlockMulch.java | 13 ++--- .../building/block/BlockPath.java | 30 +++-------- .../building/block/BlockRope.java | 14 ++++- .../recipes/block/BlockEnhancedCauldron.java | 2 + .../tweaks/block/BlockBetterFlowerPot.java | 2 + .../tweaks/block/BlockFittedCarpet.java | 5 +- .../utility/block/BlockBricksButton.java | 51 ++++--------------- .../utility/block/BlockCollector.java | 11 +++- .../inspirations/utility/block/BlockPipe.java | 8 +++ .../utility/block/BlockRedstoneBarrel.java | 26 ++++++---- .../utility/block/BlockRedstoneCharge.java | 40 +++++---------- .../utility/block/BlockTorchLever.java | 23 ++------- 17 files changed, 136 insertions(+), 176 deletions(-) diff --git a/src/main/java/knightminer/inspirations/building/block/BlockBookshelf.java b/src/main/java/knightminer/inspirations/building/block/BlockBookshelf.java index 2b7d86de..18da4d80 100644 --- a/src/main/java/knightminer/inspirations/building/block/BlockBookshelf.java +++ b/src/main/java/knightminer/inspirations/building/block/BlockBookshelf.java @@ -70,9 +70,7 @@ protected ExtendedBlockState createBlockState() { return new ExtendedBlockState(this, new IProperty[]{TYPE, FACING}, new IUnlistedProperty[]{TEXTURE, BOOKS}); } - /** - * Convert the given metadata into a BlockState for this Block - */ + @Deprecated @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState() @@ -80,19 +78,13 @@ public IBlockState getStateFromMeta(int meta) { .withProperty(FACING, EnumFacing.getHorizontal(meta >> 2)); } - /** - * Convert the BlockState into the correct metadata value - */ @Override public int getMetaFromState(IBlockState state) { return state.getValue(FACING).getHorizontalIndex() << 2 | state.getValue(TYPE).getMeta(); } - /** - * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the - * IBlockstate - */ + @Deprecated @Override public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { return this.getStateFromMeta(meta).withProperty(FACING, placer.getHorizontalFacing().getOpposite()); @@ -153,6 +145,14 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En return true; } + /** + * Called when the shelf is clicked to determine the clicked book + * @param facing Side clicked + * @param clickX Click X coordinate, block reletive + * @param clickY Click Y coordinate, block relative + * @param clickZ Click Z coordinate, block relative + * @return Clicked book index + */ private static int bookClicked(EnumFacing facing, float clickX, float clickY, float clickZ) { // if we did not click between the shelves, ignore if(clickY < 0.0625 || clickY > 0.9375) { @@ -225,6 +225,7 @@ private static int bookClicked(EnumFacing facing, float clickX, float clickY, fl TRACE_BOUNDS = builder.build(); } + @Deprecated @Nonnull @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { @@ -242,13 +243,11 @@ public RayTraceResult collisionRayTrace(IBlockState state, @Nonnull World world, return Util.closestResult(list, end); } + /* * Redstone */ - /** - * Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated - */ @Override public void breakBlock(World world, BlockPos pos, IBlockState state) { // if powered, send updates for power @@ -260,11 +259,13 @@ public void breakBlock(World world, BlockPos pos, IBlockState state) { super.breakBlock(world, pos, state); } + @Deprecated @Override public int getWeakPower(IBlockState state, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { return getPower(state, blockAccess, pos); } + @Deprecated @Override public int getStrongPower(IBlockState state, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { if (state.getValue(FACING) != side) { @@ -275,6 +276,13 @@ public int getStrongPower(IBlockState state, IBlockAccess blockAccess, BlockPos } + /** + * Gets the powered state of the block + * @param state Existing state + * @param blockAccess World access + * @param pos Position to check + * @return Power level between 0 and 15 + */ private int getPower(IBlockState state, IBlockAccess blockAccess, BlockPos pos) { if(InspirationsBuilding.redstoneBook == null) { return 0; @@ -287,9 +295,7 @@ private int getPower(IBlockState state, IBlockAccess blockAccess, BlockPos pos) return 0; } - /** - * Can this block provide power. Only wire currently seems to have this change based on its state. - */ + @Deprecated @Override public boolean canProvidePower(IBlockState state) { // ensure we have the redstone book, since it comes from the redstone module @@ -300,6 +306,7 @@ public boolean canProvidePower(IBlockState state) { /* * Block properties */ + @Override @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { @@ -319,28 +326,32 @@ public IBlockState getExtendedState(@Nonnull IBlockState state, IBlockAccess wor return super.getExtendedState(state, world, pos); } - @Override @Deprecated + @Override public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing side) { // allows placing stuff on the back return side == state.getValue(FACING).getOpposite() ? BlockFaceShape.SOLID : BlockFaceShape.UNDEFINED; } + @Deprecated @Override public boolean isFullCube(IBlockState state) { return false; } + @Deprecated @Override public boolean isOpaqueCube(IBlockState state) { return false; } + @Deprecated @Override public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(FACING, rot.rotate(state.getValue(FACING))); } + @Deprecated @Override public IBlockState withMirror(IBlockState state, Mirror mirror) { return state.withRotation(mirror.toRotation(state.getValue(FACING))); diff --git a/src/main/java/knightminer/inspirations/building/block/BlockEnlightenedBush.java b/src/main/java/knightminer/inspirations/building/block/BlockEnlightenedBush.java index 174410fb..15fe3aee 100644 --- a/src/main/java/knightminer/inspirations/building/block/BlockEnlightenedBush.java +++ b/src/main/java/knightminer/inspirations/building/block/BlockEnlightenedBush.java @@ -1,9 +1,5 @@ package knightminer.inspirations.building.block; -import java.util.Locale; - -import javax.annotation.Nonnull; - import knightminer.inspirations.building.tileentity.TileEnlightenedBush; import knightminer.inspirations.library.client.ClientUtil; import knightminer.inspirations.library.util.TextureBlockUtil; @@ -32,6 +28,9 @@ import slimeknights.mantle.block.EnumBlock; import slimeknights.mantle.property.PropertyString; +import javax.annotation.Nonnull; +import java.util.Locale; + public class BlockEnlightenedBush extends EnumBlock implements ITileEntityProvider { public static final PropertyEnum LIGHTS = PropertyEnum.create("lights", LightsType.class); @@ -68,11 +67,13 @@ public void getSubBlocks(CreativeTabs tab, NonNullList list) { /* * Properties */ + @Deprecated @Override public boolean isOpaqueCube(IBlockState state) { return false; } + @Deprecated @Override public boolean causesSuffocation(IBlockState state) { return false; diff --git a/src/main/java/knightminer/inspirations/building/block/BlockFlower.java b/src/main/java/knightminer/inspirations/building/block/BlockFlower.java index f8a10542..25b9604c 100644 --- a/src/main/java/knightminer/inspirations/building/block/BlockFlower.java +++ b/src/main/java/knightminer/inspirations/building/block/BlockFlower.java @@ -1,11 +1,5 @@ package knightminer.inspirations.building.block; -import java.util.Locale; -import java.util.Random; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - import net.minecraft.block.Block; import net.minecraft.block.BlockBush; import net.minecraft.block.BlockDoublePlant.EnumPlantType; @@ -24,6 +18,11 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.Locale; +import java.util.Random; + public class BlockFlower extends BlockBush implements IGrowable { public static final PropertyEnum TYPE = PropertyEnum.create("type", FlowerType.class); @@ -41,6 +40,7 @@ protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, TYPE); } + @Deprecated @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(TYPE, FlowerType.fromMeta(meta)); @@ -51,10 +51,6 @@ public int getMetaFromState(IBlockState state) { return state.getValue(TYPE).getMeta(); } - /** - * Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It - * returns the metadata of the dropped item based on the old metadata of the block. - */ @Override public int damageDropped(IBlockState state) { return state.getValue(TYPE).getMeta(); diff --git a/src/main/java/knightminer/inspirations/building/block/BlockGlassDoor.java b/src/main/java/knightminer/inspirations/building/block/BlockGlassDoor.java index c4286f14..22cd657c 100644 --- a/src/main/java/knightminer/inspirations/building/block/BlockGlassDoor.java +++ b/src/main/java/knightminer/inspirations/building/block/BlockGlassDoor.java @@ -1,7 +1,5 @@ package knightminer.inspirations.building.block; -import java.util.Random; - import knightminer.inspirations.building.InspirationsBuilding; import net.minecraft.block.BlockDoor; import net.minecraft.block.SoundType; @@ -15,6 +13,8 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import java.util.Random; + public class BlockGlassDoor extends BlockDoor { public BlockGlassDoor() { @@ -29,9 +29,6 @@ public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, Ent // honestly have no idea what this code was doing, but it broke silk touching the door and it seems to work without it } - /** - * Get the Item that this Block should drop when harvested. - */ @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return InspirationsBuilding.glassDoorItem; @@ -52,17 +49,14 @@ protected ItemStack getSilkTouchDrop(IBlockState state) { return new ItemStack(InspirationsBuilding.glassDoorItem); } - /** - * Returns the quantity of items to drop on block destruction. - */ @Override public int quantityDropped(Random random) { return 0; } + @Deprecated @Override protected boolean canSilkHarvest() { return true; } - } diff --git a/src/main/java/knightminer/inspirations/building/block/BlockGlassTrapdoor.java b/src/main/java/knightminer/inspirations/building/block/BlockGlassTrapdoor.java index de798204..304da694 100644 --- a/src/main/java/knightminer/inspirations/building/block/BlockGlassTrapdoor.java +++ b/src/main/java/knightminer/inspirations/building/block/BlockGlassTrapdoor.java @@ -1,11 +1,11 @@ package knightminer.inspirations.building.block; -import java.util.Random; - import net.minecraft.block.BlockTrapDoor; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; +import java.util.Random; + public class BlockGlassTrapdoor extends BlockTrapDoor { public BlockGlassTrapdoor() { @@ -23,6 +23,7 @@ public int quantityDropped(Random random) { return 0; } + @Deprecated @Override protected boolean canSilkHarvest() { return true; diff --git a/src/main/java/knightminer/inspirations/building/block/BlockMulch.java b/src/main/java/knightminer/inspirations/building/block/BlockMulch.java index adf1e838..386dde6d 100644 --- a/src/main/java/knightminer/inspirations/building/block/BlockMulch.java +++ b/src/main/java/knightminer/inspirations/building/block/BlockMulch.java @@ -1,7 +1,5 @@ package knightminer.inspirations.building.block; -import java.util.Locale; - import net.minecraft.block.BlockFalling; import net.minecraft.block.BlockSapling; import net.minecraft.block.SoundType; @@ -21,6 +19,8 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import java.util.Locale; + public class BlockMulch extends BlockFalling { protected static final AxisAlignedBB BOUNDS = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.9375D, 1.0D); @@ -36,6 +36,7 @@ public BlockMulch() { this.setCreativeTab(CreativeTabs.BUILDING_BLOCKS); } + /* * Types */ @@ -45,18 +46,13 @@ protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, COLOR); } - /** - * Convert the given metadata into a BlockState for this Block - */ + @Deprecated @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState() .withProperty(COLOR, MulchColor.fromMeta(meta)); } - /** - * Convert the BlockState into the correct metadata value - */ @Override public int getMetaFromState(IBlockState state) { return state.getValue(COLOR).getMeta(); @@ -87,7 +83,6 @@ public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos p return plantable.getPlantType(world, pos.offset(direction)) == EnumPlantType.Plains && !(plantable instanceof BlockSapling); } - public static enum MulchColor implements IStringSerializable { PLAIN, BROWN, diff --git a/src/main/java/knightminer/inspirations/building/block/BlockPath.java b/src/main/java/knightminer/inspirations/building/block/BlockPath.java index eab31c4b..f1d337e5 100644 --- a/src/main/java/knightminer/inspirations/building/block/BlockPath.java +++ b/src/main/java/knightminer/inspirations/building/block/BlockPath.java @@ -1,7 +1,5 @@ package knightminer.inspirations.building.block; -import java.util.Locale; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyEnum; @@ -16,6 +14,8 @@ import slimeknights.mantle.block.EnumBlock; import slimeknights.mantle.client.CreativeTab; +import java.util.Locale; + public class BlockPath extends EnumBlock { public static final PropertyEnum TYPE = PropertyEnum.create("type", PathType.class); @@ -31,33 +31,26 @@ public BlockPath() { /* Block Shape */ protected static final AxisAlignedBB BOUNDS = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.0625D, 1.0D); + + @Deprecated @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return BOUNDS; } - /** - * Used to determine ambient occlusion and culling when rebuilding chunks for render - */ + @Deprecated @Override public boolean isOpaqueCube(IBlockState state) { return false; } + @Deprecated @Override public boolean isFullCube(IBlockState state) { return false; } - /** - * Get the geometry of the queried face at the given position and state. This is used to decide whether things like - * buttons are allowed to be placed on the face, or how glass panes connect to the face, among other things. - *

- * Common values are {@code SOLID}, which is the default, and {@code UNDEFINED}, which represents something that - * does not fit the other descriptions and will generally cause other things not to connect to the face. - * - * @return an approximation of the form of the given face - */ + @Deprecated @Override public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) { return face == EnumFacing.DOWN ? BlockFaceShape.SOLID : BlockFaceShape.UNDEFINED; @@ -66,9 +59,6 @@ public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, /* Solid surface below */ - /** - * Checks if this block can be placed exactly at the given position. - */ @Override public boolean canPlaceBlockAt(World worldIn, BlockPos pos) { return super.canPlaceBlockAt(worldIn, pos) && this.canBlockStay(worldIn, pos); @@ -79,11 +69,7 @@ private boolean canBlockStay(World world, BlockPos pos) { return world.getBlockState(down).getBlockFaceShape(world, down, EnumFacing.UP) == BlockFaceShape.SOLID; } - /** - * Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor - * change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid - * block, etc. - */ + @Deprecated @Override public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) { if (!this.canBlockStay(world, pos)) { diff --git a/src/main/java/knightminer/inspirations/building/block/BlockRope.java b/src/main/java/knightminer/inspirations/building/block/BlockRope.java index 0f65fc49..446dd5a4 100644 --- a/src/main/java/knightminer/inspirations/building/block/BlockRope.java +++ b/src/main/java/knightminer/inspirations/building/block/BlockRope.java @@ -59,12 +59,21 @@ protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, TYPE, RUNGS, BOTTOM); } + @Deprecated @Override public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) { BlockPos down = pos.down(); return state.withProperty(BOTTOM, !canConnectTo(world.getBlockState(down), world, down, EnumFacing.UP)); } + /** + * Returns true if the block can connect to the given state + * @param state State to check + * @param world World access + * @param pos Block position + * @param side Side to connect + * @return True if it can connect + */ private boolean canConnectTo(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { if(state.getBlock() == this) { return true; @@ -260,18 +269,20 @@ public boolean isLadder(IBlockState state, IBlockAccess world, BlockPos pos, Ent return true; } + @Deprecated @Override public boolean isFullCube(IBlockState state) { return false; } + @Deprecated @Override public boolean isOpaqueCube(IBlockState state) { return false; } - @Override @Deprecated + @Override public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing side) { return BlockFaceShape.UNDEFINED; } @@ -297,6 +308,7 @@ public BlockRenderLayer getBlockLayer() { new AxisAlignedBB(0.375, 0.25, 0.0625, 0.625, 1, 0.9375) }; + @Deprecated @Nonnull @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { diff --git a/src/main/java/knightminer/inspirations/recipes/block/BlockEnhancedCauldron.java b/src/main/java/knightminer/inspirations/recipes/block/BlockEnhancedCauldron.java index 87572196..da248102 100644 --- a/src/main/java/knightminer/inspirations/recipes/block/BlockEnhancedCauldron.java +++ b/src/main/java/knightminer/inspirations/recipes/block/BlockEnhancedCauldron.java @@ -151,6 +151,7 @@ protected ExtendedBlockState createBlockState() { return new ExtendedBlockState(this, new IProperty[]{LEVEL, CONTENTS, BOILING}, new IUnlistedProperty[]{TEXTURE}); } + @Deprecated @Override public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) { TileEntity te = world.getTileEntity(pos); @@ -180,6 +181,7 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En /* boiling */ + @Deprecated @Override public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) { setBoiling(world, pos, state); diff --git a/src/main/java/knightminer/inspirations/tweaks/block/BlockBetterFlowerPot.java b/src/main/java/knightminer/inspirations/tweaks/block/BlockBetterFlowerPot.java index 8c925f51..366199b6 100644 --- a/src/main/java/knightminer/inspirations/tweaks/block/BlockBetterFlowerPot.java +++ b/src/main/java/knightminer/inspirations/tweaks/block/BlockBetterFlowerPot.java @@ -139,11 +139,13 @@ public IBlockState getExtendedState(@Nonnull IBlockState state, IBlockAccess wor * Comparator */ + @Deprecated @Override public boolean hasComparatorInputOverride(IBlockState state) { return Config.flowerPotComparator; } + @Deprecated @Override public int getComparatorInputOverride(IBlockState blockState, World world, BlockPos pos) { if(!Config.flowerPotComparator) { diff --git a/src/main/java/knightminer/inspirations/tweaks/block/BlockFittedCarpet.java b/src/main/java/knightminer/inspirations/tweaks/block/BlockFittedCarpet.java index 243bbafa..e45218fc 100644 --- a/src/main/java/knightminer/inspirations/tweaks/block/BlockFittedCarpet.java +++ b/src/main/java/knightminer/inspirations/tweaks/block/BlockFittedCarpet.java @@ -48,10 +48,7 @@ protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, COLOR, NORTHWEST, NORTHEAST, SOUTHWEST, SOUTHEAST); } - /** - * Get the actual Block state of this Block at the given position. This applies properties not visible in the - * metadata, such as fence connections. - */ + @Deprecated @Override public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) { return setProperties(state, getStairShape(world, pos.down())); diff --git a/src/main/java/knightminer/inspirations/utility/block/BlockBricksButton.java b/src/main/java/knightminer/inspirations/utility/block/BlockBricksButton.java index a77dc07a..5c28c4f4 100644 --- a/src/main/java/knightminer/inspirations/utility/block/BlockBricksButton.java +++ b/src/main/java/knightminer/inspirations/utility/block/BlockBricksButton.java @@ -1,12 +1,6 @@ package knightminer.inspirations.utility.block; -import java.util.Locale; -import java.util.Random; - -import javax.annotation.Nullable; - import com.google.common.collect.ImmutableMap; - import knightminer.inspirations.library.Util; import net.minecraft.block.BlockButton; import net.minecraft.block.BlockHorizontal; @@ -34,6 +28,10 @@ import net.minecraft.world.World; import slimeknights.mantle.block.EnumBlock; +import javax.annotation.Nullable; +import java.util.Locale; +import java.util.Random; + public class BlockBricksButton extends EnumBlock { public static final PropertyEnum TYPE = PropertyEnum.create("type", BrickType.class); @@ -61,9 +59,6 @@ protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, TYPE, FACING, POWERED); } - /** - * Convert the given metadata into a BlockState for this Block - */ @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState() @@ -72,9 +67,6 @@ public IBlockState getStateFromMeta(int meta) { .withProperty(POWERED, (meta & 8) > 0); } - /** - * Convert the BlockState into the correct metadata value - */ @Override public int getMetaFromState(IBlockState state) { return state.getValue(TYPE).getMeta() @@ -82,28 +74,19 @@ public int getMetaFromState(IBlockState state) { | (state.getValue(POWERED) ? 8 : 0); } - /** - * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the - * IBlockstate - */ + @Deprecated @Override public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { return this.getStateFromMeta(meta).withProperty(FACING, placer.getHorizontalFacing().getOpposite()); } - /** - * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed - * blockstate. - */ + @Deprecated @Override public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(FACING, rot.rotate(state.getValue(FACING))); } - /** - * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed - * blockstate. - */ + @Deprecated @Override public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { return state.withRotation(mirrorIn.toRotation(state.getValue(FACING))); @@ -121,17 +104,11 @@ protected ItemStack getSilkTouchDrop(IBlockState state) { /* Pressing the button */ - /** - * How many world ticks before ticking - */ @Override public int tickRate(World worldIn) { return 20; } - /** - * Called when the block is right clicked by a player. - */ @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { // if you did not click the secret button, no button for you @@ -152,9 +129,6 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En return true; } - /** - * Called randomly when setTickRandomly is set to true (used by e.g. crops to grow, etc.) - */ @Override public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random random) {} @@ -201,9 +175,6 @@ private static AxisAlignedBB getButtonBox(IBlockState state) { /* Redstone logic */ - /** - * Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated - */ @Override public void breakBlock(World world, BlockPos pos, IBlockState state) { if (state.getValue(POWERED)) { @@ -213,20 +184,20 @@ public void breakBlock(World world, BlockPos pos, IBlockState state) { super.breakBlock(world, pos, state); } + @Deprecated @Override public int getWeakPower(IBlockState state, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { return state.getValue(POWERED) ? 15 : 0; } + @Deprecated @Override public int getStrongPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { // we may be a button, but we act as though ourself is the block that is powered return 0; } - /** - * Can this block provide power. Only wire currently seems to have this change based on its state. - */ + @Deprecated @Override public boolean canProvidePower(IBlockState state) { return true; @@ -237,7 +208,6 @@ public boolean canConnectRedstone(IBlockState state, IBlockAccess world, BlockPo return false; } - public enum BrickType implements IStringSerializable, EnumBlock.IEnumMeta { BRICKS, NETHER; @@ -264,5 +234,4 @@ public static BrickType fromMeta(int i) { return values()[i]; } } - } diff --git a/src/main/java/knightminer/inspirations/utility/block/BlockCollector.java b/src/main/java/knightminer/inspirations/utility/block/BlockCollector.java index b135ad26..dd16fa1e 100644 --- a/src/main/java/knightminer/inspirations/utility/block/BlockCollector.java +++ b/src/main/java/knightminer/inspirations/utility/block/BlockCollector.java @@ -1,7 +1,5 @@ package knightminer.inspirations.utility.block; -import java.util.Random; - import knightminer.inspirations.Inspirations; import knightminer.inspirations.utility.tileentity.TileCollector; import net.minecraft.block.Block; @@ -26,6 +24,8 @@ import net.minecraftforge.items.ItemHandlerHelper; import slimeknights.mantle.block.BlockInventory; +import java.util.Random; + public class BlockCollector extends BlockInventory { public static final PropertyDirection FACING = BlockDirectional.FACING; @@ -48,6 +48,7 @@ protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, FACING, TRIGGERED); } + @Deprecated @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState() @@ -65,16 +66,19 @@ public int getMetaFromState(IBlockState state) { return meta; } + @Deprecated @Override public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(FACING, rot.rotate(state.getValue(FACING))); } + @Deprecated @Override public IBlockState withMirror(IBlockState state, Mirror mirror) { return state.withRotation(mirror.toRotation(state.getValue(FACING))); } + @Deprecated @Override public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { // place opposite since its more useful to face into what you clicked @@ -107,6 +111,7 @@ protected boolean openGui(EntityPlayer player, World world, BlockPos pos) { /* Comparator logic */ + @Deprecated @Override public int getComparatorInputOverride(IBlockState blockState, World world, BlockPos pos) { TileEntity te = world.getTileEntity(pos); @@ -119,6 +124,7 @@ public int getComparatorInputOverride(IBlockState blockState, World world, Block return 0; } + @Deprecated @Override public boolean hasComparatorInputOverride(IBlockState state) { return true; @@ -127,6 +133,7 @@ public boolean hasComparatorInputOverride(IBlockState state) { /* Collecting logic */ + @Deprecated @Override public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) { boolean powered = world.isBlockPowered(pos) || world.isBlockPowered(pos.up()); diff --git a/src/main/java/knightminer/inspirations/utility/block/BlockPipe.java b/src/main/java/knightminer/inspirations/utility/block/BlockPipe.java index f2f0f1d2..c927ccf5 100644 --- a/src/main/java/knightminer/inspirations/utility/block/BlockPipe.java +++ b/src/main/java/knightminer/inspirations/utility/block/BlockPipe.java @@ -73,6 +73,7 @@ protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, FACING, NORTH, EAST, SOUTH, WEST, UP, DOWN, HOPPER); } + @Deprecated @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(FACING, EnumFacing.getFront(meta & 7)); @@ -83,11 +84,13 @@ public int getMetaFromState(IBlockState state) { return state.getValue(FACING).getIndex(); } + @Deprecated @Override public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(FACING, rot.rotate(state.getValue(FACING))); } + @Deprecated @Override public IBlockState withMirror(IBlockState state, Mirror mirror) { return state.withRotation(mirror.toRotation(state.getValue(FACING))); @@ -121,6 +124,7 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En /* Model and shape */ + @Deprecated @Override public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) { EnumFacing facing = state.getValue(FACING); @@ -161,11 +165,13 @@ protected boolean openGui(EntityPlayer player, World world, BlockPos pos) { return true; } + @Deprecated @Override public boolean isFullCube(IBlockState state) { return false; } + @Deprecated @Override public boolean isOpaqueCube(IBlockState state) { return false; @@ -183,6 +189,7 @@ public boolean isOpaqueCube(IBlockState state) { } } + @Deprecated @Nonnull @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { @@ -221,6 +228,7 @@ public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, Bloc BOUNDS_DOWN, BOUNDS_UP, BOUNDS_NORTH, BOUNDS_SOUTH, BOUNDS_WEST, BOUNDS_EAST }; + @Deprecated @Override public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, AxisAlignedBB entityBox, List collidingBoxes, @Nullable Entity entity, boolean p_185477_7_) { state = state.getActualState(world, pos); diff --git a/src/main/java/knightminer/inspirations/utility/block/BlockRedstoneBarrel.java b/src/main/java/knightminer/inspirations/utility/block/BlockRedstoneBarrel.java index 93a9c465..c4e8f505 100644 --- a/src/main/java/knightminer/inspirations/utility/block/BlockRedstoneBarrel.java +++ b/src/main/java/knightminer/inspirations/utility/block/BlockRedstoneBarrel.java @@ -1,7 +1,5 @@ package knightminer.inspirations.utility.block; -import javax.annotation.Nonnull; - import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; @@ -22,6 +20,8 @@ import net.minecraft.world.World; import net.minecraftforge.items.ItemHandlerHelper; +import javax.annotation.Nonnull; + public class BlockRedstoneBarrel extends Block { private static final AxisAlignedBB BOUNDS = new AxisAlignedBB(0.0625, 0, 0.0625, 0.9375, 1, 0.9375); @@ -43,14 +43,12 @@ protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, LEVEL); } + @Deprecated @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(LEVEL, meta); } - /** - * Convert the BlockState into the correct metadata value - */ @Override public int getMetaFromState(IBlockState state) { return state.getValue(LEVEL); @@ -68,20 +66,20 @@ public void getDrops(NonNullList drops, IBlockAccess world, BlockPos } } + @Deprecated @Nonnull @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return BOUNDS; } - /** - * Used to determine ambient occlusion and culling when rebuilding chunks for render - */ + @Deprecated @Override public boolean isOpaqueCube(IBlockState state) { return false; } + @Deprecated @Override public boolean isFullCube(IBlockState state) { return false; @@ -89,19 +87,18 @@ public boolean isFullCube(IBlockState state) { /* Redstone */ + @Deprecated @Override public boolean hasComparatorInputOverride(IBlockState state) { return true; } + @Deprecated @Override public int getComparatorInputOverride(IBlockState blockState, World worldIn, BlockPos pos) { return blockState.getValue(LEVEL); } - /** - * Called when the block is right clicked by a player. - */ @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { int level = state.getValue(LEVEL); @@ -132,6 +129,13 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En return false; } + /** + * Sets the level of the redstone barrel + * @param world World setting + * @param pos Position to set the barre; + * @param state Original redstone barrel state + * @param level New level to set + */ public void setLevel(World world, BlockPos pos, IBlockState state, int level) { world.setBlockState(pos, state.withProperty(LEVEL, Integer.valueOf(MathHelper.clamp(level, 0, 15))), 2); world.updateComparatorOutputLevel(pos, this); diff --git a/src/main/java/knightminer/inspirations/utility/block/BlockRedstoneCharge.java b/src/main/java/knightminer/inspirations/utility/block/BlockRedstoneCharge.java index 97c18425..760e728c 100644 --- a/src/main/java/knightminer/inspirations/utility/block/BlockRedstoneCharge.java +++ b/src/main/java/knightminer/inspirations/utility/block/BlockRedstoneCharge.java @@ -1,10 +1,5 @@ package knightminer.inspirations.utility.block; -import java.util.Random; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - import net.minecraft.block.Block; import net.minecraft.block.BlockDirectional; import net.minecraft.block.material.Material; @@ -25,6 +20,10 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.Random; + public class BlockRedstoneCharge extends Block { public static final PropertyBool QUICK = PropertyBool.create("quick"); @@ -45,9 +44,7 @@ protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, FACING, QUICK); } - /** - * Convert the given metadata into a BlockState for this Block - */ + @Deprecated @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState() @@ -55,9 +52,6 @@ public IBlockState getStateFromMeta(int meta) { .withProperty(FACING, EnumFacing.getFront(meta & 7)); } - /** - * Convert the BlockState into the correct metadata value - */ @Override public int getMetaFromState(IBlockState state) { return state.getValue(FACING).getIndex() | (state.getValue(QUICK) ? 8 : 0); @@ -65,17 +59,12 @@ public int getMetaFromState(IBlockState state) { /* Fading */ - /** - * How many world ticks before ticking - */ + @Override public int tickRate(World world) { return 20; } - /** - * Called after the block is set in the Chunk data, but before the Tile Entity is set - */ @Override public void onBlockAdded(World world, BlockPos pos, IBlockState state) { if (!world.isRemote) { @@ -84,9 +73,6 @@ public void onBlockAdded(World world, BlockPos pos, IBlockState state) { } } - /** - * Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated - */ @Override public void breakBlock(World world, BlockPos pos, IBlockState state) { world.notifyNeighborsOfStateChange(pos, this, false); @@ -95,9 +81,6 @@ public void breakBlock(World world, BlockPos pos, IBlockState state) { super.breakBlock(world, pos, state); } - /** - * Called randomly when setTickRandomly is set to true (used by e.g. crops to grow, etc.) - */ @Override public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random random) {} @@ -112,16 +95,19 @@ public void updateTick(World world, BlockPos pos, IBlockState state, Random rand /* Powering */ + @Deprecated @Override public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { return 15; } + @Deprecated @Override public int getStrongPower(IBlockState state, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { return state.getValue(FACING).getOpposite() == side ? 15 : 0; } + @Deprecated @Override public boolean canProvidePower(IBlockState state) { return true; @@ -136,6 +122,8 @@ public boolean canConnectRedstone(IBlockState state, IBlockAccess world, BlockPo /* Bounds */ protected static final AxisAlignedBB BOUNDS = new AxisAlignedBB(0.375, 0.375, 0.375, 0.625, 0.625, 0.625); + + @Deprecated @Nonnull @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { @@ -152,9 +140,6 @@ public AxisAlignedBB getCollisionBoundingBox(IBlockState state, IBlockAccess wor /* Properties */ - /** - * Checks if this block can be placed exactly at the given position. - */ @Override public boolean canPlaceBlockAt(World world, BlockPos pos) { return super.canPlaceBlockAt(world, pos) && !world.getBlockState(pos).getMaterial().isLiquid(); @@ -167,11 +152,13 @@ public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, B return BlockFaceShape.UNDEFINED; } + @Deprecated @Override public boolean isFullCube(IBlockState state) { return false; } + @Deprecated @Override public boolean isOpaqueCube(IBlockState state) { return false; @@ -194,6 +181,7 @@ public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, } } + @Deprecated @Nonnull @Override public EnumBlockRenderType getRenderType(IBlockState state) { diff --git a/src/main/java/knightminer/inspirations/utility/block/BlockTorchLever.java b/src/main/java/knightminer/inspirations/utility/block/BlockTorchLever.java index 96c94028..7b36acac 100644 --- a/src/main/java/knightminer/inspirations/utility/block/BlockTorchLever.java +++ b/src/main/java/knightminer/inspirations/utility/block/BlockTorchLever.java @@ -1,7 +1,5 @@ package knightminer.inspirations.utility.block; -import java.util.Random; - import net.minecraft.block.BlockLever; import net.minecraft.block.BlockTorch; import net.minecraft.block.properties.IProperty; @@ -22,6 +20,8 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import java.util.Random; + public class BlockTorchLever extends BlockTorch { public static final PropertyBool POWERED = BlockLever.POWERED; @@ -78,9 +78,6 @@ public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Rand * Powering */ - /** - * Called when the block is right clicked by a player. - */ @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing sideHit, float hitX, float hitY, float hitZ) { if (world.isRemote) { @@ -105,10 +102,6 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En return true; } - - /** - * Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated - */ @Override public void breakBlock(World world, BlockPos pos, IBlockState state) { // if powered, send updates for power @@ -120,11 +113,13 @@ public void breakBlock(World world, BlockPos pos, IBlockState state) { super.breakBlock(world, pos, state); } + @Deprecated @Override public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { return blockState.getValue(POWERED) ? 15 : 0; } + @Deprecated @Override public int getStrongPower(IBlockState state, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { if (!state.getValue(POWERED)) { @@ -133,9 +128,7 @@ public int getStrongPower(IBlockState state, IBlockAccess blockAccess, BlockPos return state.getValue(FACING) == side ? 15 : 0; } - /** - * Can this block provide power. Only wire currently seems to have this change based on its state. - */ + @Deprecated @Override public boolean canProvidePower(IBlockState state) { return true; @@ -146,9 +139,6 @@ public boolean canProvidePower(IBlockState state) { * Metadata */ - /** - * Convert the given metadata into a BlockState for this Block - */ @Override public IBlockState getStateFromMeta(int meta) { EnumFacing facing = EnumFacing.getHorizontal(meta & 3); @@ -160,9 +150,6 @@ public IBlockState getStateFromMeta(int meta) { return state.withProperty(FACING, facing); } - /** - * Convert the BlockState into the correct metadata value - */ @Override public int getMetaFromState(IBlockState state) { int i = 0;