Skip to content

Commit

Permalink
Add a hook for the default color and use it for arrow fletchlings and…
Browse files Browse the repository at this point in the history
… bowstrings
  • Loading branch information
bonii-xx committed Sep 30, 2014
1 parent 7c3e21b commit f78d8af
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/main/java/tconstruct/items/tools/Arrow.java
Expand Up @@ -8,7 +8,10 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.crafting.ToolBuilder;
import tconstruct.library.tools.BowstringMaterial;
import tconstruct.library.tools.FletchingMaterial;
import tconstruct.library.tools.ToolCore;
import tconstruct.tools.TinkerTools;

Expand Down Expand Up @@ -41,6 +44,15 @@ public String getIconSuffix (int partType)
}
}

@Override
protected int getDefaultColor(int renderPass, int materialID) {
// fletchling uses custom material
if(renderPass == 2)
return TConstructRegistry.getCustomMaterial(materialID, FletchingMaterial.class).color;

return super.getDefaultColor(renderPass, materialID);
}

@Override
public String getEffectSuffix ()
{
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/tconstruct/items/tools/Shortbow.java
Expand Up @@ -9,6 +9,8 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.tools.BowstringMaterial;
import tconstruct.tools.TinkerTools;

public class Shortbow extends BowBase
Expand Down Expand Up @@ -37,6 +39,17 @@ public String getIconSuffix (int partType)
}
}


@Override
protected int getDefaultColor(int renderPass, int materialID) {
// bowstring uses custom material
if(renderPass == 0)
return TConstructRegistry.getCustomMaterial(materialID, BowstringMaterial.class).color;

return super.getDefaultColor(renderPass, materialID);
}


@Override
public String getEffectSuffix ()
{
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/tconstruct/library/tools/ToolCore.java
Expand Up @@ -675,7 +675,7 @@ public int getColorFromItemStack(ItemStack stack, int renderPass) {
return super.getColorFromItemStack(stack, renderPass);
}

private int getCorrectColor(ItemStack stack, int renderPass, NBTTagCompound tags, String key, Map<Integer, IIcon> map)
protected int getCorrectColor(ItemStack stack, int renderPass, NBTTagCompound tags, String key, Map<Integer, IIcon> map)
{
// custom coloring
if(tags.hasKey(key + "Color"))
Expand All @@ -687,7 +687,12 @@ private int getCorrectColor(ItemStack stack, int renderPass, NBTTagCompound tags
return super.getColorFromItemStack(stack, renderPass);

// color default texture with material color
return TConstructRegistry.getMaterial(matId).primaryColor();
return getDefaultColor(renderPass, matId);
}

protected int getDefaultColor(int renderPass, int materialID)
{
return TConstructRegistry.getMaterial(materialID).primaryColor();
}

@Override
Expand Down

0 comments on commit f78d8af

Please sign in to comment.