Everything posted by Roboguy99
-
Checking emtpty item stack crashes with null pointer exception
I'm trying to make my machine fill buckets if you put them in a certain slot, so I want to check that there is a bucket in the slot, however my if statement crashes with a null pointer exception when I load into the game with my current method. It crashes on this line on what I assume is the first check. if(slotBucketOut.getItem() == Items.bucket && (this.distilledWater - 1000) >= 0) Here is all of my code in that class: If anyone can help I'd greatly appreciate it, thanks.
-
CanProcess() method returning false when it shouldn't do
Ahh whoops. Thanks for pointing that out, it's just one of those things which you accidently leave somewhere and never spot.
-
How to change the player height
Have a look at the code for IChun's mod called Morph: https://github.com/iChun/Morph/tree/master/src/main/java/morph
-
CanProcess() method returning false when it shouldn't do
I've just changed my code around a bit in my mod so to make room for faster development. Essentially I've created a template off of which I can build similar machines to my pre-existing ones (3-slot machines which work similar to a vanilla furnace). In doing so, I have broken the only machine which currently uses the template. Previously you placed cobblestone in the slot with id 1, wheat in the slot with the id 0 and the output comes in slot 3 after a processing time. Now though, my canProcess() method is always returning false. I've narrowed it down to the problem being with the first if statement in the method, but this worked before. Please can someone help? My code is below and any further code can be found at https://github.com/Roboguy99/Food-Tech if you need it. Thanks in advance. TileGrindstone code: Template code:
-
Custom furnace GUI help
Ok I'll have a look and report back. Thanks.
-
Custom furnace GUI help
I'm having some problems with my custom furnace's GUI, specifically the progress bar (although the stone meter doesn't decrease so I think I've mucked that up too). I've narrowed it down slightly and worked out that the GUI is rendered correctly, however my TileEntity is returning the wrong values. I'm having some real issues trying to work out where the problem is coming from and I've just confused myself. Hopefully one of you will be kind enough to show me where I've gone wrong. Thanks in advance. Here's the entire class for my custom furnace tile entity:
-
[1.7.10] Open GUI On GUI Button Click
I can't be sure about this as I've never played around with GUI elements before (something I'm about to get into). Have you tried calling FMLNetworkHandler.openGui() from the button click listener though? EDIT: I didn't really look though your code. Interesting that we both have different GUI calling methods. You'll probably have to find a way to close your current GUI, which I don't know how to do, so I'll shut up now...
-
[1.7.10] Custom furnace inventory problems
That works. Thanks.
-
[1.7.10] Custom furnace inventory problems
Ok I've tried this but I've got the same problem I had to start with. Here's my code now:
-
[1.7.10] Custom furnace inventory problems
Anybody?
-
[1.7.10] Custom furnace inventory problems
Well this made stone act normally, but the last one in the stack still eternally remains and eternally fills up the meter. Thanks so far though.
-
[1.7.10] Custom furnace inventory problems
I'm having some problems with my custom furnace's inventory. The idea is that cobblestone goes in the bottom slot and fills up a meter. Items go in the slot above that and different items come out the other side. Recipes are working with it, however the cobblestone system is very broken (won't ever accept the last piece of cobblestone, if you take the last piece out it treats it weirdly and when you stack it with any other cobblestone it just deletes the other half of the stack, meaning you will always have 1 piece of cobblestone). I'd also like to try and make it so that nothing can be placed in the output slot and only cobblestone can be placed in the cobblestone slot, which so far I have failed at. Here is the code for my tileentity:
-
[1.7.10] Using the RF API
Got it all working. Thanks guys!
-
[1.7.10] Using the RF API
Thanks! Could you run me through exactly what it does though please because I don't really want a bunch of code I don't get in my mod.
-
[1.7.10] Using the RF API
Hey there, I'm trying to use the RF API (https://github.com/CoFH/RedstoneFlux-API) in my mod and currently I'm trying to create a power generator. I have successfully gotten power to generate, however it just sits there inside the generator. Cables (universal cables from Mekanism are what I'm using to test because TE crashes in my modding environment) connect to the generator but the power goes nowhere. Specific generator class: Generator base code: If you need to see any more code it's all here: https://github.com/Roboguy99/Food-Tech Any help with the issue will be greatly appreciated and even a link to documentation, which I have been unable to find, would be nice. Thanks.
-
Creating a progress bar on a GUI?
Ok thanks. I'll look into it and come back here if I need help.
-
Creating a progress bar on a GUI?
Hi, I'm trying to make a GUI for my electric generator and I want it to show a bar which displays how much power the generator is holding. After playing around for quite some time trying to get it to work, the progress bar shows as full permanently until you get to about 80% full, when the power bar starts to drain. Gui code: public void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) { Minecraft.getMinecraft().getTextureManager().bindTexture(texture); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); //Main gui int i = (int) this.windTurbine.getPowerScaled(162); FoodTech.print(i); drawTexturedModalRect(guiLeft+7, guiTop+10, 0, 167, guiLeft+169-i, guiTop+25); //Power bar } getPowerScaled() public int getPowerScaled(int scaled) { return (int) (buffer().getEnergy() * scaled / buffer().getEnergyCapacity()); } Rather crude unfinished GUI Any help is greatly appricated. If you need to see any more code, I will upload it.
-
Handing block updates
Ok thanks I'll have a look through and see if it helps.
-
Handing block updates
I'm trying to make a cable system, where cables join together. My system at the moment is showing to be very buggy and I'm having trouble with block updating, specifically neighbour block updates. This is my code for block updates: public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { Main.print("Block update detected at " + x + ", " + y + ", " + z); world.markBlockForUpdate(x, y, z); world.scheduleBlockUpdate(x, y, z, block, tickRate(world)); tileEntityCable.getAllConnectedWires(x, y, z, world); } public void updateTick(World world, int x, int y, int z, Random rand) { world.markBlockForUpdate(x, y, z); tileEntityCable.getAllConnectedWires(x, y, z, world); } public void onBlockAdded(World world, int x, int y, int z) { world.markBlockForUpdate(x, y, z); tileEntityCable.getAllConnectedWires(x, y, z, world); } public void breakBlock(World world, int x, int y, int z, Block block, int thingNoOneKnowsWhatItDoes) //What does this last int do? { world.markBlockForUpdate(x, y, z); tileEntityCable.getAllConnectedWires(x, y, z, world); } I have noticed that the neighbour block updates are appearing in the wrong place, in such a way that if I update the block to the north, it gives the co-ordinates of a block to the east instead. Also, placing two cables next to each other only causes the 2nd one to be placed to update, and sometimes they don't update at all. I can't find any documentation on any of this anywhere, so if anyone can help me that would be great. As for the rest of my system, here is my entire tileEntity class for checking connected wires: package foodTech.tileEntities; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import foodTech.blocks.CreateBlocks; public class TileEntityCable extends TileEntity { private boolean isWireAbove = false; private boolean isWireBelow = false; private boolean isWireNorth = false; private boolean isWireSouth = false; private boolean isWireEast = false; private boolean isWireWest = false; private boolean[] allConnectionStates = new boolean[6]; public void getAllConnectedWires(int x, int y, int z, World world) { if (world.getBlock(x, y+1, z).equals(CreateBlocks.blockCable)) this.isWireAbove = true; if (world.getBlock(x, y-1, z).equals(CreateBlocks.blockCable)) this.isWireBelow = true; if (world.getBlock(x, y, z+1).equals(CreateBlocks.blockCable)) this.isWireNorth = true; if (world.getBlock(x, y, z-1).equals(CreateBlocks.blockCable)) this.isWireSouth = true; if (world.getBlock(x+1, y, z+1).equals(CreateBlocks.blockCable)) this.isWireEast = true; if (world.getBlock(x-1, y, z-1).equals(CreateBlocks.blockCable)) this.isWireWest = true; this.allConnectionStates[0] = this.isWireAbove; this.allConnectionStates[1] = this.isWireBelow; this.allConnectionStates[2] = this.isWireNorth; this.allConnectionStates[3] = this.isWireSouth; this.allConnectionStates[4] = this.isWireEast; this.allConnectionStates[5] = this.isWireWest; } public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); this.isWireAbove = nbt.getBoolean("isWireAbove"); this.isWireBelow = nbt.getBoolean("isWireBelow"); this.isWireNorth = nbt.getBoolean("isWireNorth"); this.isWireSouth = nbt.getBoolean("isWireSouth"); this.isWireEast = nbt.getBoolean("isWireEast"); this.isWireWest = nbt.getBoolean("isWireWest"); } public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setBoolean("isWireAbove", isWireAbove); nbt.setBoolean("isWireBelow", isWireBelow); nbt.setBoolean("isWireNorth", isWireNorth); nbt.setBoolean("isWireSouth", isWireSouth); nbt.setBoolean("isWireEast", isWireEast); nbt.setBoolean("isWireWest", isWireWest); } public boolean getWireAboveConnected() { return this.isWireAbove; } public boolean getWireBelowConnected() { return this.isWireBelow; } public boolean getWireNorthConnected() { return this.isWireNorth; } public boolean getWireSouthConnected() { return this.isWireSouth; } public boolean getWireEastConnected() { return this.isWireEast; } public boolean getWireWestConnected() { return this.isWireWest; } }
-
TileEntity crashing on world load
Thanks. Everything is almost working as I want it to. I've just got to change the directions around, but that bit's the easy bit.
-
TileEntity crashing on world load
Ok thanks, but 1 more problem. The TileEntity passed in seems to just be a standard TileEntity class instance, and not one of TileEntityCable. Is this just me being stupid?
-
TileEntity crashing on world load
Hmm ok. From my understanding of static, it means that other classes can access it. I also got told somewhere else that having static fields in a block class leads to the same result in all blocks of it's type, so after a quick bit of research I've found that the static modifier means the field/method is universal among all instances of that class. Do I just need to change the type of everything in the TileEntity class to not be static? Also I will do some research into what the static modifier does in more depth. EDIT: I've attempted to convert everything from the TileEntity class to non-static, but I'm stuck when it comes to neighbourBlockWires[0] = TileEntityCable.getWireAboveConnected(); neighbourBlockWires[1] = TileEntityCable.getWireBelowConnected(); neighbourBlockWires[2] = TileEntityCable.getWireNorthConnected(); neighbourBlockWires[3] = TileEntityCable.getWireSouthConnected(); neighbourBlockWires[4] = TileEntityCable.getWireEastConnected(); neighbourBlockWires[5] = TileEntityCable.getWireWestConnected(); How can I access the methods in a non-static way?
-
TileEntity crashing on world load
Probably because I have no real idea what I'm doing and I'm making it up as I go along. If you could perhaps explain slightly more in depth about what I've got to do, I'll be thankful. EDIT: I've updated my code to what I've got now. EDIT 2: I've read what you put more carefully and updated my code to correspond with what you said. Do you think you could help me solve the problem now
-
TileEntity crashing on world load
I've been working on a wire block and I've been trying to make it render in certain places to make it join with other wires. I think I'm quite close, except the world is crashing when I try to load in on this line: return tileEntityCable.isWireAbove; Which is part of the rendering class. Inside the error log I get this error: java.lang.NullPointerException: Rendering Block Entity Any help on sorting this out would be useful, as I've spent quite a long time trying various things to no avail. Here is the rest of my code: Render class package foodTech.tileEntities.render; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import foodTech.tileEntities.TileEntityCable; import foodTech.tileEntities.models.ModelCable; public class RenderCable extends TileEntitySpecialRenderer { ResourceLocation textureOff = (new ResourceLocation("roboguy99:textures/models/cableOff.png")); ResourceLocation textureOn = (new ResourceLocation("roboguy99:textures/models/cableOn.png")); public ModelCable modelCable; public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float scale) { boolean[] neighbourBlockWires = new boolean[6]; GL11.glPushMatrix(); GL11.glTranslatef((float) x + 0.5F, (float) y - 0.5F, (float) z + 0.5F); Minecraft.getMinecraft().renderEngine.bindTexture(textureOff); neighbourBlockWires[0] = TileEntityCable.getWireAboveConnected(); neighbourBlockWires[1] = TileEntityCable.getWireBelowConnected(); neighbourBlockWires[2] = TileEntityCable.getWireNorthConnected(); neighbourBlockWires[3] = TileEntityCable.getWireSouthConnected(); neighbourBlockWires[4] = TileEntityCable.getWireEastConnected(); neighbourBlockWires[5] = TileEntityCable.getWireWestConnected(); this.modelCable = new ModelCable(neighbourBlockWires); this.modelCable.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glTranslatef((float) x - 0.5F, (float) y + 0.5F, (float) z - 0.5F); GL11.glPopMatrix(); } } TileEntity class package foodTech.tileEntities; import foodTech.blocks.CreateBlocks; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class TileEntityCable extends TileEntity { private boolean isWireAbove = false; private boolean isWireBelow = false; private boolean isWireNorth = false; private boolean isWireSouth = false; private boolean isWireEast = false; private boolean isWireWest = false; private static TileEntityCable tileEntityCable; private boolean[] allConnectionStates = new boolean[6]; public static void getAllConnectedWires(int x, int y, int z, World world) { if (world.getBlock(x, y+1, z).equals(CreateBlocks.blockCable)) tileEntityCable.isWireAbove = true; if (world.getBlock(x, y-1, z).equals(CreateBlocks.blockCable)) tileEntityCable.isWireBelow = true; if (world.getBlock(x+1, y, z).equals(CreateBlocks.blockCable)) tileEntityCable.isWireNorth = true; if (world.getBlock(x-1, y, z).equals(CreateBlocks.blockCable)) tileEntityCable.isWireSouth = true; if (world.getBlock(x, y, z+1).equals(CreateBlocks.blockCable)) tileEntityCable.isWireEast = true; if (world.getBlock(x, y, z-1).equals(CreateBlocks.blockCable)) tileEntityCable.isWireWest = true; tileEntityCable.allConnectionStates[0] = tileEntityCable.isWireAbove; tileEntityCable.allConnectionStates[1] = tileEntityCable.isWireBelow; tileEntityCable.allConnectionStates[2] = tileEntityCable.isWireNorth; tileEntityCable.allConnectionStates[3] = tileEntityCable.isWireSouth; tileEntityCable.allConnectionStates[4] = tileEntityCable.isWireEast; tileEntityCable.allConnectionStates[5] = tileEntityCable.isWireWest; } public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); tileEntityCable.isWireAbove = nbt.getBoolean("isWireAbove"); tileEntityCable.isWireBelow = nbt.getBoolean("isWireBelow"); tileEntityCable.isWireNorth = nbt.getBoolean("isWireNorth"); tileEntityCable.isWireSouth = nbt.getBoolean("isWireSouth"); tileEntityCable.isWireEast = nbt.getBoolean("isWireEast"); tileEntityCable.isWireWest = nbt.getBoolean("isWireWest"); } public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setBoolean("isWireAbove", isWireAbove); nbt.setBoolean("isWireBelow", isWireBelow); nbt.setBoolean("isWireNorth", isWireNorth); nbt.setBoolean("isWireSouth", isWireSouth); nbt.setBoolean("isWireEast", isWireEast); nbt.setBoolean("isWireWest", isWireWest); } public static boolean getWireAboveConnected() { return tileEntityCable.isWireAbove; } public static boolean getWireBelowConnected() { return tileEntityCable.isWireBelow; } public static boolean getWireNorthConnected() { return tileEntityCable.isWireNorth; } public static boolean getWireSouthConnected() { return tileEntityCable.isWireSouth; } public static boolean getWireEastConnected() { return tileEntityCable.isWireEast; } public static boolean getWireWestConnected() { return tileEntityCable.isWireWest; } }
-
Help with rendering depending on block state
Ok I've had a go, re-written things a bit and tried to incorporate NBT, but I'm getting the exact same result. If you could help me a little more thoroughly at this point I'd be very grateful as I'm not really sure what I'm doing any more. I'm going to edit the code in the original post.
IPS spam blocked by CleanTalk.