From 0b7b2fa63c8c61628a3fbf1bd137040a2c09fb60 Mon Sep 17 00:00:00 2001 From: mDiyo Date: Thu, 11 Jul 2013 22:26:34 -0700 Subject: [PATCH] Drawbridge, Igniter, and minor bugfixes --- mods/tinker/tconstruct/TConstruct.java | 2 +- .../tconstruct/blocks/RedstoneMachine.java | 2 +- .../blocks/logic/DrawbridgeLogic.java | 169 +++--------------- .../blocks/logic/FirestarterLogic.java | 31 +++- .../blocks/logic/SmelteryLogic.java | 4 +- .../tconstruct/client/CustomBowRenderer.java | 20 +-- .../tconstruct/client/TProxyClient.java | 14 ++ .../tconstruct/client/gui/DrawbridgeGui.java | 7 - .../tconstruct/client/gui/MiniGardyGui.java | 36 ++++ mods/tinker/tconstruct/common/TContent.java | 13 +- .../tconstruct/common/TProxyCommon.java | 23 ++- mods/tinker/tconstruct/entity/MiniGardy.java | 37 ++-- .../inventory/DrawbridgeContainer.java | 2 +- .../tconstruct/inventory/DrawbridgeSlot.java | 28 +++ .../inventory/MiniGardyContainer.java | 82 +++++++++ .../library/TConstructRegistry.java | 1 + mods/tinker/textures/gui/googirl.png | Bin 0 -> 1829 bytes test/XinStick.java | 1 + 18 files changed, 281 insertions(+), 191 deletions(-) create mode 100644 mods/tinker/tconstruct/client/gui/MiniGardyGui.java create mode 100644 mods/tinker/tconstruct/inventory/DrawbridgeSlot.java create mode 100644 mods/tinker/tconstruct/inventory/MiniGardyContainer.java create mode 100644 mods/tinker/textures/gui/googirl.png diff --git a/mods/tinker/tconstruct/TConstruct.java b/mods/tinker/tconstruct/TConstruct.java index 07f5ceca..42113fb5 100644 --- a/mods/tinker/tconstruct/TConstruct.java +++ b/mods/tinker/tconstruct/TConstruct.java @@ -38,7 +38,7 @@ import cpw.mods.fml.common.registry.VillagerRegistry; * @dependencies: IC2 API, MFR API */ -@Mod(modid = "TConstruct", name = "TConstruct", version = "1.5.1_1.4.dev.16", dependencies = "required-after:Forge@[7.7.1.675,)") +@Mod(modid = "TConstruct", name = "TConstruct", version = "1.5.1_1.4.dev.18", dependencies = "required-after:Forge@[7.7.1.675,)") @NetworkMod(serverSideRequired = false, clientSideRequired = true, channels = { "TConstruct" }, packetHandler = mods.tinker.tconstruct.util.network.TPacketHandler.class) public class TConstruct { diff --git a/mods/tinker/tconstruct/blocks/RedstoneMachine.java b/mods/tinker/tconstruct/blocks/RedstoneMachine.java index eafbd4b1..377293b1 100644 --- a/mods/tinker/tconstruct/blocks/RedstoneMachine.java +++ b/mods/tinker/tconstruct/blocks/RedstoneMachine.java @@ -197,7 +197,7 @@ public class RedstoneMachine extends InventoryBlock /* Redstone */ public boolean canConnectRedstone (IBlockAccess world, int x, int y, int z, int side) { - return true; + return false; } public void onNeighborBlockChange (World world, int x, int y, int z, int neighborBlockID) diff --git a/mods/tinker/tconstruct/blocks/logic/DrawbridgeLogic.java b/mods/tinker/tconstruct/blocks/logic/DrawbridgeLogic.java index 6fc0cb8e..48faecf1 100644 --- a/mods/tinker/tconstruct/blocks/logic/DrawbridgeLogic.java +++ b/mods/tinker/tconstruct/blocks/logic/DrawbridgeLogic.java @@ -140,7 +140,7 @@ public class DrawbridgeLogic extends InventoryLogic implements IFacingLogic, IAc ticks = 0; if (active) //Placement { - if (inventory[0] != null && inventory[0].stackSize > 1 && extension < 16) + if (inventory[0] != null && inventory[0].stackSize > 1 && extension < 15) { extension++; int xPos = xCoord; @@ -173,7 +173,18 @@ public class DrawbridgeLogic extends InventoryLogic implements IFacingLogic, IAc if (block == null || block.isAirBlock(worldObj, xPos, yPos, zPos) || block.isBlockReplaceable(worldObj, xPos, yPos, zPos)) { //tryExtend(worldObj, xPos, yPos, zPos, direction); - worldObj.setBlock(xPos, yPos, zPos, inventory[0].itemID, inventory[0].getItemDamage(), 3); + int blockToItem = TConstructRegistry.blockToItemMapping[inventory[0].itemID]; + if (blockToItem == 0) + { + if (inventory[0].itemID >= 4096 || Block.blocksList[inventory[0].itemID] == null) + return; + + worldObj.setBlock(xPos, yPos, zPos, inventory[0].itemID, inventory[0].getItemDamage(), 3); + } + else + { + worldObj.setBlock(xPos, yPos, zPos, blockToItem, inventory[0].getItemDamage(), 3); + } worldObj.playSoundEffect((double) xPos + 0.5D, (double) yPos + 0.5D, (double) zPos + 0.5D, "tile.piston.out", 0.25F, worldObj.rand.nextFloat() * 0.25F + 0.6F); inventory[0].stackSize--; } @@ -251,7 +262,14 @@ public class DrawbridgeLogic extends InventoryLogic implements IFacingLogic, IAc int type = TConstructRegistry.interchangableBlockMapping[block.blockID]; if (type != 0) { - return block.blockID == inventory[0].itemID || type == inventory[0].itemID; + if (type == inventory[0].itemID) + return true; + } + int blockToItem = TConstructRegistry.blockToItemMapping[block.blockID]; + if (blockToItem != 0) + { + if (blockToItem == inventory[0].itemID) + return true; } return block.blockID == inventory[0].itemID; } @@ -285,145 +303,7 @@ public class DrawbridgeLogic extends InventoryLogic implements IFacingLogic, IAc } return false; } - - private boolean tryExtend (World par1World, int x, int y, int z, int side) - { - int posX = x + Facing.offsetsXForSide[side]; - int posY = y + Facing.offsetsYForSide[side]; - int posZ = z + Facing.offsetsZForSide[side]; - int newX = 0; - - while (true) - { - int blockID; - - if (newX < 13) - { - if (posY <= 0 || posY >= par1World.getHeight() - 1) - { - return false; - } - - blockID = par1World.getBlockId(posX, posY, posZ); - - if (blockID != 0) - { - if (!canPushBlock(blockID, par1World, posX, posY, posZ, true)) - { - return false; - } - - if (Block.blocksList[blockID].getMobilityFlag() != 1) - { - if (newX == 12) - { - return false; - } - - posX += Facing.offsetsXForSide[side]; - posY += Facing.offsetsYForSide[side]; - posZ += Facing.offsetsZForSide[side]; - ++newX; - continue; - } - - //With our change to how snowballs are dropped this needs to dissallow to mimic vanilla behavior. - float chance = (Block.blocksList[blockID] instanceof BlockSnow ? -1.0f : 1.0f); - Block.blocksList[blockID].dropBlockAsItemWithChance(par1World, posX, posY, posZ, par1World.getBlockMetadata(posX, posY, posZ), chance, 0); - par1World.setBlockToAir(posX, posY, posZ); - } - } - - newX = posX; - blockID = posY; - int newZ = posZ; - int k2 = 0; - int[] aint; - int l2; - int i3; - int j3; - - for (aint = new int[13]; posX != x || posY != y || posZ != z; posZ = j3) - { - l2 = posX - Facing.offsetsXForSide[side]; - i3 = posY - Facing.offsetsYForSide[side]; - j3 = posZ - Facing.offsetsZForSide[side]; - int k3 = par1World.getBlockId(l2, i3, j3); - int l3 = par1World.getBlockMetadata(l2, i3, j3); - - if (k3 == TContent.redstoneMachine.blockID && l2 == x && i3 == y && j3 == z) - { - par1World.setBlock(posX, posY, posZ, Block.pistonMoving.blockID, side | 0, 4); - par1World.setBlockTileEntity(posX, posY, posZ, BlockPistonMoving.getTileEntity(Block.pistonExtension.blockID, side | 0, side, true, false)); - } - else - { - par1World.setBlock(posX, posY, posZ, Block.pistonMoving.blockID, l3, 4); - par1World.setBlockTileEntity(posX, posY, posZ, BlockPistonMoving.getTileEntity(k3, l3, side, true, false)); - } - - aint[k2++] = k3; - posX = l2; - posY = i3; - } - - posX = newX; - posY = blockID; - posZ = newZ; - - for (k2 = 0; posX != x || posY != y || posZ != z; posZ = j3) - { - l2 = posX - Facing.offsetsXForSide[side]; - i3 = posY - Facing.offsetsYForSide[side]; - j3 = posZ - Facing.offsetsZForSide[side]; - par1World.notifyBlocksOfNeighborChange(l2, i3, j3, aint[k2++]); - posX = l2; - posY = i3; - } - - return true; - } - } - - private static boolean canPushBlock (int par0, World par1World, int par2, int par3, int par4, boolean par5) - { - if (par0 == Block.obsidian.blockID) - { - return false; - } - else - { - if (par0 != Block.pistonBase.blockID && par0 != Block.pistonStickyBase.blockID) - { - if (Block.blocksList[par0].getBlockHardness(par1World, par2, par3, par4) == -1.0F) - { - return false; - } - - if (Block.blocksList[par0].getMobilityFlag() == 2) - { - return false; - } - - if (Block.blocksList[par0].getMobilityFlag() == 1) - { - if (!par5) - { - return false; - } - - return true; - } - } - /*else if (isExtended(par1World.getBlockMetadata(par2, par3, par4))) - { - return false; - }*/ - - return !par1World.blockHasTileEntity(par2, par3, par4); - } - } - + @Override public void readFromNBT (NBTTagCompound tags) { @@ -469,4 +349,9 @@ public class DrawbridgeLogic extends InventoryLogic implements IFacingLogic, IAc readFromNBT(packet.customParam1); worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); } + + public boolean hasExtended () + { + return extension != 0; + } } diff --git a/mods/tinker/tconstruct/blocks/logic/FirestarterLogic.java b/mods/tinker/tconstruct/blocks/logic/FirestarterLogic.java index ffdad9ba..1d4042f9 100644 --- a/mods/tinker/tconstruct/blocks/logic/FirestarterLogic.java +++ b/mods/tinker/tconstruct/blocks/logic/FirestarterLogic.java @@ -16,7 +16,8 @@ import net.minecraftforge.common.ForgeDirection; public class FirestarterLogic extends TileEntity implements IFacingLogic, IActiveLogic { boolean active; - boolean putOut; + //boolean putOut; + boolean shouldActivate; byte direction; @Override @@ -28,10 +29,14 @@ public class FirestarterLogic extends TileEntity implements IFacingLogic, IActiv @Override public void setActive (boolean flag) { - if (active && !flag) + /*if (active && !flag) + { putOut = true; + }*/ + active = flag; - setFire(); + shouldActivate = true; + //setFire(); } void setFire () @@ -65,6 +70,7 @@ public class FirestarterLogic extends TileEntity implements IFacingLogic, IActiv Block block = Block.blocksList[worldObj.getBlockId(xPos, yPos, zPos)]; if (active) { + System.out.println("Setting fire"); if (block == null || block.isAirBlock(worldObj, xPos, yPos, zPos)) { worldObj.playSoundEffect((double) xPos + 0.5D, (double) yPos + 0.5D, (double) zPos + 0.5D, "fire.ignite", 1.0F, AbilityHelper.random.nextFloat() * 0.4F + 0.8F); @@ -73,17 +79,26 @@ public class FirestarterLogic extends TileEntity implements IFacingLogic, IActiv } else { + //System.out.println("Stopping fire "+putOut); if (block == Block.fire) { - if (putOut) - { - worldObj.playSoundEffect((double) xPos + 0.5D, (double) yPos + 0.5D, (double) zPos + 0.5D, "random.fizz", 1.0F, AbilityHelper.random.nextFloat() * 0.4F + 0.8F); - putOut = false; - } + //worldObj.playSoundEffect((double) xPos + 0.5D, (double) yPos + 0.5D, (double) zPos + 0.5D, "random.fizz", 1.0F, AbilityHelper.random.nextFloat() * 0.4F + 0.8F); + worldObj.playSoundEffect((double) xPos + 0.5D, (double) yPos + 0.5D, (double) zPos + 0.5D, "fire.ignite", 1.0F, AbilityHelper.random.nextFloat() * 0.4F + 0.8F); worldObj.setBlock(xPos, yPos, zPos, 0, 0, 3); + //putOut = false; + shouldActivate = true; } } } + + public void updateEntity () + { + if (shouldActivate) + { + shouldActivate = false; + setFire(); + } + } @Override public byte getRenderDirection () diff --git a/mods/tinker/tconstruct/blocks/logic/SmelteryLogic.java b/mods/tinker/tconstruct/blocks/logic/SmelteryLogic.java index bda8e701..a723fc2f 100644 --- a/mods/tinker/tconstruct/blocks/logic/SmelteryLogic.java +++ b/mods/tinker/tconstruct/blocks/logic/SmelteryLogic.java @@ -320,11 +320,11 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci EntityLiving living = (EntityLiving) o; if (living.attackEntityFrom(new SmelteryDamageSource(), 1)) { - if (currentLiquid + 8 < maxLiquid) + /*if (currentLiquid + 8 < maxLiquid) { int amount = living.isChild() ? 2 : 8; this.addMoltenMetal(new LiquidStack(TContent.liquidMetalStill.blockID, amount, 16), false); - } + }*/ } } /*boolean itemAdded = false; diff --git a/mods/tinker/tconstruct/client/CustomBowRenderer.java b/mods/tinker/tconstruct/client/CustomBowRenderer.java index 2755681b..f8589cfc 100644 --- a/mods/tinker/tconstruct/client/CustomBowRenderer.java +++ b/mods/tinker/tconstruct/client/CustomBowRenderer.java @@ -52,12 +52,18 @@ public class CustomBowRenderer implements IItemRenderer block = Block.blocksList[stack.itemID]; } - Icon icon = living.getItemIcon(stack, renderPass); + Icon icon = null; //living.getItemIcon(stack, renderPass); if (living instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) living; if (player.getItemInUse() != null) icon = stack.getItem().getIcon(stack, renderPass, player, player.getItemInUse(), player.getItemInUseCount()); + else + icon = living.getItemIcon(stack, renderPass); + } + else + { + icon = living.getItemIcon(stack, renderPass); } if (icon == null) @@ -84,14 +90,6 @@ public class CustomBowRenderer implements IItemRenderer GL11.glRotatef(180.0F, 0F, 0F, 1.0F); GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.75F); GL11.glTranslatef(-0.6F, -0.25F, 1.0F); - //GL11.glRotatef(-90.0F, 0F, 1.0F, -1.0F); - - //GL11.glRotatef(90.0F, 0F, 1.0F, 1.0F); - //GL11.glRotatef(90.0F, 1.0F, 0F, 1.0F); - //GL11.glRotatef(90.0F, 0F, 1.0F, 0.5F); - - //GL11.glRotatef(-90.0F, 0.0F, 0.0F, 1.0F); - //GL11.glRotatef(59.0F, 0.0F, 0.0F, 1.0F); GL11.glScalef(1.75F, 1.75F, 1.75F); } @@ -111,7 +109,7 @@ public class CustomBowRenderer implements IItemRenderer GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F); ItemRenderer.renderItemIn2D(tessellator, f1, f2, f, f3, icon.getSheetWidth(), icon.getSheetHeight(), 0.0625F); - if (stack != null && stack.hasEffect() && renderPass == 0) + /*if (stack != null && stack.hasEffect() && renderPass == 0) { GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDisable(GL11.GL_LIGHTING); @@ -140,7 +138,7 @@ public class CustomBowRenderer implements IItemRenderer GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthFunc(GL11.GL_LEQUAL); - } + }*/ GL11.glDisable(GL12.GL_RESCALE_NORMAL); diff --git a/mods/tinker/tconstruct/client/TProxyClient.java b/mods/tinker/tconstruct/client/TProxyClient.java index 083d122f..178a8367 100644 --- a/mods/tinker/tconstruct/client/TProxyClient.java +++ b/mods/tinker/tconstruct/client/TProxyClient.java @@ -19,6 +19,7 @@ import mods.tinker.tconstruct.client.pages.*; import mods.tinker.tconstruct.common.*; import mods.tinker.tconstruct.entity.*; import mods.tinker.tconstruct.entity.projectile.*; +import mods.tinker.tconstruct.inventory.MiniGardyContainer; import mods.tinker.tconstruct.library.*; import mods.tinker.tconstruct.library.client.*; import mods.tinker.tconstruct.library.crafting.*; @@ -60,6 +61,7 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.settings.GameSettings; import net.minecraft.client.settings.KeyBinding; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -131,6 +133,18 @@ public class TProxyClient extends TProxyCommon TProxyClient.knapsack.init(Minecraft.getMinecraft().thePlayer); return new KnapsackGui(player.inventory, TProxyClient.knapsack); } + if (ID == miniGardyGui) + { + for (Object o : world.loadedEntityList) + { + Entity entity = (Entity) o; + if (entity.entityId == x) + { + return new MiniGardyGui(player.inventory, (MiniGardy) entity); + } + } + return null; + } return null; } diff --git a/mods/tinker/tconstruct/client/gui/DrawbridgeGui.java b/mods/tinker/tconstruct/client/gui/DrawbridgeGui.java index 25b00082..9f0bf22d 100644 --- a/mods/tinker/tconstruct/client/gui/DrawbridgeGui.java +++ b/mods/tinker/tconstruct/client/gui/DrawbridgeGui.java @@ -32,12 +32,5 @@ public class DrawbridgeGui extends GuiContainer int cornerX = (width - xSize) / 2; int cornerY = (height - ySize) / 2; drawTexturedModalRect(cornerX, cornerY, 0, 0, xSize, ySize); - /*if (logic.fuel > 0) - { - int fuel = logic.gaugeFuelScaled(12); - drawTexturedModalRect(cornerX + 27, (cornerY + 40) - fuel, 176, 12 - fuel, 14, fuel + 2); - } - int fuelgague = logic.gaugeProgressScaled(24); - drawTexturedModalRect(cornerX + 140, cornerY + 8, 176, 14, fuelgague, 16);*/ } } diff --git a/mods/tinker/tconstruct/client/gui/MiniGardyGui.java b/mods/tinker/tconstruct/client/gui/MiniGardyGui.java new file mode 100644 index 00000000..f52dd263 --- /dev/null +++ b/mods/tinker/tconstruct/client/gui/MiniGardyGui.java @@ -0,0 +1,36 @@ +package mods.tinker.tconstruct.client.gui; + +import mods.tinker.tconstruct.entity.MiniGardy; +import mods.tinker.tconstruct.inventory.MiniGardyContainer; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import org.lwjgl.opengl.GL11; + +public class MiniGardyGui extends GuiContainer +{ + public MiniGardy gardy; + + public MiniGardyGui(InventoryPlayer inventoryplayer, MiniGardy gardy) + { + super(new MiniGardyContainer(inventoryplayer, gardy)); + this.gardy = gardy; + } + + protected void drawGuiContainerForegroundLayer (int par1, int par2) + { + fontRenderer.drawString(gardy.getEntityName(), 8, 6, 0x404040); + fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, (ySize - 96) + 4, 0x404040); + } + + protected void drawGuiContainerBackgroundLayer (float f, int i, int j) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture("/mods/tinker/textures/gui/googirl.png"); + int cornerX = (width - xSize) / 2; + int cornerY = (height - ySize) / 2; + drawTexturedModalRect(cornerX, cornerY, 0, 0, xSize, ySize); + } +} diff --git a/mods/tinker/tconstruct/common/TContent.java b/mods/tinker/tconstruct/common/TContent.java index 05f0b278..0d752298 100644 --- a/mods/tinker/tconstruct/common/TContent.java +++ b/mods/tinker/tconstruct/common/TContent.java @@ -151,10 +151,10 @@ public class TContent implements IFuelHandler //InfiBlocks public static Block speedBlock; public static Block glass; - public static Block stainedGlass; + //public static Block stainedGlass; public static Block stainedGlassClear; public static Block glassPane; - public static Block stainedGlassPane; + //public static Block stainedGlassPane; public static Block stainedGlassClearPane; public static Block glassMagicSlab; public static Block stainedGlassMagicSlab; @@ -947,6 +947,15 @@ public class TContent implements IFuelHandler Smeltery.addMelting(Block.glass, 0, 625, new LiquidStack(liquidMetalStill.blockID, LiquidContainerRegistry.BUCKET_VOLUME, 13)); Smeltery.addMelting(Block.stone, 0, 800, new LiquidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue / 18, 14)); Smeltery.addMelting(Block.cobblestone, 0, 800, new LiquidStack(liquidMetalStill.blockID, TConstruct.ingotLiquidValue / 18, 14)); + + Smeltery.addMelting(glass, 0, 500, new LiquidStack(liquidMetalStill.blockID, 1000, 13)); + Smeltery.addMelting(glassPane, 0, 350, new LiquidStack(liquidMetalStill.blockID, 250, 13)); + + for (int i = 0; i < 16; i++) + { + Smeltery.addMelting(stainedGlassClear, i, 500, new LiquidStack(liquidMetalStill.blockID, 1000, 13)); + Smeltery.addMelting(stainedGlassClearPane, i, 350, new LiquidStack(liquidMetalStill.blockID, 250, 13)); + } //Alloys Smeltery.addAlloyMixing(new LiquidStack(liquidMetalStill.blockID, 16, 7), new LiquidStack(liquidMetalStill.blockID, 24, 2), new LiquidStack(liquidMetalStill.blockID, 8, 3)); //Bronze diff --git a/mods/tinker/tconstruct/common/TProxyCommon.java b/mods/tinker/tconstruct/common/TProxyCommon.java index 59600420..2c865b59 100644 --- a/mods/tinker/tconstruct/common/TProxyCommon.java +++ b/mods/tinker/tconstruct/common/TProxyCommon.java @@ -1,19 +1,16 @@ package mods.tinker.tconstruct.common; -import java.io.File; - import mods.tinker.tconstruct.TConstruct; -import mods.tinker.tconstruct.inventory.ArmorExtendedContainer; -import mods.tinker.tconstruct.inventory.KnapsackContainer; +import mods.tinker.tconstruct.entity.MiniGardy; +import mods.tinker.tconstruct.inventory.*; import mods.tinker.tconstruct.library.blocks.InventoryLogic; import mods.tinker.tconstruct.util.player.TPlayerStats; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.registry.LanguageRegistry; -import cpw.mods.fml.common.registry.TickRegistry; -import cpw.mods.fml.relauncher.Side; /** * Common proxy class for InfiTools @@ -34,6 +31,8 @@ public class TProxyCommon implements IGuiHandler public static int inventoryGui = 100; public static int armorGuiID = 101; public static int knapsackGuiID = 102; + + public static int miniGardyGui = 131; public static int manualGuiID = -1; @@ -68,6 +67,18 @@ public class TProxyCommon implements IGuiHandler TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.username); return new KnapsackContainer(player.inventory, stats.knapsack); } + if (ID == miniGardyGui) + { + for (Object o : world.loadedEntityList) + { + Entity entity = (Entity) o; + if (entity.entityId == x) + { + return new MiniGardyContainer(player.inventory, (MiniGardy) entity); + } + } + return null; + } } return null; } diff --git a/mods/tinker/tconstruct/entity/MiniGardy.java b/mods/tinker/tconstruct/entity/MiniGardy.java index 17dc626c..10b0795c 100644 --- a/mods/tinker/tconstruct/entity/MiniGardy.java +++ b/mods/tinker/tconstruct/entity/MiniGardy.java @@ -1,6 +1,9 @@ package mods.tinker.tconstruct.entity; -import mods.tinker.tconstruct.entity.ai.*; +import mods.tinker.tconstruct.TConstruct; +import mods.tinker.tconstruct.common.TProxyCommon; +import mods.tinker.tconstruct.entity.ai.GAIFellTree; +import mods.tinker.tconstruct.entity.ai.GAIFollowOwner; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; @@ -32,21 +35,35 @@ public class MiniGardy extends GolemBase public boolean interact (EntityPlayer player) { - ItemStack stack = this.getHeldItem(); - if (stack == null) + if (player.isSneaking()) { - this.setCurrentItemOrArmor(0, player.getCurrentEquippedItem().copy()); - player.destroyCurrentEquippedItem(); + if (!worldObj.isRemote) + player.openGui(TConstruct.instance, TProxyCommon.miniGardyGui, this.worldObj, this.entityId, 0, 0); + return true; + //return false; } else { - if (player.inventory.addItemStackToInventory(stack.copy())) + ItemStack stack = this.getHeldItem(); + if (stack == null) { - //this.worldObj.playSoundAtEntity(this, par1Str, par2, par3); - this.worldObj.playSoundAtEntity(player, "random.pop", 0.3F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); - this.setCurrentItemOrArmor(0, null); + ItemStack playerStack = player.getCurrentEquippedItem(); + if (playerStack != null) + { + this.setCurrentItemOrArmor(0, playerStack.copy()); + player.destroyCurrentEquippedItem(); + } } + else + { + if (player.inventory.addItemStackToInventory(stack.copy())) + { + //this.worldObj.playSoundAtEntity(this, par1Str, par2, par3); + this.worldObj.playSoundAtEntity(player, "random.pop", 0.3F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); + this.setCurrentItemOrArmor(0, null); + } + } + return true; } - return true; } } diff --git a/mods/tinker/tconstruct/inventory/DrawbridgeContainer.java b/mods/tinker/tconstruct/inventory/DrawbridgeContainer.java index cbfb7c39..33c2fe32 100644 --- a/mods/tinker/tconstruct/inventory/DrawbridgeContainer.java +++ b/mods/tinker/tconstruct/inventory/DrawbridgeContainer.java @@ -18,7 +18,7 @@ public class DrawbridgeContainer extends Container { this.logic = logic; - this.addSlotToContainer(new Slot(logic, 0, 80, 36)); + this.addSlotToContainer(new DrawbridgeSlot(logic, 0, 80, 36, logic)); this.addSlotToContainer(new Slot(logic, 1, 35, 36)); /* Player inventory */ diff --git a/mods/tinker/tconstruct/inventory/DrawbridgeSlot.java b/mods/tinker/tconstruct/inventory/DrawbridgeSlot.java new file mode 100644 index 00000000..58af4523 --- /dev/null +++ b/mods/tinker/tconstruct/inventory/DrawbridgeSlot.java @@ -0,0 +1,28 @@ +package mods.tinker.tconstruct.inventory; + +import mods.tinker.tconstruct.blocks.logic.DrawbridgeLogic; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class DrawbridgeSlot extends Slot +{ + DrawbridgeLogic logic; + public DrawbridgeSlot(IInventory iinventory, int par2, int par3, int par4, DrawbridgeLogic logic) + { + super(iinventory, par2, par3, par4); + this.logic = logic; + } + + public boolean isItemValid(ItemStack par1ItemStack) + { + return !logic.hasExtended(); + } + + + public boolean canTakeStack(EntityPlayer par1EntityPlayer) + { + return !logic.hasExtended(); + } +} diff --git a/mods/tinker/tconstruct/inventory/MiniGardyContainer.java b/mods/tinker/tconstruct/inventory/MiniGardyContainer.java new file mode 100644 index 00000000..ca63e92f --- /dev/null +++ b/mods/tinker/tconstruct/inventory/MiniGardyContainer.java @@ -0,0 +1,82 @@ +package mods.tinker.tconstruct.inventory; + +import mods.tinker.tconstruct.entity.MiniGardy; +import mods.tinker.tconstruct.library.util.IPattern; +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; + +public class MiniGardyContainer extends Container +{ + public MiniGardy gardy; + + public MiniGardyContainer(InventoryPlayer inventoryplayer, MiniGardy entity) + { + gardy = entity; + for (int column = 0; column < 2; column++) + { + for (int row = 0; row < 7; row++) + { + this.addSlotToContainer(new Slot(entity, row + column * 7, 44 + row * 18, 36 + 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, 8 + row * 18, 86 + column * 18)); + } + } + + for (int column = 0; column < 9; column++) + { + this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 144)); + } + } + + @Override + public boolean canInteractWith (EntityPlayer entityplayer) + { + return gardy.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 < gardy.getSizeInventory()) + { + if (!this.mergeItemStack(slotStack, gardy.getSizeInventory(), this.inventorySlots.size(), true)) + { + return null; + } + } + else if (!this.mergeItemStack(slotStack, 0, gardy.getSizeInventory(), false)) + { + return null; + } + + if (slotStack.stackSize == 0) + { + slot.putStack((ItemStack) null); + } + else + { + slot.onSlotChanged(); + } + } + + return stack; + } +} diff --git a/mods/tinker/tconstruct/library/TConstructRegistry.java b/mods/tinker/tconstruct/library/TConstructRegistry.java index 8588f047..4ea9a545 100644 --- a/mods/tinker/tconstruct/library/TConstructRegistry.java +++ b/mods/tinker/tconstruct/library/TConstructRegistry.java @@ -498,6 +498,7 @@ public class TConstructRegistry * 3: Has rotational metadata * 4: Rails * 5: Has rotational TileEntity data + * 6: Custom placement logic */ public static int[] drawbridgeState = new int[Block.blocksList.length]; /** Blocks that are interchangable with each other. Ex: Still and flowing water */ diff --git a/mods/tinker/textures/gui/googirl.png b/mods/tinker/textures/gui/googirl.png new file mode 100644 index 0000000000000000000000000000000000000000..59aa23ae732a58adf2bfdf11f8ece8a590f81b51 GIT binary patch literal 1829 zcmah~Yfuwc6h51TB)mZlNU;#KLa=~TsZ}5lH7TSek*7eZn5rmRf+!{gkP@^N5QS7{ z6vTum3Pg({A|Qe+z5qpm0%8fsqfUWPq{>Tqr3=zdf7o{K?72H<_ul=^_kCwK*^}$0 ztM!2v0O+#ance^hc8LI)h)rMb&)bPj#BE=?F+n{$;8NQud|kWaEa%Oq1d#% zY?~Q>qRz(6ajP;sJ}?flF}n6u{s|XJNMPBFNew$Qq_y|uj#bI`w>9Pk%XghHdt$2sjCdcMyq)Si>mr;U5{dP;EU{d!47 ztlEMrbFtneb5Tr3vAo*f42Q4mzGNj?ZVdJ>Qq-?|oR6Lly=W!*!sm}4eMn&lulX{b zjv#2#mf*Agbg`-N%ogJ}=hR$4(HLCfk?OcgH+_gH)nWkPfS#Z)4KpDC6?i(A#lG>A z+E9Q4Z@*Y`bpOq;DZEh%tFAZF?F`q(D5Yk2YNCE}<;c19;7ck^cCN2@D0#AoubT{J1gYj8lJ5>9@D>BAdCg=%W2?VU?m1>zKrp-$naUw&~lJl(GwEw z4ao&K@hA3%?jT9sUrCDSw65~^&>+%*4yYE400DG=aH|N;n zP+oB8+8EwD3m@SL?VpBq8}PY=J>PEdGWFTsye?Q;HeAh=>*3{&D5r>Sn0H*gDQK@n z{*!&GW~nQG>cj%D=S6V{J;F0$>a4^15H!7gth{m(A;7XIW#sfr!~l*-GFu6txtbCH zJW4~~B!_^*@FZWkZ3~)Pr!axM7O{T$c@WLP9X1o&!ZTa|!ie|#Y)teiF9m5R$z0Jk zq0U?Vlj8xal%ztNM@dPhhmG6Lpxc*99QiWWflUTGMRYrU1n@U0BP-4Qk2FAx6crq-OZ_JFv z0M$Ncegy6lJ)7tR06El~TO>K%>n`a9F2)b5;oS=Ya zQ2ypX)A_BANs<|=k=uG53MrWoSL9?!TVT@3*9J1odBxzJ3iEHBPf1GKPUBaee)PbV zS2q-N72_E5i@$1|ELI_*+vZcEj56E5(7tyoF+`BD8=9A-q^`Jumi~<&mYrlV15br8 z?;Wqww!|r#5*;TOCOjPwFqvU%GF3}*QYeg3aQLR@xFcsEoqU1xpCGBQ1ZMz@LmmY0 z+;Kr)>Rg#v?A)#4Ne524D4W~lXo>4bu#R|dmEu|Zks%R_66(T)=Ki=3%Y2*+$rCk9 zYS24&M3Od3xdK&dobS8tVIEK64G$B&*DlRXAk#{5G@-`3W$559eUu~A=yMMvF%vohJ| zeWJ)?@N8XoAJ*c(4k}CZ2-TV}VSC{UO9C2_bW0#qqabLeQ)4s`Q>Q1tH94!8qsNn z4#iIi==xoW=JCmCSu?vw@Gjp?_(+ckcGhRzuXmm1n?VPOA-L0Mesybwy*|uwza<>$ zGhdis0GduaXb%p$>GFv_Pb}!Na6s12ei;AF2E_A1Gc+K#?$Uf~(;lgx>(+H?9N|?2yD{(W zyuQyq44M6F!OsCRO{vv}hJmN<3vUS`ELtdN*qTU(#X7o})Bo>~