From 0499fbdf7ffcef15a5e10e0e3c0ffa58459032a6 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sat, 19 Mar 2016 11:36:17 +0100 Subject: [PATCH] Made the game actually run --- .../mod/items/InitForeignPaxels.java | 1 - .../mod/items/{base => }/ItemAllToolAA.java | 77 +++--------------- .../mod/items/ItemAxeAA.java | 41 ++++++++++ .../mod/items/ItemPickaxeAA.java | 47 +++++++++++ .../mod/items/ItemShovelAA.java | 79 +++++++++++++++++++ .../mod/items/base/ItemAxeAA.java | 64 --------------- .../mod/items/base/ItemPickaxeAA.java | 64 --------------- .../mod/items/base/ItemShovelAA.java | 65 --------------- .../mod/items/base/ItemToolAA.java | 78 ++++++++++++++++++ 9 files changed, 257 insertions(+), 259 deletions(-) rename src/main/java/de/ellpeck/actuallyadditions/mod/items/{base => }/ItemAllToolAA.java (69%) create mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAxeAA.java create mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPickaxeAA.java create mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemShovelAA.java delete mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemAxeAA.java delete mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemPickaxeAA.java delete mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemShovelAA.java create mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemToolAA.java diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/InitForeignPaxels.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/InitForeignPaxels.java index 03224bc30..95fd3d25c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/InitForeignPaxels.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/InitForeignPaxels.java @@ -14,7 +14,6 @@ import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; import de.ellpeck.actuallyadditions.mod.config.values.ConfigCrafting; import de.ellpeck.actuallyadditions.mod.crafting.ToolCrafting; import de.ellpeck.actuallyadditions.mod.creative.CreativeTab; -import de.ellpeck.actuallyadditions.mod.items.base.ItemAllToolAA; import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.RecipeUtil; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemAllToolAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAllToolAA.java similarity index 69% rename from src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemAllToolAA.java rename to src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAllToolAA.java index 28e98caa4..78f153dfd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemAllToolAA.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAllToolAA.java @@ -8,74 +8,44 @@ * © 2016 Ellpeck */ -package de.ellpeck.actuallyadditions.mod.items.base; +package de.ellpeck.actuallyadditions.mod.items; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.config.ConfigValues; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; +import de.ellpeck.actuallyadditions.mod.items.base.ItemToolAA; import de.ellpeck.actuallyadditions.mod.util.ModUtil; 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.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemTool; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import net.minecraftforge.oredict.OreDictionary; import java.util.HashSet; import java.util.Set; @SuppressWarnings("unchecked") -public class ItemAllToolAA extends ItemTool{ +public class ItemAllToolAA extends ItemToolAA implements IItemColor{ private int color; - private String name; - private EnumRarity rarity; - private ItemStack repairItem; - private String repairOredict; - public ItemAllToolAA(ToolMaterial toolMat, String repairItem, String unlocalizedName, EnumRarity rarity, int color){ - this(toolMat, (ItemStack)null, unlocalizedName, rarity, color); - this.repairOredict = repairItem; + super(4.0F, -2F, toolMat, repairItem, unlocalizedName, rarity, new HashSet()); + this.color = color; } public ItemAllToolAA(ToolMaterial toolMat, ItemStack repairItem, String unlocalizedName, EnumRarity rarity, int color){ - super(4.0F, -2F, toolMat, new HashSet()); - - this.repairItem = repairItem; - this.name = unlocalizedName; - this.rarity = rarity; + super(4.0F, -2F, toolMat, repairItem, unlocalizedName, rarity, new HashSet()); this.color = color; - - this.setMaxDamage(this.getMaxDamage()*4); - - this.register(); - } - - private void register(){ - ItemUtil.registerItem(this, this.getBaseName(), this.shouldAddCreative()); - - this.registerRendering(); - } - - protected String getBaseName(){ - return this.name; - } - - public boolean shouldAddCreative(){ - return true; } protected void registerRendering(){ @@ -88,18 +58,6 @@ public class ItemAllToolAA extends ItemTool{ return Items.iron_hoe.onItemUse(stack, playerIn, worldIn, pos, hand, side, hitX, hitY, hitZ); } - //TODO Fix ItemStack color - /*@Override - @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack stack, int pass){ - return pass > 0 ? this.color : super.(stack, pass); - }*/ - - @Override - public EnumRarity getRarity(ItemStack stack){ - return this.rarity; - } - @Override public boolean canHarvestBlock(IBlockState state, ItemStack stack){ @@ -118,22 +76,6 @@ public class ItemAllToolAA extends ItemTool{ return false; } - @Override - public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack){ - if(this.repairItem != null){ - return ItemUtil.areItemsEqual(this.repairItem, stack, false); - } - else if(this.repairOredict != null){ - int[] idsStack = OreDictionary.getOreIDs(stack); - for(int id : idsStack){ - if(OreDictionary.getOreName(id).equals(this.repairOredict)){ - return true; - } - } - } - return false; - } - @Override public Set getToolClasses(ItemStack stack){ HashSet hashSet = new HashSet(); @@ -147,4 +89,9 @@ public class ItemAllToolAA extends ItemTool{ public float getStrVsBlock(ItemStack stack, IBlockState state){ return this.hasExtraWhitelist(state.getBlock()) || state.getBlock().getHarvestTool(state) == null || state.getBlock().getHarvestTool(state).isEmpty() || this.getToolClasses(stack).contains(state.getBlock().getHarvestTool(state)) ? this.efficiencyOnProperMaterial : 1.0F; } + + @Override + public int getColorFromItemstack(ItemStack stack, int tintIndex){ + return tintIndex > 0 ? this.color : 0xFFFFFF; + } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAxeAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAxeAA.java new file mode 100644 index 000000000..1b879a5d6 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAxeAA.java @@ -0,0 +1,41 @@ +/* + * This file ("ItemAxeAA.java") is part of the Actually Additions Mod for Minecraft. + * It is created and owned by Ellpeck and distributed + * under the Actually Additions License to be found at + * http://ellpeck.de/actaddlicense/ + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2016 Ellpeck + */ + +package de.ellpeck.actuallyadditions.mod.items; + +import com.google.common.collect.Sets; +import de.ellpeck.actuallyadditions.mod.items.base.ItemToolAA; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import java.util.Set; + +public class ItemAxeAA extends ItemToolAA{ + + private static final Set EFFECTIVE_ON = Sets.newHashSet(Blocks.planks, Blocks.bookshelf, Blocks.log, Blocks.log2, Blocks.chest, Blocks.pumpkin, Blocks.lit_pumpkin, Blocks.melon_block, Blocks.ladder, Blocks.wooden_button, Blocks.wooden_pressure_plate); + + public ItemAxeAA(Item.ToolMaterial material, String repairItem, String unlocalizedName, EnumRarity rarity){ + super(6.0F, -3.0F, material, repairItem, unlocalizedName, rarity, EFFECTIVE_ON); + } + + public ItemAxeAA(Item.ToolMaterial material, ItemStack repairItem, String unlocalizedName, EnumRarity rarity){ + super(6.0F, -3.0F, material, repairItem, unlocalizedName, rarity, EFFECTIVE_ON); + } + + public float getStrVsBlock(ItemStack stack, IBlockState state){ + Material material = state.getMaterial(); + return material != Material.wood && material != Material.plants && material != Material.vine ? super.getStrVsBlock(stack, state) : this.efficiencyOnProperMaterial; + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPickaxeAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPickaxeAA.java new file mode 100644 index 000000000..404db70ca --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPickaxeAA.java @@ -0,0 +1,47 @@ +/* + * This file ("ItemPickaxeAA.java") is part of the Actually Additions Mod for Minecraft. + * It is created and owned by Ellpeck and distributed + * under the Actually Additions License to be found at + * http://ellpeck.de/actaddlicense/ + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2016 Ellpeck + */ + +package de.ellpeck.actuallyadditions.mod.items; + +import com.google.common.collect.Sets; +import de.ellpeck.actuallyadditions.mod.items.base.ItemToolAA; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import java.util.Set; + +public class ItemPickaxeAA extends ItemToolAA{ + + private static final Set EFFECTIVE_ON = Sets.newHashSet(Blocks.activator_rail, Blocks.coal_ore, Blocks.cobblestone, Blocks.detector_rail, Blocks.diamond_block, Blocks.diamond_ore, Blocks.double_stone_slab, Blocks.golden_rail, Blocks.gold_block, Blocks.gold_ore, Blocks.ice, Blocks.iron_block, Blocks.iron_ore, Blocks.lapis_block, Blocks.lapis_ore, Blocks.lit_redstone_ore, Blocks.mossy_cobblestone, Blocks.netherrack, Blocks.packed_ice, Blocks.rail, Blocks.redstone_ore, Blocks.sandstone, Blocks.red_sandstone, Blocks.stone, Blocks.stone_slab, Blocks.stone_button, Blocks.stone_pressure_plate); + + public ItemPickaxeAA(Item.ToolMaterial material, String repairItem, String unlocalizedName, EnumRarity rarity){ + super(1.0F, -2.8F, material, repairItem, unlocalizedName, rarity, EFFECTIVE_ON); + } + + public ItemPickaxeAA(Item.ToolMaterial material, ItemStack repairItem, String unlocalizedName, EnumRarity rarity){ + super(1.0F, -2.8F, material, repairItem, unlocalizedName, rarity, EFFECTIVE_ON); + } + + @Override + public boolean canHarvestBlock(IBlockState state) { + Block blockIn = state.getBlock(); + return blockIn == Blocks.obsidian ? 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 ? state.getMaterial() == Material.rock || (state.getMaterial() == Material.iron || state.getMaterial() == Material.anvil) : toolMaterial.getHarvestLevel() >= 2 : toolMaterial.getHarvestLevel() >= 1 : toolMaterial.getHarvestLevel() >= 1 : toolMaterial.getHarvestLevel() >= 2 : toolMaterial.getHarvestLevel() >= 2 : toolMaterial.getHarvestLevel() >= 2; + } + + public float getStrVsBlock(ItemStack stack, IBlockState state){ + Material material = state.getMaterial(); + return material != Material.iron && material != Material.anvil && material != Material.rock ? super.getStrVsBlock(stack, state) : this.efficiencyOnProperMaterial; + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemShovelAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemShovelAA.java new file mode 100644 index 000000000..b22a29ad6 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemShovelAA.java @@ -0,0 +1,79 @@ +/* + * This file ("ItemShovelAA.java") is part of the Actually Additions Mod for Minecraft. + * It is created and owned by Ellpeck and distributed + * under the Actually Additions License to be found at + * http://ellpeck.de/actaddlicense/ + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2016 Ellpeck + */ + +package de.ellpeck.actuallyadditions.mod.items; + +import com.google.common.collect.Sets; +import de.ellpeck.actuallyadditions.mod.items.base.ItemToolAA; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.SoundEvents; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.SoundCategory; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import java.util.Set; + +public class ItemShovelAA extends ItemToolAA{ + + private static final Set EFFECTIVE_ON = Sets.newHashSet(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); + + public ItemShovelAA(Item.ToolMaterial material, String repairItem, String unlocalizedName, EnumRarity rarity){ + super(1.5F, -3.0F, material, repairItem, unlocalizedName, rarity, EFFECTIVE_ON); + } + + public ItemShovelAA(Item.ToolMaterial material, ItemStack repairItem, String unlocalizedName, EnumRarity rarity){ + super(1.5F, -3.0F, material, repairItem, unlocalizedName, rarity, EFFECTIVE_ON); + } + + public float getStrVsBlock(ItemStack stack, IBlockState state){ + Material material = state.getMaterial(); + return material != Material.wood && material != Material.plants && material != Material.vine ? super.getStrVsBlock(stack, state) : this.efficiencyOnProperMaterial; + } + + public boolean canHarvestBlock(IBlockState blockIn){ + Block block = blockIn.getBlock(); + return block == Blocks.snow_layer || block == Blocks.snow; + } + + public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){ + if(!playerIn.canPlayerEdit(pos.offset(facing), facing, stack)){ + return EnumActionResult.FAIL; + } + else{ + IBlockState iblockstate = worldIn.getBlockState(pos); + Block block = iblockstate.getBlock(); + + if(facing != EnumFacing.DOWN && worldIn.getBlockState(pos.up()).getMaterial() == Material.air && block == Blocks.grass){ + IBlockState iblockstate1 = Blocks.grass_path.getDefaultState(); + worldIn.playSound(playerIn, pos, SoundEvents.item_shovel_flatten, SoundCategory.BLOCKS, 1.0F, 1.0F); + + if(!worldIn.isRemote){ + worldIn.setBlockState(pos, iblockstate1, 11); + stack.damageItem(1, playerIn); + } + + return EnumActionResult.SUCCESS; + } + else{ + return EnumActionResult.PASS; + } + } + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemAxeAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemAxeAA.java deleted file mode 100644 index fcf7cc0cb..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemAxeAA.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This file ("ItemAxeAA.java") is part of the Actually Additions Mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense/ - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2016 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items.base; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import de.ellpeck.actuallyadditions.mod.util.ModUtil; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemAxe; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; - -public class ItemAxeAA extends ItemAxe{ - - private String name; - private EnumRarity rarity; - private ItemStack repairItem; - - public ItemAxeAA(ToolMaterial toolMat, ItemStack repairItem, String unlocalizedName, EnumRarity rarity){ - super(toolMat); - - this.repairItem = repairItem; - this.name = unlocalizedName; - this.rarity = rarity; - - this.register(); - } - - private void register(){ - ItemUtil.registerItem(this, this.getBaseName(), this.shouldAddCreative()); - - this.registerRendering(); - } - - protected String getBaseName(){ - return this.name; - } - - public boolean shouldAddCreative(){ - return true; - } - - protected void registerRendering(){ - ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this), new ResourceLocation(ModUtil.MOD_ID_LOWER, this.getBaseName())); - } - - @Override - public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack){ - return ItemUtil.areItemsEqual(this.repairItem, stack, false); - } - - @Override - public EnumRarity getRarity(ItemStack stack){ - return this.rarity; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemPickaxeAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemPickaxeAA.java deleted file mode 100644 index 30864b796..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemPickaxeAA.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This file ("ItemPickaxeAA.java") is part of the Actually Additions Mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense/ - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2016 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items.base; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import de.ellpeck.actuallyadditions.mod.util.ModUtil; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemPickaxe; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; - -public class ItemPickaxeAA extends ItemPickaxe{ - - private String name; - private EnumRarity rarity; - private ItemStack repairItem; - - public ItemPickaxeAA(ToolMaterial toolMat, ItemStack repairItem, String unlocalizedName, EnumRarity rarity){ - super(toolMat); - - this.repairItem = repairItem; - this.name = unlocalizedName; - this.rarity = rarity; - - this.register(); - } - - private void register(){ - ItemUtil.registerItem(this, this.getBaseName(), this.shouldAddCreative()); - - this.registerRendering(); - } - - protected String getBaseName(){ - return this.name; - } - - public boolean shouldAddCreative(){ - return true; - } - - protected void registerRendering(){ - ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this), new ResourceLocation(ModUtil.MOD_ID_LOWER, this.getBaseName())); - } - - @Override - public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack){ - return ItemUtil.areItemsEqual(this.repairItem, stack, false); - } - - @Override - public EnumRarity getRarity(ItemStack stack){ - return this.rarity; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemShovelAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemShovelAA.java deleted file mode 100644 index 50f4ed67f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemShovelAA.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * This file ("ItemShovelAA.java") is part of the Actually Additions Mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense/ - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2016 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items.base; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import de.ellpeck.actuallyadditions.mod.util.ModUtil; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemSpade; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; - -public class ItemShovelAA extends ItemSpade{ - - private String name; - private EnumRarity rarity; - private ItemStack repairItem; - - public ItemShovelAA(Item.ToolMaterial toolMat, ItemStack repairItem, String unlocalizedName, EnumRarity rarity){ - super(toolMat); - - this.repairItem = repairItem; - this.name = unlocalizedName; - this.rarity = rarity; - - this.register(); - } - - private void register(){ - ItemUtil.registerItem(this, this.getBaseName(), this.shouldAddCreative()); - - this.registerRendering(); - } - - protected String getBaseName(){ - return this.name; - } - - public boolean shouldAddCreative(){ - return true; - } - - protected void registerRendering(){ - ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this), new ResourceLocation(ModUtil.MOD_ID_LOWER, this.getBaseName())); - } - - @Override - public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack){ - return ItemUtil.areItemsEqual(this.repairItem, stack, false); - } - - @Override - public EnumRarity getRarity(ItemStack stack){ - return this.rarity; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemToolAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemToolAA.java new file mode 100644 index 000000000..4ae0753c3 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemToolAA.java @@ -0,0 +1,78 @@ +package de.ellpeck.actuallyadditions.mod.items.base; + +import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +import de.ellpeck.actuallyadditions.mod.util.ItemUtil; +import de.ellpeck.actuallyadditions.mod.util.ModUtil; +import net.minecraft.block.Block; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemTool; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; +import net.minecraftforge.oredict.OreDictionary; + +import java.util.HashSet; +import java.util.Set; + +public class ItemToolAA extends ItemTool{ + + private String name; + private EnumRarity rarity; + private ItemStack repairItem; + private String repairOredict; + + public ItemToolAA(float attack, float speed, ToolMaterial toolMat, String repairItem, String unlocalizedName, EnumRarity rarity, Set effectiveStuff){ + this(attack, speed, toolMat, (ItemStack)null, unlocalizedName, rarity, effectiveStuff); + this.repairOredict = repairItem; + } + + public ItemToolAA(float attack, float speed, ToolMaterial toolMat, ItemStack repairItem, String unlocalizedName, EnumRarity rarity, Set effectiveStuff){ + super(attack, speed, toolMat, effectiveStuff); + + this.repairItem = repairItem; + this.name = unlocalizedName; + this.rarity = rarity; + + this.register(); + } + + private void register(){ + ItemUtil.registerItem(this, this.getBaseName(), this.shouldAddCreative()); + + this.registerRendering(); + } + + protected String getBaseName(){ + return this.name; + } + + public boolean shouldAddCreative(){ + return true; + } + + protected void registerRendering(){ + ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this), new ResourceLocation(ModUtil.MOD_ID_LOWER, "itemPaxel")); + ActuallyAdditions.proxy.addRenderVariant(this, new ResourceLocation(ModUtil.MOD_ID_LOWER, "itemPaxel")); + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return this.rarity; + } + + @Override + public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack){ + if(this.repairItem != null){ + return ItemUtil.areItemsEqual(this.repairItem, stack, false); + } + else if(this.repairOredict != null){ + int[] idsStack = OreDictionary.getOreIDs(stack); + for(int id : idsStack){ + if(OreDictionary.getOreName(id).equals(this.repairOredict)){ + return true; + } + } + } + return false; + } +}