Skip to content

Commit 47ff0f0

Browse files
committed
Null checks and item rendering
added null checks for itemstacks - should help with #6 and #7 (mostly) fixed the squiffy item rendering - I am excusing my laziness in this area by saying "they are disabled - they shouldn't look normal*
1 parent ff0cfdc commit 47ff0f0

4 files changed

Lines changed: 34 additions & 28 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ buildscript {
1717

1818
apply plugin: 'forge'
1919

20-
version = "0.9.0-1.7.10"
20+
version = "0.9.2-1.7.10"
2121
group= "com.hilburn.dimensionguard" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
2222
archivesBaseName = "DimensionGuard"
2323

src/main/java/com/hilburn/dimensionguard/ModInformation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
public class ModInformation {
99
public static final String MODID = "dimensionguard";
1010
public static final String NAME = "DimensionGuard";
11-
public static final String VERSION = "0.9.0-1.7.10";
11+
public static final String VERSION = "0.9.2-1.7.10";
1212
}

src/main/java/com/hilburn/dimensionguard/client/DisabledRenderer.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import net.minecraft.client.renderer.RenderBlocks;
88
import net.minecraft.client.renderer.Tessellator;
99
import net.minecraft.client.renderer.entity.RenderItem;
10+
import net.minecraft.client.renderer.entity.RenderManager;
11+
import net.minecraft.client.renderer.entity.RenderPlayer;
1012
import net.minecraft.client.renderer.texture.TextureManager;
1113
import net.minecraft.item.Item;
1214
import net.minecraft.item.ItemBlock;
@@ -120,9 +122,13 @@ public void renderItem (ItemRenderType type, ItemStack itemStack, Object... data
120122
{
121123
case EQUIPPED_FIRST_PERSON:
122124
//TODO: get items to render in the right place
125+
GL11.glRotated(90F, 0F, 1F, 0F);
126+
GL11.glTranslatef(-1F, 0.5F, 0F);
127+
break;
123128
case EQUIPPED:
124129
GL11.glRotated(90F, 0F, 1F, 0F);
125-
GL11.glTranslatef(-0.8F, 0.7F, -0.8F);
130+
GL11.glTranslatef(-1F, 0.5F, 0F);
131+
GL11.glRotated(90F, 1F, 0F, 0F);
126132
//GL11.glTranslatef(0, -4 / 16f, 0);
127133
break;
128134
case ENTITY:

src/main/java/com/hilburn/dimensionguard/handlers/DisabledHandler.java

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ public class DisabledHandler {
3434
private static ArrayList<String> registeredItems;
3535

3636
public static void init(){
37-
//Logger.log(EntityList.classToStringMapping.toString());
3837
ConfigHandler.init(DimensionGuard.config);
39-
//disabledBlocks = new ArrayList<Disabled>();
40-
//registeredBlocks=new ArrayList<String>();
4138
registeredItems=new ArrayList<String>();
4239

4340
// for (Object key:GameData.getBlockRegistry().getKeys()){
@@ -149,29 +146,32 @@ public static void scanInventory(EntityPlayer player, boolean setCanBeDisabled){
149146
}
150147

151148
public static ItemStack scanStack(ItemStack thisStack, int dim, boolean setCanBeDisabled){
152-
if(thisStack.stackTagCompound==null){
153-
thisStack.stackTagCompound=new NBTTagCompound();
154-
}
155-
if(!thisStack.stackTagCompound.hasKey("DimensionGuard"))
156-
thisStack.stackTagCompound.setTag("DimensionGuard", new NBTTagCompound());
157-
if(!thisStack.stackTagCompound.getCompoundTag("DimensionGuard").hasKey("CanBeDisabled")||setCanBeDisabled)
158-
thisStack.stackTagCompound.getCompoundTag("DimensionGuard").setBoolean("CanBeDisabled",
159-
DisabledHandler.canBeDisabled(GameRegistry.findUniqueIdentifierFor(thisStack.getItem()).toString(), thisStack.getItemDamage()));
160-
if(thisStack.stackTagCompound.getCompoundTag("DimensionGuard").getBoolean("CanBeDisabled")||thisStack.getItem()==ModItems.disable){
161-
if(!thisStack.stackTagCompound.getCompoundTag("DimensionGuard").hasKey("LastDimChecked"))
162-
thisStack.stackTagCompound.getCompoundTag("DimensionGuard").setInteger("LastDimChecked",Integer.MIN_VALUE);
163-
if(thisStack.stackTagCompound.getCompoundTag("DimensionGuard").getInteger("LastDimChecked")!=dim){
164-
if (thisStack.getItem()==ModItems.disable){
165-
ItemStack storeStack = DisableItem.recoverItemStack(thisStack);
166-
//Logger.log(storeStack.getDisplayName());
167-
if (!DisabledHandler.isDisabled(GameRegistry.findUniqueIdentifierFor(storeStack.getItem()).toString(), storeStack.getItemDamage(),dim)){
168-
return storeStack;
169-
}
170-
}else{
171-
if (DisabledHandler.isDisabled(GameRegistry.findUniqueIdentifierFor(thisStack.getItem()).toString(), thisStack.getItemDamage(),dim)){
172-
return DisableItem.storeItem(new ItemStack(ModItems.disable,1), thisStack);
149+
if (thisStack!=null&&thisStack.getItem()!=null)
150+
{
151+
if(thisStack.stackTagCompound==null){
152+
thisStack.stackTagCompound=new NBTTagCompound();
153+
}
154+
if(!thisStack.stackTagCompound.hasKey("DimensionGuard"))
155+
thisStack.stackTagCompound.setTag("DimensionGuard", new NBTTagCompound());
156+
if(!thisStack.stackTagCompound.getCompoundTag("DimensionGuard").hasKey("CanBeDisabled")||setCanBeDisabled)
157+
thisStack.stackTagCompound.getCompoundTag("DimensionGuard").setBoolean("CanBeDisabled",
158+
DisabledHandler.canBeDisabled(GameRegistry.findUniqueIdentifierFor(thisStack.getItem()).toString(), thisStack.getItemDamage()));
159+
if(thisStack.stackTagCompound.getCompoundTag("DimensionGuard").getBoolean("CanBeDisabled")||thisStack.getItem()==ModItems.disable){
160+
if(!thisStack.stackTagCompound.getCompoundTag("DimensionGuard").hasKey("LastDimChecked"))
161+
thisStack.stackTagCompound.getCompoundTag("DimensionGuard").setInteger("LastDimChecked",Integer.MIN_VALUE);
162+
if(thisStack.stackTagCompound.getCompoundTag("DimensionGuard").getInteger("LastDimChecked")!=dim){
163+
if (thisStack.getItem()==ModItems.disable){
164+
ItemStack storeStack = DisableItem.recoverItemStack(thisStack);
165+
//Logger.log(storeStack.getDisplayName());
166+
if (!DisabledHandler.isDisabled(GameRegistry.findUniqueIdentifierFor(storeStack.getItem()).toString(), storeStack.getItemDamage(),dim)){
167+
return storeStack;
168+
}
173169
}else{
174-
thisStack.stackTagCompound.getCompoundTag("DimensionGuard").setInteger("LastDimChecked",dim);
170+
if (DisabledHandler.isDisabled(GameRegistry.findUniqueIdentifierFor(thisStack.getItem()).toString(), thisStack.getItemDamage(),dim)){
171+
return DisableItem.storeItem(new ItemStack(ModItems.disable,1), thisStack);
172+
}else{
173+
thisStack.stackTagCompound.getCompoundTag("DimensionGuard").setInteger("LastDimChecked",dim);
174+
}
175175
}
176176
}
177177
}

0 commit comments

Comments
 (0)