mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-24 22:14:32 +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
@@ -23,6 +23,8 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Quat4f;
|
||||
|
||||
@@ -253,7 +255,8 @@ public final class ModelDynBucket implements IModel, IModelCustomData, IRetextur
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity)
|
||||
@Nonnull
|
||||
public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, @Nonnull ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity)
|
||||
{
|
||||
FluidStack fluidStack = FluidUtil.getFluidContained(stack);
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
@@ -72,7 +74,8 @@ public final class MultiModel implements IModel
|
||||
private final ItemOverrideList overrides = new ItemOverrideList(Lists.<ItemOverride>newArrayList())
|
||||
{
|
||||
@Override
|
||||
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity)
|
||||
@Nonnull
|
||||
public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, @Nonnull ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity)
|
||||
{
|
||||
if(originalModel != Baked.this)
|
||||
{
|
||||
|
||||
+6
-2
@@ -39,6 +39,9 @@ import net.minecraftforge.common.model.animation.IAnimationStateMachine;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class AnimationItemOverrideList extends ItemOverrideList
|
||||
{
|
||||
private final IModel model;
|
||||
@@ -60,14 +63,15 @@ public final class AnimationItemOverrideList extends ItemOverrideList
|
||||
this.bakedTextureGetter = bakedTextureGetter;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity)
|
||||
public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, @Nonnull ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity)
|
||||
{
|
||||
if(stack.hasCapability(net.minecraftforge.common.model.animation.CapabilityAnimation.ANIMATION_CAPABILITY, null))
|
||||
{
|
||||
// TODO: caching?
|
||||
IAnimationStateMachine asm = stack.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null);
|
||||
if(world == null)
|
||||
if(world == null && entity != null)
|
||||
{
|
||||
world = entity.worldObj;
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ public class ForgeHooks
|
||||
private static boolean toolInit = false;
|
||||
//static HashSet<List> toolEffectiveness = new HashSet<List>();
|
||||
|
||||
public static boolean canHarvestBlock(Block block, EntityPlayer player, IBlockAccess world, BlockPos pos)
|
||||
public static boolean canHarvestBlock(@Nonnull Block block, @Nonnull EntityPlayer player, @Nonnull IBlockAccess world, @Nonnull BlockPos pos)
|
||||
{
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
state = state.getBlock().getActualState(state, world, pos);
|
||||
@@ -165,7 +165,7 @@ public class ForgeHooks
|
||||
return true;
|
||||
}
|
||||
|
||||
ItemStack stack = player.inventory.getCurrentItem();
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
String tool = block.getHarvestTool(state);
|
||||
if (stack.func_190926_b() || tool == null)
|
||||
{
|
||||
@@ -190,7 +190,7 @@ public class ForgeHooks
|
||||
return stack.getItem().getHarvestLevel(stack, tool, null, null) >= state.getBlock().getHarvestLevel(state);
|
||||
}
|
||||
|
||||
public static float blockStrength(IBlockState state, EntityPlayer player, World world, BlockPos pos)
|
||||
public static float blockStrength(@Nonnull IBlockState state, @Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos)
|
||||
{
|
||||
float hardness = state.getBlockHardness(world, pos);
|
||||
if (hardness < 0.0F)
|
||||
|
||||
@@ -45,25 +45,7 @@ public class ForgeInternalHandler
|
||||
if (entity.getClass().equals(EntityItem.class))
|
||||
{
|
||||
ItemStack stack = ((EntityItem)entity).getEntityItem();
|
||||
|
||||
if (stack == null)
|
||||
{
|
||||
//entity.setDead();
|
||||
//event.setCanceled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Item item = stack.getItem();
|
||||
if (item == null)
|
||||
{
|
||||
FMLLog.warning("Attempted to add a EntityItem to the world with a invalid item at " +
|
||||
"(%2.2f, %2.2f, %2.2f), this is most likely a config issue between you and the server. Please double check your configs",
|
||||
entity.posX, entity.posY, entity.posZ);
|
||||
entity.setDead();
|
||||
event.setCanceled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.hasCustomEntity(stack))
|
||||
{
|
||||
Entity newEntity = item.createEntity(event.getWorld(), entity, stack);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* This is a fluid block implementation which emulates vanilla Minecraft fluid behavior.
|
||||
*
|
||||
@@ -78,7 +80,7 @@ public class BlockFluidClassic extends BlockFluidBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCollideCheck(IBlockState state, boolean fullHit)
|
||||
public boolean canCollideCheck(@Nonnull IBlockState state, boolean fullHit)
|
||||
{
|
||||
return fullHit && state.getValue(LEVEL) == 0;
|
||||
}
|
||||
@@ -90,7 +92,7 @@ public class BlockFluidClassic extends BlockFluidBase
|
||||
}
|
||||
|
||||
@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)
|
||||
{
|
||||
@@ -101,7 +103,7 @@ public class BlockFluidClassic extends BlockFluidBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand)
|
||||
public void updateTick(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull Random rand)
|
||||
{
|
||||
if (!isSourceBlock(world, pos) && ForgeEventFactory.canCreateFluidSource(world, pos, state, false))
|
||||
{
|
||||
|
||||
@@ -30,6 +30,8 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* This is a cellular-automata based finite fluid block implementation.
|
||||
*
|
||||
@@ -60,7 +62,7 @@ public class BlockFluidFinite extends BlockFluidBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCollideCheck(IBlockState state, boolean fullHit)
|
||||
public boolean canCollideCheck(@Nonnull IBlockState state, boolean fullHit)
|
||||
{
|
||||
return fullHit && state.getValue(LEVEL) == quantaPerBlock - 1;
|
||||
}
|
||||
@@ -72,7 +74,7 @@ public class BlockFluidFinite extends BlockFluidBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand)
|
||||
public void updateTick(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull Random rand)
|
||||
{
|
||||
boolean changed = false;
|
||||
int quantaRemaining = state.getValue(LEVEL) + 1;
|
||||
|
||||
@@ -103,7 +103,7 @@ public class UniversalBucket extends Item
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getSubItems(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> subItems)
|
||||
public void getSubItems(@Nonnull Item itemIn, @Nonnull CreativeTabs tab, @Nonnull NonNullList<ItemStack> subItems)
|
||||
{
|
||||
for (Fluid fluid : FluidRegistry.getRegisteredFluids().values())
|
||||
{
|
||||
@@ -123,6 +123,7 @@ public class UniversalBucket extends Item
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public String getItemStackDisplayName(@Nonnull ItemStack stack)
|
||||
{
|
||||
FluidStack fluidStack = getFluid(stack);
|
||||
@@ -146,7 +147,8 @@ public class UniversalBucket extends Item
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
@Nonnull
|
||||
public ActionResult<ItemStack> onItemRightClick(@Nonnull World world, @Nonnull EntityPlayer player, @Nonnull EnumHand hand)
|
||||
{
|
||||
ItemStack itemstack = player.getHeldItem(hand);
|
||||
FluidStack fluidStack = getFluid(itemstack);
|
||||
|
||||
@@ -27,6 +27,7 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -80,7 +81,8 @@ public abstract class CommandTreeBase extends CommandBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos)
|
||||
@Nonnull
|
||||
public List<String> getTabCompletionOptions(@Nonnull MinecraftServer server, @Nonnull ICommandSender sender, @Nonnull String[] args, @Nullable BlockPos pos)
|
||||
{
|
||||
if(args.length == 1)
|
||||
{
|
||||
@@ -109,7 +111,7 @@ public abstract class CommandTreeBase extends CommandBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsernameIndex(String[] args, int index)
|
||||
public boolean isUsernameIndex(@Nonnull String[] args, int index)
|
||||
{
|
||||
if(index > 0 && args.length > 1)
|
||||
{
|
||||
@@ -124,7 +126,7 @@ public abstract class CommandTreeBase extends CommandBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
|
||||
public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sender, @Nonnull String[] args) throws CommandException
|
||||
{
|
||||
if(args.length < 1)
|
||||
{
|
||||
|
||||
@@ -19,6 +19,6 @@ public class BreedingTest
|
||||
|
||||
@SubscribeEvent
|
||||
public void onBabyBorn(BabyEntitySpawnEvent event) {
|
||||
event.setChild(new EntityCow(event.getChild().worldObj));
|
||||
event.setChild(new EntityCow(event.getParentA().worldObj));
|
||||
}
|
||||
}
|
||||
@@ -263,8 +263,11 @@ public class DynBucketTest
|
||||
{
|
||||
ItemStack heldItem = playerIn.getHeldItem(hand);
|
||||
IFluidHandler tank = FluidUtil.getFluidHandler(worldIn, pos, side.getOpposite());
|
||||
if (tank == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (null == null)
|
||||
if (heldItem.func_190926_b())
|
||||
{
|
||||
sendText(playerIn, tank);
|
||||
return false;
|
||||
|
||||
@@ -20,6 +20,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@Mod(modid = ItemLayerModelDebug.MODID, name = "ForgeDebugItemLayerModel", version = ItemLayerModelDebug.VERSION, acceptableRemoteVersions = "*")
|
||||
@@ -95,7 +96,7 @@ public class ItemLayerModelDebug
|
||||
@Override
|
||||
public int getHarvestLevel(ItemStack stack, String toolClass, @Nullable EntityPlayer player, @Nullable IBlockState blockState) {
|
||||
// This tool is a super pickaxe if the player is wearing a helment
|
||||
if("pickaxe".equals(toolClass) && player != null && player.getItemStackFromSlot(EntityEquipmentSlot.HEAD) != null) {
|
||||
if("pickaxe".equals(toolClass) && player != null && !player.getItemStackFromSlot(EntityEquipmentSlot.HEAD).func_190926_b()) {
|
||||
return 5;
|
||||
}
|
||||
return super.getHarvestLevel(stack, toolClass, player, blockState);
|
||||
|
||||
@@ -158,7 +158,7 @@ public class ModelAnimationDebug
|
||||
GameRegistry.register(new ItemBlock(Block.REGISTRY.getObject(blockId))
|
||||
{
|
||||
@Override
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt)
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt)
|
||||
{
|
||||
return new ItemAnimationHolder();
|
||||
}
|
||||
@@ -166,11 +166,13 @@ public class ModelAnimationDebug
|
||||
GameRegistry.registerTileEntity(Chest.class, MODID + ":" + "tile_" + blockName);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract IAnimationStateMachine load(ResourceLocation location, ImmutableMap<String, ITimeValue> parameters);
|
||||
}
|
||||
|
||||
public static class ServerProxy extends CommonProxy
|
||||
{
|
||||
@Nullable
|
||||
public IAnimationStateMachine load(ResourceLocation location, ImmutableMap<String, ITimeValue> parameters)
|
||||
{
|
||||
return null;
|
||||
@@ -267,6 +269,7 @@ public class ModelAnimationDebug
|
||||
|
||||
public static class Chest extends TileEntity
|
||||
{
|
||||
@Nullable
|
||||
private final IAnimationStateMachine asm;
|
||||
private final VariableValue cycleLength = new VariableValue(4);
|
||||
private final VariableValue clickTime = new VariableValue(Float.NEGATIVE_INFINITY);
|
||||
|
||||
@@ -22,7 +22,6 @@ import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -49,6 +48,8 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.primitives.Ints;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@Mod(modid = ModelBakeEventDebug.MODID, name = "ForgeDebugModelBakeEvent", version = ModelBakeEventDebug.VERSION, acceptableRemoteVersions = "*")
|
||||
public class ModelBakeEventDebug
|
||||
{
|
||||
@@ -253,7 +254,7 @@ public class ModelBakeEventDebug
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand)
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand)
|
||||
{
|
||||
if(side != null) return ImmutableList.of();
|
||||
IExtendedBlockState exState = (IExtendedBlockState)state;
|
||||
@@ -310,7 +311,7 @@ public class ModelBakeEventDebug
|
||||
case WEST: return new Vec3d(-vec.yCoord, vec.xCoord, vec.zCoord);
|
||||
case EAST: return new Vec3d( vec.yCoord, -vec.xCoord, vec.zCoord);
|
||||
}
|
||||
return null;
|
||||
throw new IllegalArgumentException("Unknown Side " + side);
|
||||
}
|
||||
|
||||
private static Vec3d revRotate(Vec3d vec, EnumFacing side)
|
||||
@@ -324,6 +325,6 @@ public class ModelBakeEventDebug
|
||||
case WEST: return new Vec3d( vec.yCoord, -vec.xCoord, vec.zCoord);
|
||||
case EAST: return new Vec3d(-vec.yCoord, vec.xCoord, vec.zCoord);
|
||||
}
|
||||
return null;
|
||||
throw new IllegalArgumentException("Unknown Side " + side);
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class MultiLayerModelDebug
|
||||
public boolean isFullCube(IBlockState state) { return false; }
|
||||
|
||||
@Override
|
||||
public boolean canRenderInLayer(BlockRenderLayer layer)
|
||||
public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer)
|
||||
{
|
||||
return layer == BlockRenderLayer.SOLID || layer == BlockRenderLayer.TRANSLUCENT;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package net.minecraftforge.debug;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
+1
-4
@@ -1,7 +1,5 @@
|
||||
package net.minecraftforge.fml.common.registry;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDirt;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Bootstrap;
|
||||
@@ -18,7 +16,6 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
@@ -35,7 +32,7 @@ public class ItemBlockSubstitutionRemoveRestoreTest
|
||||
public ItemMyDirt() {
|
||||
super(Blocks.DIRT, Blocks.DIRT, new Mapper()
|
||||
{
|
||||
@Nullable
|
||||
@Nonnull
|
||||
public String apply(@Nonnull ItemStack p_apply_1_)
|
||||
{
|
||||
return BlockDirt.DirtType.byMetadata(p_apply_1_.getMetadata()).getUnlocalizedName();
|
||||
|
||||
@@ -15,6 +15,8 @@ import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
@@ -28,6 +30,7 @@ public class SubstitutionInjectionTest
|
||||
private ResourceLocation myDirt = new ResourceLocation("minecraft:dirt");
|
||||
private BlockDirt toSub = new BlockDirt() {
|
||||
@Override
|
||||
@Nonnull
|
||||
public String toString()
|
||||
{
|
||||
return "SUB" + super.toString() + "SUB";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.minecraftforge.test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
@@ -15,6 +16,8 @@ import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameData;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@Mod(modid="clientcommandtest", name="Client Command Test", version="0.0.0", clientSideOnly = true)
|
||||
public class ClientCommandTest {
|
||||
@EventHandler
|
||||
@@ -43,14 +46,14 @@ public class ClientCommandTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos pos)
|
||||
public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos)
|
||||
{
|
||||
if (args.length > 0)
|
||||
{
|
||||
return getListOfStringsMatchingLastWord(args, GameData.getBlockRegistry().getKeys());
|
||||
}
|
||||
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,7 @@ import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@Mod(modid="fluidhandlertest", name="FluidHandlerTest", version="0.0.0", acceptableRemoteVersions = "*")
|
||||
public class FluidHandlerTest
|
||||
@@ -83,7 +84,7 @@ public class FluidHandlerTest
|
||||
}
|
||||
}
|
||||
|
||||
private static String fluidString(FluidStack stack)
|
||||
private static String fluidString(@Nullable FluidStack stack)
|
||||
{
|
||||
if (stack == null)
|
||||
{
|
||||
|
||||
@@ -165,7 +165,8 @@ public class NoBedSleepingTest
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
@Nonnull
|
||||
public ActionResult<ItemStack> onItemRightClick(@Nonnull World world, @Nonnull EntityPlayer player, @Nonnull EnumHand hand)
|
||||
{
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (!world.isRemote)
|
||||
|
||||
@@ -47,7 +47,7 @@ public class TestCapabilityMod
|
||||
@SubscribeEvent
|
||||
public void onInteract(PlayerInteractEvent.LeftClickBlock event)
|
||||
{
|
||||
if (event.getItemStack() == null) return;
|
||||
if (event.getItemStack().func_190926_b()) return;
|
||||
if (event.getItemStack().getItem() != Items.STICK) return;
|
||||
|
||||
// This is just a example of how to interact with the TE, note the strong type binding that getCapability has
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package net.minecraftforge.test;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
Reference in new issue
Block a user