fixed rendering and NBT crash with old weapons

This commit is contained in:
Mohammad-Ali Minaie
2018-10-29 07:27:51 -04:00
parent 69b0435cc3
commit ce398ba90c
6 changed files with 100 additions and 65 deletions

View File

@@ -68,11 +68,10 @@ public class CustomSword extends ItemSword implements WeaponNBT {
public void onUpdate(ItemStack stack, World world, Entity playerin, int itemSlot, boolean isSelected) { public void onUpdate(ItemStack stack, World world, Entity playerin, int itemSlot, boolean isSelected) {
if(!world.isRemote){ if(!world.isRemote){
if(isSelected) { if(isSelected) {
if(!stack.hasTagCompound()) {
//System.out.println( + stack.getMaxDamage() * 0.6 + " : " + stack.getItemDamage() + " : " + stack.getMaxDamage() * 0.5); WeaponNBT.setDefaultNBT(stack);
//System.out.println(stack.getItemDamage() + ">" + stack.getMaxDamage() * 0.5); }
//System.out.println(stack.getItemDamage() + "<" + stack.getMaxDamage() * 0.6); if(stack.hasTagCompound()) {
//System.out.println(WeaponNBT.getSharpnessLevel(stack));
if (stack.getItemDamage() < stack.getMaxDamage() * 0.5) { if (stack.getItemDamage() < stack.getMaxDamage() * 0.5) {
WeaponNBT.setSharpnessLevel(stack, 5); WeaponNBT.setSharpnessLevel(stack, 5);
//System.out.println("Sharpness = 5"); //System.out.println("Sharpness = 5");
@@ -97,6 +96,7 @@ public class CustomSword extends ItemSword implements WeaponNBT {
WeaponNBT.setSharpnessLevel(stack, 0); WeaponNBT.setSharpnessLevel(stack, 0);
//System.out.println("Sharpness = 0"); //System.out.println("Sharpness = 0");
} }
}
//System.out.println(WeaponNBT.getSharpnessLevel(stack)); //System.out.println(WeaponNBT.getSharpnessLevel(stack));
} }
} }

View File

@@ -31,9 +31,14 @@ public class SlayerSword extends CustomSword {
if(isSelected){ if(isSelected){
EntityPlayer player = (EntityPlayer) ent; EntityPlayer player = (EntityPlayer) ent;
if(!stack.hasTagCompound()) {
WeaponNBT.setDefaultNBT(stack);
}
if(!player.inventory.offHandInventory.isEmpty()) { if(!player.inventory.offHandInventory.isEmpty()) {
ent.setSprinting(false); ent.setSprinting(false);
} }
if(stack.hasTagCompound()) {
if (stack.getItemDamage() < stack.getMaxDamage() * 0.5) { if (stack.getItemDamage() < stack.getMaxDamage() * 0.5) {
WeaponNBT.setSharpnessLevel(stack, 5); WeaponNBT.setSharpnessLevel(stack, 5);
} }
@@ -54,5 +59,6 @@ public class SlayerSword extends CustomSword {
} }
} }
} }
}
} }

View File

