mirror of
https://github.com/barkeser2002/CatServer.git
synced 2026-09-25 08:00:02 +03:00
89 lines
3.3 KiB
Diff
89 lines
3.3 KiB
Diff
--- ../src-base/minecraft/net/minecraft/item/ItemTool.java
|
|
+++ ../src-work/minecraft/net/minecraft/item/ItemTool.java
|
|
@@ -20,9 +20,9 @@
|
|
protected float efficiency;
|
|
protected float attackDamage;
|
|
protected float attackSpeed;
|
|
- protected Item.ToolMaterial toolMaterial;
|
|
+ protected ToolMaterial toolMaterial;
|
|
|
|
- protected ItemTool(float attackDamageIn, float attackSpeedIn, Item.ToolMaterial materialIn, Set<Block> effectiveBlocksIn)
|
|
+ protected ItemTool(float attackDamageIn, float attackSpeedIn, ToolMaterial materialIn, Set<Block> effectiveBlocksIn)
|
|
{
|
|
this.efficiency = 4.0F;
|
|
this.toolMaterial = materialIn;
|
|
@@ -33,15 +33,32 @@
|
|
this.attackDamage = attackDamageIn + materialIn.getAttackDamage();
|
|
this.attackSpeed = attackSpeedIn;
|
|
this.setCreativeTab(CreativeTabs.TOOLS);
|
|
+ if (this instanceof ItemPickaxe)
|
|
+ {
|
|
+ toolClass = "pickaxe";
|
|
+ }
|
|
+ else if (this instanceof ItemAxe)
|
|
+ {
|
|
+ toolClass = "axe";
|
|
+ }
|
|
+ else if (this instanceof ItemSpade)
|
|
+ {
|
|
+ toolClass = "shovel";
|
|
+ }
|
|
}
|
|
|
|
- protected ItemTool(Item.ToolMaterial materialIn, Set<Block> effectiveBlocksIn)
|
|
+ protected ItemTool(ToolMaterial materialIn, Set<Block> effectiveBlocksIn)
|
|
{
|
|
this(0.0F, 0.0F, materialIn, effectiveBlocksIn);
|
|
}
|
|
|
|
public float getDestroySpeed(ItemStack stack, IBlockState state)
|
|
{
|
|
+ for (String type : getToolClasses(stack))
|
|
+ {
|
|
+ if (state.getBlock().isToolEffective(type, state))
|
|
+ return efficiency;
|
|
+ }
|
|
return this.effectiveBlocks.contains(state.getBlock()) ? this.efficiency : 1.0F;
|
|
}
|
|
|
|
@@ -79,7 +96,9 @@
|
|
|
|
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair)
|
|
{
|
|
- return this.toolMaterial.getRepairItem() == repair.getItem() ? true : super.getIsRepairable(toRepair, repair);
|
|
+ ItemStack mat = this.toolMaterial.getRepairItemStack();
|
|
+ if (!mat.isEmpty() && net.minecraftforge.oredict.OreDictionary.itemMatches(mat, repair, false)) return true;
|
|
+ return super.getIsRepairable(toRepair, repair);
|
|
}
|
|
|
|
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot)
|
|
@@ -94,4 +113,28 @@
|
|
|
|
return multimap;
|
|
}
|
|
+
|
|
+ /*===================================== FORGE START =================================*/
|
|
+ @javax.annotation.Nullable
|
|
+ private String toolClass;
|
|
+ @Override
|
|
+ public int getHarvestLevel(ItemStack stack, String toolClass, @javax.annotation.Nullable net.minecraft.entity.player.EntityPlayer player, @javax.annotation.Nullable IBlockState blockState)
|
|
+ {
|
|
+ int level = super.getHarvestLevel(stack, toolClass, player, blockState);
|
|
+ if (level == -1 && toolClass.equals(this.toolClass))
|
|
+ {
|
|
+ return this.toolMaterial.getHarvestLevel();
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ return level;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Set<String> getToolClasses(ItemStack stack)
|
|
+ {
|
|
+ return toolClass != null ? com.google.common.collect.ImmutableSet.of(toolClass) : super.getToolClasses(stack);
|
|
+ }
|
|
+ /*===================================== FORGE END =================================*/
|
|
}
|