mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-10-26 14:33:50 +00:00
Allow coloring of tools, made Tool Recipes Itemstack sensitive to allow more customizable recipes
This commit is contained in:
1 parent
11cd2011e8
commit
22bdbdd209
4 files changed
+74
-35
No files matched your search
@@ -29,8 +29,8 @@ public class ToolBuilder
|
||||
ToolRecipe recipe = instance.recipeList.get(output.getToolName());
|
||||
if (recipe != null)
|
||||
{
|
||||
recipe.addHeadItem(head);
|
||||
recipe.addHandleItem(handle);
|
||||
recipe.addHeadItem(new ItemStack(head,1));
|
||||
recipe.addHandleItem(new ItemStack(handle));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -46,9 +46,9 @@ public class ToolBuilder
|
||||
ToolRecipe recipe = instance.recipeList.get(output.getToolName());
|
||||
if (recipe != null)
|
||||
{
|
||||
recipe.addHeadItem(head);
|
||||
recipe.addHandleItem(handle);
|
||||
recipe.addAccessoryItem(accessory);
|
||||
recipe.addHeadItem(new ItemStack(head));
|
||||
recipe.addHandleItem(new ItemStack(handle));
|
||||
recipe.addAccessoryItem(new ItemStack(accessory));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -63,10 +63,10 @@ public class ToolBuilder
|
||||
ToolRecipe recipe = instance.recipeList.get(output.getToolName());
|
||||
if (recipe != null)
|
||||
{
|
||||
recipe.addHeadItem(head);
|
||||
recipe.addHandleItem(handle);
|
||||
recipe.addAccessoryItem(accessory);
|
||||
recipe.addExtraItem(extra);
|
||||
recipe.addHeadItem(new ItemStack(head));
|
||||
recipe.addHandleItem(new ItemStack(handle));
|
||||
recipe.addAccessoryItem(new ItemStack(accessory));
|
||||
recipe.addExtraItem(new ItemStack(extra));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -91,7 +91,7 @@ public class ToolBuilder
|
||||
addNormalToolRecipe(output, items[0], items[1], items[2], items[3]);
|
||||
}
|
||||
|
||||
public ToolCore getMatchingRecipe (Item head, Item handle, Item accessory, Item extra)
|
||||
public ToolCore getMatchingRecipe (ItemStack head, ItemStack handle, ItemStack accessory, ItemStack extra)
|
||||
{
|
||||
for (ToolRecipe recipe : combos)
|
||||
{
|
||||
@@ -156,7 +156,7 @@ public class ToolBuilder
|
||||
|
||||
if (accessoryStack == null)
|
||||
{
|
||||
item = getMatchingRecipe(headStack.getItem(), handleStack.getItem(), null, null);
|
||||
item = getMatchingRecipe(headStack, handleStack, null, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -172,11 +172,11 @@ public class ToolBuilder
|
||||
if (extra == -1)
|
||||
return null;
|
||||
|
||||
item = getMatchingRecipe(headStack.getItem(), handleStack.getItem(), accessoryStack.getItem(), extraStack.getItem());
|
||||
item = getMatchingRecipe(headStack, handleStack, accessoryStack, extraStack);
|
||||
}
|
||||
else
|
||||
{
|
||||
item = getMatchingRecipe(headStack.getItem(), handleStack.getItem(), accessoryStack.getItem(), null);
|
||||
item = getMatchingRecipe(headStack, handleStack, accessoryStack, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package tconstruct.library.crafting;
|
||||
import java.util.LinkedList;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
@@ -45,49 +46,49 @@ public class ToolRecipe
|
||||
result = tool;
|
||||
}
|
||||
|
||||
public void addHeadItem (Item head)
|
||||
public void addHeadItem (ItemStack head)
|
||||
{
|
||||
this.headList.add(head);
|
||||
this.headList.add(head.getItem());
|
||||
}
|
||||
|
||||
public void addHandleItem (Item head)
|
||||
public void addHandleItem (ItemStack handle)
|
||||
{
|
||||
this.handleList.add(head);
|
||||
this.handleList.add(handle.getItem());
|
||||
}
|
||||
|
||||
public void addAccessoryItem (Item head)
|
||||
public void addAccessoryItem (ItemStack accessory)
|
||||
{
|
||||
this.accessoryList.add(head);
|
||||
this.accessoryList.add(accessory.getItem());
|
||||
}
|
||||
|
||||
public void addExtraItem (Item head)
|
||||
public void addExtraItem (ItemStack extra)
|
||||
{
|
||||
this.extraList.add(head);
|
||||
this.extraList.add(extra.getItem());
|
||||
}
|
||||
|
||||
public boolean validHead (Item input)
|
||||
public boolean validHead (ItemStack input)
|
||||
{
|
||||
for (Item part : headList)
|
||||
{
|
||||
if (part == input)
|
||||
if (part == input.getItem())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean validHandle (Item input)
|
||||
public boolean validHandle (ItemStack input)
|
||||
{
|
||||
for (Item part : handleList)
|
||||
{
|
||||
if (part == input)
|
||||
if (part == input.getItem())
|
||||
return true;
|
||||
if (toolRod != null && part == toolRod && (input == Items.stick || input == Items.bone))
|
||||
if (toolRod != null && part == toolRod && (input.getItem() == Items.stick || input.getItem() == Items.bone))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean validAccessory (Item input)
|
||||
public boolean validAccessory (ItemStack input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
@@ -97,15 +98,15 @@ public class ToolRecipe
|
||||
}
|
||||
for (Item part : accessoryList)
|
||||
{
|
||||
if (part == input)
|
||||
if (part == input.getItem())
|
||||
return true;
|
||||
if (toolRod != null && part == toolRod && (input == Items.stick || input == Items.bone))
|
||||
if (toolRod != null && part == toolRod && (input.getItem() == Items.stick || input.getItem() == Items.bone))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean validExtra (Item input)
|
||||
public boolean validExtra (ItemStack input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
@@ -115,9 +116,9 @@ public class ToolRecipe
|
||||
}
|
||||
for (Item part : extraList)
|
||||
{
|
||||
if (part == input)
|
||||
if (part == input.getItem())
|
||||
return true;
|
||||
if (toolRod != null && part == toolRod && (input == Items.stick || input == Items.bone))
|
||||
if (toolRod != null && part == toolRod && (input.getItem() == Items.stick || input.getItem() == Items.bone))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -662,6 +662,43 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem, IMo
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
|
||||
public static HashMap<Integer, Integer> materialColorMap = new HashMap<Integer, Integer>();
|
||||
|
||||
@Override
|
||||
public int getColorFromItemStack(ItemStack stack, int renderPass) {
|
||||
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
|
||||
if (tags != null)
|
||||
{
|
||||
tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (renderPass < getPartAmount())
|
||||
{
|
||||
if (renderPass == 0 && materialColorMap.containsKey(tags.getInteger("Handle"))) // Handle
|
||||
{
|
||||
return materialColorMap.get(tags.getInteger("Handle"));
|
||||
}
|
||||
|
||||
else if (renderPass == 1 && materialColorMap.containsKey(tags.getInteger("Head"))) // Head
|
||||
{
|
||||
return materialColorMap.get(tags.getInteger("Head"));
|
||||
}
|
||||
|
||||
else if (renderPass == 2 && materialColorMap.containsKey(tags.getInteger("Accessory"))) // Accessory
|
||||
{
|
||||
return materialColorMap.get(tags.getInteger("Accessory"));
|
||||
}
|
||||
|
||||
else if (renderPass == 3 && materialColorMap.containsKey(tags.getInteger("Extra"))) // Extra
|
||||
{
|
||||
return materialColorMap.get(tags.getInteger("Extra"));
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.getColorFromItemStack(stack, renderPass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@ package tconstruct.tools;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.library.crafting.ToolRecipe;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
@@ -24,13 +25,13 @@ public class BowRecipe extends ToolRecipe
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validHead (Item input)
|
||||
public boolean validHead (ItemStack input)
|
||||
{
|
||||
for (Item part : headList)
|
||||
{
|
||||
if (part == input)
|
||||
if (part == input.getItem())
|
||||
return true;
|
||||
if (toolRod != null && part == toolRod && (input == Items.stick || input == Items.bone))
|
||||
if (toolRod != null && part == toolRod && (input.getItem() == Items.stick || input.getItem() == Items.bone))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user