@@ -14,6 +14,7 @@ import net.minecraft.util.math.BlockPos;
import nmd.primal.core.common.helper.RecipeHelper; import nmd.primal.core.common.helper.RecipeHelper;
import nmd.primal.forgecraft.blocks.machine.Workbench; import nmd.primal.forgecraft.blocks.machine.Workbench;
import nmd.primal.forgecraft.items.parts.WeaponPart; import nmd.primal.forgecraft.items.parts.WeaponPart;
import nmd.primal.forgecraft.items.weapons.CustomSword;
import nmd.primal.forgecraft.tiles.TileWorkbench; import nmd.primal.forgecraft.tiles.TileWorkbench;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@@ -134,13 +135,15 @@ public class TileWorkbenchRender extends TileEntitySpecialRenderer<TileWorkbench
} }
if(!stack5.isEmpty()){ if(!stack5.isEmpty()){
GL11.glPushMatrix(); GL11.glPushMatrix();
//System.out.println(stack2); if(!(stack5.getItem() instanceof CustomSword)) {
//GL11.glRotated(90.0F, 1.0F, 0.0F, 0.0F);
GL11.glTranslated(0.48D, 0.20625D, -0.15D); GL11.glTranslated(0.48D, 0.20625D, -0.15D);
GL11.glScalef(1F, 1F, 1F); GL11.glScalef(1F, 1F, 1F);
}
if(stack5.getItem() instanceof CustomSword){
GL11.glTranslated(0.2D, 0.42D, 0.075D);
GL11.glScalef(0.5F, 0.5F, 0.5F);
}
GL11.glRotated(-90.0F, 0.0F, 1.0F, 0.0F); GL11.glRotated(-90.0F, 0.0F, 1.0F, 0.0F);
//GL11.glRotated(-90.0F, 1.0F, 0.0F, 0.0F);
renderItem.renderItem(stack5, ItemCameraTransforms.TransformType.HEAD); renderItem.renderItem(stack5, ItemCameraTransforms.TransformType.HEAD);
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
@@ -238,8 +241,16 @@ public class TileWorkbenchRender extends TileEntitySpecialRenderer<TileWorkbench
GL11.glPushMatrix(); GL11.glPushMatrix();
//System.out.println(stack2); //System.out.println(stack2);
//GL11.glRotated(90.0F, 1.0F, 0.0F, 0.0F); //GL11.glRotated(90.0F, 1.0F, 0.0F, 0.0F);
if(!(stack5.getItem() instanceof CustomSword)) {
GL11.glTranslated(0.52D, 0.20625D, 1.15D); GL11.glTranslated(0.52D, 0.20625D, 1.15D);
GL11.glScalef(1F, 1F, 1F); GL11.glScalef(1F, 1F, 1F);
}
if(stack5.getItem() instanceof CustomSword){
GL11.glTranslated(0.8D, 0.42D, 0.9D);
GL11.glScalef(0.5F, 0.5F, 0.5F);
}
GL11.glRotated(90.0F, 0.0F, 1.0F, 0.0F); GL11.glRotated(90.0F, 0.0F, 1.0F, 0.0F);
//GL11.glRotated(-90.0F, 1.0F, 0.0F, 0.0F); //GL11.glRotated(-90.0F, 1.0F, 0.0F, 0.0F);
@@ -337,10 +348,15 @@ public class TileWorkbenchRender extends TileEntitySpecialRenderer<TileWorkbench
} }
if(!stack5.isEmpty()){ if(!stack5.isEmpty()){
GL11.glPushMatrix(); GL11.glPushMatrix();
//System.out.println(stack2);
//GL11.glRotated(90.0F, 1.0F, 0.0F, 0.0F); if(!(stack5.getItem() instanceof CustomSword)) {
GL11.glTranslated(1.15D, 0.20625D, 0.485D); GL11.glTranslated(1.15D, 0.20625D, 0.485D);
GL11.glScalef(1F, 1F, 1F); GL11.glScalef(1F, 1F, 1F);
}
if(stack5.getItem() instanceof CustomSword){
GL11.glTranslated(0.91D, 0.42D, 0.235D);
GL11.glScalef(0.5F, 0.5F, 0.5F);
}
GL11.glRotated(180.0F, 0.0F, 1.0F, 0.0F); GL11.glRotated(180.0F, 0.0F, 1.0F, 0.0F);
//GL11.glRotated(-90.0F, 1.0F, 0.0F, 0.0F); //GL11.glRotated(-90.0F, 1.0F, 0.0F, 0.0F);
@@ -434,12 +450,15 @@ public class TileWorkbenchRender extends TileEntitySpecialRenderer<TileWorkbench
} }
if(!stack5.isEmpty()){ if(!stack5.isEmpty()){
GL11.glPushMatrix(); GL11.glPushMatrix();
//System.out.println(stack2);
//GL11.glRotated(90.0F, 1.0F, 0.0F, 0.0F); if(!(stack5.getItem() instanceof CustomSword)) {
GL11.glTranslated(-0.138D, 0.20625D, 0.52D); GL11.glTranslated(-0.138D, 0.20625D, 0.52D);
GL11.glScalef(1F, 1F, 1F); GL11.glScalef(1F, 1F, 1F);
//GL11.glRotated(180.0F, 0.0F, 1.0F, 0.0F); }
//GL11.glRotated(-90.0F, 1.0F, 0.0F, 0.0F); if(stack5.getItem() instanceof CustomSword){
GL11.glTranslated(0.095D, 0.42D, 0.8D);
GL11.glScalef(0.5F, 0.5F, 0.5F);
}
renderItem.renderItem(stack5, ItemCameraTransforms.TransformType.HEAD); renderItem.renderItem(stack5, ItemCameraTransforms.TransformType.HEAD);
GL11.glPopMatrix(); GL11.glPopMatrix();

View File

@@ -1,9 +1,9 @@
{ {
"__comment": "Designed by Kitsushadow with Cubik Studio - https://cubik.studio", "__comment": "Designed by Kitsushadow with Cubik Studio - https://cubik.studio",
"textures": { "textures": {
"particle": "items/finished_bronze", "particle": "forgecraft:items/finished_bronze",
"texture": "items/finished_bronze", "texture": "forgecraft:items/finished_bronze",
"handle": "blocks/planks_oak" "handle": "forgecraft:blocks/planks_oak"
}, },
"elements": [ "elements": [
{ {
@@ -280,6 +280,10 @@
"translation": [ -0.4, -0.4, 0 ], "translation": [ -0.4, -0.4, 0 ],
"scale": [ 0.5, 0.5, 0.5 ] "scale": [ 0.5, 0.5, 0.5 ]
}, },
"head": {
"rotation": [ -90, 0, 0 ],
"translation": [ 5, 7.2, -9 ]
},
"ground": { "ground": {
"rotation": [ 90, 0, 0 ], "rotation": [ 90, 0, 0 ],
"scale": [ 0.75, 0.75, 0.75 ] "scale": [ 0.75, 0.75, 0.75 ]

View File

@@ -256,6 +256,9 @@
"translation": [ -0.7, -0.7, 4 ], "translation": [ -0.7, -0.7, 4 ],
"scale": [ 0.5, 0.5, 0.5 ] "scale": [ 0.5, 0.5, 0.5 ]
}, },
"head": {
"translation": [ 5.8, 14.75, -10.53 ]
},
"ground": { "ground": {
"translation": [ 0, 2, 0 ], "translation": [ 0, 2, 0 ],
"scale": [ 0.5, 0.5, 0.5 ] "scale": [ 0.5, 0.5, 0.5 ]

View File

@@ -319,6 +319,9 @@
"translation": [ 0, -1.3, 0 ], "translation": [ 0, -1.3, 0 ],
"scale": [ 0.4, 0.4, 0.4 ] "scale": [ 0.4, 0.4, 0.4 ]
}, },
"head": {
"translation": [ 0.7, -0.9, -10 ]
},
"ground": { "ground": {
"translation": [ 0, -5, 0 ], "translation": [ 0, -5, 0 ],
"scale": [ 0.5, 0.5, 0.5 ] "scale": [ 0.5, 0.5, 0.5 ]