Jump to content

Zeretul4

Members
  • Posts

    26
  • Joined

  • Last visited

Everything posted by Zeretul4

  1. Does anyone know how packet handlers can help update a Tile Entities GUI? Every example I find is just something like sending pointless numbers to the player chat. Vanilla code isn't helping either, the interface for that only deals with ints and i need to update other things like booleans and lists.
  2. Thanks for the reply, I tried to do what you said and looked up Packet250CustomPayload and IPacketHandler but all I found were basic tutorials that showed how to print random numbers to the chat. This doesn't really help because I have no idea how I can turn that into updating numbers for the gui, they look nothing like what I currently do for updating ints. http://www.minecraftforge.net/wiki/Packet_Handling this tutorial mentions that a good use for packets is for exactly what I need but doesn't get into how to do that. I've been searching and searching but can't figure this out. Any ideas? Thanks for the help so far!
  3. Hey everyone, some of you may know that if you want numbers that you use in tile entities to interact with the gui, you need to send packets which is done in the container class. In vanilla it's only possible to update ints because that's all vanilla minecraft needs. I want to see things like booleans, floats, and other information which i've been getting around by using ints. The problem now is that I want to use lists and the way I have it working isn't going to work for that. Right now the process is this and I don't know how it works, I sorta just pieced it together from random examples and tutorials. int lastVariable public void addCraftingToCrafters(ICrafting par1ICrafting) { super.addCraftingToCrafters(par1ICrafting); par1ICrafting.sendProgressBarUpdate(this, 0, (int)this.tileEntity.variable); } public void detectAndSendChanges() { super.detectAndSendChanges(); for (int var1 = 0; var1 < this.crafters.size(); ++var1) { ICrafting var2 = (ICrafting)this.crafters.get(var1); if (this.lastVariable = this.tileEntity.variable) { var2.sendProgressBarUpdate(this, 0, (int)this.tileEntity.variable); } } lastVariable= (int)tileEntity.variable; } @SideOnly(Side.CLIENT) public void updateProgressBar(int par1, int par2) { if (par1 == 0) { this.tileEntity.variable= par2; } } I have no idea what this is doing but I have to do it for each variable I want to work with in a gui. Whenever I try to change it from ints to anything else it stops working. I know it has something to do with packets but I have no idea where to begin with that.
  4. Hey everyone, I've been working on a block that basically shares its liquid level by averaging with adjacent blocks. This is done with a LiquidMetalMix object that keeps track of all this. This isn't the important part though, the problem is that forge is constantly crashing because of one line of code that is just like anything else and the error it's giving me says it is not recoverable. Heres the error 2013-05-14 18:32:42 [sEVERE] [ForgeModLoader] Fatal errors were detected during the transition from SERVER_STARTED to SERVER_STOPPED. Loading cannot continue 2013-05-14 18:32:42 [sEVERE] [ForgeModLoader] mcp [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available FML [Forge Mod Loader] (coremods) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available Forge [Minecraft Forge] (coremods) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available Geology [Geology] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available 2013-05-14 18:32:42 [sEVERE] [ForgeModLoader] The ForgeModLoader state engine has become corrupted. Probably, a state was missed by and invalid modification to a base classForgeModLoader depends on. This is a critical error and not recoverable. Investigate any modifications to base classes outside ofForgeModLoader, especially Optifine, to see if there are fixes available. 2013-05-14 18:32:42 [iNFO] [sTDERR] Exception in thread "Server thread" java.lang.RuntimeException: The ForgeModLoader state engine is invalid 2013-05-14 18:32:42 [iNFO] [sTDERR] at cpw.mods.fml.common.LoadController.transition(LoadController.java:134) 2013-05-14 18:32:42 [iNFO] [sTDERR] at cpw.mods.fml.common.Loader.serverStopped(Loader.java:799) 2013-05-14 18:32:42 [iNFO] [sTDERR] at cpw.mods.fml.common.FMLCommonHandler.handleServerStopped(FMLCommonHandler.java:470) 2013-05-14 18:32:42 [iNFO] [sTDERR] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:530) 2013-05-14 18:32:42 [iNFO] [sTDERR] at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16) I've been toying around with it for about half an hour now and can't come up with anything. If you guys have any idea what the issue even is then please tell me. Thanks! Heres the code that's causing problems, if you need anything else just tell me. // set this and all adjacent vats liquid level to the average public void balanceLiquids(){ int numOfAdjacentVats = 1; List<LiquidMetalMix> mixtures = new ArrayList<LiquidMetalMix>(); List<Integer> xCoords = new ArrayList<Integer>(); List<Integer> zCoords = new ArrayList<Integer>(); mixtures.add(mixture); // loop through surrounding blocks for (int xx = -1; xx < 2; xx++){ for (int zz = -1; zz < 2; zz++){ // if its checking itself or a corner if (Math.abs(xx) == Math.abs(zz)){ //continue; } else { // coordinates currently being checked int x = xCoord + xx; int y = yCoord; int z = zCoord + zz; // if a vat is adjacent if (worldObj.getBlockId(x, y, z) == Geology.blockMoltenVat.blockID || worldObj.getBlockId(x, y, z) == Geology.blockIngotMold.blockID){ // get the TE at that location TileEntityMoltenVat te = (TileEntityMoltenVat)worldObj.getBlockTileEntity(x, y, z); mixtures.add(te.mixture); numOfAdjacentVats++; xCoords.add(xx); zCoords.add(zz); } else if (worldObj.getBlockId(x, y, z) == Geology.blockMoltenValve.blockID){ // a valve instead // get the TE at that location TileEntityMoltenValve te = (TileEntityMoltenValve)worldObj.getBlockTileEntity(x, y, z); if (te.canFlow){ mixtures.add(te.mixture); numOfAdjacentVats++; xCoords.add(xx); zCoords.add(zz); } } } } } // average out the new mixtures // set this mixture to the new mix // the static method returns a new LiquidMetalMix object that averaged all the mixture together LiquidMetalMix newMix = LiquidMetalMix.combineMixtures(mixtures, numOfAdjacentVats); // I have no problems setting the new mixture to this objects mixture mixture = newMix; // distribute the new mix for (int xx = -1; xx < 2; xx++){ for (int zz = -1; zz < 2; zz++){ // if its checking itself or a corner if (Math.abs(xx) == Math.abs(zz)){ //continue; } else { // coordinates currently being checked int x = xCoord + xx; int y = yCoord; int z = zCoord + zz; // if a vat is adjacent if (worldObj.getBlockId(x, y, z) == Geology.blockMoltenVat.blockID || worldObj.getBlockId(x, y, z) == Geology.blockIngotMold.blockID){ // get the TE at that location TileEntityMoltenVat te = (TileEntityMoltenVat)worldObj.getBlockTileEntity(x, y, z); // but as soon as i try to set another molten vat to the new mixture, i get the wierd error te.mixture = newMix; // commenting this one line out makes minecraft run fine } else if (worldObj.getBlockId(x, y, z) == Geology.blockMoltenValve.blockID){ // a valve instead // get the TE at that location TileEntityMoltenValve te = (TileEntityMoltenValve)worldObj.getBlockTileEntity(x, y, z); if (te.canFlow){ //te.mixture = new LiquidMetalMix(8000); } } } } } }
  5. Hey everyone, I'm working on a TE and I've been having issues with calling methods in the onBlockPlaced() method in its block class. Right now the method is basic and sets the TEs xCoord, yCoord, and zCoord to variables that will be displayed in the gui. This works perfectly when called in onBlockActivated() for the block, but in the onBlockPlaced() method, they are always set to 0. I don't know if theres another method I should call but for what I'm trying to do I need these variables to be set when you place the block down right away. I'm thinking it ha something to do with the TE not having set up its coordinates yet, but it still doesn't work if I use the blocks coordinates so I'm not sure. Thanks guys!
  6. Hey everyone, I'm trying to make a simple custom render for a block I'm working on but need some help. I've looked up plenty of tutorials on how set up what you need like modelID, registering it, etc. In the class that implements ISimpleBlockRenderingHandler, they all say put my "rendering code" into the renderWorldBlock method which always confuses me. I haven't found a single tutorial that has told me what "rendering code" looks like. I assume there are simple methods that let me create basic shapes at coordinates in the block but I don't know. Anyway, if someone knows what to do can you please tell me? Thanks a lot!
  7. Hey everyone, I'm trying to make a simple custom render for a block I'm working on but need some help. I've looked up plenty of tutorials on how set up what you need like modelID, registering it, etc. In the class that implements ISimpleBlockRenderingHandler, they all say put my "rendering code" into the renderWorldBlock method which always confuses me. I haven't found a single tutorial that has told me what "rendering code" looks like. I assume there are simple methods that let me create basic shapes at coordinates in the block but I don't know. Anyway, if someone knows what to do can you please tell me? Thanks a lot!
  8. I looked into ISimpleBlockRenderingHandler and tried to find tutorials and I actually found plenty telling me how to set things up, but they all lead me to a dead end. They all say to just fill this method with my "rendering code" @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { // TODO Auto-generated method stub return false; } That's great, but I have no idea where to go from there and nothing is telling me what I can write to make some simple square shapes render. Thanks a lot!
  9. I looked into ISimpleBlockRenderingHandler and tried to find tutorials and I actually found plenty telling me how to set things up, but they all lead me to a dead end. They all say to just fill this method with my "rendering code" @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { // TODO Auto-generated method stub return false; } That's great, but I have no idea where to go from there and nothing is telling me what I can write to make some simple square shapes render. Thanks a lot!
  10. Hey everyone, I'm trying to make a multi-block that's like a huge cauldron and I only have a question about how I would render this. I want it to look simple, basically if theres a single block then it will render similar to a cauldron, but if there is another next to it then the walls in between that would normally separate them isn't rendered so it looks like a single large cauldron. I've never done anything with special rendering yet so I'm just asking how I would get started with this. The best example I could think of is how buildcraft pipes are small squares on their own but know to connect when they are next to each other. Thanks a lot guys!
  11. Hey everyone, I'm trying to make a multi-block that's like a huge cauldron and I only have a question about how I would render this. I want it to look simple, basically if theres a single block then it will render similar to a cauldron, but if there is another next to it then the walls in between that would normally separate them isn't rendered so it looks like a single large cauldron. I've never done anything with special rendering yet so I'm just asking how I would get started with this. The best example I could think of is how buildcraft pipes are small squares on their own but know to connect when they are next to each other. Thanks a lot guys!
  12. Thank for the replies everyone. My mod adds the basics like blocks, items tools, etc and a few tile entities. I don't have any plans to make it more complicated than this, but what should I look out for? Also, how do I know which methods/classes I have to put @sideonly or @clientside or whatever? Is there a tutorial for that? Thanks a lot guys!
  13. Thank for the replies everyone. My mod adds the basics like blocks, items tools, etc and a few tile entities. I don't have any plans to make it more complicated than this, but what should I look out for? Also, how do I know which methods/classes I have to put @sideonly or @clientside or whatever? Is there a tutorial for that? Thanks a lot guys!
  14. Hey everyone, just a quick question. I'm just about done with my mod but am wondering if it can be played on multiplayer as is. I've followed the basic tutorials on here so I'm not sure what else I would have to do to make it multiplayer. I have only joined a few of my friends servers so I have no idea how the process works with multiplayer mods. I would assume it's as simple as installing the mod and joining a server that also has it installed, but this probably isn't the case ha ha. Thanks guys!
  15. Hey everyone, I finally got around to updating the mod I've working on to the latest version. I started it back in 1.4 of minecraft and figured it's about time i update to 1.5 and figured it would basically be the same, but the way textures work are completely different now. I had 2 simple texture files, one for items and one for blocks but the way i see it now am i going to have to make an individual file for every single item and block now? This seems really redundant if I have to do this, but I will if i have to. The forge wiki just updated the methods and just touched on how it works and I'm still really confused because almost none of the other tutorials are updated. I'm not sure how I'm supposed to format the folders because I use more than the tutorial says and i keep keep getting errors. It just feels like I'm the only one who doesn't know whats going on here and if someone can just give me a basic idea of what changed I would really appreciate it. Thanks a lot everyone!
  16. Yes! This fixed it. Thanks a lot for the help!
  17. Hmm, this didn't do anything at all. I'm pretty sure it's an issue with the gui because I had a similar issue with ints doing their job, but not showing up on the gui. I got that worked out by sending int packets, I just don't know how to do the same for inventory slots. Here's the gui code. package zeretul4.geology.grinder; import java.util.Random; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import org.lwjgl.opengl.GL11; import zeretul4.geology.Geology; public class GuiGrinder extends GuiContainer { TileEntityGrinder te; String[] bladeQuality = { "", "Poor" }; Random rand = new Random(); public GuiGrinder (InventoryPlayer inventoryPlayer, TileEntityGrinder tileEntity) { //the container is instanciated and passed to the superclass for handling super(new ContainerGrinder(inventoryPlayer, tileEntity)); te = tileEntity; } @Override protected void drawGuiContainerForegroundLayer(int param1, int param2) { //draw text and stuff here //the parameters for drawString are: string, x, y, color fontRenderer.drawString("Grinder", 90, 4, 4210752); fontRenderer.drawString("Blade: ", 4, 18, 4210752); fontRenderer.drawString(bladeQuality[te.bladeLevel], 4, 26, 4210752); fontRenderer.drawString("Fuel: ", 4, 38, 4210752); fontRenderer.drawString("" + te.fuelLevel, 4, 46, 4210752); //draws "Inventory" or your regional equivalent fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 94 + 2, 4210752); } @Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { //draw your Gui here, only thing you need to change is the path int texture = mc.renderEngine.getTexture("/zeretul4/geology/grinder/grinder.png"); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.renderEngine.bindTexture(texture); int x = (width - xSize) / 2; int y = (height - ySize) / 2; this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); int var7 = this.te.getGrindTimeScaled(24); this.drawTexturedModalRect(x + 54, y + 34, 176, 14, var7 + 1, 16); if (te.burnTime > 0){ int var8 = this.te.getBurnTimeScaled(12); this.drawTexturedModalRect(x + 58, y + 57 + 12 - var8, 176, 12 - var8, 14, var8 + 2); } } }
  18. Sure thing! Tile Entity package zeretul4.geology.grinder; import java.util.HashMap; import zeretul4.geology.Geology; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; public class TileEntityGrinder extends TileEntity implements IInventory { private ItemStack[] inv; public int grindTime = 0; public int bladeLevel = 0; public int fuelLevel = 0; public int burnTime = 0; public final int maxFuel = 10000; public TileEntityGrinder(){ inv = new ItemStack[18]; } @Override public void updateEntity() { bladeLevel = 0; if (getStackInSlot(0) != null){ int tempLevel = getBladeLevel(); if (tempLevel != -1) bladeLevel = tempLevel; } if(burnTime > 0){ if (fuelLevel < maxFuel) fuelLevel++; burnTime--; } else if (fuelLevel < maxFuel && getStackInSlot(2) != null){ burnTime = 1000; decrStackSize(2, 1); } if (fuelLevel > 0 && canGrind()){ fuelLevel--; grindTime += 2; if (grindTime >= 200){ grindTime = 0; grindItem(); } } else grindTime = 0; } private int getBladeLevel(){ ItemStack item = getStackInSlot(0); if (item == null) return -1; if (item.itemID == Geology.cobbleBlade.itemID) return 1; return -1; } private boolean checkIfFuel(){ ItemStack item = getStackInSlot(2); if (item == null) return false; int id = item.itemID; if (id == Item.coal.itemID) return true; return false; } public boolean canGrind(){ ItemStack input = getStackInSlot(1); if (!RecipesGrinder.checkRecipeExists(input)) // recipes does not exist return false; if (checkIfRoomForOutput()) // if there is room for any outputs return true; return false; } private boolean checkIfRoomForOutput(){ for (int i = 0; i < 15; i++){ ItemStack stack = getStackInSlot(i + 3); if (stack == null) return true; } return false; } private void grindItem(){ ItemStack input = getStackInSlot(1).copy(); // get the input ItemStack output = RecipesGrinder.getOutputRandom(input, false); decrStackSize(1, 1);// RecipesGrinder.getInput(input).stackSize); int outputIndex = 2; boolean foundIndex = false; while(!foundIndex){ outputIndex++; if (getStackInSlot(outputIndex) == null){ // just set if empty setInventorySlotContents(outputIndex, output.copy()); foundIndex = true; } else if (getStackInSlot(outputIndex).itemID == output.itemID){ // otherwise increase by proper amount getStackInSlot(outputIndex).stackSize++;// += output.stackSize; foundIndex = true; } } } @Override public int getSizeInventory() { return inv.length; } @Override public ItemStack getStackInSlot(int slot) { return inv[slot]; } @Override public void setInventorySlotContents(int slot, ItemStack stack) { inv[slot] = stack; if (stack != null && stack.stackSize > getInventoryStackLimit()) { stack.stackSize = getInventoryStackLimit(); } } @Override public ItemStack decrStackSize(int slot, int amt) { ItemStack stack = getStackInSlot(slot); if (stack != null) { if (stack.stackSize <= amt) { setInventorySlotContents(slot, null); } else { stack = stack.splitStack(amt); if (stack.stackSize == 0) { setInventorySlotContents(slot, null); } } } return stack; } @Override public ItemStack getStackInSlotOnClosing(int slot) { ItemStack stack = getStackInSlot(slot); if (stack != null) { setInventorySlotContents(slot, null); } return stack; } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUseableByPlayer(EntityPlayer player) { return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64; } @Override public void openChest() {} @Override public void closeChest() {} @Override public void readFromNBT(NBTTagCompound tagCompound) { // working code for setting itemstacks, commenting this out breaks the furnace so i know this is being called super.readFromNBT(tagCompound); NBTTagList tagList = tagCompound.getTagList("Inventory"); for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound tag = (NBTTagCompound) tagList.tagAt(i); byte slot = tag.getByte("Slot"); if (slot >= 0 && slot < inv.length) { inv[slot] = ItemStack.loadItemStackFromNBT(tag); } } //(ends here) this.fuelLevel = tagCompound.getInteger("Fuel"); this.burnTime = tagCompound.getInteger("BurnTime"); this.bladeLevel = tagCompound.getInteger("BladeLevel"); this.grindTime = tagCompound.getInteger("GrindTime"); } @Override public void writeToNBT(NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); tagCompound.setInteger("Fuel", fuelLevel); tagCompound.setInteger("BurnTime", burnTime); tagCompound.setInteger("BladeLevel", bladeLevel); tagCompound.setInteger("GrindTime", grindTime); NBTTagList itemList = new NBTTagList(); for (int i = 0; i < inv.length; i++) { ItemStack stack = inv[i]; if (stack != null) { NBTTagCompound tag = new NBTTagCompound(); tag.setByte("Slot", (byte) i); stack.writeToNBT(tag); itemList.appendTag(tag); } } tagCompound.setTag("Inventory", itemList); } @Override public String getInvName() { return "zeretul4.geology.grinder.tileEntityGrinder"; } @SideOnly(Side.CLIENT) public int getGrindTimeScaled(int par1) { return this.grindTime * par1 / 200; } @SideOnly(Side.CLIENT) public int getBurnTimeScaled(int par1) { return this.burnTime * par1 / 1000; } } and container package zeretul4.geology.grinder; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; public class ContainerGrinder extends Container { protected TileEntityGrinder tileEntity; private final static int slots = 18; private int lastFuelLevel = 0; private int lastBurnTime = 0; private int lastBladeLevel = 0; private int lastGrindTime = 0; private ItemStack[] lastOutputs = new ItemStack[15]; public ContainerGrinder (InventoryPlayer inventoryPlayer, TileEntityGrinder te){ tileEntity = te; addSlotToContainer(new Slot(tileEntity, 0, 36, 14)); // blade slot addSlotToContainer(new Slot(tileEntity, 1, 36, 35)); // input addSlotToContainer(new Slot(tileEntity, 2, 36, 56)); // fuel // 15 output slots addSlotToContainer(new Slot(tileEntity, 3, 80, 17)); addSlotToContainer(new Slot(tileEntity, 4, 98, 17)); addSlotToContainer(new Slot(tileEntity, 5, 116, 17)); addSlotToContainer(new Slot(tileEntity, 6, 134, 17)); addSlotToContainer(new Slot(tileEntity, 7, 152, 17)); addSlotToContainer(new Slot(tileEntity, 8, 80, 35)); addSlotToContainer(new Slot(tileEntity, 9, 98, 35)); addSlotToContainer(new Slot(tileEntity, 10, 116, 35)); addSlotToContainer(new Slot(tileEntity, 11, 134, 35)); addSlotToContainer(new Slot(tileEntity, 12, 152, 35)); addSlotToContainer(new Slot(tileEntity, 13, 80, 53)); addSlotToContainer(new Slot(tileEntity, 14, 98, 53)); addSlotToContainer(new Slot(tileEntity, 15, 116, 53)); addSlotToContainer(new Slot(tileEntity, 16, 134, 53)); addSlotToContainer(new Slot(tileEntity, 17, 152, 53)); //commonly used vanilla code that adds the player's inventory bindPlayerInventory(inventoryPlayer); } public void addCraftingToCrafters(ICrafting par1ICrafting) { super.addCraftingToCrafters(par1ICrafting); par1ICrafting.sendProgressBarUpdate(this, 0, this.tileEntity.fuelLevel); par1ICrafting.sendProgressBarUpdate(this, 1, this.tileEntity.burnTime); par1ICrafting.sendProgressBarUpdate(this, 2, this.tileEntity.bladeLevel); par1ICrafting.sendProgressBarUpdate(this, 3, this.tileEntity.grindTime); for (int i = 0; i < 15; i++){ par1ICrafting.sendSlotContents(this, i + 4, tileEntity.getStackInSlot(i + 3)); } } public void detectAndSendChanges() { super.detectAndSendChanges(); for (int var1 = 0; var1 < this.crafters.size(); ++var1) { ICrafting var2 = (ICrafting)this.crafters.get(var1); if (this.lastFuelLevel != this.tileEntity.fuelLevel) { var2.sendProgressBarUpdate(this, 0, this.tileEntity.fuelLevel); } if (this.lastBurnTime != this.tileEntity.burnTime) { var2.sendProgressBarUpdate(this, 1, this.tileEntity.burnTime); } if (this.lastBladeLevel != this.tileEntity.bladeLevel) { var2.sendProgressBarUpdate(this, 2, this.tileEntity.bladeLevel); } if (this.lastBladeLevel != this.tileEntity.grindTime) { var2.sendProgressBarUpdate(this, 3, this.tileEntity.grindTime); } for (int i = 0; i < 15; i++){ var2.sendSlotContents(this, i + 4, tileEntity.getStackInSlot(i + 3)); } } this.lastFuelLevel = this.tileEntity.fuelLevel; this.lastBurnTime = this.tileEntity.burnTime; this.lastBladeLevel = this.tileEntity.bladeLevel; this.lastGrindTime = this.tileEntity.grindTime; for (int i = 0; i < 15; i++){ this.lastOutputs[i] = this.tileEntity.getStackInSlot(i + 3); } } @SideOnly(Side.CLIENT) public void updateProgressBar(int par1, int par2) { if (par1 == 0) { this.tileEntity.fuelLevel = par2; } if (par1 == 1) { this.tileEntity.burnTime = par2; } if (par1 == 2) { this.tileEntity.bladeLevel = par2; } if (par1 == 3) { this.tileEntity.grindTime = par2; } } // @SideOnly(Side.CLIENT) // public void updateProgressBar(int par1, ItemStack par2) // { // for (int i = 0; i < 15; i++){ // if (par1 == i + 4) // this.tileEntity.setInventorySlotContents(i + 3, par2); // } // } @Override public boolean canInteractWith(EntityPlayer player) { return tileEntity.isUseableByPlayer(player); } protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) { for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for (int i = 0; i < 9; i++) { addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142)); } } @Override public ItemStack transferStackInSlot(EntityPlayer player, int slot) { ItemStack stack = null; Slot slotObject = (Slot) inventorySlots.get(slot); //null checks and checks if the item can be stacked (maxStackSize > 1) if (slotObject != null && slotObject.getHasStack()) { ItemStack stackInSlot = slotObject.getStack(); stack = stackInSlot.copy(); //merges the item into player inventory since its in the tileEntity if (slot < slots) { if (!this.mergeItemStack(stackInSlot, slots, 36 + slots, true)) { return null; } } //places it into the tileEntity is possible since its in the player inventory else if (!this.mergeItemStack(stackInSlot, 0, slots, false)) { return null; } if (stackInSlot.stackSize == 0) { slotObject.putStack(null); } else { slotObject.onSlotChanged(); } if (stackInSlot.stackSize == stack.stackSize) { return null; } slotObject.onPickupFromSlot(player, stackInSlot); } return stack; } }
  19. Hey everyone, I'm still working on my custom furnace and I almost have it working. It has multiple outputs and for some reason the GUI is being really glitchy about it. I'm having issues similar to when certain variables were no updating and I worked it out by sending packets in the container class. Well now the itemstacks are acting similarly. The way it works is that a single item goes in through the input slot, then one of several possible outputs are randomly chosen to go into the first available output slot of 15. When i throw a stack in and let it process, what looks like is happening is that 2 are coming out from one item but only one of them is real. I know it's working fine because as soon as i try to take something out or save and quit minecraft, the whole inventory fixes itself and gets rid of all the fake items. I'm pretty sure the issue is with nbt data not being sent to the GUI, all I really need to know is how to update the output slots like i did with other variables. Thanks!
  20. Ah, thanks so much! None of the tutorials i found about nbt mentioned this.
  21. I tried using nbt data before after looking up the problem, but it wasn't working for me. Heres the code I have, I don't have a clue as to why it's not working. This is just a method in my tile entity class. @Override public void readFromNBT(NBTTagCompound tagCompound) { // working code for setting itemstacks, commenting this out breaks the furnace so i know this is being called super.readFromNBT(tagCompound); NBTTagList tagList = tagCompound.getTagList("Inventory"); for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound tag = (NBTTagCompound) tagList.tagAt(i); byte slot = tag.getByte("Slot"); if (slot >= 0 && slot < inv.length) { inv[slot] = ItemStack.loadItemStackFromNBT(tag); } } //(ends here) fuelLevel = tagCompound.getInteger("Fuel"); // reading it isn't working //fuelLevel = 50; // me even trying to brute force set it and still not working }
  22. Hey everyone, I'm working on a furnace that will have a fuel buffer and it's working like I want it to. It'll burn coal when theres room to store energy and then it'll use that energy to cook items. The only problem is that whenever i save and quit then come back, the buffer is reset to 0. Is there a way to save that number? Thanks a lot!
  23. Sorry, but did you forgot to add a link? There's nothing to click on.
  24. Hey everyone, I'm working on a mod and I'm on the world generation part. The issue I'm having is the way the mod will work is that I need to replace a majority of generic stone with some of my custom stone. The problem is that the only way i know how to generate it is like normal ores, but in such huge amounts that most of it replaces the stone. This is making world gen take a very long time so I'm wondering of there's a simpler way to do this because I can't find anything anywhere else. Thanks!
×
×
  • Create New...

Important Information

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