Skip to content

Commit

Permalink
Horns are no longer platings
Browse files Browse the repository at this point in the history
  • Loading branch information
Clashsoft committed Aug 5, 2014
1 parent 498505e commit b4bf814
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 41 deletions.
39 changes: 4 additions & 35 deletions src/main/java/minestrapteam/minestrappolation/item/ItemHorn.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

import net.minecraft.item.ItemStack;

public class ItemHorn extends MItem implements IPlating
public class ItemHorn extends MItem implements IItemAddon
{
public ItemHorn()
{
platings.put("horn", this);
addons.add(this);
}

Expand All @@ -24,49 +23,19 @@ public boolean canApply(ItemStack platable)
@Override
public void apply(ItemStack platable)
{
MItemTool.setPlating(platable, this);
MItemTool.setHorned(platable, true);
}

@Override
public void unapply(ItemStack platable)
{
MItemTool.setPlating(platable, null);
MItemTool.setHorned(platable, false);
}

@Override
public boolean isApplied(ItemStack platable)
{
return MItemTool.getPlating(platable) == this;
}

@Override
public String getType()
{
return "horn";
}

@Override
public String getType(ItemStack stack)
{
return "horn";
}

@Override
public float getEntityDamage()
{
return 1F;
}

@Override
public float getDigSpeed()
{
return 1.1F;
}

@Override
public int getDurability()
{
return 16;
return MItemTool.isHorned(platable);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class MItemSword extends ItemSword implements IPlatable
private ToolMaterial material;
private boolean ignites;

private IIcon hornIcon;
private Map<String, IIcon> overlayIcons = new HashMap();

public MItemSword(ToolMaterial material)
Expand Down Expand Up @@ -110,10 +111,18 @@ public boolean requiresMultipleRenderPasses()
return true;
}

@Override
public int getRenderPasses(int metadata)
{
return 3;
}

@Override
public void registerIcons(IIconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon(this.getIconString());
this.hornIcon = iconRegister.registerIcon(MAssetManager.getWeaponTexture("horned_sword_overlay"));

ItemStack thisStack = new ItemStack(this, 1, 0);

for (Entry<String, IPlating> e : IPlating.platings.entrySet())
Expand All @@ -137,14 +146,21 @@ public void registerIcons(IIconRegister iconRegister)
public IIcon getIcon(ItemStack stack, int renderPass)
{
IIcon icon = null;
if (renderPass == 1)
if (renderPass == 2)
{
IPlating plating = MItemTool.getPlating(stack);
if (plating != null)
{
icon = this.overlayIcons.get(plating.getType());
}
}
else if (renderPass == 1)
{
if (MItemTool.isHorned(stack))
{
icon = this.hornIcon;
}
}
return icon == null ? this.itemIcon : icon;
}
}
40 changes: 35 additions & 5 deletions src/main/java/minestrapteam/minestrappolation/item/MItemTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
public class MItemTool extends ItemTool implements IPlatable
{
public static final UUID PLATING_UUID = UUID.fromString("DB3F55D3-645C-4F38-A497-9C13A33DB5CF");
public static final UUID HORN_UUID = UUID.fromString("DB3F55D3-645C-4F38-A497-9C13A33DB5DF");

protected boolean ignites;
protected boolean weapon;
Expand Down Expand Up @@ -82,22 +83,40 @@ public static IPlating getPlating(ItemStack stack)
return null;
}

public static float getPoisonLevel(ItemStack stack)
public static void setPlating(ItemStack stack, IPlating plating)
{
if (stack.stackTagCompound == null)
{
stack.stackTagCompound = new NBTTagCompound();
}
stack.stackTagCompound.setString("Plating", plating == null ? "" : plating.getType());
}

public static boolean isHorned(ItemStack stack)
{
if (stack.stackTagCompound != null)
{
return stack.stackTagCompound.getFloat("PoisonLevel");
return stack.stackTagCompound.getBoolean("Horned");
}
return 0F;
return false;
}

public static void setPlating(ItemStack stack, IPlating plating)
public static void setHorned(ItemStack stack, boolean horned)
{
if (stack.stackTagCompound == null)
{
stack.stackTagCompound = new NBTTagCompound();
}
stack.stackTagCompound.setString("Plating", plating == null ? "" : plating.getType());
stack.stackTagCompound.setBoolean("Horned", horned);
}

public static float getPoisonLevel(ItemStack stack)
{
if (stack.stackTagCompound != null)
{
return stack.stackTagCompound.getFloat("PoisonLevel");
}
return 0F;
}

public static void setPoisonLevel(ItemStack stack, float level)
Expand Down Expand Up @@ -177,6 +196,11 @@ public static void addInformation(ItemStack stack, List list)
{
list.add(I18n.getString("item.poison_sword.desc", poisonLevel));
}

if (isHorned(stack))
{
list.add(I18n.getString("item.horned_sword.desc"));
}
}

@Override
Expand Down Expand Up @@ -255,6 +279,12 @@ public static Multimap getAttributeModifiers(Multimap multimap, ItemStack stack)
AttributeModifier modifier = new AttributeModifier(PLATING_UUID, "Plating Modifier", plating.getEntityDamage(), 0);
multimap.put("generic.attackDamage", modifier);
}

if (isHorned(stack))
{
AttributeModifier modifier = new AttributeModifier(PLATING_UUID, "Plating Modifier", 2, 0);
multimap.put("generic.attackDamage", modifier);
}
return multimap;
}

Expand Down

0 comments on commit b4bf814

Please sign in to comment.