Worked on tools a bit

This commit is contained in:
DarkGuardsman 2013-11-05 03:39:39 -05:00
parent 2119b5043b
commit f87eec9af1
3 changed files with 73 additions and 30 deletions

View file

@ -20,17 +20,17 @@ public enum EnumMaterial
WOOD("Wood", EnumToolMaterial.WOOD, EnumOrePart.INGOTS, EnumOrePart.PLATES, EnumOrePart.RUBBLE, EnumOrePart.ROD, EnumOrePart.GEARS),
STONE("Stone", EnumToolMaterial.STONE, EnumOrePart.INGOTS, EnumOrePart.SCRAPS),
IRON("Iron", EnumToolMaterial.IRON, EnumOrePart.INGOTS),
OBBY("Obby", true, 7.0f, 500, EnumOrePart.INGOTS, EnumOrePart.RUBBLE, EnumOrePart.SCRAPS, EnumOrePart.PLATES),
OBBY("Obby", true, 7.0f, 500, 4, EnumOrePart.INGOTS, EnumOrePart.RUBBLE, EnumOrePart.SCRAPS, EnumOrePart.PLATES),
GOLD("Gold", EnumToolMaterial.GOLD, EnumOrePart.GEARS, EnumOrePart.INGOTS),
COAL("Coal", EnumToolMaterial.WOOD, EnumOrePart.GEARS, EnumOrePart.TUBE, EnumOrePart.PLATES, EnumOrePart.RUBBLE, EnumOrePart.SCRAPS),
COPPER("Copper", true, 3.5f, 79),
TIN("Tin", true, 2.0f, 50, EnumOrePart.GEARS, EnumOrePart.TUBE),
LEAD("Lead", false, 0, 0, EnumOrePart.GEARS, EnumOrePart.TUBE),
ALUMINIUM("Aluminum", true, 5.0f, 100, EnumOrePart.GEARS, EnumOrePart.TUBE),
SILVER("Silver", true, 11.0f, 30, EnumOrePart.GEARS),
STEEL("Steel", true, 7.0f, 1000, EnumOrePart.RUBBLE),
BRONZE("Bronze", true, 6.5f, 560, EnumOrePart.RUBBLE);
COPPER("Copper", true, 3.5f, 79, 1),
TIN("Tin", true, 2.0f, 50, 1, EnumOrePart.GEARS, EnumOrePart.TUBE),
LEAD("Lead", false, 0, 0, 1, EnumOrePart.GEARS, EnumOrePart.TUBE),
ALUMINIUM("Aluminum", true, 5.0f, 100, 2, EnumOrePart.GEARS, EnumOrePart.TUBE),
SILVER("Silver", true, 11.0f, 30, 0, EnumOrePart.GEARS),
STEEL("Steel", true, 7.0f, 4, 1000, EnumOrePart.RUBBLE),
BRONZE("Bronze", true, 6.5f, 3, 560, EnumOrePart.RUBBLE);
/** Name of the material */
public String simpleName;
@ -52,18 +52,20 @@ public enum EnumMaterial
public float materialEffectiveness = 2.0f;
public int maxUses = 100;
public float damageBoost = 0;
private EnumMaterial(String name, EnumToolMaterial material, EnumOrePart... enumOreParts)
{
this(name, false, material.getEfficiencyOnProperMaterial(), material.getMaxUses(), enumOreParts);
this(name, false, material.getEfficiencyOnProperMaterial(), material.getMaxUses(), material.getDamageVsEntity(), enumOreParts);
}
private EnumMaterial(String name, boolean tool, float effectiveness, int toolUses, EnumOrePart... enumOreParts)
private EnumMaterial(String name, boolean tool, float effectiveness, int toolUses, float damage, EnumOrePart... enumOreParts)
{
this.simpleName = name;
this.hasTools = tool;
this.materialEffectiveness = effectiveness;
this.maxUses = toolUses;
this.damageBoost = damage;
unneedItems = new ArrayList<EnumOrePart>();
for (int i = 0; enumOreParts != null && i < enumOreParts.length; i++)
{

View file

@ -13,9 +13,9 @@ public enum EnumTool
PICKAX("pickaxe", Material.rock, Material.iron, Material.ice, Material.anvil, Material.glass, Material.tnt, Material.piston),
AX("axe", Material.wood, Material.pumpkin, Material.plants, Material.vine),
SPADE("shovel", Material.sand, Material.snow, Material.clay, Material.craftedSnow, Material.grass, Material.ground),
HOE("hoe"),
HOE("hoe", Material.plants, Material.pumpkin),
SHEAR("shear", Material.cloth, Material.circuits, Material.web),
NA5(),
SWORD("sword", false, Material.web, Material.vine, Material.coral, Material.pumpkin, Material.leaves, Material.plants),
NA6(),
NA7(),
NA8(),
@ -30,13 +30,18 @@ public enum EnumTool
}
private EnumTool(String name, Material... mats)
private EnumTool(String name, boolean enabled, Material... mats)
{
this.name = name;
this.enabled = true;
this.setEffectiveList(mats);
}
private EnumTool(String name, Material... mats)
{
this(name, true, mats);
}
public void setEffectiveList(Material... blocks)
{
for (Material block : blocks)

View file

@ -1,6 +1,7 @@
package dark.core.common.items;
import java.awt.Color;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@ -17,9 +18,11 @@ import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.stats.StatList;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
@ -30,6 +33,7 @@ import net.minecraftforge.event.Event.Result;
import net.minecraftforge.event.entity.player.UseHoeEvent;
import net.minecraftforge.oredict.OreDictionary;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import cpw.mods.fml.relauncher.Side;
@ -59,16 +63,24 @@ public class ItemCommonTool extends Item implements IExtraItemInfo
}
@Override
public void onCreated(ItemStack itemStack, World par2World, EntityPlayer entityPlayer)
public void onCreated(ItemStack itemStack, World world, EntityPlayer entityPlayer)
{
if (itemStack.stackTagCompound == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
itemStack.getTagCompound().setString("Creator", entityPlayer.username);
itemStack.getTagCompound().setString("Creator", (entityPlayer != null ? entityPlayer.username : "Magical Dwarfs"));
itemStack.getTagCompound().setInteger("ToolID", itemStack.getItemDamage());
}
@Override
public Multimap getItemAttributeModifiers()
{
Multimap multimap = super.getItemAttributeModifiers();
multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Tool modifier", 6, 0));
return multimap;
}
@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4)
{
@ -165,6 +177,36 @@ public class ItemCommonTool extends Item implements IExtraItemInfo
return false;
}
@Override
public EnumAction getItemUseAction(ItemStack par1ItemStack)
{
if (EnumMaterial.getToolFromMeta(par1ItemStack.getItemDamage()) == EnumTool.SWORD)
{
return EnumAction.block;
}
return super.getItemUseAction(par1ItemStack);
}
@Override
public int getMaxItemUseDuration(ItemStack par1ItemStack)
{
if (EnumMaterial.getToolFromMeta(par1ItemStack.getItemDamage()) == EnumTool.SWORD)
{
return 72000;
}
return super.getMaxItemUseDuration(par1ItemStack);
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
if (EnumMaterial.getToolFromMeta(par1ItemStack.getItemDamage()) == EnumTool.SWORD)
{
par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
}
return par1ItemStack;
}
@Override
public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer player, EntityLivingBase entity)
{
@ -297,7 +339,7 @@ public class ItemCommonTool extends Item implements IExtraItemInfo
@Override
public boolean hitEntity(ItemStack itemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase)
{
this.damage(itemStack, 2, par2EntityLivingBase);
this.damage(itemStack, EnumMaterial.getToolFromMeta(itemStack.getItemDamage()) == EnumTool.SWORD ? 1 : 2, par2EntityLivingBase);
return true;
}
@ -310,7 +352,7 @@ public class ItemCommonTool extends Item implements IExtraItemInfo
}
if (Block.blocksList[par3].getBlockHardness(par2World, par4, par5, par6) != 0.0D)
{
this.damage(itemStack, 1, par7EntityLivingBase);
this.damage(itemStack, EnumMaterial.getToolFromMeta(itemStack.getItemDamage()) == EnumTool.SWORD ? 2 : 1, par7EntityLivingBase);
}
return true;
@ -336,14 +378,6 @@ public class ItemCommonTool extends Item implements IExtraItemInfo
return false;
}
@Override
public Multimap getItemAttributeModifiers()
{
Multimap multimap = super.getItemAttributeModifiers();
multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Tool modifier", 3.0, 0));
return multimap;
}
@Override
public float getStrVsBlock(ItemStack itemStack, Block block)
{
@ -461,7 +495,9 @@ public class ItemCommonTool extends Item implements IExtraItemInfo
ItemStack stack = EnumMaterial.getTool(tool, mat);
if (tool.enabled && stack != null)
{
this.onCreated(stack, null, null);
par3List.add(stack);
}
}
}