mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-26 06:52:58 +00:00
Crafting Station can modify tools if near a Tool Station
This commit is contained in:
1 parent
faedd83413
commit
977287e440
6 files changed
+68
-30
No files matched your search
@@ -3,25 +3,23 @@ package tconstruct.blocks.logic;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import mantle.world.CoordTuple;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.inventory.CraftingStationContainer;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
public class CraftingStationLogic extends InventoryLogic implements ISidedInventory
|
||||
{
|
||||
/*public boolean chest;
|
||||
public boolean doubleChest;
|
||||
public boolean patternChest;
|
||||
public boolean nearbyFurnace;*/
|
||||
|
||||
|
||||
public WeakReference<IInventory> chest;
|
||||
public WeakReference<IInventory> doubleChest;
|
||||
public WeakReference<IInventory> patternChest;
|
||||
@@ -37,7 +35,6 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
//System.out.println("Getting container on side: "+FMLCommonHandler.instance().getEffectiveSide());
|
||||
chest = null;
|
||||
doubleChest = null;
|
||||
patternChest = null;
|
||||
@@ -47,7 +44,7 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
|
||||
{
|
||||
for (int xPos = x - 1; xPos <= x + 1; xPos++)
|
||||
{
|
||||
for (int zPos = z - 1; zPos <= x + 1; zPos++)
|
||||
for (int zPos = z - 1; zPos <= z + 1; zPos++)
|
||||
{
|
||||
TileEntity tile = world.getBlockTileEntity(xPos, yPos, zPos);
|
||||
if (chest == null && tile instanceof TileEntityChest)
|
||||
@@ -72,9 +69,6 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
|
||||
|
||||
void checkForChest (World world, int x, int y, int z)
|
||||
{
|
||||
if (doubleChest != null)
|
||||
return;
|
||||
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
if (tile instanceof TileEntityChest)
|
||||
doubleChest = new WeakReference(tile);
|
||||
@@ -96,7 +90,7 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int var1)
|
||||
{
|
||||
return new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
|
||||
return new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -57,6 +57,7 @@ public class ToolStationLogic extends InventoryLogic implements ISidedInventory
|
||||
|
||||
public void onInventoryChanged ()
|
||||
{
|
||||
System.out.println("Changed");
|
||||
buildTool(toolName);
|
||||
if (this.worldObj != null)
|
||||
{
|
||||
|
||||
@@ -312,6 +312,7 @@ public class CraftingStationGui extends GuiContainer
|
||||
private static final ResourceLocation icons = new ResourceLocation("tinker", "textures/gui/icons.png");
|
||||
private static final ResourceLocation chest = new ResourceLocation("tinker", "textures/gui/chestside.png");
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer (float par1, int par2, int par3)
|
||||
{
|
||||
// Draw the background
|
||||
|
||||
@@ -11,12 +11,15 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.blocks.logic.CraftingStationLogic;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
public class CraftingStationContainer extends Container
|
||||
{
|
||||
/** The crafting matrix inventory (3x3). */
|
||||
public InventoryCrafting craftMatrix;// = new InventoryCrafting(this, 3, 3);
|
||||
public IInventory craftResult;// = new InventoryCraftResult();
|
||||
private CraftingStationLogic logic;
|
||||
private World worldObj;
|
||||
private int posX;
|
||||
private int posY;
|
||||
@@ -28,6 +31,7 @@ public class CraftingStationContainer extends Container
|
||||
this.posX = x;
|
||||
this.posY = y;
|
||||
this.posZ = z;
|
||||
this.logic = logic;
|
||||
craftMatrix = new InventoryCraftingStation(this, 3, 3, logic);
|
||||
craftResult = new InventoryCraftingStationResult(logic);
|
||||
|
||||
@@ -84,7 +88,34 @@ public class CraftingStationContainer extends Container
|
||||
|
||||
public void onCraftMatrixChanged (IInventory par1IInventory)
|
||||
{
|
||||
this.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj));
|
||||
ItemStack tool = modifyTool();
|
||||
if (tool != null)
|
||||
this.craftResult.setInventorySlotContents(0, tool);
|
||||
else
|
||||
this.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ItemStack modifyTool ()
|
||||
{
|
||||
ItemStack input = craftResult.getStackInSlot(5);
|
||||
if (input != null)
|
||||
{
|
||||
if (input.getItem() instanceof ToolCore)
|
||||
{
|
||||
ItemStack[] slots = new ItemStack[8];
|
||||
for (int i = 0; i < 0; i++)
|
||||
{
|
||||
slots[i] = craftResult.getStackInSlot(i + 1);
|
||||
slots[i + 4] = craftResult.getStackInSlot(i + 6);
|
||||
}
|
||||
ItemStack output = ToolBuilder.instance.modifyTool(input, slots, "");
|
||||
if (output != null)
|
||||
return output;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void onContainerClosed (EntityPlayer par1EntityPlayer)
|
||||
|
||||
@@ -44,7 +44,7 @@ public class SpecialFood extends ItemFood
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIconFromDamage (int meta)
|
||||
{
|
||||
return icons[meta];
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -144,12 +144,6 @@ public class ToolBuilder
|
||||
ToolCore item;
|
||||
boolean validMaterials = true;
|
||||
int head = -1, handle = -1, accessory = -1, extra = -1;
|
||||
/*if (headStack.getItem() instanceof IToolPart)
|
||||
{
|
||||
head = ((IToolPart) headStack.getItem()).getMaterialID(headStack);
|
||||
}
|
||||
else
|
||||
validMaterials = false;*/
|
||||
head = getMaterialID(headStack);
|
||||
if (head == -1)
|
||||
validMaterials = false;
|
||||
@@ -157,14 +151,6 @@ public class ToolBuilder
|
||||
handle = getMaterialID(handleStack);
|
||||
if (handle == -1)
|
||||
validMaterials = false;
|
||||
/*if (handleItem == Item.stick)
|
||||
handle = 0;
|
||||
else if (handleItem == Item.bone)
|
||||
handle = 5;
|
||||
else if (handleItem instanceof IToolPart)
|
||||
handle = ((IToolPart) handleItem).getMaterialID(handleStack);
|
||||
else
|
||||
validMaterials = false;*/
|
||||
|
||||
if (!validMaterials)
|
||||
return null;
|
||||
@@ -363,9 +349,34 @@ public class ToolBuilder
|
||||
return tool;
|
||||
}
|
||||
|
||||
public ItemStack modifyTool (ItemStack input, ItemStack[] modifiers, String name)
|
||||
public ItemStack modifyTool (ItemStack input, ItemStack[] slots, String name)
|
||||
{
|
||||
return null;
|
||||
ItemStack tool = input.copy();
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
tags.removeTag("Built");
|
||||
|
||||
boolean built = false;
|
||||
for (ToolMod mod : toolMods)
|
||||
{
|
||||
if (mod.matches(slots, tool))
|
||||
{
|
||||
built = true;
|
||||
mod.addMatchingEffect(tool);
|
||||
mod.modify(slots, tool);
|
||||
}
|
||||
}
|
||||
|
||||
tags = tool.getTagCompound();
|
||||
if (name != null && !name.equals("") && !tags.hasKey("display"))
|
||||
{
|
||||
tags.setCompoundTag("display", new NBTTagCompound());
|
||||
tags.getCompoundTag("display").setString("Name", "\u00A7f" + name);
|
||||
}
|
||||
|
||||
if (built)
|
||||
return tool;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack modifyArmor (ItemStack input, ItemStack[] slots, String name)
|
||||
|
||||
Reference in new issue
Block a user