update to fix bug with toolhead drop missing NBT

This commit is contained in:
Mohammad-Ali Minaie
2017-07-15 14:30:13 -04:00
parent 4e270cccc1
commit 6476b0aee1
26 changed files with 49 additions and 611 deletions

View File

@@ -17,7 +17,7 @@ public class ModInfo {
public static final String MOD_CONFIG = "primal/" + MOD_ID;
//public static final String MOD_PREFIX = MOD_ID + ":";
public static final String MOD_CHANNEL = MOD_ID;
public static final String MOD_VERSION = "1.2.72";
public static final String MOD_VERSION = "1.2.73";
public static final String MC_VERSIONS = "[1.11.0, 1.12.0)";
public static final String DEPENDENCIES = "required-after:forge@[13.20.1.2388,);" + "required-after:primal@[0.4,);";

View File

@@ -759,7 +759,7 @@ public class ModCrafting {
ForgeCrafting.addRecipe(
ModItems.steelpickaxehead,
new ItemStack(ModItems.steelpickaxehead, 1 ),
800,
1000,
160,
400,
1.0f,

View File

@@ -252,6 +252,7 @@ public class ToolPart extends Item implements ToolNBT{
@Override
public void onUpdate(ItemStack item, World world, Entity player, int itemSlot, boolean isSelected) {
//System.out.println(item.getTagCompound());
if (!item.hasTagCompound()) {
item.setTagCompound(new NBTTagCompound());
NBTTagCompound tags = new NBTTagCompound();

View File

@@ -191,11 +191,8 @@ public class BronzeAxe extends ItemAxe implements ToolNBT {
stack.damageItem(1, attacker);
return true;
} else {
ItemStack dropStack = new ItemStack(drop, 1);
dropStack.setItemDamage(stack.getItemDamage());
dropStack.setTagCompound(new NBTTagCompound());
NBTTagCompound copyNBT;
copyNBT = stack.getSubCompound("tags").copy();
ItemStack dropStack = new ItemStack(drop, 1, stack.getItemDamage());
NBTTagCompound copyNBT = stack.getTagCompound();
dropStack.setTagCompound(copyNBT);
EntityPlayer player = (EntityPlayer) attacker;
@@ -224,9 +221,7 @@ public class BronzeAxe extends ItemAxe implements ToolNBT {
} else stack.damageItem(1, entityLiving);
} else {
ItemStack dropStack = new ItemStack(drop, 1, stack.getItemDamage());
dropStack.setTagCompound(new NBTTagCompound());
NBTTagCompound copyNBT;
copyNBT = stack.getSubCompound("tags").copy();
NBTTagCompound copyNBT = stack.getTagCompound();
dropStack.setTagCompound(copyNBT);
EntityPlayer player = (EntityPlayer) entityLiving;
PlayerHelper.spawnItemOnPlayer(world, player, dropStack);

View File

@@ -220,11 +220,8 @@ public class BronzeHoe extends ItemHoe implements ToolNBT {
stack.damageItem(1, attacker);
return true;
} else {
ItemStack dropStack = new ItemStack(drop, 1);
dropStack.setItemDamage(stack.getItemDamage());
dropStack.setTagCompound(new NBTTagCompound());
NBTTagCompound copyNBT;
copyNBT = stack.getSubCompound("tags").copy();
ItemStack dropStack = new ItemStack(drop, 1, stack.getItemDamage());
NBTTagCompound copyNBT = stack.getTagCompound();
dropStack.setTagCompound(copyNBT);
EntityPlayer player = (EntityPlayer) attacker;
@@ -253,9 +250,7 @@ public class BronzeHoe extends ItemHoe implements ToolNBT {
} else stack.damageItem(1, entityLiving);
} else {
ItemStack dropStack = new ItemStack(drop, 1, stack.getItemDamage());
dropStack.setTagCompound(new NBTTagCompound());
NBTTagCompound copyNBT;
copyNBT = stack.getSubCompound("tags").copy();
NBTTagCompound copyNBT = stack.getTagCompound();
dropStack.setTagCompound(copyNBT);
EntityPlayer player = (EntityPlayer) entityLiving;
PlayerHelper.spawnItemOnPlayer(world, player, dropStack);

View File

@@ -190,11 +190,8 @@ public class BronzePickaxe extends ItemPickaxe implements ToolNBT{
stack.damageItem(1, attacker);
return true;
} else {
ItemStack dropStack = new ItemStack(drop, 1);
dropStack.setItemDamage(stack.getItemDamage());
dropStack.setTagCompound(new NBTTagCompound());
NBTTagCompound copyNBT;
copyNBT = stack.getSubCompound("tags").copy();
ItemStack dropStack = new ItemStack(drop, 1, stack.getItemDamage());
NBTTagCompound copyNBT = stack.getTagCompound();
dropStack.setTagCompound(copyNBT);
EntityPlayer player = (EntityPlayer) attacker;
@@ -223,9 +220,7 @@ public class BronzePickaxe extends ItemPickaxe implements ToolNBT{
} else stack.damageItem(1, entityLiving);
} else {
ItemStack dropStack = new ItemStack(drop, 1, stack.getItemDamage());
dropStack.setTagCompound(new NBTTagCompound());
NBTTagCompound copyNBT;
copyNBT = stack.getSubCompound("tags").copy();
NBTTagCompound copyNBT = stack.getTagCompound();
dropStack.setTagCompound(copyNBT);
EntityPlayer player = (EntityPlayer) entityLiving;
PlayerHelper.spawnItemOnPlayer(world, player, dropStack);

View File

@@ -191,11 +191,8 @@ Item drop;
stack.damageItem(1, attacker);
return true;
} else {
ItemStack dropStack = new ItemStack(drop, 1);
dropStack.setItemDamage(stack.getItemDamage());
dropStack.setTagCompound(new NBTTagCompound());
NBTTagCompound copyNBT;
copyNBT = stack.getSubCompound("tags").copy();
ItemStack dropStack = new ItemStack(drop, 1, stack.getItemDamage());
NBTTagCompound copyNBT = stack.getTagCompound();
dropStack.setTagCompound(copyNBT);
EntityPlayer player = (EntityPlayer) attacker;
@@ -224,9 +221,7 @@ Item drop;
} else stack.damageItem(1, entityLiving);
} else {
ItemStack dropStack = new ItemStack(drop, 1, stack.getItemDamage());
dropStack.setTagCompound(new NBTTagCompound());
NBTTagCompound copyNBT;
copyNBT = stack.getSubCompound("tags").copy();
NBTTagCompound copyNBT = stack.getTagCompound();
dropStack.setTagCompound(copyNBT);
EntityPlayer player = (EntityPlayer) entityLiving;
PlayerHelper.spawnItemOnPlayer(world, player, dropStack);

View File

@@ -335,11 +335,8 @@ public class CustomAxe extends ItemAxe implements ToolNBT {
stack.damageItem(1, attacker);
return true;
} else {
ItemStack dropStack = new ItemStack(drop, 1);
dropStack.setItemDamage(stack.getItemDamage());
dropStack.setTagCompound(new NBTTagCompound());
NBTTagCompound copyNBT;
copyNBT = stack.getSubCompound("tags").copy();
ItemStack dropStack = new ItemStack(drop, 1, stack.getItemDamage());
NBTTagCompound copyNBT = stack.getTagCompound();
dropStack.setTagCompound(copyNBT);
EntityPlayer player = (EntityPlayer) attacker;
@@ -368,9 +365,7 @@ public class CustomAxe extends ItemAxe implements ToolNBT {
} else stack.damageItem(1, entityLiving);
} else {
ItemStack dropStack = new ItemStack(drop, 1, stack.getItemDamage());
dropStack.setTagCompound(new NBTTagCompound());
NBTTagCompound copyNBT;
copyNBT = stack.getSubCompound("tags").copy();
NBTTagCompound copyNBT = stack.getTagCompound();
dropStack.setTagCompound(copyNBT);
EntityPlayer player = (EntityPlayer) entityLiving;
PlayerHelper.spawnItemOnPlayer(world, player, dropStack);

View File

@@ -357,11 +357,8 @@ public class CustomHoe extends ItemHoe implements ToolNBT {
stack.damageItem(1, attacker);
return true;
} else {
ItemStack dropStack = new ItemStack(drop, 1);
dropStack.setItemDamage(stack.getItemDamage());
dropStack.setTagCompound(new NBTTagCompound());
NBTTagCompound copyNBT;
copyNBT = stack.getSubCompound("tags").copy();
ItemStack dropStack = new ItemStack(drop, 1, stack.getItemDamage());
NBTTagCompound copyNBT = stack.getTagCompound();
dropStack.setTagCompound(copyNBT);
EntityPlayer player = (EntityPlayer) attacker;
@@ -390,9 +387,7 @@ public class CustomHoe extends ItemHoe implements ToolNBT {
} else stack.damageItem(1, entityLiving);
} else {
ItemStack dropStack = new ItemStack(drop, 1, stack.getItemDamage());
dropStack.setTagCompound(new NBTTagCompound());
NBTTagCompound copyNBT;
copyNBT = stack.getSubCompound("tags").copy();
NBTTagCompound copyNBT = stack.getTagCompound();
dropStack.setTagCompound(copyNBT);
EntityPlayer player = (EntityPlayer) entityLiving;
PlayerHelper.spawnItemOnPlayer(world, player, dropStack);

View File

@@ -237,14 +237,14 @@ public class CustomPickaxe extends ItemPickaxe implements ToolNBT{
item.getTagCompound().setTag("tags", tags);
/*setHot(item, false);
setHot(item, false);
setHot(item, false);
setEmerald(item, false);
setDiamondLevel(item, 0);
setRedstoneLevel(item, 0);
setLapisLevel(item, 0);
setModifiers(item, 0);*/
setModifiers(item, 0);
}
}
@@ -253,6 +253,8 @@ public class CustomPickaxe extends ItemPickaxe implements ToolNBT{
@Override
public void onUpdate(ItemStack item, World world, Entity player, int itemSlot, boolean isSelected) {
if(!world.isRemote) {
//item.setItemDamage(item.getMaxDamage()-2);
if (!item.hasTagCompound()) {
item.setTagCompound(new NBTTagCompound());
NBTTagCompound tags = new NBTTagCompound();
@@ -268,9 +270,6 @@ public class CustomPickaxe extends ItemPickaxe implements ToolNBT{
}
}
/*if(){
}*/
}
//public void onItemTooltip(ItemTooltipEvent event){
@@ -335,11 +334,8 @@ public class CustomPickaxe extends ItemPickaxe implements ToolNBT{
stack.damageItem(1, attacker);
return true;
} else {
ItemStack dropStack = new ItemStack(drop, 1);
dropStack.setItemDamage(stack.getItemDamage());
dropStack.setTagCompound(new NBTTagCompound());
NBTTagCompound copyNBT;
copyNBT = stack.getSubCompound("tags").copy();
ItemStack dropStack = new ItemStack(drop, 1, stack.getItemDamage());
NBTTagCompound copyNBT = stack.getTagCompound();
dropStack.setTagCompound(copyNBT);
EntityPlayer player = (EntityPlayer) attacker;
@@ -368,14 +364,14 @@ public class CustomPickaxe extends ItemPickaxe implements ToolNBT{
} else stack.damageItem(1, entityLiving);
} else {
ItemStack dropStack = new ItemStack(drop, 1, stack.getItemDamage());
dropStack.setTagCompound(new NBTTagCompound());
NBTTagCompound copyNBT;
copyNBT = stack.getSubCompound("tags").copy();
NBTTagCompound copyNBT = stack.getTagCompound();
dropStack.setTagCompound(copyNBT);
EntityPlayer player = (EntityPlayer) entityLiving;
PlayerHelper.spawnItemOnPlayer(world, player, dropStack);
entityLiving.renderBrokenItemStack(stack);
stack.shrink(1);
player.inventory.markDirty();
player.inventory.inventoryChanged = true;
}
}

View File

@@ -335,11 +335,8 @@ public class CustomShovel extends ItemSpade implements ToolNBT {
stack.damageItem(1, attacker);
return true;
} else {
ItemStack dropStack = new ItemStack(drop, 1);
dropStack.setItemDamage(stack.getItemDamage());
dropStack.setTagCompound(new NBTTagCompound());
NBTTagCompound copyNBT;
copyNBT = stack.getSubCompound("tags").copy();
ItemStack dropStack = new ItemStack(drop, 1, stack.getItemDamage());
NBTTagCompound copyNBT = stack.getTagCompound();
dropStack.setTagCompound(copyNBT);
EntityPlayer player = (EntityPlayer) attacker;
@@ -368,9 +365,7 @@ public class CustomShovel extends ItemSpade implements ToolNBT {
} else stack.damageItem(1, entityLiving);
} else {
ItemStack dropStack = new ItemStack(drop, 1, stack.getItemDamage());
dropStack.setTagCompound(new NBTTagCompound());
NBTTagCompound copyNBT;
copyNBT = stack.getSubCompound("tags").copy();
NBTTagCompound copyNBT = stack.getTagCompound();
dropStack.setTagCompound(copyNBT);
EntityPlayer player = (EntityPlayer) entityLiving;
PlayerHelper.spawnItemOnPlayer(world, player, dropStack);

View File

@@ -14,9 +14,11 @@ import net.minecraft.world.World;
import nmd.primal.core.api.PrimalItems;
import nmd.primal.core.api.PrimalStates;
import nmd.primal.core.common.helper.CommonUtils;
import nmd.primal.core.common.helper.FireHelper;
import nmd.primal.core.common.helper.RecipeHelper;
import nmd.primal.forgecraft.blocks.Forge;
import nmd.primal.forgecraft.crafting.ForgeCrafting;
import nmd.primal.forgecraft.util.ToolNBT;
import static nmd.primal.core.common.helper.FireHelper.makeSmoke;
import static nmd.primal.forgecraft.CommonUtils.getVanillaItemBurnTime;
@@ -24,7 +26,7 @@ import static nmd.primal.forgecraft.CommonUtils.getVanillaItemBurnTime;
/**
* Created by mminaie on 11/30/16.
*/
public class TileForge extends TileBaseSlot implements ITickable {
public class TileForge extends TileBaseSlot implements ITickable, ToolNBT{
private NonNullList<ItemStack> slotList = NonNullList.<ItemStack>withSize(7, ItemStack.EMPTY);
//private ItemStack[] inventory = new ItemStack [0];
@@ -84,7 +86,7 @@ public class TileForge extends TileBaseSlot implements ITickable {
}
if (world.rand.nextInt(decrInt) == 0) {
if (world.rand.nextInt(burnModifier) == 0) {
System.out.println("Fuel Burn" + this.getSlotStack(0));
//System.out.println("Fuel Burn" + this.getSlotStack(0));
this.decrStackSize(0, 1);
this.markDirty();
this.updateBlock();
@@ -111,7 +113,8 @@ public class TileForge extends TileBaseSlot implements ITickable {
world.setBlockState(pos, state.withProperty(PrimalStates.ACTIVE, false), 2);
}
}
if(stack.isEmpty()){
if(stack.isEmpty() || RecipeHelper.getBurnTime(stack) <=0){
System.out.println(stack);
world.setBlockState(pos, state.withProperty(PrimalStates.ACTIVE, false), 2);
}
if(this.getSlotStack(0).getItem() == PrimalItems.CHARCOAL_FAIR){
@@ -199,12 +202,14 @@ public class TileForge extends TileBaseSlot implements ITickable {
}
if (cookCounter4 >= recipe.getIdealTime()) {
if(this.getSlotStack(i).hasTagCompound()){
if( this.getSlotStack(i).getSubCompound("tags").getBoolean("hot") == false) {
this.getSlotStack(i).getSubCompound("tags").setBoolean("hot", true);
//System.out.println(this.getSlotStack(i).getSubCompound("tags"));
//System.out.println("its hot now");
cookCounter4 = 0;
}
//System.out.println(this.getSlotStack(i).getTagCompound());
if (!getHot(this.getSlotStack(i))) {
this.getSlotStack(i).getSubCompound("tags").setBoolean("hot", true);
//System.out.println(this.getSlotStack(i).getSubCompound("tags"));
//System.out.println("its hot now");
cookCounter4 = 0;
}
} else this.setSlotStack(i, recipe.getOutput());
cookCounter4 = 0;
}

View File

@@ -2,7 +2,7 @@
"modid": "forgecraft",
"name": "Kitsu's Forgecraft",
"description": "Forged with sweat and blood",
"version": "1.2.72",
"version": "1.2.73",
"mcversion": "1.11.2",
"url": "",
"updateUrl": "",