
Pancake
Members-
Posts
43 -
Joined
-
Last visited
Everything posted by Pancake
-
[1.7.10] [SOLVED] On world load method / Saving world data
Pancake replied to Pancake's topic in Modder Support
It worked! One note to future readers though... I got a runtime error because it could not instantiate my class. Apparently you need a constructor with a String for your WorldSavedData class. Keep that in mind -
Greetings! I'm trying to save extra data per world, based on this post. The WorldSavedData class is taken care of, now I only need a method that gets called every time a world gets created to add the WorldSavedData object to the world.mapStorage Any suggestions? Thanks in advance, Pancake
-
[1.7.10] [SOLVED] world setBlock not updating client
Pancake replied to Pancake's topic in Modder Support
The code gets called. That's why if I exit and re-enter the world the blocks are gone. I found a fix. I changed the last return to return true instead of false. All the blocks now dissapear correctly. Sweet. -
[1.7.10] [SOLVED] world setBlock not updating client
Pancake replied to Pancake's topic in Modder Support
-
Greetings! When making a treecapitator axe, I ran across an issue which I can't seem to resolve on my own. When I call the method setBlock(x,y,z,Blocks.air) on the server world object, it doesn't update the client. It should, since that method calls setBlock(x,y,z,Blocks.air,0,3), in which the 3 stands for block update AND send change to client. I also tried calling the setBlock(x,y,z,Blocks.air,0,3) method directly, to no avail. I'm calling it on BlockOldLog and BLockLeaves objects, if that helps narrow the problem down. When I exit and re-enter the world, the blocks are gone, like it's supposed to be. I know one solution would be to just call markBlockForUpdate, but I'm not sure why the setblock method does not do what it tells me it should. Thanks in advance, Pancake
-
You have 2 kinds of OreRecipe: ShapedOreRecipe and ShapelessOreRecipe. The ShapedOreRecipe object has a method called getInput() which gives you an array of Objects, which are either an ItemStack, an ArrayList<ItemStack>, or null. The ShapelessOreRecipe has the same method, but returns an ArrayList<Object>. The objects in the arraylist are, once again, an ItemStack or an ArrayList<ItemStack>. There is a trick to get the orename from that arraylist of itemstacks (since that's the collection that contains all possible itemstacks). If you can't figure it out I'll tell you, but I don't feel like spoonfeeding you everything. Let's see if you can figure this one out. :3 Good luck!
-
You could try making an item that, when rightclicked on the master, binds to it (stores it's location or something) When you then click on a slave block, it links the 2 together. It's manual work, but I'm pretty sure that should work. Oh wait. I made it. Ofcourse it works. It also solves some problems that could arise by your method. What if a slaveblock is surrounded by 10 masters? pick a random one? Good luck!
-
I just figured it out! I was using the TileEntity's blockMetadata. It said -1, but worldObj.getBlockMetadata(xCoord,yCoord,zCoord) gave me the correct metadata. I know I have to use the getBlockMetadata method now, which initialises the blockMetadata if it's -1. My bad! :3 It's weird that that field isn't initialised from the start though. [sOLVED]
-
Greetings! It's been a while since I've asked a question here. I was wondering if it's necessary to save the metadata in the NBT data of the TileEntity of a block. BlockFurnace does not do that, yet it managas to save the direction it's facing. I took a look at the Transposer from Redpower, it uses NBT. (link to redpower TileMachine) This is my current code: The metadata returned from Utils.getMetaFromDirection(yaw,pitch) is correct, and I added a line to the TileEntity of this block that prints the metadata of the block. It has the correct value. Now, when I exit the world and enter again, it prints -1. What. Am I really supposed to use NBT data here? I thought metadata was something saved automatically? Thanks in advance, Pancake
-
~ Bump ~ I usually figure things out +-3 hours after I've posted my question on this forum. This isn't one of those times. :'(
-
So... Yeah. I'm still looking for solutions. I really can't think of anything other than either: * doing stuff in the tile entity that implements IInventory, which I tried and couldn't configure it the right way for my purposes. * using that itemstack, which keeps returning null. I'll rephrase my original question. I want to make slots that do the same as the creative gui. They increase the held itemstack stacksize by 1 if clicked on the same item. (I want to make some kind of shop, it will check if you have enough of a currency and then increment) Please? :\
-
Alright, I tried using reflection, and getting that field. It keeps returning null. All relevant code: public class GuiMainframeCore extends GuiContainer{ public GuiMainframeCore(InventoryPlayer inventoryPlayer,TileEntityMainframeCore entity) { super(new ContainerMainframeCore(inventoryPlayer,entity)); ((ContainerMainframeCore)inventorySlots).setGui(this); this.entity=entity; xSize=176; ySize=194; } public ItemStack getHeldItem(){ try { Field heldItemField = GuiContainer.class.getDeclaredField("field_146994_N"); heldItemField.setAccessible(true); return (ItemStack)heldItemField.get(this); } catch (Exception e) { e.printStackTrace(); } return null; } } public class ContainerMainframeCore extends Container { private TileEntityMainframeCore entity; private GuiMainframeCore gui; public ContainerMainframeCore(InventoryPlayer inventoryPlayer,TileEntityMainframeCore entity){ this.entity = entity; for(int i=0;i<entity.getSizeInventory();i++){ addSlotToContainer(new Slot(entity,i,70+(i<6?0:18),10+(i<6?i:i-6)*18)); } for(int x=0;x<9;x++){ addSlotToContainer(new Slot(inventoryPlayer,x,8+18*x,150)); } } @Override public ItemStack slotClick(int slot, int mouseid, int p3,EntityPlayer player){ if(gui!=null){ System.out.println(gui.getHeldItem()); } return super.slotClick(slot,mouseid,p3,player); } public void setGui(GuiMainframeCore gui){ this.gui=gui; } } ... help.
-
How to make an item have a different icon/texture depending on some state?
Pancake replied to McJty's topic in Modder Support
You could try overriding the method getIconFromDamage in your Item class. You'd have to change the item damage to get different textures though. I'm sure there are other ways, but if's just a suggestion -
Define 'glow'? Giving off light / changing the texture brightness / giving off particles / ...
-
Yeah... and it's private with no getters. I suppose this is one of the situations where I'm obliged to use reflection? This doesn't feel right...
-
~ Bump ~ Could someone please point me in the right direction? Still stuck on this... :'(
-
[1.7.10][SOLVED] GUI + Player Inventory Interaction
Pancake replied to Arkoonius's topic in Modder Support
I might be completely wrong and not understand what you're trying to do. In your class that extends GuiContainer, you pass the InventoryPlayer in your constructor. Save it as a field and change the slots when you click on the button. I'm not sure if the changes get synced between client and gui, but you could try... :3 -
Alright, I couldn't find the class that manages the creative inventory, but I discovered a method in the Container Class that gets fired everytime a slot gets clicked (slotClick). Now, I need to get the ItemStack the player is 'holding' with it's mouse. I tried EntityPlayer#getHeldItem and EntityPlayer#getItemInUse , neither give the desired ItemStack, and there are no other methods that return ItemStacks. How can I access this ItemStack I'm talking about? I need to modify it's stacksize on specific conditions when clicking a slot. Thanks in advance, Pancake.
-
Greetings! I've tried to make a GUI with slots that has a comparable functionality as the creative inventory screen. I know how to work with slots, and my TileEntity extends IInventory. I placed prints in each of the methods, but no method is executed when I click on a slot which contains the same item as you're holding with your mouse. If you do that in the creative screen, it increments the stacksize of the itemstack you're holding by one. Could anyone tell me if this is viable with a plain IInventory? If not, what's the name of the class that handles the creative tabs slots? I can't find it. Thanks in advance, Pancake
-
[1.7.10] [SOLVED] TileEntity not saving to disk properly
Pancake replied to Pancake's topic in Modder Support
None the less, it's still crappy code. I always new-line and indent stuff like that unless it's simple crap. I actually had it one line, but decided to make it a bit more readable for you guys. Yes, I should be ashamed of myself. -
[1.7.10] [SOLVED] TileEntity not saving to disk properly
Pancake replied to Pancake's topic in Modder Support
I do use those 3 integers, look at the way the brackets are around them. I know, It's hard to miss And efficiency wasn't the point of this setup, but I suppose putting it in a class would allow me to monitor access more. Thanks for the advice! I've messed around a bit with the debugger, and figured out the tile entity that had arraylist size 0 was another entity, somewhere in my world. So now I'm testing it in a new world. I did some more checking, and discovered a typo. It's also in my original post. instead of asking "process1"+i , I asked "process1+i". Wow, that was one of the hardest errors I ever had to find. Why don't Tags throw exceptions when they can't find a thing associated with the string? -.-' That's just silly! #endrant Thanks for the help anyways guys. -
You're getting a nullpointer exception, which means you're accessing methods or fields from an object that doesn't actually exist, it's null. The things that COULD be null at line 87 are: * texturemanager * par2ItemStack The most likely to be null is the ItemStack. in your function renderItem, try checking if the itemstack to be rendered is null.
-
Greetings! I've been working with tile entities for quite some time now, and I had no troubles updating entity data from the server to client, and saving to disk. However, I've come across something I really can't find the mistake in. @Override public void writeToNBT(NBTTagCompound tag){ super.writeToNBT(tag); tag.setInteger("numberOfProcesses",craftingProcesses.size()); System.out.println("write:"+craftingProcesses.size()); if(worldObj!=null){ System.out.println("world: "+worldObj.isRemote); } for(int i=0;i<craftingProcesses.size();i++){ NBTTagCompound tag2=new NBTTagCompound(); ((ItemStack)craftingProcesses.get(i)[0]).writeToNBT(tag2); tag.setTag("process0"+i,tag2); tag.setInteger("process1"+i,(Integer)craftingProcesses.get(i)[1]); tag.setInteger("process2"+i,(Integer)craftingProcesses.get(i)[2]); tag.setInteger("process3"+i,(Integer)craftingProcesses.get(i)[3]); } } @Override public void readFromNBT(NBTTagCompound tag){ super.readFromNBT(tag); int numberOfProcesses=tag.getInteger("numberOfProcesses"); System.out.println("read: "+numberOfProcesses); if(worldObj!=null){ System.out.println("world: "+worldObj.isRemote); } craftingProcesses.clear(); for(int i=0;i<numberOfProcesses;i++){ craftingProcesses.add(new Object[]{ItemStack.loadItemStackFromNBT(tag.getCompoundTag("process0"+i)), tag.getInteger("process1+i"), tag.getInteger("process2"+i), tag.getInteger("process3"+i)}); } } I have an arraylist of objects to be saved. I put an integer in the tag, saying how many elements there are in the arraylist, and use a for-loop to put them all the objects (ItemStack and 3 integers per element) in the arraylist, nothing I haven't successfully done before. When I read I do the reverse. I get the number, and do a for loop getting an itemstack and 3 integers and put them in an Object array, and add that to the (now cleared) arraylist. I added prints to the writeToNBT and readFromNBT saying howmany elements they're saving. When using the world normally all is fine. If I edit my arraylist i do the following. worldObj.markBlockForUpdate(xCoord,yCoord,zCoord); markDirty(); This might be a bit overkill, but I wanted to be sure. So, as I said, everything is okay, untill i press escape (the game checks for the dirty entities and saves them to disk) I then get the following output... [server thread/INFO]: Saving and pausing game... [server thread/INFO]: Saving chunks for level 'New World'/Overworld [server thread/INFO] [sTDOUT]: [net.pancake.singularity.tileentities.TileEntityItemCrafter:writeToNBT:44]: write:1 [server thread/INFO] [sTDOUT]: [net.pancake.singularity.tileentities.TileEntityItemCrafter:writeToNBT:46]: world: false [server thread/INFO] [sTDOUT]: [net.pancake.singularity.tileentities.TileEntityItemCrafter:writeToNBT:44]: write:0 [server thread/INFO] [sTDOUT]: [net.pancake.singularity.tileentities.TileEntityItemCrafter:writeToNBT:46]: world: false [server thread/INFO]: Saving chunks for level 'New World'/Nether [server thread/INFO]: Saving chunks for level 'New World'/The End As you can see, it writes two times, both from the server. But suddenly the size of my arraylist is 0. My writeToNBT method doesn't edit the arraylist in any way. What happened? If I exit the world, and log back in, the arraylist size is 0., instead of the 1 it was. Maybe I just need a pair of fresh eyes... or fresh brains. Thanks in advance, Pancake.
-
Greetings! Would it be possible to create a submenu gui without making a new container/gui class? I'm trying to make a submenu that will have itemslots, but the main menu shouldn't show those. Can slots be hidden (not rendered)? If so, what method should I override in what class to stop the slots from rendering? Thanks in advance, Pancake.