mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-23 11:49:23 +01:00
Made the game actually run
This commit is contained in:
parent
1e2732195d
commit
0499fbdf7f
9 changed files with 257 additions and 259 deletions
|
@ -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;
|
||||
|
|
|
@ -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<Block>());
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public ItemAllToolAA(ToolMaterial toolMat, ItemStack repairItem, String unlocalizedName, EnumRarity rarity, int color){
|
||||
super(4.0F, -2F, toolMat, new HashSet<Block>());
|
||||
|
||||
this.repairItem = repairItem;
|
||||
this.name = unlocalizedName;
|
||||
this.rarity = rarity;
|
||||
super(4.0F, -2F, toolMat, repairItem, unlocalizedName, rarity, new HashSet<Block>());
|
||||
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<String> getToolClasses(ItemStack stack){
|
||||
HashSet<String> hashSet = new HashSet<String>();
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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<Block> 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;
|
||||
}
|
||||
}
|
|
@ -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<Block> 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;
|
||||
}
|
||||
}
|
|
@ -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<Block> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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<Block> 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<Block> 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;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue