Jump to content

Skytanic

Members
  • Posts

    29
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • URL
    http://SkytanicDevelopment.com
  • Location
    Oregon
  • Personal Text
    Developer of Atomic Manipulation

Skytanic's Achievements

Tree Puncher

Tree Puncher (2/8)

1

Reputation

  1. I have a hopefully easy to answer question. I want to add a slot to this machine using this.addSlotToContainer(new Slot(MolecularAssemblerTileEntity, ID, xCoord, yCoord); Now, I have a few questions, first off, how do the ID's between the tile entity slots, the slotCrafting slots, and the player inventory slots work? Because in my code (which I took from vanilla) it assigns the id 0 to the following slots SlotCrafting( the first slot added) craftMatrix(the second slot added) action bar (the first slot added in the third loop down) So my question is how are these handled exactly? Obviously they can't all be assigned to 0 otherwise the transferStackInSlot method would not work correctly. My next question is this, if I were to add the slot I want to (the first MolecularAssemblerTileEntitySlot) and assigned it to 0 as well, how would that be handled in relation to the rest? Would it "push" the other slots by one? And finally, if I did add this slot, how would I alter my transferStackInSlot method to compensate for the "push" mentioned above (assuming that is what is happening). I have tried this already and found out that with both the Tile Entity slot and SlotCrafting slot assigned to 0, when I debug in transferStackInSlot it seems that the Tile Entity slot is read as 0 and the SlotCrafting slot is read as 1. However, if I for example use if (par2 == 0) // Should take what is in the Tile Entity slot and place it in the inventory { if (!this.mergeItemStack(itemstack1, 11, 47, false)) { return null; } } if (par2 == 1) // Identical to the original if check in the code below, but functions differently { if (!this.mergeItemStack(itemstack1, 11, 47, true)) { return null; } slot.onSlotChange(itemstack1, itemstack); } first of all, the first if check does place the item from the TileEntity slot into my inventory, but leaves a copy in the slot that I have to manually take out. The second if check should function as normal because the only change is that I added one more slot (which I accommodated for by changing 10 and 46 to 11 and 47) but instead, moves the result to my inventory but does not remove the item used to craft it. I'm sorry, I realize how confusing I'm making this sound but it is really hard for me to describe the actual problems. If you need clarification on anything please ask!! Container Class: package skytanic.atomicmanipulation.blocks.magui; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCraftResult; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.Slot; import net.minecraft.inventory.SlotCrafting; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import skytanic.atomicmanipulation.blocks.crafting.MolecularAssemblerCraftingManager; import skytanic.atomicmanipulation.blocks.tileentity.MolecularAssemblerTileEntity; import skytanic.atomicmanipulation.common.AtomicManipulation; public class MolecularAssemblerContainer extends Container { /** The crafting matrix inventory (3x3). */ public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3); public IInventory craftResult = new InventoryCraftResult(); private World worldObj; private int posX; private int posY; private int posZ; public MolecularAssemblerContainer(InventoryPlayer par1InventoryPlayer, MolecularAssemblerTileEntity entity, World par2World, int par3, int par4, int par5) { worldObj = par2World; this.posX = par3; this.posY = par4; this.posZ = par5; this.addSlotToContainer(new SlotCrafting(par1InventoryPlayer.player, this.craftMatrix, this.craftResult, 0, 121, 35)); for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { this.addSlotToContainer(new Slot(this.craftMatrix, j + i * 3, 39 + j * 18, 17 + i * 18)); } } for (int i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(par1InventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for (int i = 0; i < 9; ++i) { this.addSlotToContainer(new Slot(par1InventoryPlayer, i, 8 + i * 18, 142)); } this.onCraftMatrixChanged(this.craftMatrix); } public void onCraftMatrixChanged(IInventory iinventory){ craftResult.setInventorySlotContents(0, MolecularAssemblerCraftingManager.getInstance().findMatchingRecipe(craftMatrix, worldObj)); } /** * Called when the container is closed. */ public void onContainerClosed(EntityPlayer par1EntityPlayer) { super.onContainerClosed(par1EntityPlayer); if (!this.worldObj.isRemote) { for (int i = 0; i < 9; ++i) { ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i); if (itemstack != null) { par1EntityPlayer.dropPlayerItemWithRandomChoice(itemstack, false); } } } } public boolean canInteractWith(EntityPlayer player) { if(worldObj.getBlock(posX, posY, posZ) != AtomicManipulation.MolecularAssembler){ return false; }else{ return player.getDistanceSq((double)posX + 0.5D, (double)posY + 0.5D, (double)posZ + 0.5D) <= 64.0D; } } /** * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that. */ public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) { ItemStack itemstack = null; Slot slot = (Slot)this.inventorySlots.get(par2); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (par2 == 0) { if (!this.mergeItemStack(itemstack1, 10, 46, true)) { return null; } slot.onSlotChange(itemstack1, itemstack); } else if (par2 >= 10 && par2 < 37) { if (!this.mergeItemStack(itemstack1, 37, 46, false)) { return null; } } else if (par2 >= 37 && par2 < 46) { if (!this.mergeItemStack(itemstack1, 10, 37, false)) { return null; } } else if (!this.mergeItemStack(itemstack1, 10, 46, false)) { return null; } if (itemstack1.stackSize == 0) { slot.putStack((ItemStack)null); } else { slot.onSlotChanged(); } if (itemstack1.stackSize == itemstack.stackSize) { return null; } slot.onPickupFromSlot(par1EntityPlayer, itemstack1); } return itemstack; } }
  2. still trying to figure this one out if anyone can see something wrong or knows a way to find out what is
  3. Damn..too bad. I really appreciate your time anyways
  4. Hmm, well this all has me really confused. Can't seem to find out why it wouldn't be working..
  5. Hmm, well I set a break point at the server return and it was called, it went into a bunch of the vanilla server and network classes but I couldn't follow it to calling the Client method. Is there anything you would recommend to help debug this, because I don't exactly have the best Idea on what I am doing.
  6. I tested first with no code commented out, then I commented out the return new container, then commented both return new container and return new gui. Every time it crashed, and every time only the server side was called. Actually it only crashed the last two times because I didn't return anything in the case I think. Anyways, now it isn't crashing but only the server side is being called still.
  7. Sure! Here it is, I can see why it would happen here, as this is the first gui I've done without it being a tile entity so I kinda just followed what someone else said. package skytanic.atomicmanipulation.blocks.msgui; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import skytanic.atomicmanipulation.blocks.aesgui.AESContainer; import skytanic.atomicmanipulation.blocks.aesgui.AESGui; import skytanic.atomicmanipulation.blocks.eegui.ElementExtractorContainer; import skytanic.atomicmanipulation.blocks.eegui.ElementExtractorGui; import skytanic.atomicmanipulation.blocks.magui.MolecularAssemblerContainer; import skytanic.atomicmanipulation.blocks.magui.MolecularAssemblerGui; import skytanic.atomicmanipulation.blocks.orgui.RefineryControllerContainer; import skytanic.atomicmanipulation.blocks.orgui.RefineryControllerGui; import skytanic.atomicmanipulation.blocks.petrogui.PetroProcessorContainer; import skytanic.atomicmanipulation.blocks.petrogui.PetroProcessorGui; import skytanic.atomicmanipulation.blocks.polygui.PolymerizerContainer; import skytanic.atomicmanipulation.blocks.polygui.PolymerizerGui; import skytanic.atomicmanipulation.blocks.tileentity.AESTileEntity; import skytanic.atomicmanipulation.blocks.tileentity.ElementExtractorTileEntity; import skytanic.atomicmanipulation.blocks.tileentity.MatterScannerTileEntity; import skytanic.atomicmanipulation.blocks.tileentity.PetroProcessorTileEntity; import skytanic.atomicmanipulation.blocks.tileentity.PolymerizerTileEntity; import skytanic.atomicmanipulation.blocks.tileentity.RefineryControllerTileEntity; import skytanic.atomicmanipulation.common.AtomicManipulation; import cpw.mods.fml.common.network.IGuiHandler; public class GuiHandler implements IGuiHandler{ @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity entity = world.getTileEntity(x, y, z); switch(ID){ case AtomicManipulation.ElementExtractorGuiId: if (entity instanceof ElementExtractorTileEntity) { return new ElementExtractorContainer(player.inventory, (ElementExtractorTileEntity) entity); }else{ return null; } case AtomicManipulation.MatterScannerGuiId: if(entity != null && entity instanceof MatterScannerTileEntity){ return new MatterScannerContainer(player.inventory, (MatterScannerTileEntity) entity); }else{ return null; } case AtomicManipulation.AESGuiId: if(entity != null && entity instanceof AESTileEntity){ return new AESContainer(player.inventory, (AESTileEntity) entity); }else{ return null; } case AtomicManipulation.PetroProcessorGuiId: if (entity instanceof PetroProcessorTileEntity) { return new PetroProcessorContainer(player.inventory, (PetroProcessorTileEntity) entity); }else{ return null; } case AtomicManipulation.PolymerizerGuiId: if (entity instanceof PolymerizerTileEntity) { return new PolymerizerContainer(player.inventory, (PolymerizerTileEntity) entity); }else{ return null; } case AtomicManipulation.MolecularAssemblerGuiId: return ID == AtomicManipulation.MolecularAssemblerGuiId && world.getBlock(x, y, z) == AtomicManipulation.MolecularAssembler ? new MolecularAssemblerContainer(player.inventory, world, x, y, z): null; case AtomicManipulation.RefineryControllerGuiId: int z2 = 0; int y2 = 0; int x2 = 0; int z3 = 0; int y3 = 0; int x3 = 0; while(entity instanceof RefineryControllerTileEntity && world.getBlockMetadata(x+x2-x3, y+y2-y3, z+z2-z3) != 15){ if(z3 != 2){ ++z3; } else if(z3 == 2 && y3 != 2){ ++y3; z3 = 0; } else if(z3 == 2 && y3 == 2 && x3 != 2){ ++x3; y3 = 0; z3 = 0; } else if(z3 == 2 && y3 == 2 && x3 == 2 && z2 != 2){ ++z2; x3 = 0; y3 = 0; z3 = 0; } else if(z3 == 2 && y3 == 2 && x3 == 2 && z2 == 2 && y2 != 2){ ++y2; z2 = 0; x3 = 0; y3 = 0; z3 = 0; } else if(z3 == 2 && y3 == 2 && x3 == 2 && z2 == 2 && y2 == 2 && x2 != 2){ ++x2; y2 = 0; z2 = 0; x3 = 0; y3 = 0; z3 = 0; } } return new RefineryControllerContainer(player.inventory, (RefineryControllerTileEntity)world.getTileEntity(x+x2-x3, y+y2-y3, z+z2-z3)); } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity entity = world.getTileEntity(x, y, z); if(entity != null) { switch(ID){ case AtomicManipulation.MatterScannerGuiId: if(entity instanceof MatterScannerTileEntity){ return new MatterScannerGui(player.inventory, (MatterScannerTileEntity) entity); } case AtomicManipulation.ElementExtractorGuiId: if (entity instanceof ElementExtractorTileEntity) { return new ElementExtractorGui(player.inventory, (ElementExtractorTileEntity) entity); } case AtomicManipulation.PetroProcessorGuiId: if(entity instanceof PetroProcessorTileEntity){ return new PetroProcessorGui(player.inventory, (PetroProcessorTileEntity) entity); } case AtomicManipulation.PolymerizerGuiId: if(entity instanceof PolymerizerTileEntity){ return new PolymerizerGui(player.inventory, (PolymerizerTileEntity) entity); } case AtomicManipulation.AESGuiId: if(entity instanceof AESTileEntity){ return new AESGui(player.inventory, (AESTileEntity) entity); } case AtomicManipulation.MolecularAssemblerGuiId: return ID == AtomicManipulation.MolecularAssemblerGuiId && world.getBlock(x, y, z) == AtomicManipulation.MolecularAssembler ? new MolecularAssemblerGui(player.inventory, world, x, y, z): null; case AtomicManipulation.RefineryControllerGuiId: int z2 = 0; int y2 = 0; int x2 = 0; int z3 = 0; int y3 = 0; int x3 = 0; while(entity instanceof RefineryControllerTileEntity && world.getBlockMetadata(x+x2-x3, y+y2-y3, z+z2-z3) != 15){ if(z3 != 2){ ++z3; } else if(z3 == 2 && y3 != 2){ ++y3; z3 = 0; } else if(z3 == 2 && y3 == 2 && x3 != 2){ ++x3; y3 = 0; z3 = 0; } else if(z3 == 2 && y3 == 2 && x3 == 2 && z2 != 2){ ++z2; x3 = 0; y3 = 0; z3 = 0; } else if(z3 == 2 && y3 == 2 && x3 == 2 && z2 == 2 && y2 != 2){ ++y2; z2 = 0; x3 = 0; y3 = 0; z3 = 0; } else if(z3 == 2 && y3 == 2 && x3 == 2 && z2 == 2 && y2 == 2 && x2 != 2){ ++x2; y2 = 0; z2 = 0; x3 = 0; y3 = 0; z3 = 0; } } return new RefineryControllerGui(player.inventory, (RefineryControllerTileEntity)world.getTileEntity(x+x2-x3, y+y2-y3, z+z2-z3)); } } return null; } } The one in question is Molecular Assembler
  8. So I'm not exactly sure what's wrong, I used a lot of the workbench source code so I may have missed something and that is the reason why I am crashing, but I just can't find it. Anyways here is the error. ---- Minecraft Crash Report ---- // Don't be sad. I'll do better next time, I promise! Time: 7/11/14 2:02 AM Description: Unexpected error java.lang.IndexOutOfBoundsException: Index: 45, Size: 45 at java.util.ArrayList.rangeCheck(Unknown Source) at java.util.ArrayList.get(Unknown Source) at net.minecraft.inventory.Container.getSlot(Container.java:132) at net.minecraft.inventory.Container.putStacksInSlots(Container.java:560) at net.minecraft.client.network.NetHandlerPlayClient.handleWindowItems(NetHandlerPlayClient.java:1192) at net.minecraft.network.play.server.S30PacketWindowItems.processPacket(S30PacketWindowItems.java:70) at net.minecraft.network.play.server.S30PacketWindowItems.processPacket(S30PacketWindowItems.java:78) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:232) at net.minecraft.client.multiplayer.PlayerControllerMP.updateController(PlayerControllerMP.java:321) at net.minecraft.client.Minecraft.runTick(Minecraft.java:1649) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:996) at net.minecraft.client.Minecraft.run(Minecraft.java:912) at net.minecraft.client.main.Main.main(Main.java:112) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at java.util.ArrayList.rangeCheck(Unknown Source) at java.util.ArrayList.get(Unknown Source) at net.minecraft.inventory.Container.getSlot(Container.java:132) at net.minecraft.inventory.Container.putStacksInSlots(Container.java:560) at net.minecraft.client.network.NetHandlerPlayClient.handleWindowItems(NetHandlerPlayClient.java:1192) at net.minecraft.network.play.server.S30PacketWindowItems.processPacket(S30PacketWindowItems.java:70) at net.minecraft.network.play.server.S30PacketWindowItems.processPacket(S30PacketWindowItems.java:78) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:232) at net.minecraft.client.multiplayer.PlayerControllerMP.updateController(PlayerControllerMP.java:321) -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityClientPlayerMP['Player847'/1, l='MpServer', x=234.33, y=57.62, z=-809.47]] Chunk stats: MultiplayerChunkCache: 225, 225 Level seed: 0 Level generator: ID 01 - flat, ver 0. Features enabled: false Level generator options: Level spawn location: World: (222,4,-815), Chunk: (at 14,0,1 in 13,-51; contains blocks 208,0,-816 to 223,255,-801), Region: (0,-2; contains chunks 0,-64 to 31,-33, blocks 0,0,-1024 to 511,255,-513) Level time: 2185 game time, 2185 day time Level dimension: 0 Level storage version: 0x00000 - Unknown? Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false Forced entities: 1 total; [EntityClientPlayerMP['Player847'/1, l='MpServer', x=234.33, y=57.62, z=-809.47]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:412) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2523) at net.minecraft.client.Minecraft.run(Minecraft.java:941) at net.minecraft.client.main.Main.main(Main.java:112) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) -- System Details -- Details: Minecraft Version: 1.7.2 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.8.0_05, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 650196952 bytes (620 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 20006 (1120336 bytes; 1 MB) allocated, 2 (112 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP v9.03 FML v7.2.211.1121 Minecraft Forge 10.12.2.1121 6 mods loaded, 6 mods active mcp{9.03} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available FML{7.2.211.1121} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.2.1121.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Forge{10.12.2.1121} [Minecraft Forge] (forgeSrc-1.7.2-10.12.2.1121.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available CodeChickenCore{1.0.1.7} [CodeChicken Core] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available NotEnoughItems{1.0.2.14} [Not Enough Items] (NotEnoughItems-1.7.2-1.0.2.14-dev.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Atomic{0.0.1 Pre-Alpha} [Atomic Manipulation] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Launched Version: 1.6 LWJGL: 2.9.0 OpenGL: AMD Radeon HD 7900 Series GL version 4.2.12002 Compatibility Profile Context 9.12.0.0, ATI Technologies Inc. Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Packs: [] Current Language: English (US) Profiler Position: N/A (disabled) Vec3 Pool Size: 69 (3864 bytes; 0 MB) allocated, 23 (1288 bytes; 0 MB) used Anisotropic Filtering: Off (1) and here are my classes Block: package skytanic.atomicmanipulation.blocks; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.IIcon; import net.minecraft.world.World; import skytanic.atomicmanipulation.common.AtomicManipulation; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockMolecularAssembler extends Block { @SideOnly(Side.CLIENT) private IIcon field_150035_a; @SideOnly(Side.CLIENT) private IIcon field_150034_b; private static final String __OBFID = "CL_00000221"; public BlockMolecularAssembler(int i, Material material) { super(material); this.setCreativeTab(AtomicManipulation.TabAtomic); this.setBlockName("MolecularAssembler"); } @SideOnly(Side.CLIENT) private IIcon bottom; @SideOnly(Side.CLIENT) private IIcon front; @SideOnly(Side.CLIENT) private IIcon side; @SideOnly(Side.CLIENT) @Override public IIcon getIcon(int side, int metadata){ if (side == 1) return this.blockIcon; else if (side == 0) return this.bottom; else if (metadata == 2 && side == 2) return this.front; else if (metadata == 3 && side == 5) return this.front; else if (metadata == 0 && side == 3) return this.front; else if (metadata == 1 && side == 4) return this.front; else return this.side; } @SideOnly(Side.CLIENT) // Registers textures for the block. public void registerBlockIcons(IIconRegister p_149651_1_){ this.blockIcon = p_149651_1_.registerIcon("atomic:MolecularAssembler"); this.side = p_149651_1_.registerIcon("atomic:MachineSide"); this.bottom = p_149651_1_.registerIcon("atomic:MachineBottom"); this.front = p_149651_1_.registerIcon("atomic:MachineSide"); } /** * Called upon block activation (right click on the block.) */ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { if(!player.isSneaking()){ player.openGui(AtomicManipulation.instance, AtomicManipulation.MolecularAssemblerGuiId, world, x, y, z); return true; }else{ return false; } } } Container package skytanic.atomicmanipulation.blocks.magui; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCraftResult; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.Slot; import net.minecraft.inventory.SlotCrafting; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import skytanic.atomicmanipulation.common.AtomicManipulation; public class MolecularAssemblerContainer extends Container { /** The crafting matrix inventory (3x3). */ public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3); public IInventory craftResult = new InventoryCraftResult(); private World worldObj; private int posX; private int posY; private int posZ; public MolecularAssemblerContainer(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5) { worldObj = par2World; this.posX = par3; this.posY = par4; this.posZ = par5; this.addSlotToContainer(new SlotCrafting(par1InventoryPlayer.player, this.craftMatrix, this.craftResult, 0, 121, 35)); for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { this.addSlotToContainer(new Slot(this.craftMatrix, j + i * 3, 39 + j * 18, 17 + i * 18)); } } for (int i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(par1InventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for (int i = 0; i < 9; ++i) { this.addSlotToContainer(new Slot(par1InventoryPlayer, i, 8 + i * 18, 142)); } this.onCraftMatrixChanged(this.craftMatrix); } public void onCraftMatrixChanged(IInventory iinventory){ //craftResult.setInventorySlotContents(0, MolecularAssemblerCraftingManager.getInstanct().findMatchingRecipe(craftMatrix, worldObj)); } /** * Called when the container is closed. */ public void onContainerClosed(EntityPlayer par1EntityPlayer) { super.onContainerClosed(par1EntityPlayer); if (!this.worldObj.isRemote) { for (int i = 0; i < 9; ++i) { ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i); if (itemstack != null) { par1EntityPlayer.dropPlayerItemWithRandomChoice(itemstack, false); } } } } public boolean canInteractWith(EntityPlayer player) { if(worldObj.getBlock(posX, posY, posZ) != AtomicManipulation.MolecularAssembler){ return false; }else{ return player.getDistanceSq((double)posX + 0.5D, (double)posY + 0.5D, (double)posZ + 0.5D) <= 64.0D; } } /** * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that. */ public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) { ItemStack itemstack = null; Slot slot = (Slot)this.inventorySlots.get(par2); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (par2 == 0) { if (!this.mergeItemStack(itemstack1, 10, 46, true)) { return null; } slot.onSlotChange(itemstack1, itemstack); } else if (par2 >= 10 && par2 < 37) { if (!this.mergeItemStack(itemstack1, 37, 46, false)) { return null; } } else if (par2 >= 37 && par2 < 46) { if (!this.mergeItemStack(itemstack1, 10, 37, false)) { return null; } } else if (!this.mergeItemStack(itemstack1, 10, 46, false)) { return null; } if (itemstack1.stackSize == 0) { slot.putStack((ItemStack)null); } else { slot.onSlotChanged(); } if (itemstack1.stackSize == itemstack.stackSize) { return null; } slot.onPickupFromSlot(par1EntityPlayer, itemstack1); } return itemstack; } } Gui package skytanic.atomicmanipulation.blocks.magui; import net.minecraft.client.Minecraft; 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 cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class MolecularAssemblerGui extends GuiContainer { public static final ResourceLocation texture = new ResourceLocation("atomic", "textures/gui/MolecularAssemblerGui.png"); public MolecularAssemblerGui(InventoryPlayer invPlayer, World world, int x, int y, int z) { super(new MolecularAssemblerContainer(invPlayer, world, x, y, z)); this.xSize = 176; this.ySize = 165; } public void drawGuiContainerForegroundLayer(int par1, int par2){ String s = "container.MolecularAssembler"; this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752); this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 5, 4210752); } public void drawGuiContainerBackgroundLayer(float f, int j, int i) { GL11.glColor4f(1F, 1F, 1F, 1F); Minecraft.getMinecraft().getTextureManager(). bindTexture(texture); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); } } From what I understand it is trying to access the 46th (index 45) slot when there are only 45 (index 44) slots in the inventory. However, I literally took the add container slot code directly from source and only changed their positions so I'm stumped as to why this would error.
  9. I'm really excited about this latest update, check it out! (click the picture) This is the start of what I like the call the core of the mod, and because of this, feedback is extremely important right now. I appreciate anyone who wants to help!
  10. I just put out a small update on power network updates, check it out! With Great Power...
  11. I've done a quick blog update on the new crafting items! check it out here, you may need to refresh your page for it to update as I just posted this. Crafting Items Galore!
  12. Thank you! Glad to hear it's not looking terrible haha. I've updated my multi-block structure progress on my latest blog post for any who would like to check it out! http://skytanicdevelopment.com/blog#Oil-Refinery-Progress
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.