Bound Tools (61 errors)
This commit is contained in:
parent
dcbc1c0bc4
commit
000c4c5692
7 changed files with 148 additions and 133 deletions
|
@ -6,6 +6,7 @@ import java.util.Set;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
@ -13,6 +14,8 @@ import net.minecraft.entity.SharedMonsterAttributes;
|
|||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Enchantments;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -49,13 +52,13 @@ public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockDestroyed(ItemStack stack, World world, Block block, BlockPos pos, EntityLivingBase player)
|
||||
public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState block, BlockPos pos, EntityLivingBase entityLiving)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHarvestBlock(Block blockIn)
|
||||
public boolean canHarvestBlock(IBlockState blockIn)
|
||||
{
|
||||
return blockIn == Blocks.obsidian ? this.toolMaterial.getHarvestLevel() == 3
|
||||
: (blockIn != Blocks.diamond_block && blockIn != Blocks.diamond_ore ? (blockIn != Blocks.emerald_ore && blockIn != Blocks.emerald_block ? (blockIn != Blocks.gold_block && blockIn != Blocks.gold_ore ? (blockIn != Blocks.iron_block && blockIn != Blocks.iron_ore ? (blockIn != Blocks.lapis_block && blockIn != Blocks.lapis_ore ? (blockIn != Blocks.redstone_ore && blockIn != Blocks.lit_redstone_ore ? (blockIn.getMaterial() == Material.rock || (blockIn.getMaterial() == Material.iron || blockIn.getMaterial() == Material.anvil)) : this.toolMaterial.getHarvestLevel() >= 2)
|
||||
|
@ -63,12 +66,12 @@ public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public float getStrVsBlock(ItemStack stack, Block block)
|
||||
public float getStrVsBlock(ItemStack stack, IBlockState state)
|
||||
{
|
||||
if (!getActivated(stack))
|
||||
return 1.0F;
|
||||
|
||||
return block.getMaterial() != Material.iron && block.getMaterial() != Material.anvil && block.getMaterial() != Material.rock ? super.getStrVsBlock(stack, block) : this.efficiencyOnProperMaterial;
|
||||
return state.getMaterial() != Material.iron && state.getMaterial() != Material.anvil && state.getMaterial() != Material.rock ? super.getStrVsBlock(stack, state) : this.efficiencyOnProperMaterial;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -77,8 +80,8 @@ public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider
|
|||
if (world.isRemote)
|
||||
return;
|
||||
|
||||
boolean silkTouch = EnchantmentHelper.getSilkTouchModifier(player);
|
||||
int fortuneLvl = EnchantmentHelper.getFortuneModifier(player);
|
||||
boolean silkTouch = EnchantmentHelper.getEnchantmentLevel(Enchantments.silkTouch, stack) > 0;
|
||||
int fortuneLvl = EnchantmentHelper.getEnchantmentLevel(Enchantments.fortune, stack);
|
||||
int range = (int) (charge / 6); //Charge is a max of 30 - want 5 to be the max
|
||||
|
||||
HashMultiset<ItemStackWrapper> drops = HashMultiset.create();
|
||||
|
@ -94,16 +97,16 @@ public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider
|
|||
BlockPos blockPos = playerPos.add(i, j, k);
|
||||
BlockStack blockStack = BlockStack.getStackFromPos(world, blockPos);
|
||||
|
||||
if (blockStack.getBlock().isAir(world, blockPos))
|
||||
if (blockStack.getBlock().isAir(blockStack.getState(), world, blockPos))
|
||||
continue;
|
||||
|
||||
BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, blockPos, blockStack.getState(), player);
|
||||
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY)
|
||||
continue;
|
||||
|
||||
if (blockStack.getBlock() != null && blockStack.getBlock().getBlockHardness(world, blockPos) != -1)
|
||||
if (blockStack.getBlock() != null && blockStack.getBlock().getBlockHardness(blockStack.getState(), world, blockPos) != -1)
|
||||
{
|
||||
float strengthVsBlock = getStrVsBlock(stack, blockStack.getBlock());
|
||||
float strengthVsBlock = getStrVsBlock(stack, blockStack.getState());
|
||||
|
||||
if (strengthVsBlock > 1.1F && world.canMineBlockBody(player, blockPos))
|
||||
{
|
||||
|
@ -131,10 +134,12 @@ public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(ItemStack stack)
|
||||
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot)
|
||||
{
|
||||
Multimap<String, AttributeModifier> multimap = super.getAttributeModifiers(stack);
|
||||
multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(itemModifierUUID, "Weapon modifier", 5, 0));
|
||||
Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);
|
||||
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", 5, 0));
|
||||
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", -2.5, 0));
|
||||
|
||||
return multimap;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue