diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAllToolAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAllToolAA.java index 7a27f543b..0b5b41b92 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAllToolAA.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAllToolAA.java @@ -19,6 +19,7 @@ import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.color.IItemColor; +import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -36,12 +37,14 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.HashSet; import java.util.Set; +import com.google.common.collect.Sets; + public class ItemAllToolAA extends ItemToolAA implements IColorProvidingItem{ public final int color; public ItemAllToolAA(ToolMaterial toolMat, String repairItem, String unlocalizedName, EnumRarity rarity, int color){ - super(4.0F, -2F, toolMat, repairItem, unlocalizedName, rarity, new HashSet()); + super(4.0F, -2F, toolMat, repairItem, unlocalizedName, rarity, new HashSet<>()); this.color = color; this.setMaxDamage(toolMat.getMaxUses()*4); @@ -49,7 +52,7 @@ public class ItemAllToolAA extends ItemToolAA implements IColorProvidingItem{ } public ItemAllToolAA(ToolMaterial toolMat, ItemStack repairItem, String unlocalizedName, EnumRarity rarity, int color){ - super(4.0F, -2F, toolMat, repairItem, unlocalizedName, rarity, new HashSet()); + super(4.0F, -2F, toolMat, repairItem, unlocalizedName, rarity, new HashSet<>()); this.color = color; this.setMaxDamage(toolMat.getMaxUses()*4); @@ -64,47 +67,35 @@ public class ItemAllToolAA extends ItemToolAA implements IColorProvidingItem{ @Override protected void registerRendering(){ - ResourceLocation resLoc = new ResourceLocation(ModUtil.MOD_ID, "item_paxel"); - ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this), resLoc, "inventory"); + ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this), new ResourceLocation(ModUtil.MOD_ID, "item_paxel"), "inventory"); } @Override public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ){ - if(!playerIn.isSneaking()){ - return Items.IRON_HOE.onItemUse(playerIn, worldIn, pos, hand, side, hitX, hitY, hitZ); - } - else{ - return Items.IRON_SHOVEL.onItemUse(playerIn, worldIn, pos, hand, side, hitX, hitY, hitZ); - } + if(!playerIn.isSneaking()) return Items.IRON_HOE.onItemUse(playerIn, worldIn, pos, hand, side, hitX, hitY, hitZ); + return Items.IRON_SHOVEL.onItemUse(playerIn, worldIn, pos, hand, side, hitX, hitY, hitZ); } @Override public boolean canHarvestBlock(IBlockState state, ItemStack stack){ - return this.hasExtraWhitelist(state.getBlock()) || state.getMaterial().isToolNotRequired() || (state.getBlock() == Blocks.SNOW_LAYER || state.getBlock() == Blocks.SNOW || (state.getBlock() == Blocks.OBSIDIAN ? this.toolMaterial.getHarvestLevel() >= 3 : (state.getBlock() != Blocks.DIAMOND_BLOCK && state.getBlock() != Blocks.DIAMOND_ORE ? (state.getBlock() != Blocks.EMERALD_ORE && state.getBlock() != Blocks.EMERALD_BLOCK ? (state.getBlock() != Blocks.GOLD_BLOCK && state.getBlock() != Blocks.GOLD_ORE ? (state.getBlock() != Blocks.IRON_BLOCK && state.getBlock() != Blocks.IRON_ORE ? (state.getBlock() != Blocks.LAPIS_BLOCK && state.getBlock() != Blocks.LAPIS_ORE ? (state.getBlock() != Blocks.REDSTONE_ORE && state.getBlock() != Blocks.LIT_REDSTONE_ORE ? (state.getMaterial() == Material.ROCK || (state.getMaterial() == Material.IRON || state.getMaterial() == Material.ANVIL)) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2))); } private boolean hasExtraWhitelist(Block block){ String name = block.getRegistryName().toString(); - if(name != null){ for(String list : ConfigStringListValues.PAXEL_EXTRA_MINING_WHITELIST.getValue()){ if(list.equals(name)){ return true; } } - } return false; } @Override public Set getToolClasses(ItemStack stack){ - HashSet hashSet = new HashSet(); - hashSet.add("pickaxe"); - hashSet.add("axe"); - hashSet.add("shovel"); - return hashSet; + return Sets.newHashSet("pickaxe", "axe", "shovel"); } @Override @@ -127,4 +118,9 @@ public class ItemAllToolAA extends ItemToolAA implements IColorProvidingItem{ } }; } + + @Override + public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) { + return super.canApplyAtEnchantingTable(stack, enchantment) || enchantment.type.canEnchantItem(Items.DIAMOND_SWORD); + } } \ No newline at end of file