Change StencilTable from hardcoded patterns to a flexible system

This commit is contained in:
Bernhard Bonigl committed 2014-08-20 19:15:16 +02:00
1 parent 49764fd251
commit 5dd0e0c8fa
4 files changed
+92 -36

No files matched your search

@@ -43,10 +43,7 @@ import tconstruct.items.tools.Shortbow;
import tconstruct.items.tools.Shovel;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.client.TConstructClientRegistry;
import tconstruct.library.crafting.Detailing;
import tconstruct.library.crafting.ModifyBuilder;
import tconstruct.library.crafting.PatternBuilder;
import tconstruct.library.crafting.ToolBuilder;
import tconstruct.library.crafting.*;
import tconstruct.library.tools.ToolCore;
import tconstruct.library.util.IPattern;
import tconstruct.modifiers.tools.ModAntiSpider;
@@ -358,6 +355,15 @@ public class TinkerTools
registerMaterials();
// register stencils/wooden patterns in the stencil table
StencilBuilder.registerBlankStencil(new ItemStack(TinkerTools.blankPattern));
for(int i = 1; i < 26; i++) {
if(i == 22) continue; // hide full guard
StencilBuilder.registerStencil(TinkerTools.woodPattern, i);
}
//TODO: Redesign stencil table to be a sensible block
TinkerTools.patternOutputs = new Item[] { TinkerTools.toolRod, TinkerTools.pickaxeHead, TinkerTools.shovelHead, TinkerTools.hatchetHead, TinkerTools.swordBlade, TinkerTools.wideGuard,
TinkerTools.handGuard, TinkerTools.crossbar, TinkerTools.binding, TinkerTools.frypanHead, TinkerTools.signHead, TinkerTools.knifeBlade, TinkerTools.chiselHead, TinkerTools.toughRod,
@@ -11,6 +11,7 @@ import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import tconstruct.TConstruct;
import tconstruct.library.crafting.StencilBuilder;
import tconstruct.tools.TinkerTools;
import tconstruct.tools.inventory.PatternShaperContainer;
import tconstruct.tools.logic.StencilTableLogic;
@@ -85,37 +86,24 @@ public class StencilTableGui extends GuiContainer
protected void actionPerformed (GuiButton button)
{
ItemStack pattern = logic.getStackInSlot(0);
if (pattern != null && pattern.getItem() == TinkerTools.blankPattern)
if (pattern != null && StencilBuilder.isBlank(pattern))
{
int meta = pattern.getItemDamage();
if (meta == 0)
if (button.id == 0)
{
if (button.id == 0)
{
patternIndex++;
if (patternIndex == 21)
patternIndex++;
if (patternIndex >= TinkerTools.patternOutputs.length - 1)
patternIndex = 0;
}
else if (button.id == 1)
{
patternIndex--;
if (patternIndex < 0)
patternIndex = TinkerTools.patternOutputs.length - 2;
if (patternIndex == 21)
patternIndex--;
}
ItemStack stack = new ItemStack(TinkerTools.woodPattern, 1, patternIndex + 1);
logic.setInventorySlotContents(1, stack);
updateServer(stack);
patternIndex++;
if (patternIndex >= StencilBuilder.getStencilCount() - 1)
patternIndex = 0;
}
/*else if (meta == 1 || meta == 2)
else if (button.id == 1)
{
ItemStack stack = new ItemStack(TContent.metalPattern, 1, 0);
logic.setInventorySlotContents(1, stack);
updateServer(stack);
}*/
patternIndex--;
if (patternIndex < 0)
patternIndex = StencilBuilder.getStencilCount() - 2;
}
ItemStack stack = StencilBuilder.getStencil(patternIndex);
logic.setInventorySlotContents(1, stack);
updateServer(stack);
}
}
@@ -7,6 +7,7 @@ import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import tconstruct.library.crafting.StencilBuilder;
import tconstruct.tools.TinkerTools;
import tconstruct.tools.inventory.PatternShaperContainer;
@@ -47,12 +48,9 @@ public class StencilTableLogic extends InventoryLogic implements ISidedInventory
public void setInventorySlotContents (int slot, ItemStack itemstack)
{
super.setInventorySlotContents(slot, itemstack);
if (slot == 0 && itemstack != null && itemstack.getItem() == TinkerTools.blankPattern)//instanceof tconstruct.items.Pattern)
if (slot == 0 && itemstack != null && StencilBuilder.isBlank(itemstack))
{
if (itemstack.getItemDamage() == 0)
setInventorySlotContents(1, new ItemStack(TinkerTools.woodPattern, 1, 1));
/*else if (itemstack.getItemDamage() == 1)
setInventorySlotContents(1, new ItemStack(TContent.metalPattern, 1, 0));*/
setInventorySlotContents(1, new ItemStack(TinkerTools.woodPattern, 1, 1));
}
}