fixed item drop for item tool breaking and breaker not breaking

This commit is contained in:
Mohammad-Ali Minaie
2017-07-06 06:28:28 -04:00
parent 210c023f2b
commit 25d426ff31
15 changed files with 278 additions and 149 deletions

View File

@@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx3G
mod_group=nmd.primal.forgecraft mod_group=nmd.primal.forgecraft
mod_name=ForgeCraft mod_name=ForgeCraft
mod_version=1.2.70 mod_version=1.2.71
forge_version=13.20.1.2388 forge_version=13.20.1.2388
mcp_mappings=snapshot_20170610 mcp_mappings=snapshot_20170610
mc_version=1.11.2 mc_version=1.11.2

View File

@@ -1,5 +1,5 @@
#Minecraft server properties #Minecraft server properties
#Mon Jul 03 22:50:34 EDT 2017 #Thu Jul 06 06:13:42 EDT 2017
max-tick-time=60000 max-tick-time=60000
generator-settings= generator-settings=
force-gamemode=false force-gamemode=false

View File

@@ -17,7 +17,7 @@ public class ModInfo {
public static final String MOD_CONFIG = "primal/" + MOD_ID; public static final String MOD_CONFIG = "primal/" + MOD_ID;
//public static final String MOD_PREFIX = MOD_ID + ":"; //public static final String MOD_PREFIX = MOD_ID + ":";
public static final String MOD_CHANNEL = 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 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,);"; public static final String DEPENDENCIES = "required-after:forge@[13.20.1.2388,);" + "required-after:primal@[0.4,);";

View File

