diff --git a/kfc/gradle.properties b/kfc/gradle.properties index 4259ff52..f07985cf 100644 --- a/kfc/gradle.properties +++ b/kfc/gradle.properties @@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx3G mod_group=nmd.primal.forgecraft mod_name=ForgeCraft -mod_version=1.2.70 +mod_version=1.2.71 forge_version=13.20.1.2388 mcp_mappings=snapshot_20170610 mc_version=1.11.2 diff --git a/kfc/server.properties b/kfc/server.properties index 76cd685e..916324ce 100644 --- a/kfc/server.properties +++ b/kfc/server.properties @@ -1,5 +1,5 @@ #Minecraft server properties -#Mon Jul 03 22:50:34 EDT 2017 +#Thu Jul 06 06:13:42 EDT 2017 max-tick-time=60000 generator-settings= force-gamemode=false diff --git a/kfc/src/main/java/nmd/primal/forgecraft/ModInfo.java b/kfc/src/main/java/nmd/primal/forgecraft/ModInfo.java index e120d008..9673ea33 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/ModInfo.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/ModInfo.java @@ -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.70"; + public static final String MOD_VERSION = "1.2.71"; 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,);"; diff --git a/kfc/src/main/java/nmd/primal/forgecraft/init/ModItems.java b/kfc/src/main/java/nmd/primal/forgecraft/init/ModItems.java index 09080dbd..16c83870 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/init/ModItems.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/init/ModItems.java @@ -194,30 +194,30 @@ public class ModItems { /********** TOOLS **********/ - bronzepickaxe = new BronzePickaxe("bronzepickaxe", PrimalMaterials.TOOL_BRONZE); - bronzeaxe = new BronzeAxe("bronzeaxe", PrimalMaterials.TOOL_BRONZE); - bronzeshovel = new BronzeShovel("bronzeshovel", PrimalMaterials.TOOL_BRONZE); - bronzehoe = new BronzeHoe("bronzehoe", PrimalMaterials.TOOL_BRONZE); + bronzepickaxe = new BronzePickaxe("bronzepickaxe", PrimalMaterials.TOOL_BRONZE, bronzepickaxehead); + bronzeaxe = new BronzeAxe("bronzeaxe", PrimalMaterials.TOOL_BRONZE, bronzeaxehead); + bronzeshovel = new BronzeShovel("bronzeshovel", PrimalMaterials.TOOL_BRONZE, bronzeshovelhead); + bronzehoe = new BronzeHoe("bronzehoe", PrimalMaterials.TOOL_BRONZE, bronzehoehead); - ironpickaxe = new CustomPickaxe("ironpickaxe", PrimalMaterials.TOOL_WROUGHT_IRON, brokenwroughtirontool); - ironaxe = new CustomAxe("ironaxe", PrimalMaterials.TOOL_WROUGHT_IRON, brokenwroughtirontool); - ironshovel = new CustomShovel("ironshovel", PrimalMaterials.TOOL_WROUGHT_IRON, brokenwroughtirontool); - ironhoe = new CustomHoe("ironhoe", PrimalMaterials.TOOL_WROUGHT_IRON, brokenwroughtirontool); + ironpickaxe = new CustomPickaxe("ironpickaxe", PrimalMaterials.TOOL_WROUGHT_IRON, pickaxehead); + ironaxe = new CustomAxe("ironaxe", PrimalMaterials.TOOL_WROUGHT_IRON, ironaxehead); + ironshovel = new CustomShovel("ironshovel", PrimalMaterials.TOOL_WROUGHT_IRON, ironshovelhead); + ironhoe = new CustomHoe("ironhoe", PrimalMaterials.TOOL_WROUGHT_IRON, ironhoehead); - cleanironpickaxe = new CustomPickaxe("cleanironpickaxe", PrimalMaterials.TOOL_CLEAN_IRON, brokencleanirontool); - cleanironaxe = new CustomAxe("cleanironaxe", PrimalMaterials.TOOL_CLEAN_IRON, brokencleanirontool); - cleanironshovel = new CustomShovel("cleanironshovel", PrimalMaterials.TOOL_CLEAN_IRON, brokencleanirontool); - cleanironhoe = new CustomHoe("cleanironhoe", PrimalMaterials.TOOL_CLEAN_IRON, brokencleanirontool); + cleanironpickaxe = new CustomPickaxe("cleanironpickaxe", PrimalMaterials.TOOL_CLEAN_IRON, cleanironpickaxehead); + cleanironaxe = new CustomAxe("cleanironaxe", PrimalMaterials.TOOL_CLEAN_IRON, cleanironaxehead); + cleanironshovel = new CustomShovel("cleanironshovel", PrimalMaterials.TOOL_CLEAN_IRON, cleanironshovelhead); + cleanironhoe = new CustomHoe("cleanironhoe", PrimalMaterials.TOOL_CLEAN_IRON, cleanironhoehead); - steelpickaxe = new CustomPickaxe("steelpickaxe", PrimalMaterials.TOOL_BASIC_STEEL, brokensteeltool); - steelaxe = new CustomAxe("steelaxe", PrimalMaterials.TOOL_BASIC_STEEL, brokensteeltool); - steelshovel = new CustomShovel("steelshovel", PrimalMaterials.TOOL_BASIC_STEEL, brokensteeltool); - steelhoe = new CustomHoe("steelhoe", PrimalMaterials.TOOL_BASIC_STEEL, brokensteeltool); + steelpickaxe = new CustomPickaxe("steelpickaxe", PrimalMaterials.TOOL_BASIC_STEEL, steelpickaxehead); + steelaxe = new CustomAxe("steelaxe", PrimalMaterials.TOOL_BASIC_STEEL, steelaxehead); + steelshovel = new CustomShovel("steelshovel", PrimalMaterials.TOOL_BASIC_STEEL, steelshovelhead); + steelhoe = new CustomHoe("steelhoe", PrimalMaterials.TOOL_BASIC_STEEL, steelhoehead); - wootzpickaxe = new CustomPickaxe("wootzpickaxe", PrimalMaterials.TOOL_WOOTZ_STEEL, brokenwootztool); - wootzaxe = new CustomAxe("wootzaxe", PrimalMaterials.TOOL_WOOTZ_STEEL, brokenwootztool); - wootzshovel = new CustomShovel("wootzshovel", PrimalMaterials.TOOL_WOOTZ_STEEL, brokenwootztool); - wootzhoe = new CustomHoe("wootzhoe", PrimalMaterials.TOOL_WOOTZ_STEEL, brokenwootztool); + wootzpickaxe = new CustomPickaxe("wootzpickaxe", PrimalMaterials.TOOL_WOOTZ_STEEL, wootzpickaxehead); + wootzaxe = new CustomAxe("wootzaxe", PrimalMaterials.TOOL_WOOTZ_STEEL, wootzaxehead); + wootzshovel = new CustomShovel("wootzshovel", PrimalMaterials.TOOL_WOOTZ_STEEL, wootzshovelhead); + wootzhoe = new CustomHoe("wootzhoe", PrimalMaterials.TOOL_WOOTZ_STEEL, wootzhoehead); /********** WEAPONS diff --git a/kfc/src/main/java/nmd/primal/forgecraft/items/tools/BronzeAxe.java b/kfc/src/main/java/nmd/primal/forgecraft/items/tools/BronzeAxe.java index a6e05527..237ec087 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/items/tools/BronzeAxe.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/items/tools/BronzeAxe.java @@ -31,14 +31,16 @@ import java.util.concurrent.ThreadLocalRandom; */ public class BronzeAxe extends ItemAxe implements ToolNBT { - public BronzeAxe(String name, Item.ToolMaterial material) { + Item drop; + + public BronzeAxe(String name, Item.ToolMaterial material, Item damageDrop) { super(material, 5, -2f); this.setUnlocalizedName(name); this.setRegistryName(name); this.setCreativeTab(ModInfo.TAB_FORGECRAFT); this.setMaxStackSize(1); this.setNoRepair(); - + this.drop=damageDrop; this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() { /*** @@ -189,13 +191,22 @@ public class BronzeAxe extends ItemAxe implements ToolNBT { stack.damageItem(1, attacker); return true; } else { - ItemStack dropStack = new ItemStack(ModItems.brokenbronzetool, 1); + ItemStack dropStack = new ItemStack(drop, 1); + dropStack.setItemDamage(stack.getItemDamage()); + dropStack.setTagCompound(new NBTTagCompound()); + NBTTagCompound copyNBT; + copyNBT = stack.getSubCompound("tags").copy(); + dropStack.setTagCompound(copyNBT); + EntityPlayer player = (EntityPlayer) attacker; World world = attacker.getEntityWorld(); - PlayerHelper.spawnItemOnPlayer(world, player, dropStack); - attacker.renderBrokenItemStack(stack); - stack.shrink(1); - return true; + if(!world.isRemote) { + PlayerHelper.spawnItemOnPlayer(world, player, dropStack); + attacker.renderBrokenItemStack(stack); + stack.shrink(1); + return true; + } + return false; } } @@ -212,7 +223,11 @@ public class BronzeAxe extends ItemAxe implements ToolNBT { } } else stack.damageItem(1, entityLiving); } else { - ItemStack dropStack = new ItemStack(ModItems.brokenbronzetool, 1); + ItemStack dropStack = new ItemStack(drop, 1, stack.getItemDamage()); + dropStack.setTagCompound(new NBTTagCompound()); + NBTTagCompound copyNBT; + copyNBT = stack.getSubCompound("tags").copy(); + dropStack.setTagCompound(copyNBT); EntityPlayer player = (EntityPlayer) entityLiving; PlayerHelper.spawnItemOnPlayer(world, player, dropStack); entityLiving.renderBrokenItemStack(stack); diff --git a/kfc/src/main/java/nmd/primal/forgecraft/items/tools/BronzeHoe.java b/kfc/src/main/java/nmd/primal/forgecraft/items/tools/BronzeHoe.java index 8984588a..5f5a7ebe 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/items/tools/BronzeHoe.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/items/tools/BronzeHoe.java @@ -8,6 +8,7 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.SoundEvents; import net.minecraft.item.IItemPropertyGetter; +import net.minecraft.item.Item; import net.minecraft.item.ItemHoe; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -31,14 +32,16 @@ import java.util.concurrent.ThreadLocalRandom; */ public class BronzeHoe extends ItemHoe implements ToolNBT { - public BronzeHoe(String name, ToolMaterial material) { + Item drop; + + public BronzeHoe(String name, ToolMaterial material, Item damageDrop) { super(material); this.setUnlocalizedName(name); this.setRegistryName(name); this.setCreativeTab(ModInfo.TAB_FORGECRAFT); this.setMaxStackSize(1); this.setNoRepair(); - + this.drop=damageDrop; this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() { /*** @@ -186,23 +189,6 @@ public class BronzeHoe extends ItemHoe implements ToolNBT { return false; } - @Override - public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) - { - if(stack.getMaxDamage() - stack.getItemDamage() >1 ) { - stack.damageItem(1, attacker); - return true; - } else { - ItemStack dropStack = new ItemStack(ModItems.brokenbronzetool, 1); - EntityPlayer player = (EntityPlayer) attacker; - World world = attacker.getEntityWorld(); - PlayerHelper.spawnItemOnPlayer(world, player, dropStack); - attacker.renderBrokenItemStack(stack); - stack.shrink(1); - return true; - } - } - @Override protected void setBlock(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos, IBlockState state) { @@ -214,7 +200,12 @@ public class BronzeHoe extends ItemHoe implements ToolNBT { if(stack.getMaxDamage() - stack.getItemDamage() >1 ) { stack.damageItem(1, player); } else { - ItemStack dropStack = new ItemStack(ModItems.brokenbronzetool, 1); + ItemStack dropStack = new ItemStack(drop, 1); + dropStack.setItemDamage(stack.getItemDamage()); + dropStack.setTagCompound(new NBTTagCompound()); + NBTTagCompound copyNBT; + copyNBT = stack.getSubCompound("tags").copy(); + dropStack.setTagCompound(copyNBT); PlayerHelper.spawnItemOnPlayer(worldIn, player, dropStack); player.renderBrokenItemStack(stack); stack.shrink(1); @@ -223,22 +214,51 @@ public class BronzeHoe extends ItemHoe implements ToolNBT { } @Override - public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) + public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { - if (!worldIn.isRemote && (double)state.getBlockHardness(worldIn, pos) != 0.0D) + if(stack.getMaxDamage() - stack.getItemDamage() >1 ) { + 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(); + dropStack.setTagCompound(copyNBT); + + EntityPlayer player = (EntityPlayer) attacker; + World world = attacker.getEntityWorld(); + if(!world.isRemote) { + PlayerHelper.spawnItemOnPlayer(world, player, dropStack); + attacker.renderBrokenItemStack(stack); + stack.shrink(1); + return true; + } + return false; + } + } + + @Override + public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) + { + if (!world.isRemote && (double)state.getBlockHardness(world, pos) != 0.0D) { if(stack.getMaxDamage() - stack.getItemDamage() >1 ) { - stack.getTagCompound().removeTag("ench"); - //System.out.println(stack.getTagCompound()); - if(getDiamondLevel(stack) > 0) { - if(ThreadLocalRandom.current().nextInt(0, getDiamondLevel(stack)) == 0) { - stack.damageItem(1, entityLiving); - } - } else stack.damageItem(1, entityLiving); + stack.getTagCompound().removeTag("ench"); + if(getDiamondLevel(stack) > 0) { + if(ThreadLocalRandom.current().nextInt(0, getDiamondLevel(stack)) == 0) { + stack.damageItem(1, entityLiving); + } + } else stack.damageItem(1, entityLiving); } else { - ItemStack dropStack = new ItemStack(ModItems.brokenbronzetool, 1); + ItemStack dropStack = new ItemStack(drop, 1, stack.getItemDamage()); + dropStack.setTagCompound(new NBTTagCompound()); + NBTTagCompound copyNBT; + copyNBT = stack.getSubCompound("tags").copy(); + dropStack.setTagCompound(copyNBT); EntityPlayer player = (EntityPlayer) entityLiving; - PlayerHelper.spawnItemOnPlayer(worldIn, player, dropStack); + PlayerHelper.spawnItemOnPlayer(world, player, dropStack); entityLiving.renderBrokenItemStack(stack); stack.shrink(1); } diff --git a/kfc/src/main/java/nmd/primal/forgecraft/items/tools/BronzePickaxe.java b/kfc/src/main/java/nmd/primal/forgecraft/items/tools/BronzePickaxe.java index 6c37fe21..72c48107 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/items/tools/BronzePickaxe.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/items/tools/BronzePickaxe.java @@ -8,6 +8,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.IItemPropertyGetter; +import net.minecraft.item.Item; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -30,14 +31,16 @@ import java.util.concurrent.ThreadLocalRandom; */ public class BronzePickaxe extends ItemPickaxe implements ToolNBT{ - public BronzePickaxe(String name, ToolMaterial material) { + private Item drop; + + public BronzePickaxe(String name, ToolMaterial material, Item damageDrop) { super(material); this.setUnlocalizedName(name); this.setRegistryName(name); this.setCreativeTab(ModInfo.TAB_FORGECRAFT); this.setMaxStackSize(1); this.setNoRepair(); - + this.drop=damageDrop; //this.toolClass = "pickaxe"; this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() { @@ -187,13 +190,22 @@ public class BronzePickaxe extends ItemPickaxe implements ToolNBT{ stack.damageItem(1, attacker); return true; } else { - ItemStack dropStack = new ItemStack(ModItems.brokenbronzetool, 1); + ItemStack dropStack = new ItemStack(drop, 1); + dropStack.setItemDamage(stack.getItemDamage()); + dropStack.setTagCompound(new NBTTagCompound()); + NBTTagCompound copyNBT; + copyNBT = stack.getSubCompound("tags").copy(); + dropStack.setTagCompound(copyNBT); + EntityPlayer player = (EntityPlayer) attacker; World world = attacker.getEntityWorld(); - PlayerHelper.spawnItemOnPlayer(world, player, dropStack); - attacker.renderBrokenItemStack(stack); - stack.shrink(1); - return true; + if(!world.isRemote) { + PlayerHelper.spawnItemOnPlayer(world, player, dropStack); + attacker.renderBrokenItemStack(stack); + stack.shrink(1); + return true; + } + return false; } } @@ -202,21 +214,26 @@ public class BronzePickaxe extends ItemPickaxe implements ToolNBT{ { if (!world.isRemote && (double)state.getBlockHardness(world, pos) != 0.0D) { - if(stack.getMaxDamage() - stack.getItemDamage() > 1 ) { + if(stack.getMaxDamage() - stack.getItemDamage() >1 ) { stack.getTagCompound().removeTag("ench"); - if (getDiamondLevel(stack) > 0) { - if (ThreadLocalRandom.current().nextInt(0, getDiamondLevel(stack)) == 0) { + if(getDiamondLevel(stack) > 0) { + if(ThreadLocalRandom.current().nextInt(0, getDiamondLevel(stack)) == 0) { stack.damageItem(1, entityLiving); } } else stack.damageItem(1, entityLiving); } else { - ItemStack dropStack = new ItemStack(ModItems.brokenbronzetool, 1); + ItemStack dropStack = new ItemStack(drop, 1, stack.getItemDamage()); + dropStack.setTagCompound(new NBTTagCompound()); + NBTTagCompound copyNBT; + copyNBT = stack.getSubCompound("tags").copy(); + dropStack.setTagCompound(copyNBT); EntityPlayer player = (EntityPlayer) entityLiving; PlayerHelper.spawnItemOnPlayer(world, player, dropStack); entityLiving.renderBrokenItemStack(stack); stack.shrink(1); } } + return true; } diff --git a/kfc/src/main/java/nmd/primal/forgecraft/items/tools/BronzeShovel.java b/kfc/src/main/java/nmd/primal/forgecraft/items/tools/BronzeShovel.java index c83396d3..fddbbc03 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/items/tools/BronzeShovel.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/items/tools/BronzeShovel.java @@ -35,15 +35,16 @@ import java.util.concurrent.ThreadLocalRandom; public class BronzeShovel extends ItemSpade implements ToolNBT { private static final Set EFFECTIVE_ON = Sets.newHashSet(new Block[] {Blocks.CLAY, Blocks.DIRT, Blocks.FARMLAND, Blocks.GRASS, Blocks.GRAVEL, Blocks.MYCELIUM, Blocks.SAND, Blocks.SNOW, Blocks.SNOW_LAYER, Blocks.SOUL_SAND, Blocks.GRASS_PATH}); +Item drop; - public BronzeShovel(String name, ToolMaterial material) { + public BronzeShovel(String name, ToolMaterial material, Item damageDrop) { super(material); this.setUnlocalizedName(name); this.setRegistryName(name); this.setCreativeTab(ModInfo.TAB_FORGECRAFT); this.setMaxStackSize(1); this.setNoRepair(); - + this.drop=damageDrop; this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() { /*** @@ -190,33 +191,45 @@ public class BronzeShovel extends ItemSpade implements ToolNBT { stack.damageItem(1, attacker); return true; } else { - ItemStack dropStack = new ItemStack(ModItems.brokenbronzetool, 1); + ItemStack dropStack = new ItemStack(drop, 1); + dropStack.setItemDamage(stack.getItemDamage()); + dropStack.setTagCompound(new NBTTagCompound()); + NBTTagCompound copyNBT; + copyNBT = stack.getSubCompound("tags").copy(); + dropStack.setTagCompound(copyNBT); + EntityPlayer player = (EntityPlayer) attacker; World world = attacker.getEntityWorld(); - PlayerHelper.spawnItemOnPlayer(world, player, dropStack); - attacker.renderBrokenItemStack(stack); - stack.shrink(1); - return true; + if(!world.isRemote) { + PlayerHelper.spawnItemOnPlayer(world, player, dropStack); + attacker.renderBrokenItemStack(stack); + stack.shrink(1); + return true; + } + return false; } } @Override - public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) + public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) { - if (!worldIn.isRemote && (double)state.getBlockHardness(worldIn, pos) != 0.0D) + if (!world.isRemote && (double)state.getBlockHardness(world, pos) != 0.0D) { if(stack.getMaxDamage() - stack.getItemDamage() >1 ) { stack.getTagCompound().removeTag("ench"); - //System.out.println(stack.getTagCompound()); if(getDiamondLevel(stack) > 0) { if(ThreadLocalRandom.current().nextInt(0, getDiamondLevel(stack)) == 0) { stack.damageItem(1, entityLiving); } } else stack.damageItem(1, entityLiving); } else { - ItemStack dropStack = new ItemStack(ModItems.brokenbronzetool, 1); + ItemStack dropStack = new ItemStack(drop, 1, stack.getItemDamage()); + dropStack.setTagCompound(new NBTTagCompound()); + NBTTagCompound copyNBT; + copyNBT = stack.getSubCompound("tags").copy(); + dropStack.setTagCompound(copyNBT); EntityPlayer player = (EntityPlayer) entityLiving; - PlayerHelper.spawnItemOnPlayer(worldIn, player, dropStack); + PlayerHelper.spawnItemOnPlayer(world, player, dropStack); entityLiving.renderBrokenItemStack(stack); stack.shrink(1); } diff --git a/kfc/src/main/java/nmd/primal/forgecraft/items/tools/CustomAxe.java b/kfc/src/main/java/nmd/primal/forgecraft/items/tools/CustomAxe.java index 1a8b7de5..163ed7bf 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/items/tools/CustomAxe.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/items/tools/CustomAxe.java @@ -31,7 +31,7 @@ import java.util.concurrent.ThreadLocalRandom; */ public class CustomAxe extends ItemAxe implements ToolNBT { - private Item damageDrop; + Item drop; public CustomAxe(String name, Item.ToolMaterial material, Item damageDrop) { super(material, 6, -3.1f); @@ -40,7 +40,7 @@ public class CustomAxe extends ItemAxe implements ToolNBT { this.setCreativeTab(ModInfo.TAB_FORGECRAFT); this.setMaxStackSize(1); this.setNoRepair(); - damageDrop = damageDrop; + this.drop = damageDrop; this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() { /*** @@ -232,6 +232,7 @@ public class CustomAxe extends ItemAxe implements ToolNBT { public void onCreated(ItemStack item, World world, EntityPlayer playerIn) { if(!world.isRemote) { + item.setItemDamage(item.getMaxDamage()-5); if (!item.hasTagCompound()) { item.setTagCompound(new NBTTagCompound()); NBTTagCompound tags = new NBTTagCompound(); @@ -254,6 +255,7 @@ public class CustomAxe extends ItemAxe implements ToolNBT { @Override public void onUpdate(ItemStack item, World world, Entity player, int itemSlot, boolean isSelected) { if(!world.isRemote) { + if (!item.hasTagCompound()) { item.setTagCompound(new NBTTagCompound()); NBTTagCompound tags = new NBTTagCompound(); @@ -305,7 +307,6 @@ public class CustomAxe extends ItemAxe implements ToolNBT { { if(!player.world.isRemote){ World world = player.getEntityWorld(); - //System.out.println(world.getBlockState(pos).getBlock()); if(itemstack.getItem() instanceof CustomAxe){ if( getEmerald(itemstack)){ itemstack.addEnchantment(Enchantment.getEnchantmentByID(33), 1); @@ -334,13 +335,22 @@ public class CustomAxe extends ItemAxe implements ToolNBT { stack.damageItem(1, attacker); return true; } else { - ItemStack dropStack = new ItemStack(damageDrop, 1); + ItemStack dropStack = new ItemStack(drop, 1); + dropStack.setItemDamage(stack.getItemDamage()); + dropStack.setTagCompound(new NBTTagCompound()); + NBTTagCompound copyNBT; + copyNBT = stack.getSubCompound("tags").copy(); + dropStack.setTagCompound(copyNBT); + EntityPlayer player = (EntityPlayer) attacker; World world = attacker.getEntityWorld(); - PlayerHelper.spawnItemOnPlayer(world, player, dropStack); - attacker.renderBrokenItemStack(stack); - stack.shrink(1); - return true; + if(!world.isRemote) { + PlayerHelper.spawnItemOnPlayer(world, player, dropStack); + attacker.renderBrokenItemStack(stack); + stack.shrink(1); + return true; + } + return false; } } @@ -357,7 +367,11 @@ public class CustomAxe extends ItemAxe implements ToolNBT { } } else stack.damageItem(1, entityLiving); } else { - ItemStack dropStack = new ItemStack(damageDrop, 1); + ItemStack dropStack = new ItemStack(drop, 1, stack.getItemDamage()); + dropStack.setTagCompound(new NBTTagCompound()); + NBTTagCompound copyNBT; + copyNBT = stack.getSubCompound("tags").copy(); + dropStack.setTagCompound(copyNBT); EntityPlayer player = (EntityPlayer) entityLiving; PlayerHelper.spawnItemOnPlayer(world, player, dropStack); entityLiving.renderBrokenItemStack(stack); diff --git a/kfc/src/main/java/nmd/primal/forgecraft/items/tools/CustomHoe.java b/kfc/src/main/java/nmd/primal/forgecraft/items/tools/CustomHoe.java index 0838f812..0516afd4 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/items/tools/CustomHoe.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/items/tools/CustomHoe.java @@ -32,7 +32,7 @@ import java.util.concurrent.ThreadLocalRandom; */ public class CustomHoe extends ItemHoe implements ToolNBT { - private Item damageDrop; + private Item drop; public CustomHoe(String name, Item.ToolMaterial material, Item damageDrop) { super(material); @@ -41,7 +41,7 @@ public class CustomHoe extends ItemHoe implements ToolNBT { this.setCreativeTab(ModInfo.TAB_FORGECRAFT); this.setMaxStackSize(1); this.setNoRepair(); - this.damageDrop = damageDrop; + this.drop = damageDrop; this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() { /*** @@ -326,23 +326,6 @@ public class CustomHoe extends ItemHoe implements ToolNBT { return false; } - @Override - public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) - { - if(stack.getMaxDamage() - stack.getItemDamage() >1 ) { - stack.damageItem(1, attacker); - return true; - } else { - ItemStack dropStack = new ItemStack(damageDrop, 1); - EntityPlayer player = (EntityPlayer) attacker; - World world = attacker.getEntityWorld(); - PlayerHelper.spawnItemOnPlayer(world, player, dropStack); - attacker.renderBrokenItemStack(stack); - stack.shrink(1); - return true; - } - } - @Override protected void setBlock(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos, IBlockState state) { @@ -354,7 +337,12 @@ public class CustomHoe extends ItemHoe implements ToolNBT { if(stack.getMaxDamage() - stack.getItemDamage() >1 ) { stack.damageItem(1, player); } else { - ItemStack dropStack = new ItemStack(damageDrop, 1); + ItemStack dropStack = new ItemStack(drop, 1); + dropStack.setItemDamage(stack.getItemDamage()); + dropStack.setTagCompound(new NBTTagCompound()); + NBTTagCompound copyNBT; + copyNBT = stack.getSubCompound("tags").copy(); + dropStack.setTagCompound(copyNBT); PlayerHelper.spawnItemOnPlayer(worldIn, player, dropStack); player.renderBrokenItemStack(stack); stack.shrink(1); @@ -363,18 +351,54 @@ public class CustomHoe extends ItemHoe implements ToolNBT { } @Override - public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) + public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { - if (!worldIn.isRemote && (double)state.getBlockHardness(worldIn, pos) != 0.0D) - { + if(stack.getMaxDamage() - stack.getItemDamage() >1 ) { + 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(); + dropStack.setTagCompound(copyNBT); - stack.getTagCompound().removeTag("ench"); - //System.out.println(stack.getTagCompound()); - if(getDiamondLevel(stack) > 0) { - if(ThreadLocalRandom.current().nextInt(0, getDiamondLevel(stack)) == 0) { - stack.damageItem(1, entityLiving); - } - } else stack.damageItem(1, entityLiving); + EntityPlayer player = (EntityPlayer) attacker; + World world = attacker.getEntityWorld(); + if(!world.isRemote) { + PlayerHelper.spawnItemOnPlayer(world, player, dropStack); + attacker.renderBrokenItemStack(stack); + stack.shrink(1); + return true; + } + return false; + } + } + + @Override + public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) + { + if (!world.isRemote && (double)state.getBlockHardness(world, pos) != 0.0D) + { + if(stack.getMaxDamage() - stack.getItemDamage() >1 ) { + stack.getTagCompound().removeTag("ench"); + if(getDiamondLevel(stack) > 0) { + if(ThreadLocalRandom.current().nextInt(0, getDiamondLevel(stack)) == 0) { + stack.damageItem(1, entityLiving); + } + } 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(); + dropStack.setTagCompound(copyNBT); + EntityPlayer player = (EntityPlayer) entityLiving; + PlayerHelper.spawnItemOnPlayer(world, player, dropStack); + entityLiving.renderBrokenItemStack(stack); + stack.shrink(1); + } } return true; diff --git a/kfc/src/main/java/nmd/primal/forgecraft/items/tools/CustomPickaxe.java b/kfc/src/main/java/nmd/primal/forgecraft/items/tools/CustomPickaxe.java index 8dac2e35..6cdd4f1e 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/items/tools/CustomPickaxe.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/items/tools/CustomPickaxe.java @@ -31,7 +31,7 @@ import java.util.concurrent.ThreadLocalRandom; */ public class CustomPickaxe extends ItemPickaxe implements ToolNBT{ - private Item damageDrop; + private Item drop; public CustomPickaxe(String name, Item.ToolMaterial material, Item damageDrop) { super(material); @@ -40,7 +40,7 @@ public class CustomPickaxe extends ItemPickaxe implements ToolNBT{ this.setCreativeTab(ModInfo.TAB_FORGECRAFT); this.setMaxStackSize(1); this.setNoRepair(); - this.damageDrop=damageDrop; + this.drop=damageDrop; //this.toolClass = "pickaxe"; this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() { @@ -335,13 +335,22 @@ public class CustomPickaxe extends ItemPickaxe implements ToolNBT{ stack.damageItem(1, attacker); return true; } else { - ItemStack dropStack = new ItemStack(damageDrop, 1); + ItemStack dropStack = new ItemStack(drop, 1); + dropStack.setItemDamage(stack.getItemDamage()); + dropStack.setTagCompound(new NBTTagCompound()); + NBTTagCompound copyNBT; + copyNBT = stack.getSubCompound("tags").copy(); + dropStack.setTagCompound(copyNBT); + EntityPlayer player = (EntityPlayer) attacker; World world = attacker.getEntityWorld(); - PlayerHelper.spawnItemOnPlayer(world, player, dropStack); - attacker.renderBrokenItemStack(stack); - stack.shrink(1); - return true; + if(!world.isRemote) { + PlayerHelper.spawnItemOnPlayer(world, player, dropStack); + attacker.renderBrokenItemStack(stack); + stack.shrink(1); + return true; + } + return false; } } @@ -350,21 +359,26 @@ public class CustomPickaxe extends ItemPickaxe implements ToolNBT{ { if (!world.isRemote && (double)state.getBlockHardness(world, pos) != 0.0D) { - if(stack.getMaxDamage() - stack.getItemDamage() > 1 ) { + if(stack.getMaxDamage() - stack.getItemDamage() >1 ) { stack.getTagCompound().removeTag("ench"); - if (getDiamondLevel(stack) > 0) { - if (ThreadLocalRandom.current().nextInt(0, getDiamondLevel(stack)) == 0) { + if(getDiamondLevel(stack) > 0) { + if(ThreadLocalRandom.current().nextInt(0, getDiamondLevel(stack)) == 0) { stack.damageItem(1, entityLiving); } } else stack.damageItem(1, entityLiving); } else { - ItemStack dropStack = new ItemStack(damageDrop, 1); + ItemStack dropStack = new ItemStack(drop, 1, stack.getItemDamage()); + dropStack.setTagCompound(new NBTTagCompound()); + NBTTagCompound copyNBT; + copyNBT = stack.getSubCompound("tags").copy(); + dropStack.setTagCompound(copyNBT); EntityPlayer player = (EntityPlayer) entityLiving; PlayerHelper.spawnItemOnPlayer(world, player, dropStack); entityLiving.renderBrokenItemStack(stack); stack.shrink(1); } } + return true; } diff --git a/kfc/src/main/java/nmd/primal/forgecraft/items/tools/CustomShovel.java b/kfc/src/main/java/nmd/primal/forgecraft/items/tools/CustomShovel.java index b02dfafe..1922477b 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/items/tools/CustomShovel.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/items/tools/CustomShovel.java @@ -35,7 +35,7 @@ import java.util.concurrent.ThreadLocalRandom; public class CustomShovel extends ItemSpade implements ToolNBT { private static final Set EFFECTIVE_ON = Sets.newHashSet(new Block[] {Blocks.CLAY, Blocks.DIRT, Blocks.FARMLAND, Blocks.GRASS, Blocks.GRAVEL, Blocks.MYCELIUM, Blocks.SAND, Blocks.SNOW, Blocks.SNOW_LAYER, Blocks.SOUL_SAND, Blocks.GRASS_PATH}); - private Item damageDrop; + private Item drop; public CustomShovel(String name, Item.ToolMaterial material, Item damageDrop) { super(material); @@ -44,7 +44,7 @@ public class CustomShovel extends ItemSpade implements ToolNBT { this.setCreativeTab(ModInfo.TAB_FORGECRAFT); this.setMaxStackSize(1); this.setNoRepair(); - this.damageDrop=damageDrop; + this.drop=damageDrop; this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() { /*** @@ -335,33 +335,45 @@ public class CustomShovel extends ItemSpade implements ToolNBT { stack.damageItem(1, attacker); return true; } else { - ItemStack dropStack = new ItemStack(damageDrop, 1); + ItemStack dropStack = new ItemStack(drop, 1); + dropStack.setItemDamage(stack.getItemDamage()); + dropStack.setTagCompound(new NBTTagCompound()); + NBTTagCompound copyNBT; + copyNBT = stack.getSubCompound("tags").copy(); + dropStack.setTagCompound(copyNBT); + EntityPlayer player = (EntityPlayer) attacker; World world = attacker.getEntityWorld(); - PlayerHelper.spawnItemOnPlayer(world, player, dropStack); - attacker.renderBrokenItemStack(stack); - stack.shrink(1); - return true; + if(!world.isRemote) { + PlayerHelper.spawnItemOnPlayer(world, player, dropStack); + attacker.renderBrokenItemStack(stack); + stack.shrink(1); + return true; + } + return false; } } @Override - public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) + public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) { - if (!worldIn.isRemote && (double)state.getBlockHardness(worldIn, pos) != 0.0D) + if (!world.isRemote && (double)state.getBlockHardness(world, pos) != 0.0D) { if(stack.getMaxDamage() - stack.getItemDamage() >1 ) { stack.getTagCompound().removeTag("ench"); - //System.out.println(stack.getTagCompound()); if(getDiamondLevel(stack) > 0) { if(ThreadLocalRandom.current().nextInt(0, getDiamondLevel(stack)) == 0) { stack.damageItem(1, entityLiving); } } else stack.damageItem(1, entityLiving); } else { - ItemStack dropStack = new ItemStack(damageDrop, 1); + ItemStack dropStack = new ItemStack(drop, 1, stack.getItemDamage()); + dropStack.setTagCompound(new NBTTagCompound()); + NBTTagCompound copyNBT; + copyNBT = stack.getSubCompound("tags").copy(); + dropStack.setTagCompound(copyNBT); EntityPlayer player = (EntityPlayer) entityLiving; - PlayerHelper.spawnItemOnPlayer(worldIn, player, dropStack); + PlayerHelper.spawnItemOnPlayer(world, player, dropStack); entityLiving.renderBrokenItemStack(stack); stack.shrink(1); } diff --git a/kfc/src/main/java/nmd/primal/forgecraft/util/BreakerHandler.java b/kfc/src/main/java/nmd/primal/forgecraft/util/BreakerHandler.java index a06800f3..3cafdcf5 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/util/BreakerHandler.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/util/BreakerHandler.java @@ -44,7 +44,7 @@ public interface BreakerHandler { //Block smashBlock = world.getBlockState(pos.offset(face)).getBlock(); IBlockState smashState = world.getBlockState(pos.offset(face)); if(!smashState.getBlock().equals(Blocks.AIR)) { - ItemStack smashStack = new ItemStack(Item.getItemFromBlock(smashState.getBlock()), 1, smashState.getBlock().getMetaFromState(state)); + ItemStack smashStack = new ItemStack(Item.getItemFromBlock(smashState.getBlock()), 1, smashState.getBlock().getMetaFromState(smashState)); if (hasOreName(smashStack, "oreIron")) { if (tile.getCharge() > getThreshold(world, pos.offset(face))) { world.setBlockToAir(pos.offset(face)); diff --git a/kfc/src/main/resources/mcmod.info b/kfc/src/main/resources/mcmod.info index 4ffba9be..cc93f06c 100644 --- a/kfc/src/main/resources/mcmod.info +++ b/kfc/src/main/resources/mcmod.info @@ -2,7 +2,7 @@ "modid": "forgecraft", "name": "Kitsu's Forgecraft", "description": "Forged with sweat and blood", - "version": "1.2.70", + "version": "1.2.71", "mcversion": "1.11.2", "url": "", "updateUrl": "", diff --git a/kfc/world-20170706-060817.zip b/kfc/world-20170706-060817.zip new file mode 100644 index 00000000..412a42b8 Binary files /dev/null and b/kfc/world-20170706-060817.zip differ