mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-27 15:33:03 +00:00
part chest / add pattern chest for stencil table / fix manual render postition (#258)
Co-authored-by: Martin Robertz <[email protected]> Co-authored-by: zyf051520 <[email protected]> Co-authored-by: Caedis <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: iouter <[email protected]>
This commit is contained in:
35 files changed
+1042
-222
No files matched your search
@@ -109,6 +109,7 @@ import tconstruct.tools.logic.CraftingStationLogic;
|
||||
import tconstruct.tools.logic.FrypanLogic;
|
||||
import tconstruct.tools.logic.FurnaceLogic;
|
||||
import tconstruct.tools.logic.PartBuilderLogic;
|
||||
import tconstruct.tools.logic.PartChestLogic;
|
||||
import tconstruct.tools.logic.PatternChestLogic;
|
||||
import tconstruct.tools.logic.StencilTableLogic;
|
||||
import tconstruct.tools.logic.ToolForgeLogic;
|
||||
@@ -251,6 +252,7 @@ public class TinkerTools {
|
||||
GameRegistry.registerTileEntity(ToolStationLogic.class, "ToolStation");
|
||||
GameRegistry.registerTileEntity(PartBuilderLogic.class, "PartCrafter");
|
||||
GameRegistry.registerTileEntity(PatternChestLogic.class, "PatternHolder");
|
||||
GameRegistry.registerTileEntity(PartChestLogic.class, "PartHolder");
|
||||
GameRegistry.registerTileEntity(StencilTableLogic.class, "PatternShaper");
|
||||
GameRegistry.registerBlock(TinkerTools.toolForge, MetadataItemBlock.class, "ToolForgeBlock");
|
||||
GameRegistry.registerTileEntity(ToolForgeLogic.class, "ToolForge");
|
||||
|
||||
@@ -52,6 +52,7 @@ import tconstruct.tools.gui.BattlesignGui;
|
||||
import tconstruct.tools.gui.CraftingStationGui;
|
||||
import tconstruct.tools.gui.FrypanGui;
|
||||
import tconstruct.tools.gui.FurnaceGui;
|
||||
import tconstruct.tools.gui.PartChestGui;
|
||||
import tconstruct.tools.gui.PartCrafterGui;
|
||||
import tconstruct.tools.gui.PatternChestGui;
|
||||
import tconstruct.tools.gui.StencilTableGui;
|
||||
@@ -62,6 +63,7 @@ import tconstruct.tools.logic.CraftingStationLogic;
|
||||
import tconstruct.tools.logic.FrypanLogic;
|
||||
import tconstruct.tools.logic.FurnaceLogic;
|
||||
import tconstruct.tools.logic.PartBuilderLogic;
|
||||
import tconstruct.tools.logic.PartChestLogic;
|
||||
import tconstruct.tools.logic.PatternChestLogic;
|
||||
import tconstruct.tools.logic.StencilTableLogic;
|
||||
import tconstruct.tools.logic.ToolForgeLogic;
|
||||
@@ -297,6 +299,7 @@ public class ToolProxyClient extends ToolProxyCommon {
|
||||
MantleClientRegistry.registerManualIcon("toolstation", new ItemStack(TinkerTools.toolStationWood, 1, 0));
|
||||
MantleClientRegistry.registerManualIcon("partcrafter", new ItemStack(TinkerTools.toolStationWood, 1, 1));
|
||||
MantleClientRegistry.registerManualIcon("patternchest", new ItemStack(TinkerTools.toolStationWood, 1, 5));
|
||||
MantleClientRegistry.registerManualIcon("partchest", new ItemStack(TinkerTools.toolStationWood, 1, 6));
|
||||
MantleClientRegistry.registerManualIcon("stenciltable", new ItemStack(TinkerTools.toolStationWood, 1, 10));
|
||||
|
||||
// TODO: Untwine this
|
||||
@@ -397,6 +400,13 @@ public class ToolProxyClient extends ToolProxyCommon {
|
||||
pattern,
|
||||
null,
|
||||
chest);
|
||||
MantleClientRegistry.registerManualSmallRecipe(
|
||||
"partchest",
|
||||
new ItemStack(TinkerTools.toolStationWood, 1, 6),
|
||||
null,
|
||||
stick,
|
||||
null,
|
||||
chest);
|
||||
MantleClientRegistry.registerManualSmallRecipe(
|
||||
"stenciltable",
|
||||
new ItemStack(TinkerTools.toolStationWood, 1, 10),
|
||||
@@ -596,6 +606,7 @@ public class ToolProxyClient extends ToolProxyCommon {
|
||||
TProxyCommon.registerClientGuiHandler(toolStationID, this);
|
||||
TProxyCommon.registerClientGuiHandler(partBuilderID, this);
|
||||
TProxyCommon.registerClientGuiHandler(patternChestID, this);
|
||||
TProxyCommon.registerClientGuiHandler(partChestID, this);
|
||||
TProxyCommon.registerClientGuiHandler(stencilTableID, this);
|
||||
TProxyCommon.registerClientGuiHandler(frypanGuiID, this);
|
||||
TProxyCommon.registerClientGuiHandler(toolForgeID, this);
|
||||
@@ -627,6 +638,8 @@ public class ToolProxyClient extends ToolProxyCommon {
|
||||
x,
|
||||
y,
|
||||
z);
|
||||
if (ID == ToolProxyCommon.partChestID)
|
||||
return new PartChestGui(player.inventory, (PartChestLogic) world.getTileEntity(x, y, z), world, x, y, z);
|
||||
if (ID == ToolProxyCommon.frypanGuiID)
|
||||
return new FrypanGui(player.inventory, (FrypanLogic) world.getTileEntity(x, y, z), world, x, y, z);
|
||||
if (ID == ToolProxyCommon.battlesignTextID)
|
||||
@@ -683,13 +696,13 @@ public class ToolProxyClient extends ToolProxyCommon {
|
||||
{ 10, 2 }, // excavator head
|
||||
{ 6, 2 }, // lumberaxe head
|
||||
{ 9, 2 }, // large plate
|
||||
{}, { 4, 2 }, // frying pan
|
||||
{ 4, 2 }, // frying pan
|
||||
{ 5, 2 }, // battlesign
|
||||
{ 7, 3 }, // chisel
|
||||
{}, { 7, 2 }, // knifeblade
|
||||
{ 7, 2 }, // knifeblade
|
||||
{ 1, 2 }, // swordblade
|
||||
{ 6, 3 }, // cleaver blade
|
||||
{}, { 4, 3 }, // crossbar
|
||||
{ 4, 3 }, // crossbar
|
||||
{ 3, 3 }, // small guard
|
||||
{ 2, 3 }, // wide guard
|
||||
};
|
||||
|
||||
@@ -16,6 +16,7 @@ public class ToolProxyCommon implements IGuiHandler {
|
||||
public static final int stencilTableID = 3;
|
||||
public static final int frypanGuiID = 4;
|
||||
public static final int toolForgeID = 5;
|
||||
public static final int partChestID = 6;
|
||||
public static final int furnaceID = 8;
|
||||
public static final int craftingStationID = 11;
|
||||
public static final int battlesignTextID = 12;
|
||||
@@ -33,6 +34,7 @@ public class ToolProxyCommon implements IGuiHandler {
|
||||
TProxyCommon.registerServerGuiHandler(stencilTableID, this);
|
||||
TProxyCommon.registerServerGuiHandler(frypanGuiID, this);
|
||||
TProxyCommon.registerServerGuiHandler(toolForgeID, this);
|
||||
TProxyCommon.registerServerGuiHandler(partChestID, this);
|
||||
TProxyCommon.registerServerGuiHandler(furnaceID, this);
|
||||
TProxyCommon.registerServerGuiHandler(craftingStationID, this);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.tools.ToolProxyCommon;
|
||||
import tconstruct.tools.logic.CraftingStationLogic;
|
||||
import tconstruct.tools.logic.PartBuilderLogic;
|
||||
import tconstruct.tools.logic.PartChestLogic;
|
||||
import tconstruct.tools.logic.PatternChestLogic;
|
||||
import tconstruct.tools.logic.StencilTableLogic;
|
||||
import tconstruct.tools.logic.ToolForgeLogic;
|
||||
@@ -47,7 +48,8 @@ public class CraftingSlab extends InventorySlab {
|
||||
"toolstation_top", "toolstation_slab_side", "toolstation_bottom", "partbuilder_oak_top",
|
||||
"partbuilder_slab_side", "partbuilder_oak_bottom", "stenciltable_oak_top", "stenciltable_slab_side",
|
||||
"stenciltable_oak_bottom", "patternchest_top", "patternchest_slab_side", "patternchest_bottom",
|
||||
"toolforge_top", "toolforge_slab_side", "toolforge_top" };
|
||||
"toolforge_top", "toolforge_slab_side", "toolforge_top", "partchest_top", "partchest_slab_side",
|
||||
"partchest_bottom" };
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,7 +73,7 @@ public class CraftingSlab extends InventorySlab {
|
||||
@Override
|
||||
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
if (metadata == 5) return AxisAlignedBB.getBoundingBox(
|
||||
if (metadata == 5 || metadata == 6) return AxisAlignedBB.getBoundingBox(
|
||||
(double) x + this.minX,
|
||||
(double) y + this.minY,
|
||||
(double) z + this.minZ,
|
||||
@@ -96,6 +98,7 @@ public class CraftingSlab extends InventorySlab {
|
||||
case 3 -> new StencilTableLogic();
|
||||
case 4 -> new PatternChestLogic();
|
||||
case 5 -> new ToolForgeLogic();
|
||||
case 6 -> new PartChestLogic();
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
@@ -110,6 +113,7 @@ public class CraftingSlab extends InventorySlab {
|
||||
case 3 -> ToolProxyCommon.stencilTableID;
|
||||
case 4 -> ToolProxyCommon.patternChestID;
|
||||
case 5 -> ToolProxyCommon.toolForgeID;
|
||||
case 6 -> ToolProxyCommon.partChestID;
|
||||
default -> -1;
|
||||
};
|
||||
|
||||
@@ -122,7 +126,7 @@ public class CraftingSlab extends InventorySlab {
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item b, CreativeTabs tab, List<ItemStack> list) {
|
||||
for (int iter = 0; iter < 6; iter++) {
|
||||
for (int iter = 0; iter < 7; iter++) {
|
||||
list.add(new ItemStack(b, 1, iter));
|
||||
}
|
||||
}
|
||||
@@ -163,6 +167,7 @@ public class CraftingSlab extends InventorySlab {
|
||||
case 3 -> new StencilTableLogic();
|
||||
case 4 -> new PatternChestLogic();
|
||||
case 5 -> new ToolForgeLogic();
|
||||
case 6 -> new PartChestLogic();
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -21,12 +21,15 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import mantle.blocks.abstracts.InventoryBlock;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.tools.logic.PartBuilderLogic;
|
||||
import tconstruct.tools.logic.PartChestLogic;
|
||||
import tconstruct.tools.logic.PatternChestLogic;
|
||||
import tconstruct.tools.logic.StencilTableLogic;
|
||||
import tconstruct.tools.logic.TiCChestLogic;
|
||||
import tconstruct.tools.logic.ToolStationLogic;
|
||||
import tconstruct.tools.model.TableRender;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
@@ -50,21 +53,28 @@ public class ToolStationBlock extends InventoryBlock {
|
||||
"partbuilder_spruce_bottom", "partbuilder_birch_top", "partbuilder_birch_side",
|
||||
"partbuilder_birch_bottom", "partbuilder_jungle_top", "partbuilder_jungle_side",
|
||||
"partbuilder_jungle_bottom", "patternchest_top", "patternchest_side", "patternchest_bottom",
|
||||
"stenciltable_oak_top", "stenciltable_oak_side", "stenciltable_oak_bottom", "stenciltable_spruce_top",
|
||||
"stenciltable_spruce_side", "stenciltable_spruce_bottom", "stenciltable_birch_top",
|
||||
"stenciltable_birch_side", "stenciltable_birch_bottom", "stenciltable_jungle_top",
|
||||
"stenciltable_jungle_side", "stenciltable_jungle_bottom" };
|
||||
"partchest_top", "partchest_side", "partchest_bottom", "stenciltable_oak_top", "stenciltable_oak_side",
|
||||
"stenciltable_oak_bottom", "stenciltable_spruce_top", "stenciltable_spruce_side",
|
||||
"stenciltable_spruce_bottom", "stenciltable_birch_top", "stenciltable_birch_side",
|
||||
"stenciltable_birch_bottom", "stenciltable_jungle_top", "stenciltable_jungle_side",
|
||||
"stenciltable_jungle_bottom" };
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
if (meta <= 4) {
|
||||
// toolstation && partbuilder
|
||||
return icons[meta * 3 + getTextureIndex(side)];
|
||||
} else if (meta <= 9) {
|
||||
} else if (meta == 5) {
|
||||
// patternchest meta == 5
|
||||
return icons[15 + getTextureIndex(side)];
|
||||
} else if (meta <= 9) {
|
||||
// partchest meta == 6
|
||||
return icons[18 + getTextureIndex(side)];
|
||||
} else {
|
||||
return icons[meta * 3 + getTextureIndex(side) - 12];
|
||||
// stenciltable
|
||||
return icons[meta * 3 + getTextureIndex(side) - 9];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +113,7 @@ public class ToolStationBlock extends InventoryBlock {
|
||||
@Override
|
||||
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
if (metadata == 5) return AxisAlignedBB.getBoundingBox(
|
||||
if (metadata == 5 || metadata == 6) return AxisAlignedBB.getBoundingBox(
|
||||
(double) x + this.minX,
|
||||
(double) y + this.minY,
|
||||
(double) z + this.minZ,
|
||||
@@ -124,7 +134,8 @@ public class ToolStationBlock extends InventoryBlock {
|
||||
return switch (metadata) {
|
||||
case 0 -> new ToolStationLogic();
|
||||
case 1, 3, 2, 4 -> new PartBuilderLogic();
|
||||
case 5, 9, 8, 7, 6 -> new PatternChestLogic();
|
||||
case 5 -> new PatternChestLogic();
|
||||
case 6, 9, 8, 7 -> new PartChestLogic();
|
||||
case 10, 13, 12, 11 -> new StencilTableLogic();
|
||||
default -> null;
|
||||
};
|
||||
@@ -135,6 +146,7 @@ public class ToolStationBlock extends InventoryBlock {
|
||||
int md = world.getBlockMetadata(x, y, z);
|
||||
if (md == 0) return 0;
|
||||
else if (md < 5) return 1;
|
||||
else if (md == 6) return 6;
|
||||
else if (md < 10) return 2;
|
||||
else return 3;
|
||||
|
||||
@@ -148,7 +160,7 @@ public class ToolStationBlock extends InventoryBlock {
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item id, CreativeTabs tab, List<ItemStack> list) {
|
||||
for (int iter = 0; iter < 6; iter++) {
|
||||
for (int iter = 0; iter < 7; iter++) {
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
|
||||
@@ -179,9 +191,22 @@ public class ToolStationBlock extends InventoryBlock {
|
||||
if (!world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops")) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta >= 5 && meta <= 9) {
|
||||
ItemStack chest = new ItemStack(this, 1, 5);
|
||||
ItemStack chest = null;
|
||||
InventoryLogic logic = null;
|
||||
switch (meta) {
|
||||
case 5: {
|
||||
chest = new ItemStack(this, 1, 5);
|
||||
logic = (PatternChestLogic) world.getTileEntity(x, y, z);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
chest = new ItemStack(this, 1, 6);
|
||||
logic = (PartChestLogic) world.getTileEntity(x, y, z);
|
||||
break;
|
||||
}
|
||||
}
|
||||
NBTTagCompound inventory = new NBTTagCompound();
|
||||
PatternChestLogic logic = (PatternChestLogic) world.getTileEntity(x, y, z);
|
||||
|
||||
logic.writeInventoryToNBT(inventory);
|
||||
NBTTagCompound baseTag = new NBTTagCompound();
|
||||
baseTag.setTag("Inventory", inventory);
|
||||
@@ -223,7 +248,7 @@ public class ToolStationBlock extends InventoryBlock {
|
||||
if (stack.hasTagCompound()) {
|
||||
NBTTagCompound inventory = stack.getTagCompound().getCompoundTag("Inventory");
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (inventory != null && te instanceof PatternChestLogic logic) {
|
||||
if (inventory != null && te instanceof TiCChestLogic logic) {
|
||||
logic.readInventoryFromNBT(inventory);
|
||||
logic.xCoord = x;
|
||||
logic.yCoord = y;
|
||||
@@ -243,4 +268,21 @@ public class ToolStationBlock extends InventoryBlock {
|
||||
}
|
||||
super.onBlockPlacedBy(world, x, y, z, living, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float clickX,
|
||||
float clickY, float clickZ) {
|
||||
if (world.getTileEntity(x, y, z) instanceof TiCChestLogic logic && !player.isSneaking()) {
|
||||
// is the pattern/part chest and player is not holding shift key
|
||||
ItemStack itemInHand = player.getHeldItem();
|
||||
if (itemInHand != null && logic.isItemValidForSlot(0, itemInHand)) {
|
||||
// is the player holding a tinker pattern/part
|
||||
if (logic.insertItemStackIntoInventory(itemInHand)) {
|
||||
// try insert into chest
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.onBlockActivated(world, x, y, z, player, side, clickX, clickY, clickZ);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package tconstruct.tools.gui;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tconstruct.tools.logic.PartChestLogic;
|
||||
|
||||
public class PartChestGui extends GuiContainer {
|
||||
|
||||
public PartChestLogic logic;
|
||||
|
||||
public PartChestGui(InventoryPlayer inventoryplayer, PartChestLogic holder, World world, int x, int y, int z) {
|
||||
super(holder.getGuiContainer(inventoryplayer, world, x, y, z));
|
||||
logic = holder;
|
||||
xSize = 194;
|
||||
ySize = 168;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
fontRendererObj.drawString(StatCollector.translateToLocal("inventory.PartChest"), 8, 8, 0x404040);
|
||||
fontRendererObj
|
||||
.drawString(StatCollector.translateToLocal("container.inventory"), 17, (ySize - 96) + 2, 0x404040);
|
||||
}
|
||||
|
||||
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/partchest.png");
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(background);
|
||||
int cornerX = (width - xSize) / 2;
|
||||
int cornerY = (height - ySize) / 2;
|
||||
drawTexturedModalRect(cornerX, cornerY, 0, 0, xSize, ySize);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package tconstruct.tools.gui;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -18,10 +20,15 @@ import codechicken.nei.api.TaggedInventoryArea;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.crafting.PatternBuilder;
|
||||
import tconstruct.library.tools.ArrowMaterial;
|
||||
import tconstruct.library.tools.BowMaterial;
|
||||
import tconstruct.library.tools.ToolMaterial;
|
||||
import tconstruct.library.util.HarvestLevels;
|
||||
import tconstruct.library.weaponry.ArrowShaftMaterial;
|
||||
import tconstruct.tools.TinkerTools.MaterialID;
|
||||
import tconstruct.tools.inventory.PartCrafterChestContainer;
|
||||
import tconstruct.tools.logic.PartBuilderLogic;
|
||||
import tconstruct.util.McTextFormatter;
|
||||
|
||||
@Optional.Interface(iface = "codechicken.nei.api.INEIGuiHandler", modid = "NotEnoughItems")
|
||||
public class PartCrafterGui extends GuiContainer implements INEIGuiHandler {
|
||||
@@ -29,9 +36,12 @@ public class PartCrafterGui extends GuiContainer implements INEIGuiHandler {
|
||||
PartBuilderLogic logic;
|
||||
String title, otherTitle = "";
|
||||
boolean drawChestPart;
|
||||
boolean hasTop, hasBottom;
|
||||
ItemStack topMaterial, bottomMaterial;
|
||||
ToolMaterial topEnum, bottomEnum;
|
||||
boolean hasMaterial;
|
||||
ItemStack materialStack;
|
||||
ToolMaterial materialEnum;
|
||||
ArrowMaterial arrowMaterial;
|
||||
BowMaterial bowMaterial;
|
||||
ArrowShaftMaterial arrowShaftMaterial;
|
||||
|
||||
private static final int CRAFT_WIDTH = 176;
|
||||
private static final int CRAFT_HEIGHT = 166;
|
||||
@@ -39,6 +49,7 @@ public class PartCrafterGui extends GuiContainer implements INEIGuiHandler {
|
||||
private static final int DESC_HEIGHT = 166;
|
||||
private static final int CHEST_WIDTH = 122;
|
||||
private static final int CHEST_HEIGHT = 114;
|
||||
private static final String SPACE_STRING = " ";
|
||||
|
||||
// Panel positions
|
||||
|
||||
@@ -53,13 +64,15 @@ public class PartCrafterGui extends GuiContainer implements INEIGuiHandler {
|
||||
private int chestLeft = 0;
|
||||
private int chestTop = 0;
|
||||
|
||||
private static DecimalFormat df = new DecimalFormat("##.##");
|
||||
|
||||
public PartCrafterGui(InventoryPlayer inventoryplayer, PartBuilderLogic partlogic, World world, int x, int y,
|
||||
int z) {
|
||||
super(partlogic.getGuiContainer(inventoryplayer, world, x, y, z));
|
||||
logic = partlogic;
|
||||
drawChestPart = inventorySlots instanceof PartCrafterChestContainer;
|
||||
|
||||
title = "\u00A7n" + (StatCollector.translateToLocal("gui.partcrafter1"));
|
||||
title = McTextFormatter.addUnderLine(StatCollector.translateToLocal("gui.partcrafter1"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -93,140 +106,134 @@ public class PartCrafterGui extends GuiContainer implements INEIGuiHandler {
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
if (drawChestPart) {
|
||||
this.fontRendererObj.drawString(StatCollector.translateToLocal("inventory.PatternChest"), 14, 17, 4210752);
|
||||
this.fontRendererObj.drawString(StatCollector.translateToLocal("inventory.PatternChest"), 8, 17, 0x404040);
|
||||
}
|
||||
|
||||
this.fontRendererObj
|
||||
.drawString(StatCollector.translateToLocal("crafters.PartBuilder"), craftingTextLeft + 6, 6, 4210752);
|
||||
.drawString(StatCollector.translateToLocal("crafters.PartBuilder"), craftingTextLeft + 6, 6, 0x404040);
|
||||
this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("container.inventory"),
|
||||
craftingTextLeft + 8,
|
||||
this.ySize - 96 + 2,
|
||||
4210752);
|
||||
0x404040);
|
||||
|
||||
drawMaterialInformation();
|
||||
}
|
||||
|
||||
void drawDefaultInformation() {
|
||||
title = "\u00A7n" + StatCollector.translateToLocal("gui.partcrafter2");
|
||||
this.drawCenteredString(fontRendererObj, title, descTextLeft + DESC_WIDTH / 2, 8, 16777215);
|
||||
title = McTextFormatter.addUnderLine(StatCollector.translateToLocal("gui.partcrafter2"));
|
||||
this.drawCenteredString(fontRendererObj, title, descTextLeft + DESC_WIDTH / 2, 8, 0xFFFFFF);
|
||||
fontRendererObj.drawSplitString(
|
||||
StatCollector.translateToLocal("gui.partcrafter3"),
|
||||
descTextLeft + 8,
|
||||
24,
|
||||
115,
|
||||
16777215);
|
||||
0xFFFFFF);
|
||||
}
|
||||
|
||||
void drawMaterialInformation() {
|
||||
ItemStack top = logic.getStackInSlot(2);
|
||||
// ItemStack topResult = logic.getStackInSlot(4);
|
||||
ItemStack bottom = logic.getStackInSlot(3);
|
||||
// ItemStack bottomResult = logic.getStackInSlot(6);
|
||||
if (topMaterial != top) {
|
||||
topMaterial = top;
|
||||
int topID = PatternBuilder.instance.getPartID(top);
|
||||
ItemStack met = logic.getStackInSlot(2) != null ? logic.getStackInSlot(2) : logic.getStackInSlot(3);
|
||||
|
||||
if (materialStack != met) {
|
||||
materialStack = met;
|
||||
int topID = PatternBuilder.instance.getPartID(met);
|
||||
|
||||
if (topID != Short.MAX_VALUE) // && topResult != null)
|
||||
{
|
||||
topEnum = TConstructRegistry.getMaterial(topID);
|
||||
hasTop = true;
|
||||
title = "\u00A7n" + topEnum.localizedName();
|
||||
} else hasTop = false;
|
||||
materialEnum = TConstructRegistry.getMaterial(topID);
|
||||
arrowMaterial = TConstructRegistry.getArrowMaterial(topID);
|
||||
bowMaterial = TConstructRegistry.getBowMaterial(topID);
|
||||
arrowShaftMaterial = topID <= MaterialID.Wood
|
||||
? (ArrowShaftMaterial) TConstructRegistry.getCustomMaterial(topID, ArrowShaftMaterial.class)
|
||||
: null;
|
||||
|
||||
hasMaterial = true;
|
||||
title = McTextFormatter.addUnderLine(materialEnum.localizedName());
|
||||
} else hasMaterial = false;
|
||||
}
|
||||
|
||||
if (bottomMaterial != bottom) {
|
||||
bottomMaterial = bottom;
|
||||
int bottomID = PatternBuilder.instance.getPartID(bottom);
|
||||
int offset = 6;
|
||||
if (hasMaterial) {
|
||||
this.drawCenteredString(
|
||||
fontRendererObj,
|
||||
title,
|
||||
descTextLeft + DESC_WIDTH / 2,
|
||||
offset,
|
||||
materialEnum.primaryColor());
|
||||
offset += 14;
|
||||
|
||||
if (bottomID != Short.MAX_VALUE) // && bottomResult != null)
|
||||
{
|
||||
bottomEnum = TConstructRegistry.getMaterial(bottomID);
|
||||
hasBottom = true;
|
||||
otherTitle = "\u00A7n" + bottomEnum.localizedName();
|
||||
} else hasBottom = false;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled(0.95f, 0.95f, 1.0f);
|
||||
int scaledDescTextLeft = (int) (descTextLeft / 0.95) + 7;
|
||||
|
||||
List<String> strWait2Draw = new ArrayList<>();
|
||||
|
||||
strWait2Draw.add(
|
||||
StatCollector.translateToLocalFormatted(
|
||||
"gui.partcrafter.durability",
|
||||
McTextFormatter.addGreen(String.valueOf(materialEnum.durability()))));
|
||||
strWait2Draw.add(
|
||||
StatCollector.translateToLocalFormatted(
|
||||
"gui.partcrafter.mininglevel",
|
||||
HarvestLevels.getHarvestLevelName(materialEnum.harvestLevel())));
|
||||
strWait2Draw.add(
|
||||
StatCollector.translateToLocalFormatted(
|
||||
"gui.partcrafter.miningspeed",
|
||||
McTextFormatter.addAqua(String.valueOf(materialEnum.toolSpeed() / 100f))));
|
||||
strWait2Draw.add(
|
||||
StatCollector.translateToLocalFormatted(
|
||||
"gui.partcrafter.attack",
|
||||
McTextFormatter.addRed(String.valueOf(materialEnum.attack()))));
|
||||
strWait2Draw.add(
|
||||
StatCollector.translateToLocalFormatted(
|
||||
"gui.partcrafter.handlemodifier",
|
||||
McTextFormatter.addYellow(String.valueOf(materialEnum.handleDurability()))));
|
||||
|
||||
if (bowMaterial != null) {
|
||||
strWait2Draw.add(
|
||||
StatCollector.translateToLocalFormatted(
|
||||
"gui.partcrafter.drawspeed",
|
||||
McTextFormatter.addGray(df.format(bowMaterial.drawspeed / 20f))));
|
||||
strWait2Draw.add(
|
||||
StatCollector.translateToLocalFormatted(
|
||||
"gui.partcrafter.arrowspeed",
|
||||
McTextFormatter.addGray(df.format(bowMaterial.flightSpeedMax))));
|
||||
}
|
||||
|
||||
if (arrowShaftMaterial != null) {
|
||||
strWait2Draw.add(
|
||||
McTextFormatter.addUnderLine(StatCollector.translateToLocalFormatted("gui.partcrafter.arrow")));
|
||||
strWait2Draw.add(
|
||||
SPACE_STRING + StatCollector.translateToLocalFormatted(
|
||||
"gui.partcrafter.weight",
|
||||
McTextFormatter.addYellow(df.format(arrowShaftMaterial.weight))));
|
||||
strWait2Draw.add(
|
||||
SPACE_STRING + StatCollector.translateToLocalFormatted(
|
||||
"gui.partcrafter.breakchance",
|
||||
McTextFormatter.addYellow(df.format(arrowShaftMaterial.fragility * 100f))));
|
||||
}
|
||||
|
||||
if (arrowMaterial != null) {
|
||||
strWait2Draw.add(
|
||||
McTextFormatter.addUnderLine(StatCollector.translateToLocalFormatted("gui.partcrafter.bolt")));
|
||||
strWait2Draw.add(
|
||||
SPACE_STRING + StatCollector.translateToLocalFormatted(
|
||||
"gui.partcrafter.weight",
|
||||
McTextFormatter.addYellow(df.format(arrowMaterial.mass))));
|
||||
strWait2Draw.add(
|
||||
SPACE_STRING + StatCollector.translateToLocalFormatted(
|
||||
"gui.partcrafter.breakchance",
|
||||
McTextFormatter.addYellow(df.format(arrowMaterial.breakChance * 100f))));
|
||||
}
|
||||
|
||||
for (String tempStr : strWait2Draw) {
|
||||
this.fontRendererObj.drawString(tempStr, scaledDescTextLeft, offset, 0xFFFFFF);
|
||||
offset += 11;
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
int offset = 8;
|
||||
if (hasTop) {
|
||||
this.drawCenteredString(fontRendererObj, title, descTextLeft + DESC_WIDTH / 2, offset, 16777215);
|
||||
this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter4") + topEnum.durability(),
|
||||
descTextLeft + 8,
|
||||
offset + 16,
|
||||
16777215);
|
||||
this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter5") + topEnum.handleDurability() + "x",
|
||||
descTextLeft + 8,
|
||||
offset + 27,
|
||||
16777215);
|
||||
this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter6") + topEnum.toolSpeed() / 100f,
|
||||
descTextLeft + 8,
|
||||
offset + 38,
|
||||
16777215);
|
||||
this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter7")
|
||||
+ HarvestLevels.getHarvestLevelName(topEnum.harvestLevel()),
|
||||
descTextLeft + 8,
|
||||
offset + 49,
|
||||
16777215);
|
||||
|
||||
int attack = topEnum.attack();
|
||||
String heart = attack == 2 ? StatCollector.translateToLocal("gui.partcrafter8")
|
||||
: StatCollector.translateToLocal("gui.partcrafter9");
|
||||
if (attack % 2 == 0) this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter10") + attack / 2 + heart,
|
||||
descTextLeft + 8,
|
||||
offset + 60,
|
||||
0xffffff);
|
||||
else this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter10") + attack / 2f + heart,
|
||||
descTextLeft + 8,
|
||||
offset + 60,
|
||||
0xffffff);
|
||||
}
|
||||
|
||||
offset = 90;
|
||||
if (hasBottom) {
|
||||
this.drawCenteredString(fontRendererObj, otherTitle, descTextLeft + DESC_WIDTH / 2, offset, 16777215);
|
||||
this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter4") + bottomEnum.durability(),
|
||||
descTextLeft + 8,
|
||||
offset + 16,
|
||||
16777215);
|
||||
this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter5") + bottomEnum.handleDurability() + "x",
|
||||
descTextLeft + 8,
|
||||
offset + 27,
|
||||
16777215);
|
||||
this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter6") + bottomEnum.toolSpeed() / 100f,
|
||||
descTextLeft + 8,
|
||||
offset + 38,
|
||||
16777215);
|
||||
this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter7")
|
||||
+ HarvestLevels.getHarvestLevelName(bottomEnum.harvestLevel()),
|
||||
descTextLeft + 8,
|
||||
offset + 49,
|
||||
16777215);
|
||||
int attack = bottomEnum.attack();
|
||||
String heart = attack == 2 ? StatCollector.translateToLocal("gui.partcrafter8")
|
||||
: StatCollector.translateToLocal("gui.partcrafter9");
|
||||
if (attack % 2 == 0) this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter10") + attack / 2 + heart,
|
||||
descTextLeft + 8,
|
||||
offset + 60,
|
||||
0xffffff);
|
||||
else this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("gui.partcrafter10") + attack / 2f + heart,
|
||||
descTextLeft + 8,
|
||||
offset + 60,
|
||||
0xffffff);
|
||||
}
|
||||
|
||||
if (!hasTop && !hasBottom) drawDefaultInformation();
|
||||
if (!hasMaterial) drawDefaultInformation();
|
||||
}
|
||||
|
||||
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/toolparts.png");
|
||||
|
||||
@@ -24,7 +24,7 @@ public class PatternChestGui extends GuiContainer {
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
fontRendererObj.drawString(StatCollector.translateToLocal("inventory.PatternChest"), 60, 6, 0x404040);
|
||||
fontRendererObj.drawString(StatCollector.translateToLocal("inventory.PatternChest"), 8, 8, 0x404040);
|
||||
fontRendererObj
|
||||
.drawString(StatCollector.translateToLocal("container.inventory"), 17, (ySize - 96) + 2, 0x404040);
|
||||
}
|
||||
|
||||
@@ -21,23 +21,34 @@ import tconstruct.TConstruct;
|
||||
import tconstruct.library.client.StencilGuiElement;
|
||||
import tconstruct.library.client.TConstructClientRegistry;
|
||||
import tconstruct.library.crafting.StencilBuilder;
|
||||
import tconstruct.tools.inventory.PatternShaperContainer;
|
||||
import tconstruct.tools.inventory.PatternShaperChestContainer;
|
||||
import tconstruct.tools.logic.StencilTableLogic;
|
||||
import tconstruct.util.network.PatternTablePacket;
|
||||
|
||||
@Optional.Interface(iface = "codechicken.nei.api.INEIGuiHandler", modid = "NotEnoughItems")
|
||||
public class StencilTableGui extends GuiContainer implements INEIGuiHandler {
|
||||
|
||||
private static final int CHEST_WIDTH = 122;
|
||||
private static final int CHEST_HEIGHT = 114;
|
||||
|
||||
private static final int TEXTURE_WIDTH = 176;
|
||||
private static final int TEXTURE_HEIGHT = 166;
|
||||
|
||||
private int chestLeft = 0;
|
||||
private int chestTop = 0;
|
||||
|
||||
int[] buttonsLeftRect = new int[] { Integer.MAX_VALUE, Integer.MIN_VALUE };
|
||||
int[] buttonsRightRect = new int[] { Integer.MIN_VALUE, Integer.MIN_VALUE };
|
||||
StencilTableLogic logic;
|
||||
int activeButton;
|
||||
boolean drawChestPart;
|
||||
|
||||
public StencilTableGui(InventoryPlayer inventoryplayer, StencilTableLogic shaper, World world, int x, int y,
|
||||
int z) {
|
||||
super(new PatternShaperContainer(inventoryplayer, shaper));
|
||||
super(shaper.getGuiContainer(inventoryplayer, world, x, y, z));
|
||||
logic = shaper;
|
||||
activeButton = 0;
|
||||
drawChestPart = inventorySlots instanceof PatternShaperChestContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,22 +58,37 @@ public class StencilTableGui extends GuiContainer implements INEIGuiHandler {
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
if (drawChestPart) {
|
||||
this.fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("inventory.PatternChest"),
|
||||
TEXTURE_WIDTH + 5,
|
||||
17,
|
||||
0x404040);
|
||||
}
|
||||
|
||||
fontRendererObj.drawString(StatCollector.translateToLocal("crafters.PatternShaper"), 50, 6, 0x404040);
|
||||
fontRendererObj
|
||||
.drawString(StatCollector.translateToLocal("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||
}
|
||||
|
||||
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/patternshaper.png");
|
||||
private static final ResourceLocation minichest = new ResourceLocation(
|
||||
"tinker",
|
||||
"textures/gui/patternchestminiright.png");
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(background);
|
||||
int cornerX = (this.width - this.xSize) / 2;
|
||||
int cornerY = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(cornerX, cornerY, 0, 0, this.xSize, this.ySize);
|
||||
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, TEXTURE_WIDTH, TEXTURE_HEIGHT);
|
||||
if (!logic.isStackInSlot(0)) {
|
||||
this.drawTexturedModalRect(cornerX + 47, cornerY + 34, 176, 0, 18, 18);
|
||||
this.drawTexturedModalRect(this.guiLeft + 47, this.guiTop + 34, 176, 0, 18, 18);
|
||||
}
|
||||
|
||||
// Draw chest
|
||||
if (drawChestPart) {
|
||||
this.mc.getTextureManager().bindTexture(minichest);
|
||||
this.drawTexturedModalRect(chestLeft, chestTop, 0, 0, CHEST_WIDTH, CHEST_HEIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +96,12 @@ public class StencilTableGui extends GuiContainer implements INEIGuiHandler {
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
this.xSize = TEXTURE_WIDTH;
|
||||
this.ySize = TEXTURE_HEIGHT;
|
||||
|
||||
this.guiLeft = (this.width - TEXTURE_WIDTH) / 2;
|
||||
this.guiTop = (this.height - TEXTURE_HEIGHT) / 2;
|
||||
|
||||
int bpr = 4; // buttons per row!
|
||||
int cornerX = this.guiLeft - 22 * bpr;
|
||||
int cornerY = this.guiTop + 2;
|
||||
@@ -98,7 +130,7 @@ public class StencilTableGui extends GuiContainer implements INEIGuiHandler {
|
||||
|
||||
// secondary buttons, yay!
|
||||
// these are to use for other mods :I
|
||||
cornerX = this.guiLeft + this.xSize + 4;
|
||||
cornerX = this.guiLeft + TEXTURE_WIDTH + 4;
|
||||
for (int iter = 0; iter < TConstructClientRegistry.stencilButtons2.size(); iter++) {
|
||||
StencilGuiElement element = TConstructClientRegistry.stencilButtons2.get(iter);
|
||||
if (element.stencilIndex == -1) continue;
|
||||
@@ -131,6 +163,17 @@ public class StencilTableGui extends GuiContainer implements INEIGuiHandler {
|
||||
logic.setSelectedPattern(stack);
|
||||
updateServer(stack);
|
||||
}
|
||||
|
||||
if (drawChestPart) {
|
||||
// make gui closer to main gui
|
||||
this.chestLeft = this.guiLeft + TEXTURE_WIDTH - 3;
|
||||
this.chestTop = this.guiTop + 11;
|
||||
|
||||
this.xSize += CHEST_WIDTH;
|
||||
// don't know why need add those buttons size
|
||||
// other wise nei will cover the chest
|
||||
this.xSize += 27 * bpr;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
package tconstruct.tools.gui;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiLabel;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import mantle.books.BookData;
|
||||
import mantle.client.MProxyClient;
|
||||
import mantle.client.RenderItemCopy;
|
||||
import mantle.client.SmallFontRenderer;
|
||||
import mantle.client.gui.GuiManual;
|
||||
import mantle.client.gui.TurnPageButton;
|
||||
import mantle.client.pages.BookPage;
|
||||
import tconstruct.TConstruct;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TiCGuiManual extends GuiManual {
|
||||
|
||||
ItemStack itemstackBook;
|
||||
Document manual;
|
||||
public RenderItemCopy renderitem = new RenderItemCopy();
|
||||
int bookImageWidth = 206;
|
||||
int bookImageHeight = 200;
|
||||
int bookTotalPages = 1;
|
||||
int currentPage;
|
||||
int maxPages;
|
||||
BookData bData;
|
||||
|
||||
private TurnPageButton buttonNextPage;
|
||||
private TurnPageButton buttonPreviousPage;
|
||||
private static ResourceLocation bookRight;// = new ResourceLocation("mantle", "textures/gui/bookright.png");
|
||||
private static ResourceLocation bookLeft;// = new ResourceLocation("mantle", "textures/gui/bookleft.png");
|
||||
|
||||
BookPage pageLeft;
|
||||
BookPage pageRight;
|
||||
|
||||
public SmallFontRenderer fonts = MProxyClient.smallFontRenderer;
|
||||
|
||||
public TiCGuiManual(ItemStack stack, BookData data) {
|
||||
super(stack, data);
|
||||
this.mc = Minecraft.getMinecraft();
|
||||
this.itemstackBook = stack;
|
||||
currentPage = 0; // Stack page
|
||||
manual = data.getDoc();
|
||||
if (data.font != null) this.fonts = data.font;
|
||||
bookLeft = data.leftImage;
|
||||
bookRight = data.rightImage;
|
||||
this.bData = data;
|
||||
|
||||
// renderitem.renderInFrame = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @Override public void setWorldAndResolution (Minecraft minecraft, int w, int h) { this.guiParticles = new
|
||||
* GuiParticle(minecraft); this.mc = minecraft; this.width = w; this.height = h; this.buttonList.clear();
|
||||
* this.initGui(); }
|
||||
*/
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void initGui() {
|
||||
maxPages = manual.getElementsByTagName("page").getLength();
|
||||
ticUpdateText();
|
||||
int xPos = (this.width) / 2; // TODO Width?
|
||||
// TODO buttonList
|
||||
this.buttonList.add(
|
||||
this.buttonNextPage = new TurnPageButton(
|
||||
1,
|
||||
xPos + bookImageWidth - 50,
|
||||
(this.height + this.bookImageHeight) / 2 - 28,
|
||||
true,
|
||||
bData));
|
||||
this.buttonList.add(
|
||||
this.buttonPreviousPage = new TurnPageButton(
|
||||
2,
|
||||
xPos - bookImageWidth + 24,
|
||||
(this.height + this.bookImageHeight) / 2 - 28,
|
||||
false,
|
||||
bData));
|
||||
updateButtonVisibility();
|
||||
}
|
||||
|
||||
private void updateButtonVisibility() {
|
||||
buttonPreviousPage.visible = currentPage > 0;
|
||||
buttonNextPage.visible = currentPage < maxPages - 2;
|
||||
}
|
||||
|
||||
protected void actionPerformed(GuiButton button) {
|
||||
if (button.enabled) {
|
||||
changePage(button.id);
|
||||
updateButtonVisibility();
|
||||
ticUpdateText();
|
||||
}
|
||||
}
|
||||
|
||||
void ticUpdateText() {
|
||||
if (maxPages % 2 == 1) {
|
||||
if (currentPage > maxPages) currentPage = maxPages;
|
||||
} else {
|
||||
if (currentPage >= maxPages) currentPage = maxPages - 2;
|
||||
}
|
||||
if (currentPage % 2 == 1) currentPage--;
|
||||
if (currentPage < 0) currentPage = 0;
|
||||
|
||||
NodeList nList = manual.getElementsByTagName("page");
|
||||
|
||||
Node node = nList.item(currentPage);
|
||||
if (node.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Element element = (Element) node;
|
||||
Class<? extends BookPage> clazz = MProxyClient.getPageClass(element.getAttribute("type"));
|
||||
if (clazz != null) {
|
||||
try {
|
||||
pageLeft = clazz.getDeclaredConstructor().newInstance();
|
||||
pageLeft.init(this, 0);
|
||||
pageLeft.readPageFromXML(element);
|
||||
} catch (Exception e) {
|
||||
TConstruct.logger.error(e);
|
||||
}
|
||||
} else {
|
||||
pageLeft = null;
|
||||
}
|
||||
}
|
||||
|
||||
node = nList.item(currentPage + 1);
|
||||
if (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Element element = (Element) node;
|
||||
Class<? extends BookPage> clazz = MProxyClient.getPageClass(element.getAttribute("type"));
|
||||
if (clazz != null) {
|
||||
try {
|
||||
pageRight = clazz.getDeclaredConstructor().newInstance();
|
||||
pageRight.init(this, 1);
|
||||
pageRight.readPageFromXML(element);
|
||||
} catch (Exception e) {
|
||||
TConstruct.logger.error(e);
|
||||
}
|
||||
} else {
|
||||
pageLeft = null;
|
||||
}
|
||||
} else {
|
||||
pageRight = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void changePage(int buttonId) {
|
||||
if (buttonId == 1) {
|
||||
currentPage += 2;
|
||||
}
|
||||
if (buttonId == 2) {
|
||||
currentPage -= 2;
|
||||
}
|
||||
}
|
||||
|
||||
public void drawScreen(int par1, int par2, float par3) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(bookRight);
|
||||
|
||||
// aligen to center
|
||||
int localWidth = (this.width / 2);
|
||||
int localHeight = ((this.height - this.bookImageHeight) / 2);
|
||||
|
||||
this.drawTexturedModalRect(localWidth, localHeight, 0, 0, this.bookImageWidth, this.bookImageHeight);
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(bookLeft);
|
||||
localWidth = localWidth - this.bookImageWidth;
|
||||
this.drawTexturedModalRect(
|
||||
localWidth,
|
||||
localHeight,
|
||||
256 - this.bookImageWidth,
|
||||
0,
|
||||
this.bookImageWidth,
|
||||
this.bookImageHeight);
|
||||
|
||||
this.drawButtons(par1, par2);
|
||||
|
||||
if (pageLeft != null) pageLeft.renderBackgroundLayer(localWidth + 16, localHeight + 12);
|
||||
if (pageRight != null) pageRight.renderBackgroundLayer(localWidth + 220, localHeight + 12);
|
||||
if (pageLeft != null) pageLeft.renderContentLayer(localWidth + 16, localHeight + 12, bData.isTranslatable);
|
||||
if (pageRight != null) pageRight.renderContentLayer(localWidth + 220, localHeight + 12, bData.isTranslatable);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* copy from {@link net.minecraft.client.gui.GuiScreen#drawScreen(int, int, float)}
|
||||
*/
|
||||
public void drawButtons(int mouseX, int mouseY) {
|
||||
// copy from @GuiScreen.drawScreen
|
||||
int k;
|
||||
|
||||
for (k = 0; k < this.buttonList.size(); ++k) {
|
||||
((GuiButton) this.buttonList.get(k)).drawButton(this.mc, mouseX, mouseY);
|
||||
}
|
||||
|
||||
for (k = 0; k < this.labelList.size(); ++k) {
|
||||
((GuiLabel) this.labelList.get(k)).func_146159_a(this.mc, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
public Minecraft getMC() {
|
||||
return mc;
|
||||
}
|
||||
|
||||
public boolean doesGuiPauseGame() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package tconstruct.tools.inventory;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import invtweaks.api.container.ChestContainer;
|
||||
import tconstruct.library.util.IToolPart;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.tools.logic.PartChestLogic;
|
||||
|
||||
@ChestContainer
|
||||
public class PartChestContainer extends Container {
|
||||
|
||||
public PartChestLogic logic;
|
||||
|
||||
public PartChestContainer(InventoryPlayer inventoryplayer, PartChestLogic chest) {
|
||||
logic = chest;
|
||||
for (int column = 0; column < 3; column++) {
|
||||
for (int row = 0; row < 10; row++) {
|
||||
this.addSlotToContainer(new SlotPart(chest, row + column * 10, 8 + row * 18, 18 + column * 18));
|
||||
}
|
||||
}
|
||||
|
||||
/* Player inventory */
|
||||
for (int column = 0; column < 3; column++) {
|
||||
for (int row = 0; row < 9; row++) {
|
||||
this.addSlotToContainer(
|
||||
new Slot(inventoryplayer, row + column * 9 + 9, 17 + row * 18, 86 + column * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int column = 0; column < 9; column++) {
|
||||
this.addSlotToContainer(new Slot(inventoryplayer, column, 17 + column * 18, 144));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
Block block = logic.getWorldObj().getBlock(logic.xCoord, logic.yCoord, logic.zCoord);
|
||||
if (block != TinkerTools.toolStationWood && block != TinkerTools.craftingSlabWood) return false;
|
||||
return logic.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
|
||||
ItemStack stack = null;
|
||||
Slot slot = (Slot) this.inventorySlots.get(slotID);
|
||||
|
||||
if (slot != null && slot.getHasStack()) {
|
||||
ItemStack slotStack = slot.getStack();
|
||||
stack = slotStack.copy();
|
||||
|
||||
if (slotID < logic.getSizeInventory()) {
|
||||
if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true)) {
|
||||
return null;
|
||||
}
|
||||
} else if (!this.mergeItemStack(slotStack, 0, logic.getSizeInventory(), false)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (slotStack.stackSize == 0) {
|
||||
slot.putStack(null);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean mergeItemStack(ItemStack stack, int inventorySize, int slotSize, boolean par4) {
|
||||
if (!(stack.getItem() instanceof IToolPart)) return false;
|
||||
|
||||
return super.mergeItemStack(stack, inventorySize, slotSize, par4);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package tconstruct.tools.inventory;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import tconstruct.armor.inventory.SlotOnlyTake;
|
||||
import tconstruct.library.util.IPattern;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.tools.logic.PatternChestLogic;
|
||||
import tconstruct.tools.logic.StencilTableLogic;
|
||||
|
||||
public class PatternShaperChestContainer extends Container {
|
||||
|
||||
protected PatternChestLogic patternLogic;
|
||||
public StencilTableLogic logic;
|
||||
|
||||
public static ItemStack BLANK_PATTERN = new ItemStack(TinkerTools.blankPattern, 1, 0);
|
||||
|
||||
public PatternShaperChestContainer(InventoryPlayer inventoryplayer, StencilTableLogic shaper,
|
||||
PatternChestLogic pLogic) {
|
||||
this.logic = shaper;
|
||||
this.patternLogic = pLogic;
|
||||
this.addSlotToContainer(new Slot(shaper, 0, 48, 35));
|
||||
this.addSlotToContainer(new SlotOnlyTake(shaper, 1, 106, 35));
|
||||
/*
|
||||
* for (int i = 0; i < 3; i++) { for (int l = 0; l < 3; l++) { this.addSlotToContainer(new Slot(craftMatrix, l +
|
||||
* i * 3, 30 + l * 18, 17 + i * 18)); } }
|
||||
*/
|
||||
|
||||
/* Player inventory */
|
||||
for (int column = 0; column < 3; column++) {
|
||||
for (int row = 0; row < 9; row++) {
|
||||
this.addSlotToContainer(
|
||||
new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int column = 0; column < 9; column++) {
|
||||
this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142));
|
||||
}
|
||||
|
||||
/* Holder inventory */
|
||||
for (int column = 0; column < 5; column++) {
|
||||
for (int row = 0; row < 6; row++) {
|
||||
this.addSlotToContainer(new SlotPattern(pLogic, row + column * 6, 178 + row * 18, 30 + column * 18));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* public void onCraftMatrixChanged(IInventory iinventory) { craftResult.setInventorySloTRepos(0,
|
||||
* CraftingManager.getInstance().findMatchingRecipe(craftMatrix, worldObj)); }
|
||||
*/
|
||||
|
||||
/*
|
||||
* @Override public void onContainerClosed(EntityPlayer entityplayer) { super.onContainerClosed(entityplayer); if
|
||||
* (logic.worldObj.isRemote) { return; } ItemStack itemstack = logic.getStackInSlot(0); if (itemstack != null) {
|
||||
* entityplayer.dropPlayerItem(itemstack); } }
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
Block block = logic.getWorldObj().getBlock(logic.xCoord, logic.yCoord, logic.zCoord);
|
||||
if (block != TinkerTools.toolStationWood && block != TinkerTools.craftingSlabWood) return false;
|
||||
return logic.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack slotClick(int slotId, int clickedButton, int mode, EntityPlayer player) {
|
||||
if (mode == 1 && clickedButton == 0) {
|
||||
// is it shift left click?
|
||||
Slot slot = (Slot) this.inventorySlots.get(slotId);
|
||||
if (slot != null && slot.getHasStack()) {
|
||||
ItemStack stack = slot.getStack();
|
||||
if (slotId >= logic.getSizeInventory() && stack.isItemEqual(BLANK_PATTERN)) {
|
||||
// clicked in player inventory
|
||||
if (stack.isItemEqual(BLANK_PATTERN) && !this.mergeItemStack(stack, 0, 1, false)) {
|
||||
// fail to move blank pattern into stencil table
|
||||
return null;
|
||||
} else if (stack.getItem() instanceof IPattern
|
||||
&& !this.mergeItemStack(stack, 4 * 9 + 2, this.inventorySlots.size(), false)) {
|
||||
// fail to move pattern into pattern chest
|
||||
return null;
|
||||
}
|
||||
} else if (slotId < logic.getSizeInventory()) {
|
||||
if (stack.getItem() instanceof IPattern) {
|
||||
// pattern slot, search from pattern chest first
|
||||
if (!this.mergeItemStack(stack, 4 * 9 + 2, this.inventorySlots.size(), false)) {
|
||||
if (!this.mergeItemStack(stack, 2, 4 * 9 + 2, false)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// special for shift click the output pattern
|
||||
if (slotId == 1) {
|
||||
this.inventorySlots.get(0).decrStackSize(1);
|
||||
// if there still have blank pattern
|
||||
if (this.inventorySlots.get(0).getStack().stackSize != 0) {
|
||||
ItemStack stackCopy = stack.copy();
|
||||
stackCopy.stackSize = 1;
|
||||
this.inventorySlots.get(1).putStack(stackCopy);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!this.mergeItemStack(stack, 2, 4 * 9 + 2, false)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (stack.stackSize == 0 && slotId != 1) {
|
||||
slot.putStack((ItemStack) null);
|
||||
}
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
return super.slotClick(slotId, clickedButton, mode, player);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import tconstruct.armor.inventory.SlotOnlyTake;
|
||||
import tconstruct.library.util.IPattern;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.tools.logic.StencilTableLogic;
|
||||
|
||||
@@ -78,16 +79,22 @@ public class PatternShaperContainer extends Container {
|
||||
// pattern slot
|
||||
if (!this.mergeItemStack(stack, 2, this.inventorySlots.size(), false)) {
|
||||
return null;
|
||||
} else if (slotId == 1) {
|
||||
}
|
||||
if (stack.getItem() instanceof IPattern && slotId == 1) {
|
||||
// special for shift click the output pattern
|
||||
this.inventorySlots.get(0).decrStackSize(1);
|
||||
// if there still have blank pattern
|
||||
if (this.inventorySlots.get(0).getStack().stackSize != 0) {
|
||||
ItemStack stackCopy = stack.copy();
|
||||
stackCopy.stackSize = 1;
|
||||
this.inventorySlots.get(1).putStack(stack.copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (stack.stackSize == 0) {
|
||||
if (stack.stackSize == 0 && slotId != 1) {
|
||||
slot.putStack((ItemStack) null);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
return super.slotClick(slotId, clickedButton, mode, player);
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package tconstruct.tools.inventory;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import tconstruct.library.util.IToolPart;
|
||||
|
||||
public class SlotPart extends Slot {
|
||||
|
||||
public SlotPart(IInventory builder, int par3, int par4, int par5) {
|
||||
super(builder, par3, par4, par5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return stack.getItem() instanceof IToolPart;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import mantle.blocks.abstracts.MultiItemBlock;
|
||||
public class CraftingSlabItemBlock extends MultiItemBlock {
|
||||
|
||||
public static final String[] blockTypes = { "tile.CraftingStation", "Crafter", "Parts", "PatternShaper",
|
||||
"PatternChest", "tile.ToolForge" };
|
||||
"PatternChest", "tile.ToolForge", "PartChest" };
|
||||
|
||||
public CraftingSlabItemBlock(Block b) {
|
||||
super(b, "ToolStation", blockTypes);
|
||||
|
||||
@@ -7,8 +7,8 @@ import mantle.blocks.abstracts.MultiItemBlock;
|
||||
public class ToolStationItemBlock extends MultiItemBlock {
|
||||
|
||||
public static final String[] blockTypes = { "Crafter", "Parts", "Parts", "Parts", "Parts", "PatternChest",
|
||||
"PatternChest", "PatternChest", "PatternChest", "PatternChest", "PatternShaper", "PatternShaper",
|
||||
"PatternShaper", "PatternShaper", "CastingTable" };
|
||||
"PartChest", "PartChest", "PartChest", "PartChest", "PatternShaper", "PatternShaper", "PatternShaper",
|
||||
"PatternShaper", "CastingTable" };
|
||||
|
||||
public ToolStationItemBlock(Block b) {
|
||||
super(b, "ToolStation", blockTypes);
|
||||
|
||||
@@ -13,11 +13,12 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import mantle.books.BookData;
|
||||
import mantle.books.BookDataStore;
|
||||
import mantle.client.gui.GuiManual;
|
||||
import mantle.items.abstracts.CraftingItem;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.achievements.TAchievements;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.tools.gui.TiCGuiManual;
|
||||
import tconstruct.util.McTextFormatter;
|
||||
|
||||
public class Manual extends CraftingItem {
|
||||
|
||||
@@ -45,7 +46,7 @@ public class Manual extends CraftingItem {
|
||||
BookData data = BookDataStore.getBookfromName(TConstruct.modID, getBookName(stack.getItemDamage()));
|
||||
if (Objects.nonNull(data)) {
|
||||
player.openGui(TConstruct.instance, mantle.client.MProxyClient.manualGuiID, world, 0, 0, 0);
|
||||
FMLClientHandler.instance().displayGuiScreen(player, new GuiManual(stack, data));
|
||||
FMLClientHandler.instance().displayGuiScreen(player, new TiCGuiManual(stack, data));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,19 +65,19 @@ public class Manual extends CraftingItem {
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List<String> list, boolean par4) {
|
||||
switch (stack.getItemDamage()) {
|
||||
case 0:
|
||||
list.add("\u00a7o" + StatCollector.translateToLocal("manual1.tooltip"));
|
||||
list.add(McTextFormatter.addItalic(StatCollector.translateToLocal("manual1.tooltip")));
|
||||
break;
|
||||
case 1:
|
||||
list.add("\u00a7o" + StatCollector.translateToLocal("manual2.tooltip"));
|
||||
list.add(McTextFormatter.addItalic(StatCollector.translateToLocal("manual2.tooltip")));
|
||||
break;
|
||||
case 2:
|
||||
list.add("\u00a7o" + StatCollector.translateToLocal("manual3.tooltip"));
|
||||
list.add(McTextFormatter.addItalic(StatCollector.translateToLocal("manual3.tooltip")));
|
||||
break;
|
||||
case 4:
|
||||
list.add("\u00a7o" + StatCollector.translateToLocal("manual4.tooltip"));
|
||||
list.add(McTextFormatter.addItalic(StatCollector.translateToLocal("manual4.tooltip")));
|
||||
break;
|
||||
default:
|
||||
list.add("\u00a7o" + StatCollector.translateToLocal("manual5.tooltip"));
|
||||
list.add(McTextFormatter.addItalic(StatCollector.translateToLocal("manual5.tooltip")));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package tconstruct.tools.logic;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import tconstruct.library.util.IToolPart;
|
||||
import tconstruct.tools.inventory.PartChestContainer;
|
||||
|
||||
public class PartChestLogic extends TiCChestLogic {
|
||||
|
||||
@Override
|
||||
public String getDefaultName() {
|
||||
return "toolstation.partholder";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z) {
|
||||
return new PartChestContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack itemstack) {
|
||||
return itemstack != null && itemstack.getItem() instanceof IToolPart;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,20 +5,10 @@ import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import tconstruct.library.util.IPattern;
|
||||
import tconstruct.tools.inventory.PatternChestContainer;
|
||||
|
||||
public class PatternChestLogic extends InventoryLogic {
|
||||
|
||||
public PatternChestLogic() {
|
||||
super(30);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
return false;
|
||||
}
|
||||
public class PatternChestLogic extends TiCChestLogic {
|
||||
|
||||
@Override
|
||||
public String getDefaultName() {
|
||||
@@ -30,24 +20,9 @@ public class PatternChestLogic extends InventoryLogic {
|
||||
return new PatternChestContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return getDefaultName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack itemstack) {
|
||||
return itemstack != null && itemstack.getItem() instanceof IPattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {}
|
||||
}
|
||||
@@ -4,11 +4,13 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import tconstruct.library.crafting.StencilBuilder;
|
||||
import tconstruct.tools.inventory.PatternShaperChestContainer;
|
||||
import tconstruct.tools.inventory.PatternShaperContainer;
|
||||
|
||||
public class StencilTableLogic extends InventoryLogic implements ISidedInventory {
|
||||
@@ -31,6 +33,15 @@ public class StencilTableLogic extends InventoryLogic implements ISidedInventory
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z) {
|
||||
for (int xPos = x - 1; xPos <= x + 1; xPos++) {
|
||||
for (int zPos = z - 1; zPos <= z + 1; zPos++) {
|
||||
for (int yPos = y - 1; yPos <= y + 1; yPos++) {
|
||||
TileEntity tile = world.getTileEntity(xPos, yPos, zPos);
|
||||
if (tile instanceof PatternChestLogic && (x == xPos || z == zPos))
|
||||
return new PatternShaperChestContainer(inventoryplayer, this, (PatternChestLogic) tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new PatternShaperContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
@@ -41,7 +52,25 @@ public class StencilTableLogic extends InventoryLogic implements ISidedInventory
|
||||
|
||||
public void setSelectedPattern(ItemStack stack) {
|
||||
selectedStack = stack;
|
||||
this.setInventorySlotContents(1, stack);
|
||||
if (stack == null) this.setInventorySlotContents(1, null);
|
||||
else {
|
||||
ItemStack stackBlank = this.getStackInSlot(0);
|
||||
if (stackBlank != null && stackBlank.stackSize > 0 && StencilBuilder.isBlank(stackBlank)) {
|
||||
boolean warning = true;
|
||||
for (ItemStack tempStack : StencilBuilder.instance.stencils.values()) {
|
||||
if (tempStack != null && stack.isItemEqual(tempStack)) {
|
||||
stack = tempStack.copy();
|
||||
warning = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!warning) this.setInventorySlotContents(1, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setSelectedPattern() {
|
||||
setSelectedPattern(selectedStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package tconstruct.tools.logic;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
|
||||
public abstract class TiCChestLogic extends InventoryLogic {
|
||||
|
||||
public TiCChestLogic() {
|
||||
super(30);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return getDefaultName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {}
|
||||
|
||||
public boolean insertItemStackIntoInventory(ItemStack stack) {
|
||||
for (int i = 0; i < this.inventory.length; i++) {
|
||||
if (this.inventory[i] == null) {
|
||||
this.inventory[i] = stack.copy();
|
||||
stack.stackSize = 0;
|
||||
this.markDirty();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract boolean isItemValidForSlot(int slot, ItemStack itemstack);
|
||||
|
||||
@Override
|
||||
public abstract String getDefaultName();
|
||||
|
||||
@Override
|
||||
public abstract Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z);
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package tconstruct.util;
|
||||
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
public class McTextFormatter {
|
||||
|
||||
private McTextFormatter() {}
|
||||
|
||||
public static String addBlack(String str) {
|
||||
return EnumChatFormatting.BLACK + str + EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
public static String addDarkBlue(String str) {
|
||||
return EnumChatFormatting.DARK_BLUE + str + EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
public static String addDarkGreen(String str) {
|
||||
return EnumChatFormatting.DARK_GREEN + str + EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
public static String addDarkAqua(String str) {
|
||||
return EnumChatFormatting.DARK_AQUA + str + EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
public static String addDarkRed(String str) {
|
||||
return EnumChatFormatting.DARK_RED + str + EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
public static String addDarkPurple(String str) {
|
||||
return EnumChatFormatting.DARK_PURPLE + str + EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
public static String addGold(String str) {
|
||||
return EnumChatFormatting.GOLD + str + EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
public static String addGray(String str) {
|
||||
return EnumChatFormatting.GRAY + str + EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
public static String addDarkGray(String str) {
|
||||
return EnumChatFormatting.DARK_GRAY + str + EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
public static String addBlue(String str) {
|
||||
return EnumChatFormatting.BLUE + str + EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
public static String addGreen(String str) {
|
||||
return EnumChatFormatting.GREEN + str + EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
public static String addAqua(String str) {
|
||||
return EnumChatFormatting.AQUA + str + EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
public static String addRed(String str) {
|
||||
return EnumChatFormatting.RED + str + EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
public static String addLightPurple(String str) {
|
||||
return EnumChatFormatting.LIGHT_PURPLE + str + EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
public static String addYellow(String str) {
|
||||
return EnumChatFormatting.YELLOW + str + EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
public static String addWhite(String str) {
|
||||
return EnumChatFormatting.WHITE + str + EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
public static String addObfuscated(String str) {
|
||||
return EnumChatFormatting.OBFUSCATED + str + EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
public static String addBold(String str) {
|
||||
return EnumChatFormatting.BOLD + str + EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
public static String addStrikethrough(String str) {
|
||||
return EnumChatFormatting.STRIKETHROUGH + str + EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
public static String addUnderLine(String str) {
|
||||
return EnumChatFormatting.UNDERLINE + str + EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
public static String addItalic(String str) {
|
||||
return EnumChatFormatting.ITALIC + str + EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,8 +7,7 @@ import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import mantle.common.network.AbstractPacket;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.crafting.StencilBuilder;
|
||||
import tconstruct.tools.inventory.PatternShaperChestContainer;
|
||||
import tconstruct.tools.inventory.PatternShaperContainer;
|
||||
import tconstruct.tools.logic.StencilTableLogic;
|
||||
|
||||
@@ -47,28 +46,16 @@ public class PatternTablePacket extends AbstractPacket {
|
||||
|
||||
@Override
|
||||
public void handleServerSide(EntityPlayer player) {
|
||||
if (player.openContainer instanceof PatternShaperContainer) {
|
||||
PatternShaperContainer container = (PatternShaperContainer) player.openContainer;
|
||||
StencilTableLogic logic = container.logic;
|
||||
if (player.openContainer instanceof PatternShaperContainer
|
||||
|| player.openContainer instanceof PatternShaperChestContainer) {
|
||||
StencilTableLogic logic = null;
|
||||
if (player.openContainer instanceof PatternShaperContainer psc) {
|
||||
logic = psc.logic;
|
||||
} else if (player.openContainer instanceof PatternShaperChestContainer pscc) {
|
||||
logic = pscc.logic;
|
||||
}
|
||||
if (logic != null && logic.xCoord == this.x && logic.yCoord == this.y && logic.zCoord == this.z)
|
||||
if (this.contents == null) logic.setSelectedPattern(null);
|
||||
else {
|
||||
ItemStack stackBlank = logic.getStackInSlot(0);
|
||||
if (stackBlank != null && stackBlank.stackSize > 0 && StencilBuilder.isBlank(stackBlank)) {
|
||||
boolean warning = true;
|
||||
for (ItemStack stack : StencilBuilder.instance.stencils.values()) {
|
||||
if (stack != null && this.contents.isItemEqual(stack)) {
|
||||
this.contents = stack.copy();
|
||||
warning = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (warning) TConstruct.logger.warn(
|
||||
"Possible packet-cheating with PatternTable for player "
|
||||
+ player.getCommandSenderName());
|
||||
else logic.setSelectedPattern(this.contents);
|
||||
}
|
||||
}
|
||||
logic.setSelectedPattern(contents);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,17 +122,28 @@ public class WeaponryClientProxy extends WeaponryCommonProxy {
|
||||
final String tex = "textures/gui/icons.png";
|
||||
|
||||
// Stencil Table
|
||||
TConstructClientRegistry.addStencilButton2(11, 3, 21, Reference.RESOURCE, tex); // arrow head
|
||||
TConstructClientRegistry.addStencilButton2(12, 3, 22, Reference.RESOURCE, tex); // fletchling
|
||||
TConstructClientRegistry.addStencilButton2(0, 0, -1, null, null);
|
||||
TConstructClientRegistry.addStencilButton2(0, 0, -1, null, null);
|
||||
// TConstructClientRegistry.addStencilButton2(11, 3, 21, Reference.RESOURCE, tex); // arrow head
|
||||
// TConstructClientRegistry.addStencilButton2(12, 3, 22, Reference.RESOURCE, tex); // fletchling
|
||||
// TConstructClientRegistry.addStencilButton2(0, 0, -1, null, null);
|
||||
// TConstructClientRegistry.addStencilButton2(0, 0, -1, null, null);
|
||||
|
||||
TConstructClientRegistry.addStencilButton2(10, 3, 23, Reference.RESOURCE, tex); // bowstring
|
||||
TConstructClientRegistry.addStencilButton2(0, 4, 24, Reference.RESOURCE, tex); // shuriken
|
||||
TConstructClientRegistry.addStencilButton2(1, 4, 25, Reference.RESOURCE, tex); // crossbow limb
|
||||
TConstructClientRegistry.addStencilButton2(2, 4, 26, Reference.RESOURCE, tex); // crossbow body
|
||||
// TConstructClientRegistry.addStencilButton2(10, 3, 23, Reference.RESOURCE, tex); // bowstring
|
||||
// TConstructClientRegistry.addStencilButton2(0, 4, 24, Reference.RESOURCE, tex); // shuriken
|
||||
// TConstructClientRegistry.addStencilButton2(1, 4, 25, Reference.RESOURCE, tex); // crossbow limb
|
||||
// TConstructClientRegistry.addStencilButton2(2, 4, 26, Reference.RESOURCE, tex); // crossbow body
|
||||
//
|
||||
// TConstructClientRegistry.addStencilButton2(3, 4, 27, Reference.RESOURCE, tex); // bow limb
|
||||
|
||||
// move to left
|
||||
TConstructClientRegistry.addStencilButton(11, 3, 21, Reference.RESOURCE, tex); // arrow head
|
||||
TConstructClientRegistry.addStencilButton(12, 3, 22, Reference.RESOURCE, tex); // fletchling
|
||||
TConstructClientRegistry.addStencilButton(10, 3, 23, Reference.RESOURCE, tex); // bowstring
|
||||
TConstructClientRegistry.addStencilButton(0, 4, 24, Reference.RESOURCE, tex); // shuriken
|
||||
TConstructClientRegistry.addStencilButton(1, 4, 25, Reference.RESOURCE, tex); // crossbow limb
|
||||
TConstructClientRegistry.addStencilButton(2, 4, 26, Reference.RESOURCE, tex); // crossbow body
|
||||
|
||||
TConstructClientRegistry.addStencilButton(3, 4, 27, Reference.RESOURCE, tex); // bow limb
|
||||
|
||||
TConstructClientRegistry.addStencilButton2(3, 4, 27, Reference.RESOURCE, tex); // bow limb
|
||||
// TConstructClientRegistry.addStencilButton2(4, 4, index, Reference.RESOURCE, "textures/gui/icons.png"); //
|
||||
// bolt
|
||||
|
||||
|
||||
Reference in new issue
Block a user