larsgerrits
Members-
Posts
3462 -
Joined
-
Last visited
-
Days Won
17
Everything posted by larsgerrits
-
[Solved] [1.7.2] Is there a ender pearl throw event?
larsgerrits replied to MinecraftMart's topic in Modder Support
You are comparing a Itemstack:heldItem with a Item:Item.ender_pearl. If you want to compare those 2, you need to get the item out of the ItemStack and compare that with the item. Then you can update the PT variable. -
[1.7.2]Simple 1-slot chest/Container returns ClassCastException
larsgerrits replied to n1ghtk1n9's topic in Modder Support
Show all classes related to your backpack item. -
[1.7.2][UNSOLVED] Container - Basic Issue
larsgerrits replied to kenbeannet's topic in Modder Support
Can you post a screenshot? I don't exactly know what you mean. -
[SOLVED] How to stop a block causing shadows?
larsgerrits replied to Bedrock_Miner's topic in Modder Support
Add these 2 methods to your block: public boolean renderAsNormalBlock() { return false; } public boolean isOpaqueCube() { return false; } That did it for me. -
What does your code currently do?
-
[1.7.2][UNSOLVED] Container - Basic Issue
larsgerrits replied to kenbeannet's topic in Modder Support
The only thing i can think of, is that you look through all of your classes related to the market, and look for something that looks for chestContents[6] and change it to chestContents[5]. -
Can you see the actual texture in your eclipse environment?
-
[1.7.2][UNSOLVED] Container - Basic Issue
larsgerrits replied to kenbeannet's topic in Modder Support
Can you post the full crash log? Then i can figure out where the problem occurs -
Try using back slashes in the ResourceLocation definition
-
[Solved] [1.7.2] Is there a ender pearl throw event?
larsgerrits replied to MinecraftMart's topic in Modder Support
Then this happens RIGHT_CLICK_AIR cannot be resolved or is not a field -
[1.7.2][UNSOLVED] Container - Basic Issue
larsgerrits replied to kenbeannet's topic in Modder Support
If you have a array which has 6 thingys, it ranges from 0-5. So if you do something like this: YOUR_ARRAY[6], it will try to find slot 7 but that doesn't exist. So that's why you get a ArrayIndexOutOfBoundsException. -
[1.7.2]Simple 1-slot chest/Container returns ClassCastException
larsgerrits replied to n1ghtk1n9's topic in Modder Support
Do I replace the return new BasicGui(player.inventory, (BasicTileEntity) tileEntity) with the thing I suggested? because I can only return one or the other Also, if I wanted to say create a backpack, how on right click with the backpack item, it would open a chest inventory and store the contents in the item, would I only need a IGuiHandler and a GuiContainer, or those 2 and a container? That's the line you need to replace. I haven't done anything with backpack type stuff, but i know what you need: Something with IInventory A GuiContainer class A Container class A GuiHandler (you already got one) -
[1.7.2]Simple 1-slot chest/Container returns ClassCastException
larsgerrits replied to n1ghtk1n9's topic in Modder Support
Yeah, that should work. -
[1.7.2]Simple 1-slot chest/Container returns ClassCastException
larsgerrits replied to n1ghtk1n9's topic in Modder Support
In your GuiHandler: @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity tileEntity = world.getTileEntity(x, y, z); if(tileEntity instanceof BasicTileEntity) { return new BasicGui(player.inventory, (BasicTileEntity) tileEntity); } return null; } You're returning a gui on the server side, but you need to return a container class. -
No,you don't need to learn any of these to make a gui. If you want to change values client and server side, you want to use packets. If you want your mod to be checking for a specific value on a player which is set by the gui, you want to use a tick handler. NBT is for saving information trough a world reload, and tile entitys are for block which need to store/do more stuff then a regular block can save/do.
-
[1.7.2]java.lang.NoClassDefFoundError
larsgerrits replied to Hackbaellchen's topic in Modder Support
Actually, eclipse has a icon like that. When you have a green arrow pointing up in that sidebar, you can see what that method does, in my case -
[Solved] NullPointerException at custom canInfuse() method
larsgerrits replied to Feronzed's topic in Modder Support
Can you post the full crash log? Line 261 seems correct to me. -
[Solved] Why is this value desyncronized? [1.6.4]
larsgerrits replied to larsgerrits's topic in Modder Support
Thanks to all of you! I used the way that diesieben07 linked and it worked! -
[Solved] Why is this value desyncronized? [1.6.4]
larsgerrits replied to larsgerrits's topic in Modder Support
At the handlePacket method, how can you make that method? (I'm not good with packets yet, this is the first time i used them) -
[Solved] Why is this value desyncronized? [1.6.4]
larsgerrits replied to larsgerrits's topic in Modder Support
Ok, i tried using packets, but i can't find find a way to update the tileentity value... Can anyone give a good tutorial, or some code (possibly some pseudocode)? -
[Solved] Why is this value desyncronized? [1.6.4]
larsgerrits replied to larsgerrits's topic in Modder Support
So i have to use packets? Damnit, guess it's time to learn how to deal with packets... -
Hello, i got another problem for you now. I have a value that's getting updated on the client side, but not on the server side. The way i update the code is via a GUI, when a click a button it's incrementing or decrementing a value and setting it to a TileEntity. In my container class i have some debug code: System.out.println((tileentity.worldObj.isRemote ? "Client" : "Server") + " : " + tileentity.getPage()); That prints this in the console: 2014-02-24 17:00:47 [iNFO] [sTDOUT] Server : 0 2014-02-24 17:00:47 [iNFO] [sTDOUT] Client : 0 And if i increment the value using a button, this is getting printed in the console: 2014-02-24 17:07:41 [iNFO] [sTDOUT] Server : 0 2014-02-24 17:07:42 [iNFO] [sTDOUT] Client :1 As you see the value is getting updated client-side, but not on the server side. I added this code to my TileEntity class: public Packet getDescriptionPacket() { NBTTagCompound tag = new NBTTagCompound(); this.writeToNBT(tag); return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, tag); } public void onDataPacket(INetworkManager networkManager, Packet132TileEntityData packet) { this.readFromNBT(packet.data); } But that doesn't seem to work. I have registered my TileEntity class. Does anyone know how to correctly syncronize that value? Code: [spoiler=TileEntityCustomizableBlock] package larsg310.mods.customization.tileentity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet132TileEntityData; import net.minecraft.tileentity.TileEntity; public class TileEntityCustomizableBlock extends TileEntity implements ISidedInventory { private ItemStack[] inventory = new ItemStack[2]; private float minX = 0; private float maxX = 1; private int page = 0; public float getMinX() { return minX; } public void setMinX(float minX) { this.minX = minX; } public float getMaxX() { return maxX; } public void setMaxX(float maxX) { this.maxX = maxX; } public int getPage() { return page; } public void setPage(int page) { this.page = page; } public Packet getDescriptionPacket() { NBTTagCompound tag = new NBTTagCompound(); this.writeToNBT(tag); return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, tag); } public void onDataPacket(INetworkManager networkManager, Packet132TileEntityData packet) { this.readFromNBT(packet.data); } public void writeToNBT(NBTTagCompound tag) { super.writeToNBT(tag); tag.setInteger("Page", page); tag.setFloat("minX", minX); tag.setFloat("maxX", maxX); } public void readFromNBT(NBTTagCompound tag) { page = tag.getInteger("Page"); minX = tag.getFloat("minX"); maxX = tag.getFloat("maxX"); } public int getSizeInventory() { return inventory.length; } public ItemStack getStackInSlot(int slot) { return inventory[slot]; } public ItemStack decrStackSize(int slot, int amount) { if (this.inventory[slot] != null) { ItemStack itemstack; if (this.inventory[slot].stackSize <= amount) { itemstack = this.inventory[slot]; this.inventory[slot] = null; return itemstack; } else { itemstack = this.inventory[slot].splitStack(amount); if (this.inventory[slot].stackSize == 0) { this.inventory[slot] = null; } return itemstack; } } else { return null; } } public ItemStack getStackInSlotOnClosing(int slot) { if (this.inventory[slot] != null) { ItemStack itemstack = this.inventory[slot]; this.inventory[slot] = null; return itemstack; } else { return null; } } public void setInventorySlotContents(int slot, ItemStack itemstack) { this.inventory[slot] = itemstack; if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()) { itemstack.stackSize = this.getInventoryStackLimit(); } } public String getInvName() { return "container.customizableBlock"; } public boolean isInvNameLocalized() { return false; } public int getInventoryStackLimit() { return 1; } public boolean isUseableByPlayer(EntityPlayer entityplayer) { return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : entityplayer.getDistanceSq((double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D, (double) this.zCoord + 0.5D) <= 64.0D; } public void openChest() { } public void closeChest() { } public boolean isItemValidForSlot(int slot, ItemStack itemstack) { return true; } public int[] getAccessibleSlotsFromSide(int var1) { return null; } public boolean canInsertItem(int i, ItemStack itemstack, int j) { return false; } public boolean canExtractItem(int i, ItemStack itemstack, int j) { return false; } } [spoiler=ContainerCustomizableBlock] package larsg310.mods.customization.inventory; import larsg310.mods.customization.tileentity.TileEntityCustomizableBlock; import net.minecraft.client.Minecraft; 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 ContainerCustomizableBlock extends Container { private TileEntityCustomizableBlock tileentity; private InventoryPlayer inventory; private Slot[] slots; public ContainerCustomizableBlock(InventoryPlayer inventory, TileEntityCustomizableBlock tileentity) { this.tileentity = tileentity; this.inventory = inventory; for (int i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18 + 80)); } } for (int i = 0; i < 9; ++i) { this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 142 + 80)); } slots = new Slot[]{new Slot(tileentity, 0, Integer.MIN_VALUE, 20), new Slot(tileentity, 1, Integer.MIN_VALUE, 20)}; this.addSlotToContainer(slots[0]); this.addSlotToContainer(slots[1]); System.out.println((tileentity.worldObj.isRemote ? "Client" : "Server") + " : " + tileentity.getPage()); this.drawSlotsBasedOnPage(); } public boolean canInteractWith(EntityPlayer entityplayer) { return this.tileentity.isUseableByPlayer(entityplayer); } public void detectAndSendChanges() { super.detectAndSendChanges(); drawSlotsBasedOnPage(); } private void drawSlotsBasedOnPage() { for(Slot slot : slots) { slot.xDisplayPosition = Integer.MIN_VALUE; } switch (tileentity.getPage()) { case 0: slots[0].xDisplayPosition = 100; break; case 1: slots[1].xDisplayPosition = 118; break; } } public ItemStack transferStackInSlot(EntityPlayer player, int slot) { return null; } } [spoiler=GuiCustomizableBlock] package larsg310.mods.customization.gui; import larsg310.mods.customization.inventory.ContainerCustomizableBlock; import larsg310.mods.customization.lib.Reference; import larsg310.mods.customization.tileentity.TileEntityCustomizableBlock; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; public class GuiCustomizableBlock extends GuiContainer { private int page; private int maxPages = 1; private TileEntityCustomizableBlock tileentity; ResourceLocation texture = new ResourceLocation(Reference.MOD_ID, "textures/gui/customizableBlock.png"); public GuiCustomizableBlock(InventoryPlayer inventory, TileEntityCustomizableBlock tileentity) { super(new ContainerCustomizableBlock(inventory, tileentity)); this.tileentity = tileentity; this.page = tileentity.getPage(); this.ySize = 246; } @Override protected void drawGuiContainerForegroundLayer(int x, int y) { fontRenderer.drawString(StatCollector.translateToLocal("container.customizableBlock"), 8, 6, 4210752); String pageString = "Page: " + page + " / " + maxPages; fontRenderer.drawString(pageString, xSize / 2 - ((pageString.length() / 2) * 6), 123, 4210752); } @Override protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { this.mc.getTextureManager().bindTexture(texture); int x1 = (width - xSize) / 2; int y1 = (height - ySize) / 2; this.drawTexturedModalRect(x1, y1, 0, 0, xSize, ySize); } @SuppressWarnings("unchecked") public void initGui() { super.initGui(); this.buttonList.clear(); this.buttonList.add(new GuiButton(0, (width - xSize) / 2 + 7, 113, 12, 20, "<")); this.buttonList.add(new GuiButton(1, (width - xSize) / 2 + (xSize - 19), 113, 12, 20, ">")); } public void actionPerformed(GuiButton button) { switch (button.id) { case 0: page--; break; case 1: page++; break; } if (page < 0) { page = 0; } if (page > maxPages) { page = maxPages; } this.tileentity.setPage(page); } } [spoiler=BlockCustomizableBlock] package larsg310.mods.customization.block; import larsg310.mods.customization.CustomizationCraft; import larsg310.mods.customization.lib.GuiIds; import larsg310.mods.customization.lib.Names; import larsg310.mods.customization.tileentity.TileEntityCustomizableBlock; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockCustomizableBlock extends Block { public BlockCustomizableBlock(int id) { super(id, Material.iron); this.setCreativeTab(CreativeTabs.tabBlock); this.setUnlocalizedName(Names.CUSTOMIZABLE_BLOCK); } public TileEntity createTileEntity(World world, int meta) { return new TileEntityCustomizableBlock(); } public boolean hasTileEntity(int meta) { return true; } public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { if(!world.isRemote) { player.openGui(CustomizationCraft.instance, GuiIds.CUSTOMIZABLE_BLOCK, world, x, y, z); } return true; } public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { TileEntity te = world.getBlockTileEntity(x, y, z); if (te instanceof TileEntityCustomizableBlock) { TileEntityCustomizableBlock tileentity = (TileEntityCustomizableBlock) te; this.setBlockBounds(tileentity.getMinX(), 0, 0, tileentity.getMaxX(), 1, 1); } } public boolean isOpaqueCube() { return false; } } [spoiler=GuiHandler] package larsg310.mods.customization.handler; import larsg310.mods.customization.CustomizationCraft; import larsg310.mods.customization.gui.GuiCustomizableBlock; import larsg310.mods.customization.inventory.ContainerCustomizableBlock; import larsg310.mods.customization.lib.GuiIds; import larsg310.mods.customization.tileentity.TileEntityCustomizableBlock; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.NetworkRegistry; public class GuiHandler implements IGuiHandler { @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { switch(ID) { case GuiIds.CUSTOMIZABLE_BLOCK: return new ContainerCustomizableBlock(player.inventory, (TileEntityCustomizableBlock)world.getBlockTileEntity(x, y, z)); } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { switch(ID) { case GuiIds.CUSTOMIZABLE_BLOCK: return new GuiCustomizableBlock(player.inventory, (TileEntityCustomizableBlock)world.getBlockTileEntity(x, y, z)); } return null; } public static void register() { NetworkRegistry.instance().registerGuiHandler(CustomizationCraft.instance, new GuiHandler()); } } If you need more code, i'll be happy to provide more.
-
[SOLVED?][1.6.4][Coremod] Need help with error during transformation
larsgerrits replied to angelix's topic in Modder Support
You could also use the RenderGameOverlayEvent and then check if it is the GuiMainMenu class and then cancel the rendering and then render your own menu -
http://techne.zeux.me/Techne