mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 08:17:35 +00:00
Cleanup some null checks and remove deprecated methods in Item and Block (#3429)
This commit is contained in:
1 parent
2823447b6e
commit
2bd8b95a3b
31 files changed
+175
-174
No files matched your search
@@ -31,6 +31,7 @@ import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -49,6 +50,8 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* This is a base implementation for Fluid blocks.
|
||||
*
|
||||
@@ -161,17 +164,20 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new ExtendedBlockState(this, new IProperty[] { LEVEL }, FLUID_RENDER_PROPS.toArray(new IUnlistedProperty<?>[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state)
|
||||
public int getMetaFromState(@Nonnull IBlockState state)
|
||||
{
|
||||
return state.getValue(LEVEL);
|
||||
}
|
||||
@Override
|
||||
@Deprecated
|
||||
@Nonnull
|
||||
public IBlockState getStateFromMeta(int meta)
|
||||
{
|
||||
return this.getDefaultState().withProperty(LEVEL, meta);
|
||||
@@ -313,19 +319,19 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
||||
public abstract int getQuantaValue(IBlockAccess world, BlockPos pos);
|
||||
|
||||
@Override
|
||||
public abstract boolean canCollideCheck(IBlockState state, boolean fullHit);
|
||||
public abstract boolean canCollideCheck(@Nonnull IBlockState state, boolean fullHit);
|
||||
|
||||
public abstract int getMaxRenderHeightMeta();
|
||||
|
||||
/* BLOCK FUNCTIONS */
|
||||
@Override
|
||||
public void onBlockAdded(World world, BlockPos pos, IBlockState state)
|
||||
public void onBlockAdded(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state)
|
||||
{
|
||||
world.scheduleUpdate(pos, this, tickRate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, BlockPos neighbourPos)
|
||||
public void neighborChanged(@Nonnull IBlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Block neighborBlock, @Nonnull BlockPos neighbourPos)
|
||||
{
|
||||
world.scheduleUpdate(pos, this, tickRate);
|
||||
}
|
||||
@@ -338,31 +344,33 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPassable(IBlockAccess world, BlockPos pos)
|
||||
public boolean isPassable(@Nonnull IBlockAccess world, @Nonnull BlockPos pos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||
@Nonnull
|
||||
public Item getItemDropped(@Nonnull IBlockState state, @Nonnull Random rand, int fortune)
|
||||
{
|
||||
return null;
|
||||
return Items.field_190931_a;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random par1Random)
|
||||
public int quantityDropped(@Nonnull Random par1Random)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int tickRate(World world)
|
||||
public int tickRate(@Nonnull World world)
|
||||
{
|
||||
return tickRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d modifyAcceleration(World world, BlockPos pos, Entity entity, Vec3d vec)
|
||||
@Nonnull
|
||||
public Vec3d modifyAcceleration(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull Entity entity, @Nonnull Vec3d vec)
|
||||
{
|
||||
if (densityDir > 0) return vec;
|
||||
Vec3d vec_flow = this.getFlowVector(world, pos);
|
||||
@@ -373,7 +381,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
public int getLightValue(@Nonnull IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos)
|
||||
{
|
||||
if (maxScaledLight == 0)
|
||||
{
|
||||
@@ -384,13 +392,13 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state)
|
||||
public boolean isOpaqueCube(@Nonnull IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state)
|
||||
public boolean isFullCube(@Nonnull IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -406,7 +414,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int getPackedLightmapCoords(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
public int getPackedLightmapCoords(@Nonnull IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos)
|
||||
{
|
||||
int lightThis = world.getCombinedLight(pos, 0);
|
||||
int lightUp = world.getCombinedLight(pos.up(), 0);
|
||||
@@ -420,13 +428,14 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Nonnull
|
||||
public BlockRenderLayer getBlockLayer()
|
||||
{
|
||||
return this.renderLayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side)
|
||||
public boolean shouldSideBeRendered(@Nonnull IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull EnumFacing side)
|
||||
{
|
||||
IBlockState neighbor = world.getBlockState(pos.offset(side));
|
||||
if (neighbor.getMaterial() == state.getMaterial())
|
||||
@@ -445,7 +454,8 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getExtendedState(IBlockState oldState, IBlockAccess worldIn, BlockPos pos)
|
||||
@Nonnull
|
||||
public IBlockState getExtendedState(@Nonnull IBlockState oldState, @Nonnull IBlockAccess worldIn, @Nonnull BlockPos pos)
|
||||
{
|
||||
IExtendedBlockState state = (IExtendedBlockState)oldState;
|
||||
state = state.withProperty(FLOW_DIRECTION, (float)getFlowDirection(worldIn, pos));
|
||||
@@ -675,7 +685,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos)
|
||||
public AxisAlignedBB getCollisionBoundingBox(@Nonnull IBlockState blockState, @Nonnull IBlockAccess worldIn, @Nonnull BlockPos pos)
|
||||
{
|
||||
return NULL_AABB;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user