@@ -194,30 +194,30 @@ public class ModItems {
/********** /**********
TOOLS TOOLS
**********/ **********/
bronzepickaxe = new BronzePickaxe("bronzepickaxe", PrimalMaterials.TOOL_BRONZE); bronzepickaxe = new BronzePickaxe("bronzepickaxe", PrimalMaterials.TOOL_BRONZE, bronzepickaxehead);
bronzeaxe = new BronzeAxe("bronzeaxe", PrimalMaterials.TOOL_BRONZE); bronzeaxe = new BronzeAxe("bronzeaxe", PrimalMaterials.TOOL_BRONZE, bronzeaxehead);
bronzeshovel = new BronzeShovel("bronzeshovel", PrimalMaterials.TOOL_BRONZE); bronzeshovel = new BronzeShovel("bronzeshovel", PrimalMaterials.TOOL_BRONZE, bronzeshovelhead);
bronzehoe = new BronzeHoe("bronzehoe", PrimalMaterials.TOOL_BRONZE); bronzehoe = new BronzeHoe("bronzehoe", PrimalMaterials.TOOL_BRONZE, bronzehoehead);
ironpickaxe = new CustomPickaxe("ironpickaxe", PrimalMaterials.TOOL_WROUGHT_IRON, brokenwroughtirontool); ironpickaxe = new CustomPickaxe("ironpickaxe", PrimalMaterials.TOOL_WROUGHT_IRON, pickaxehead);
ironaxe = new CustomAxe("ironaxe", PrimalMaterials.TOOL_WROUGHT_IRON, brokenwroughtirontool); ironaxe = new CustomAxe("ironaxe", PrimalMaterials.TOOL_WROUGHT_IRON, ironaxehead);
ironshovel = new CustomShovel("ironshovel", PrimalMaterials.TOOL_WROUGHT_IRON, brokenwroughtirontool); ironshovel = new CustomShovel("ironshovel", PrimalMaterials.TOOL_WROUGHT_IRON, ironshovelhead);
ironhoe = new CustomHoe("ironhoe", PrimalMaterials.TOOL_WROUGHT_IRON, brokenwroughtirontool); ironhoe = new CustomHoe("ironhoe", PrimalMaterials.TOOL_WROUGHT_IRON, ironhoehead);
cleanironpickaxe = new CustomPickaxe("cleanironpickaxe", PrimalMaterials.TOOL_CLEAN_IRON, brokencleanirontool); cleanironpickaxe = new CustomPickaxe("cleanironpickaxe", PrimalMaterials.TOOL_CLEAN_IRON, cleanironpickaxehead);
cleanironaxe = new CustomAxe("cleanironaxe", PrimalMaterials.TOOL_CLEAN_IRON, brokencleanirontool); cleanironaxe = new CustomAxe("cleanironaxe", PrimalMaterials.TOOL_CLEAN_IRON, cleanironaxehead);
cleanironshovel = new CustomShovel("cleanironshovel", PrimalMaterials.TOOL_CLEAN_IRON, brokencleanirontool); cleanironshovel = new CustomShovel("cleanironshovel", PrimalMaterials.TOOL_CLEAN_IRON, cleanironshovelhead);
cleanironhoe = new CustomHoe("cleanironhoe", PrimalMaterials.TOOL_CLEAN_IRON, brokencleanirontool); cleanironhoe = new CustomHoe("cleanironhoe", PrimalMaterials.TOOL_CLEAN_IRON, cleanironhoehead);
steelpickaxe = new CustomPickaxe("steelpickaxe", PrimalMaterials.TOOL_BASIC_STEEL, brokensteeltool); steelpickaxe = new CustomPickaxe("steelpickaxe", PrimalMaterials.TOOL_BASIC_STEEL, steelpickaxehead);
steelaxe = new CustomAxe("steelaxe", PrimalMaterials.TOOL_BASIC_STEEL, brokensteeltool); steelaxe = new CustomAxe("steelaxe", PrimalMaterials.TOOL_BASIC_STEEL, steelaxehead);
steelshovel = new CustomShovel("steelshovel", PrimalMaterials.TOOL_BASIC_STEEL, brokensteeltool); steelshovel = new CustomShovel("steelshovel", PrimalMaterials.TOOL_BASIC_STEEL, steelshovelhead);
steelhoe = new CustomHoe("steelhoe", PrimalMaterials.TOOL_BASIC_STEEL, brokensteeltool); steelhoe = new CustomHoe("steelhoe", PrimalMaterials.TOOL_BASIC_STEEL, steelhoehead);
wootzpickaxe = new CustomPickaxe("wootzpickaxe", PrimalMaterials.TOOL_WOOTZ_STEEL, brokenwootztool); wootzpickaxe = new CustomPickaxe("wootzpickaxe", PrimalMaterials.TOOL_WOOTZ_STEEL, wootzpickaxehead);
wootzaxe = new CustomAxe("wootzaxe", PrimalMaterials.TOOL_WOOTZ_STEEL, brokenwootztool); wootzaxe = new CustomAxe("wootzaxe", PrimalMaterials.TOOL_WOOTZ_STEEL, wootzaxehead);
wootzshovel = new CustomShovel("wootzshovel", PrimalMaterials.TOOL_WOOTZ_STEEL, brokenwootztool); wootzshovel = new CustomShovel("wootzshovel", PrimalMaterials.TOOL_WOOTZ_STEEL, wootzshovelhead);
wootzhoe = new CustomHoe("wootzhoe", PrimalMaterials.TOOL_WOOTZ_STEEL, brokenwootztool); wootzhoe = new CustomHoe("wootzhoe", PrimalMaterials.TOOL_WOOTZ_STEEL, wootzhoehead);
/********** /**********
WEAPONS WEAPONS

View File

@@ -31,14 +31,16 @@ import java.util.concurrent.ThreadLocalRandom;
*/ */
public class BronzeAxe extends ItemAxe implements ToolNBT { 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); super(material, 5, -2f);
this.setUnlocalizedName(name); this.setUnlocalizedName(name);
this.setRegistryName(name); this.setRegistryName(name);
this.setCreativeTab(ModInfo.TAB_FORGECRAFT); this.setCreativeTab(ModInfo.TAB_FORGECRAFT);
this.setMaxStackSize(1); this.setMaxStackSize(1);
this.setNoRepair(); this.setNoRepair();
this.drop=damageDrop;
this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() { this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() {
/*** /***
@@ -189,14 +191,23 @@ public class BronzeAxe extends ItemAxe implements ToolNBT {
stack.damageItem(1, attacker); stack.damageItem(1, attacker);
return true; return true;
} else { } 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; EntityPlayer player = (EntityPlayer) attacker;
World world = attacker.getEntityWorld(); World world = attacker.getEntityWorld();
if(!world.isRemote) {
PlayerHelper.spawnItemOnPlayer(world, player, dropStack); PlayerHelper.spawnItemOnPlayer(world, player, dropStack);
attacker.renderBrokenItemStack(stack); attacker.renderBrokenItemStack(stack);
stack.shrink(1); stack.shrink(1);
return true; return true;
} }
return false;
}
} }
@Override @Override
@@ -212,7 +223,11 @@ public class BronzeAxe extends ItemAxe implements ToolNBT {
} }
} else stack.damageItem(1, entityLiving); } else stack.damageItem(1, entityLiving);
} else { } 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; EntityPlayer player = (EntityPlayer) entityLiving;
PlayerHelper.spawnItemOnPlayer(world, player, dropStack); PlayerHelper.spawnItemOnPlayer(world, player, dropStack);
entityLiving.renderBrokenItemStack(stack); entityLiving.renderBrokenItemStack(stack);

View File

@@ -8,6 +8,7 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents; import net.minecraft.init.SoundEvents;
import net.minecraft.item.IItemPropertyGetter; import net.minecraft.item.IItemPropertyGetter;
import net.minecraft.item.Item;
import net.minecraft.item.ItemHoe; import net.minecraft.item.ItemHoe;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@@ -31,14 +32,16 @@ import java.util.concurrent.ThreadLocalRandom;
*/ */
public class BronzeHoe extends ItemHoe implements ToolNBT { 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); super(material);
this.setUnlocalizedName(name); this.setUnlocalizedName(name);
this.setRegistryName(name); this.setRegistryName(name);
this.setCreativeTab(ModInfo.TAB_FORGECRAFT); this.setCreativeTab(ModInfo.TAB_FORGECRAFT);
this.setMaxStackSize(1); this.setMaxStackSize(1);
this.setNoRepair(); this.setNoRepair();
this.drop=damageDrop;
this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() { this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() {
/*** /***
@@ -186,23 +189,6 @@ public class BronzeHoe extends ItemHoe implements ToolNBT {
return false; 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 @Override
protected void setBlock(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos, IBlockState state) 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 ) { if(stack.getMaxDamage() - stack.getItemDamage() >1 ) {
stack.damageItem(1, player); stack.damageItem(1, player);
} else { } 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); PlayerHelper.spawnItemOnPlayer(worldIn, player, dropStack);
player.renderBrokenItemStack(stack); player.renderBrokenItemStack(stack);
stack.shrink(1); stack.shrink(1);
@@ -223,22 +214,51 @@ public class BronzeHoe extends ItemHoe implements ToolNBT {
} }
@Override @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 ) { if(stack.getMaxDamage() - stack.getItemDamage() >1 ) {
stack.getTagCompound().removeTag("ench"); stack.getTagCompound().removeTag("ench");
//System.out.println(stack.getTagCompound());
if(getDiamondLevel(stack) > 0) { if(getDiamondLevel(stack) > 0) {
if(ThreadLocalRandom.current().nextInt(0, getDiamondLevel(stack)) == 0) { if(ThreadLocalRandom.current().nextInt(0, getDiamondLevel(stack)) == 0) {
stack.damageItem(1, entityLiving); stack.damageItem(1, entityLiving);
} }
} else stack.damageItem(1, entityLiving); } else stack.damageItem(1, entityLiving);
} else { } 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; EntityPlayer player = (EntityPlayer) entityLiving;
PlayerHelper.spawnItemOnPlayer(worldIn, player, dropStack); PlayerHelper.spawnItemOnPlayer(world, player, dropStack);
entityLiving.renderBrokenItemStack(stack); entityLiving.renderBrokenItemStack(stack);
stack.shrink(1); stack.shrink(1);
} }

View File

@@ -8,6 +8,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.IItemPropertyGetter; import net.minecraft.item.IItemPropertyGetter;
import net.minecraft.item.Item;
import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemPickaxe;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@@ -30,14 +31,16 @@ import java.util.concurrent.ThreadLocalRandom;
*/ */
public class BronzePickaxe extends ItemPickaxe implements ToolNBT{ 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); super(material);
this.setUnlocalizedName(name); this.setUnlocalizedName(name);
this.setRegistryName(name); this.setRegistryName(name);
this.setCreativeTab(ModInfo.TAB_FORGECRAFT); this.setCreativeTab(ModInfo.TAB_FORGECRAFT);
this.setMaxStackSize(1); this.setMaxStackSize(1);
this.setNoRepair(); this.setNoRepair();
this.drop=damageDrop;
//this.toolClass = "pickaxe"; //this.toolClass = "pickaxe";
this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() { this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() {
@@ -187,14 +190,23 @@ public class BronzePickaxe extends ItemPickaxe implements ToolNBT{
stack.damageItem(1, attacker); stack.damageItem(1, attacker);
return true; return true;
} else { } 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; EntityPlayer player = (EntityPlayer) attacker;
World world = attacker.getEntityWorld(); World world = attacker.getEntityWorld();
if(!world.isRemote) {
PlayerHelper.spawnItemOnPlayer(world, player, dropStack); PlayerHelper.spawnItemOnPlayer(world, player, dropStack);
attacker.renderBrokenItemStack(stack); attacker.renderBrokenItemStack(stack);
stack.shrink(1); stack.shrink(1);
return true; return true;
} }
return false;
}
} }
@Override @Override
@@ -210,13 +222,18 @@ public class BronzePickaxe extends ItemPickaxe implements ToolNBT{
} }
} else stack.damageItem(1, entityLiving); } else stack.damageItem(1, entityLiving);
} else { } 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; EntityPlayer player = (EntityPlayer) entityLiving;
PlayerHelper.spawnItemOnPlayer(world, player, dropStack); PlayerHelper.spawnItemOnPlayer(world, player, dropStack);
entityLiving.renderBrokenItemStack(stack); entityLiving.renderBrokenItemStack(stack);
stack.shrink(1); stack.shrink(1);
} }
} }
return true; return true;
} }

