mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-26 13:09:22 +01:00
make aiot accept sword enchantments
This commit is contained in:
parent
8a1ed7b14b
commit
4493a687ce
1 changed files with 14 additions and 18 deletions
|
@ -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<Block>());
|
||||
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<Block>());
|
||||
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<String> getToolClasses(ItemStack stack){
|
||||
HashSet<String> hashSet = new HashSet<String>();
|
||||
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);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue