Add some null safety for extended state props

This commit is contained in:
Xander committed 2017-09-02 11:51:30 +08:00
1 parent 42efc07d3a
commit 3cc755f33d
3 files changed
+6 -4

No files matched your search

@@ -67,7 +67,7 @@ public class GlowPanelModel extends OBJBakedModelBase
return EnumColor.DYES[tempStack.getItemDamage()];
}
if(tempState != null)
if(tempState != null && ((IExtendedBlockState)tempState).getValue(PropertyColor.INSTANCE) != null)
{
return ((IExtendedBlockState)tempState).getValue(PropertyColor.INSTANCE).color;
}
@@ -178,7 +178,7 @@ public class TransmitterModel extends OBJBakedModelBase
EnumFacing side = EnumFacing.getFacingFromVector(f.getNormal().x, f.getNormal().y, f.getNormal().z);
PropertyColor prop = ((IExtendedBlockState)tempState).getValue(PropertyColor.INSTANCE);
PropertyConnection connection = ((IExtendedBlockState)tempState).getValue(PropertyConnection.INSTANCE);
boolean sideIconOverride = getIconStatus(side, connection) > 0;
boolean sideIconOverride = connection != null && getIconStatus(side, connection) > 0;
if(MinecraftForgeClient.getRenderLayer() == BlockRenderLayer.TRANSLUCENT)
{
@@ -228,7 +228,7 @@ public class TransmitterModel extends OBJBakedModelBase
EnumFacing side = EnumFacing.getFacingFromVector(f.getNormal().x, f.getNormal().y, f.getNormal().z);
PropertyConnection connection = ((IExtendedBlockState)tempState).getValue(PropertyConnection.INSTANCE);
if(groupName.endsWith("NONE") && getIconStatus(side, connection) == 2)
if(connection != null && groupName.endsWith("NONE") && getIconStatus(side, connection) == 2)
{
return true;
}
@@ -112,7 +112,9 @@ public class TileEntityGlowPanel extends TileEntity implements ITileNetwork
public static int hash(IExtendedBlockState state)
{
int hash = 1;
hash = 31 * hash + state.getValue(PropertyColor.INSTANCE).color.ordinal();
PropertyColor propColor = state.getValue(PropertyColor.INSTANCE);
EnumColor color = propColor != null ? propColor.color : EnumColor.WHITE;
hash = 31 * hash + color.ordinal();
hash = 31 * hash + state.getValue(BlockStateFacing.facingProperty).ordinal();
return hash;