View File

@@ -35,15 +35,16 @@ import java.util.concurrent.ThreadLocalRandom;
public class BronzeShovel extends ItemSpade implements ToolNBT { public class BronzeShovel extends ItemSpade implements ToolNBT {
private static final Set<Block> 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 static final Set<Block> 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); super(material);
this.setUnlocalizedName(name); this.setUnlocalizedName(name);
this.setRegistryName(name); this.setRegistryName(name);
this.setCreativeTab(ModInfo.TAB_FORGECRAFT); this.setCreativeTab(ModInfo.TAB_FORGECRAFT);
this.setMaxStackSize(1); this.setMaxStackSize(1);
this.setNoRepair(); this.setNoRepair();
this.drop=damageDrop;
this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() { this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() {
/*** /***
@@ -190,33 +191,45 @@ public class BronzeShovel extends ItemSpade implements ToolNBT {
stack.damageItem(1, attacker); stack.damageItem(1, attacker);
return true; return true;
} else { } 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; EntityPlayer player = (EntityPlayer) attacker;
World world = attacker.getEntityWorld(); World world = attacker.getEntityWorld();
if(!world.isRemote) {
PlayerHelper.spawnItemOnPlayer(world, player, dropStack); PlayerHelper.spawnItemOnPlayer(world, player, dropStack);
attacker.renderBrokenItemStack(stack); attacker.renderBrokenItemStack(stack);
stack.shrink(1); stack.shrink(1);
return true; return true;
} }
return false;
}
} }
@Override @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 ) { if(stack.getMaxDamage() - stack.getItemDamage() >1 ) {
stack.getTagCompound().removeTag("ench"); stack.getTagCompound().removeTag("ench");
//System.out.println(stack.getTagCompound());
if(getDiamondLevel(stack) > 0) { if(getDiamondLevel(stack) > 0) {
if(ThreadLocalRandom.current().nextInt(0, getDiamondLevel(stack)) == 0) { if(ThreadLocalRandom.current().nextInt(0, getDiamondLevel(stack)) == 0) {
stack.damageItem(1, entityLiving); stack.damageItem(1, entityLiving);
} }
} else stack.damageItem(1, entityLiving); } else stack.damageItem(1, entityLiving);
} else { } 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; EntityPlayer player = (EntityPlayer) entityLiving;
PlayerHelper.spawnItemOnPlayer(worldIn, player, dropStack); PlayerHelper.spawnItemOnPlayer(world, player, dropStack);
entityLiving.renderBrokenItemStack(stack); entityLiving.renderBrokenItemStack(stack);
stack.shrink(1); stack.shrink(1);
} }

View File

@@ -31,7 +31,7 @@ import java.util.concurrent.ThreadLocalRandom;
*/ */
public class CustomAxe extends ItemAxe implements ToolNBT { public class CustomAxe extends ItemAxe implements ToolNBT {
private Item damageDrop; Item drop;
public CustomAxe(String name, Item.ToolMaterial material, Item damageDrop) { public CustomAxe(String name, Item.ToolMaterial material, Item damageDrop) {
super(material, 6, -3.1f); super(material, 6, -3.1f);
@@ -40,7 +40,7 @@ public class CustomAxe extends ItemAxe implements ToolNBT {
this.setCreativeTab(ModInfo.TAB_FORGECRAFT); this.setCreativeTab(ModInfo.TAB_FORGECRAFT);
this.setMaxStackSize(1); this.setMaxStackSize(1);
this.setNoRepair(); this.setNoRepair();
damageDrop = damageDrop; this.drop = damageDrop;
this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() { 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) { public void onCreated(ItemStack item, World world, EntityPlayer playerIn) {
if(!world.isRemote) { if(!world.isRemote) {
item.setItemDamage(item.getMaxDamage()-5);
if (!item.hasTagCompound()) { if (!item.hasTagCompound()) {
item.setTagCompound(new NBTTagCompound()); item.setTagCompound(new NBTTagCompound());
NBTTagCompound tags = new NBTTagCompound(); NBTTagCompound tags = new NBTTagCompound();
@@ -254,6 +255,7 @@ public class CustomAxe extends ItemAxe implements ToolNBT {
@Override @Override
public void onUpdate(ItemStack item, World world, Entity player, int itemSlot, boolean isSelected) { public void onUpdate(ItemStack item, World world, Entity player, int itemSlot, boolean isSelected) {
if(!world.isRemote) { if(!world.isRemote) {
if (!item.hasTagCompound()) { if (!item.hasTagCompound()) {
item.setTagCompound(new NBTTagCompound()); item.setTagCompound(new NBTTagCompound());
NBTTagCompound tags = new NBTTagCompound(); NBTTagCompound tags = new NBTTagCompound();
@@ -305,7 +307,6 @@ public class CustomAxe extends ItemAxe implements ToolNBT {
{ {
if(!player.world.isRemote){ if(!player.world.isRemote){
World world = player.getEntityWorld(); World world = player.getEntityWorld();
//System.out.println(world.getBlockState(pos).getBlock());
if(itemstack.getItem() instanceof CustomAxe){ if(itemstack.getItem() instanceof CustomAxe){
if( getEmerald(itemstack)){ if( getEmerald(itemstack)){
itemstack.addEnchantment(Enchantment.getEnchantmentByID(33), 1); itemstack.addEnchantment(Enchantment.getEnchantmentByID(33), 1);
@@ -334,14 +335,23 @@ public class CustomAxe extends ItemAxe implements ToolNBT {
stack.damageItem(1, attacker); stack.damageItem(1, attacker);
return true; return true;
} else { } 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; EntityPlayer player = (EntityPlayer) attacker;
World world = attacker.getEntityWorld(); World world = attacker.getEntityWorld();
if(!world.isRemote) {
PlayerHelper.spawnItemOnPlayer(world, player, dropStack); PlayerHelper.spawnItemOnPlayer(world, player, dropStack);
attacker.renderBrokenItemStack(stack); attacker.renderBrokenItemStack(stack);
stack.shrink(1); stack.shrink(1);
return true; return true;
} }
return false;
}
} }
@Override @Override
@@ -357,7 +367,11 @@ public class CustomAxe extends ItemAxe implements ToolNBT {
} }
} else stack.damageItem(1, entityLiving); } else stack.damageItem(1, entityLiving);
} else { } 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; EntityPlayer player = (EntityPlayer) entityLiving;
PlayerHelper.spawnItemOnPlayer(world, player, dropStack); PlayerHelper.spawnItemOnPlayer(world, player, dropStack);
entityLiving.renderBrokenItemStack(stack); entityLiving.renderBrokenItemStack(stack);

View File

@@ -32,7 +32,7 @@ import java.util.concurrent.ThreadLocalRandom;
*/ */
public class CustomHoe extends ItemHoe implements ToolNBT { public class CustomHoe extends ItemHoe implements ToolNBT {
private Item damageDrop; private Item drop;
public CustomHoe(String name, Item.ToolMaterial material, Item damageDrop) { public CustomHoe(String name, Item.ToolMaterial material, Item damageDrop) {
super(material); super(material);
@@ -41,7 +41,7 @@ public class CustomHoe extends ItemHoe implements ToolNBT {
this.setCreativeTab(ModInfo.TAB_FORGECRAFT); this.setCreativeTab(ModInfo.TAB_FORGECRAFT);
this.setMaxStackSize(1); this.setMaxStackSize(1);
this.setNoRepair(); this.setNoRepair();
this.damageDrop = damageDrop; this.drop = damageDrop;
this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() { this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() {
/*** /***
@@ -326,23 +326,6 @@ public class CustomHoe extends ItemHoe implements ToolNBT {
return false; 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 @Override
protected void setBlock(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos, IBlockState state) 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 ) { if(stack.getMaxDamage() - stack.getItemDamage() >1 ) {
stack.damageItem(1, player); stack.damageItem(1, player);
} else { } 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); PlayerHelper.spawnItemOnPlayer(worldIn, player, dropStack);
player.renderBrokenItemStack(stack); player.renderBrokenItemStack(stack);
stack.shrink(1); stack.shrink(1);
@@ -363,18 +351,54 @@ public class CustomHoe extends ItemHoe implements ToolNBT {
} }
@Override @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"); stack.getTagCompound().removeTag("ench");
//System.out.println(stack.getTagCompound());
if(getDiamondLevel(stack) > 0) { if(getDiamondLevel(stack) > 0) {
if(ThreadLocalRandom.current().nextInt(0, getDiamondLevel(stack)) == 0) { if(ThreadLocalRandom.current().nextInt(0, getDiamondLevel(stack)) == 0) {
stack.damageItem(1, entityLiving); stack.damageItem(1, entityLiving);
} }
} else 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; return true;

View File

@@ -31,7 +31,7 @@ import java.util.concurrent.ThreadLocalRandom;
*/ */
public class CustomPickaxe extends ItemPickaxe implements ToolNBT{ public class CustomPickaxe extends ItemPickaxe implements ToolNBT{
private Item damageDrop; private Item drop;
public CustomPickaxe(String name, Item.ToolMaterial material, Item damageDrop) { public CustomPickaxe(String name, Item.ToolMaterial material, Item damageDrop) {
super(material); super(material);
@@ -40,7 +40,7 @@ public class CustomPickaxe extends ItemPickaxe implements ToolNBT{
this.setCreativeTab(ModInfo.TAB_FORGECRAFT); this.setCreativeTab(ModInfo.TAB_FORGECRAFT);
this.setMaxStackSize(1); this.setMaxStackSize(1);
this.setNoRepair(); this.setNoRepair();
this.damageDrop=damageDrop; this.drop=damageDrop;
//this.toolClass = "pickaxe"; //this.toolClass = "pickaxe";
this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() { this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() {
@@ -335,14 +335,23 @@ public class CustomPickaxe extends ItemPickaxe implements ToolNBT{
stack.damageItem(1, attacker); stack.damageItem(1, attacker);
return true; return true;
} else { } 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; EntityPlayer player = (EntityPlayer) attacker;
World world = attacker.getEntityWorld(); World world = attacker.getEntityWorld();
if(!world.isRemote) {
PlayerHelper.spawnItemOnPlayer(world, player, dropStack); PlayerHelper.spawnItemOnPlayer(world, player, dropStack);
attacker.renderBrokenItemStack(stack); attacker.renderBrokenItemStack(stack);
stack.shrink(1); stack.shrink(1);
return true; return true;
} }
return false;
}
} }
@Override @Override
@@ -358,13 +367,18 @@ public class CustomPickaxe extends ItemPickaxe implements ToolNBT{
} }
} else stack.damageItem(1, entityLiving); } else stack.damageItem(1, entityLiving);
} else { } 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; EntityPlayer player = (EntityPlayer) entityLiving;
PlayerHelper.spawnItemOnPlayer(world, player, dropStack); PlayerHelper.spawnItemOnPlayer(world, player, dropStack);
entityLiving.renderBrokenItemStack(stack); entityLiving.renderBrokenItemStack(stack);
stack.shrink(1); stack.shrink(1);
} }
} }
return true; return true;
} }

View File

@@ -35,7 +35,7 @@ import java.util.concurrent.ThreadLocalRandom;
public class CustomShovel extends ItemSpade implements ToolNBT { public class CustomShovel extends ItemSpade implements ToolNBT {
private static final Set<Block> 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 static final Set<Block> 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) { public CustomShovel(String name, Item.ToolMaterial material, Item damageDrop) {
super(material); super(material);
@@ -44,7 +44,7 @@ public class CustomShovel extends ItemSpade implements ToolNBT {
this.setCreativeTab(ModInfo.TAB_FORGECRAFT); this.setCreativeTab(ModInfo.TAB_FORGECRAFT);
this.setMaxStackSize(1); this.setMaxStackSize(1);
this.setNoRepair(); this.setNoRepair();
this.damageDrop=damageDrop; this.drop=damageDrop;
this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() { this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() {
/*** /***
@@ -335,33 +335,45 @@ public class CustomShovel extends ItemSpade implements ToolNBT {
stack.damageItem(1, attacker); stack.damageItem(1, attacker);
return true; return true;
} else { } 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; EntityPlayer player = (EntityPlayer) attacker;
World world = attacker.getEntityWorld(); World world = attacker.getEntityWorld();
if(!world.isRemote) {
PlayerHelper.spawnItemOnPlayer(world, player, dropStack); PlayerHelper.spawnItemOnPlayer(world, player, dropStack);
attacker.renderBrokenItemStack(stack); attacker.renderBrokenItemStack(stack);
stack.shrink(1); stack.shrink(1);
return true; return true;
} }
return false;
}
} }
@Override @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 ) { if(stack.getMaxDamage() - stack.getItemDamage() >1 ) {
stack.getTagCompound().removeTag("ench"); stack.getTagCompound().removeTag("ench");
//System.out.println(stack.getTagCompound());
if(getDiamondLevel(stack) > 0) { if(getDiamondLevel(stack) > 0) {
if(ThreadLocalRandom.current().nextInt(0, getDiamondLevel(stack)) == 0) { if(ThreadLocalRandom.current().nextInt(0, getDiamondLevel(stack)) == 0) {
stack.damageItem(1, entityLiving); stack.damageItem(1, entityLiving);
} }
} else stack.damageItem(1, entityLiving); } else stack.damageItem(1, entityLiving);
} else { } 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; EntityPlayer player = (EntityPlayer) entityLiving;
PlayerHelper.spawnItemOnPlayer(worldIn, player, dropStack); PlayerHelper.spawnItemOnPlayer(world, player, dropStack);
entityLiving.renderBrokenItemStack(stack); entityLiving.renderBrokenItemStack(stack);
stack.shrink(1); stack.shrink(1);
} }

View File

@@ -44,7 +44,7 @@ public interface BreakerHandler {
//Block smashBlock = world.getBlockState(pos.offset(face)).getBlock(); //Block smashBlock = world.getBlockState(pos.offset(face)).getBlock();
IBlockState smashState = world.getBlockState(pos.offset(face)); IBlockState smashState = world.getBlockState(pos.offset(face));
if(!smashState.getBlock().equals(Blocks.AIR)) { 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 (hasOreName(smashStack, "oreIron")) {
if (tile.getCharge() > getThreshold(world, pos.offset(face))) { if (tile.getCharge() > getThreshold(world, pos.offset(face))) {
world.setBlockToAir(pos.offset(face)); world.setBlockToAir(pos.offset(face));

View File

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

Binary file not shown.