mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 03:25:18 +00:00
Clean up null issues, add more annotations (#3590)
This commit is contained in:
1 parent
43efa3cfc4
commit
c545b8ecd4
130 files changed
+629
-262
No files matched your search
@@ -30,6 +30,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.AxisAngle4d;
|
||||
import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Quat4f;
|
||||
@@ -218,7 +219,7 @@ public class ForgeBlockStateV1 extends Marker
|
||||
return ret;
|
||||
}
|
||||
|
||||
private Multimap<String, ForgeBlockStateV1.Variant> getPermutations(List<String> sorted, Map<String, Map<String, ForgeBlockStateV1.Variant>> base, int depth, String prefix, Multimap<String, ForgeBlockStateV1.Variant> ret, ForgeBlockStateV1.Variant parent)
|
||||
private Multimap<String, ForgeBlockStateV1.Variant> getPermutations(List<String> sorted, Map<String, Map<String, ForgeBlockStateV1.Variant>> base, int depth, String prefix, Multimap<String, ForgeBlockStateV1.Variant> ret, @Nullable ForgeBlockStateV1.Variant parent)
|
||||
{
|
||||
if (depth == sorted.size())
|
||||
{
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.BitSet;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Vector4f;
|
||||
|
||||
@@ -140,7 +141,7 @@ public final class ItemLayerModel implements IRetexturableModel
|
||||
private final boolean isCulled;
|
||||
private final ItemOverrideList overrides;
|
||||
|
||||
public BakedItemModel(ImmutableList<BakedQuad> quads, TextureAtlasSprite particle, ImmutableMap<TransformType, TRSRTransformation> transforms, ItemOverrideList overrides, IBakedModel otherModel)
|
||||
public BakedItemModel(ImmutableList<BakedQuad> quads, TextureAtlasSprite particle, ImmutableMap<TransformType, TRSRTransformation> transforms, ItemOverrideList overrides, @Nullable IBakedModel otherModel)
|
||||
{
|
||||
this.quads = quads;
|
||||
this.particle = particle;
|
||||
|
||||
@@ -75,10 +75,13 @@ public final class ModelDynBucket implements IModel, IModelCustomData, IRetextur
|
||||
|
||||
public static final IModel MODEL = new ModelDynBucket();
|
||||
|
||||
@Nullable
|
||||
private final ResourceLocation baseLocation;
|
||||
@Nullable
|
||||
private final ResourceLocation liquidLocation;
|
||||
@Nullable
|
||||
private final ResourceLocation coverLocation;
|
||||
|
||||
@Nullable
|
||||
private final Fluid fluid;
|
||||
private final boolean flipGas;
|
||||
|
||||
@@ -87,7 +90,7 @@ public final class ModelDynBucket implements IModel, IModelCustomData, IRetextur
|
||||
this(null, null, null, null, false);
|
||||
}
|
||||
|
||||
public ModelDynBucket(ResourceLocation baseLocation, ResourceLocation liquidLocation, ResourceLocation coverLocation, Fluid fluid, boolean flipGas)
|
||||
public ModelDynBucket(@Nullable ResourceLocation baseLocation, @Nullable ResourceLocation liquidLocation, @Nullable ResourceLocation coverLocation, @Nullable Fluid fluid, boolean flipGas)
|
||||
{
|
||||
this.baseLocation = baseLocation;
|
||||
this.liquidLocation = liquidLocation;
|
||||
|
||||
@@ -121,6 +121,8 @@ import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Multimaps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public final class ModelLoader extends ModelBakery
|
||||
{
|
||||
private final Map<ModelResourceLocation, IModel> stateModels = Maps.newHashMap();
|
||||
@@ -1167,7 +1169,7 @@ public final class ModelLoader extends ModelBakery
|
||||
ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition()
|
||||
{
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack)
|
||||
public ModelResourceLocation getModelLocation(@Nonnull ItemStack stack)
|
||||
{
|
||||
return ModelDynBucket.LOCATION;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ package net.minecraftforge.client.model;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.vecmath.Matrix4f;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
@@ -177,6 +178,7 @@ public final class MultiLayerModel implements IModelCustomData
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand)
|
||||
{
|
||||
|
||||
+2
-2
@@ -67,10 +67,10 @@ public final class AnimationItemOverrideList extends ItemOverrideList
|
||||
@Override
|
||||
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))
|
||||
IAnimationStateMachine asm = stack.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null);
|
||||
if (asm != null)
|
||||
{
|
||||
// TODO: caching?
|
||||
IAnimationStateMachine asm = stack.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null);
|
||||
if(world == null && entity != null)
|
||||
{
|
||||
world = entity.world;
|
||||
|
||||
@@ -44,6 +44,7 @@ import net.minecraftforge.common.animation.IEventHandler;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.animation.CapabilityAnimation;
|
||||
|
||||
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -67,12 +68,12 @@ public class AnimationModelBase<T extends Entity> extends ModelBase implements I
|
||||
@Override
|
||||
public void render(Entity entity, float limbSwing, float limbSwingSpeed, float timeAlive, float yawHead, float rotationPitch, float scale)
|
||||
{
|
||||
if(!(entity.hasCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null)))
|
||||
IAnimationStateMachine capability = entity.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null);
|
||||
if (capability == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Pair<IModelState, Iterable<Event>> pair = entity.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null).apply(timeAlive / 20);
|
||||
Pair<IModelState, Iterable<Event>> pair = capability.apply(timeAlive / 20);
|
||||
handleEvents((T)entity, timeAlive / 20, pair.getRight());
|
||||
IModel model = ModelLoaderRegistry.getModelOrMissing(modelLocation);
|
||||
IBakedModel bakedModel = model.bake(pair.getLeft(), DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter());
|
||||
|
||||
@@ -32,11 +32,14 @@ import net.minecraftforge.common.animation.Event;
|
||||
import net.minecraftforge.common.animation.IEventHandler;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.animation.CapabilityAnimation;
|
||||
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.common.property.Properties;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Generic TileEntitySpecialRenderer that works with the Forge model system and animations.
|
||||
*/
|
||||
@@ -44,7 +47,7 @@ public class AnimationTESR<T extends TileEntity> extends FastTESR<T> implements
|
||||
{
|
||||
protected static BlockRendererDispatcher blockRenderer;
|
||||
|
||||
public void renderTileEntityFast(T te, double x, double y, double z, float partialTick, int breakStage, VertexBuffer renderer)
|
||||
public void renderTileEntityFast(@Nonnull T te, double x, double y, double z, float partialTick, int breakStage, @Nonnull VertexBuffer renderer)
|
||||
{
|
||||
if(!te.hasCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null))
|
||||
{
|
||||
@@ -64,16 +67,20 @@ public class AnimationTESR<T extends TileEntity> extends FastTESR<T> implements
|
||||
if(exState.getUnlistedNames().contains(Properties.AnimationProperty))
|
||||
{
|
||||
float time = Animation.getWorldTime(getWorld(), partialTick);
|
||||
Pair<IModelState, Iterable<Event>> pair = te.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null).apply(time);
|
||||
handleEvents(te, time, pair.getRight());
|
||||
IAnimationStateMachine capability = te.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null);
|
||||
if (capability != null)
|
||||
{
|
||||
Pair<IModelState, Iterable<Event>> pair = capability.apply(time);
|
||||
handleEvents(te, time, pair.getRight());
|
||||
|
||||
// TODO: caching?
|
||||
IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(exState.getClean());
|
||||
exState = exState.withProperty(Properties.AnimationProperty, pair.getLeft());
|
||||
// TODO: caching?
|
||||
IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(exState.getClean());
|
||||
exState = exState.withProperty(Properties.AnimationProperty, pair.getLeft());
|
||||
|
||||
renderer.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ());
|
||||
renderer.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ());
|
||||
|
||||
blockRenderer.getBlockModelRenderer().renderModel(world, model, exState, pos, renderer, false);
|
||||
blockRenderer.getBlockModelRenderer().renderModel(world, model, exState, pos, renderer, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,10 +31,12 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public abstract class FastTESR<T extends TileEntity> extends TileEntitySpecialRenderer<T>
|
||||
{
|
||||
@Override
|
||||
public final void renderTileEntityAt(T te, double x, double y, double z, float partialTicks, int destroyStage)
|
||||
public final void renderTileEntityAt(@Nonnull T te, double x, double y, double z, float partialTicks, int destroyStage)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
VertexBuffer VertexBuffer = tessellator.getBuffer();
|
||||
@@ -64,5 +66,5 @@ public abstract class FastTESR<T extends TileEntity> extends TileEntitySpecialRe
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void renderTileEntityFast(T te, double x, double y, double z, float partialTicks, int destroyStage, VertexBuffer VertexBuffer);
|
||||
public abstract void renderTileEntityFast(@Nonnull T te, double x, double y, double z, float partialTicks, int destroyStage, @Nonnull VertexBuffer VertexBuffer);
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.AxisAngle4f;
|
||||
import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Quat4f;
|
||||
@@ -515,6 +516,7 @@ public class ModelBlockAnimation
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TRSRTransformation getPartTransform(IModelState state, BlockPart part, int i)
|
||||
{
|
||||
ImmutableCollection<MBJointWeight> infos = getJoint(i);
|
||||
|
||||
@@ -30,6 +30,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Vector3f;
|
||||
|
||||
@@ -168,6 +169,7 @@ public enum B3DLoader implements ICustomModelLoader
|
||||
private final int frame;
|
||||
private final int nextFrame;
|
||||
private final float progress;
|
||||
@Nullable
|
||||
private final IModelState parent;
|
||||
|
||||
public B3DState(Animation animation, int frame)
|
||||
@@ -185,7 +187,7 @@ public enum B3DLoader implements ICustomModelLoader
|
||||
this(animation, frame, nextFrame, progress, null);
|
||||
}
|
||||
|
||||
public B3DState(Animation animation, int frame, int nextFrame, float progress, IModelState parent)
|
||||
public B3DState(Animation animation, int frame, int nextFrame, float progress, @Nullable IModelState parent)
|
||||
{
|
||||
this.animation = animation;
|
||||
this.frame = frame;
|
||||
@@ -194,7 +196,8 @@ public enum B3DLoader implements ICustomModelLoader
|
||||
this.parent = getParent(parent);
|
||||
}
|
||||
|
||||
private IModelState getParent(IModelState parent)
|
||||
@Nullable
|
||||
private IModelState getParent(@Nullable IModelState parent)
|
||||
{
|
||||
if (parent == null) return null;
|
||||
else if (parent instanceof B3DState) return ((B3DState)parent).parent;
|
||||
@@ -221,6 +224,7 @@ public enum B3DLoader implements ICustomModelLoader
|
||||
return progress;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public IModelState getParent()
|
||||
{
|
||||
return parent;
|
||||
|
||||
@@ -33,6 +33,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix3f;
|
||||
import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Vector2f;
|
||||
@@ -1068,7 +1069,7 @@ public class OBJModel implements IRetexturableModel, IModelCustomData
|
||||
// public float[] minUVBounds = new float[] {0.0f, 0.0f};
|
||||
// public float[] maxUVBounds = new float[] {1.0f, 1.0f};
|
||||
|
||||
public Group(String name, LinkedHashSet<Face> faces)
|
||||
public Group(String name, @Nullable LinkedHashSet<Face> faces)
|
||||
{
|
||||
this.name = name != null ? name : DEFAULT_NAME;
|
||||
this.faces = faces == null ? new LinkedHashSet<Face>() : faces;
|
||||
@@ -1129,6 +1130,7 @@ public class OBJModel implements IRetexturableModel, IModelCustomData
|
||||
for (String s : visibleGroups) this.visibilityMap.put(s, visibility);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public IModelState getParent(IModelState parent)
|
||||
{
|
||||
if (parent == null) return null;
|
||||
|
||||
Reference in new issue
Block a user