mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 11:05:40 +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
@@ -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