Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Guje

Members
  • Joined

  • Last visited

Everything posted by Guje

  1. It works. And thanks for the tips.
  2. If it helps here is the class of the ItemTest: public class ItemTest extends Item { public static ItemTest create() { ItemTest result = new ItemTest (); result.init(); return result; } protected ItemTest () { setCreativeTab(EnderIOTab.tabEnderIO); setUnlocalizedName("itemTest"); setMaxDamage(0); setMaxStackSize(1); } @Override public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { if (itemStack.stackTagCompound==null){ itemStack.stackTagCompound = new NBTTagCompound(); itemStack.stackTagCompound.setString("text", ""); } if (!world.isRemote){ Minecraft.getMinecraft().displayGuiScreen(new TestGui(itemStack)); } return itemStack; } @Override public void onCreated(ItemStack itemStack, World world, EntityPlayer entityPlayer) { if (itemStack.stackTagCompound==null){ itemStack.stackTagCompound = new NBTTagCompound(); itemStack.stackTagCompound.setString("text", ""); } super.onCreated(itemStack, world, entityPlayer); } @Override public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean b) { if (itemStack.stackTagCompound==null){ itemStack.stackTagCompound = new NBTTagCompound(); itemStack.stackTagCompound.setString("text", ""); } list.add(itemStack.stackTagCompound.getString("text")); } @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister IIconRegister) { itemIcon = IIconRegister.registerIcon("enderiofilters:itemTest"); } private void init() { GameRegistry.registerItem(this, "itemTest"); } }
  3. But how do i get the ItemStack on the server?
  4. public class PacketTestItem implements IMessageHandler<PacketTestItem, IMessage>, IMessage { private ItemStack itemTest; private String text; public PacketTestItem () { } public PacketTestItem (ItemStack itemTest, String text) { this.itemTest= itemTest; this.text= text; } @Override public void fromBytes(ByteBuf buf) { itemTest= ByteBufUtils.readItemStack(buf); text= ByteBufUtils.readUTF8String(buf); } @Override public void toBytes(ByteBuf buf) { ByteBufUtils.writeItemStack(buf, itemTest); ByteBufUtils.writeUTF8String(buf, text); } @Override public IMessage onMessage(PacketTestItem message, MessageContext ctx) { message.itemTest.stackTagCompound.setString("text",message.text); return null; } }
  5. Hey everyone! I have a problem with setting the nbt data of an item inside a gui. I am able to set the nbt data of the item in the Constructor and in the initGui() method, but when i try to set it in the onGuiClosed() method the nbt data isn't changed. Can someone explain why and how i can fix it? Here the code of the onGuiClosed method: @Override public void onGuiClosed() { super.onGuiClosed(); String s = textField.getText(); itemTest.stackTagCompound.setString("text", s); System.out.println(itemTest.stackTagCompound.getString("text")); //here it shows the right value PacketHandler.INSTANCE.sendToServer(new PacketTestItem(itemTest, s)); }
  6. Thanks, i will try that!
  7. I thought about that. But when i change it like that, there aren't any changes made to the server, so it doesn't work
  8. So how can I fix this?
  9. in this function @Override public boolean onItemUse(ItemStack item, EntityPlayer player, World world, int x, int y, int z, int par7, float xFloat, float yFloat, float zFloat) { if (!player.canPlayerEdit(x, y, z, par7, item)){ return false; } if (!world.isRemote){ Block target = world.getBlock(x, y, z); Minecraft.getMinecraft().displayGuiScreen(new TestBlockGui(target,world,x,y,z)); } return true;
  10. In line 71 there is only drawDefaultBackground(); rest of the class: package com.guje.test_mod; import org.lwjgl.opengl.GL11; import net.minecraft.block.Block; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiTextField; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; public class TestBlockGui extends GuiScreen { private int textureX; private int textureY; private int posY; private int posX; private int bY; private int bX; private int bZ; private ResourceLocation texture; private World world; private String blockId; private String blockMetadata; private GuiTextField text_BlockId; private GuiTextField text_BlockMetadata; public TestBlockGui(Block block, World world, int bX, int bY, int bZ) { super(); this.textureX = 175; this.textureY = 221; this.bX = bX; this.bY = bY; this.bZ = bZ; this.world = world; this.blockId = block.getIdFromBlock(block)+""; this.blockMetadata = world.getBlockMetadata(bX, bY, bZ)+""; texture = new ResourceLocation(Hack_n_Mine.MODID, "textures/gui/hackingGui.png"); } @Override public void initGui() { buttonList.clear(); posX = (this.width - textureX) / 2; posY = (this.height - textureY) / 2; text_BlockId = new GuiTextField(fontRendererObj, posX + 77, posY + 5, 40, 10); text_BlockId.setText(blockId); text_BlockId.setMaxStringLength(5); text_BlockMetadata = new GuiTextField(fontRendererObj, posX + 77, posY + 18, 40, 10); text_BlockMetadata.setText(blockMetadata); text_BlockMetadata.setMaxStringLength(5); super.initGui(); } @Override protected void keyTyped(char c, int i) { text_BlockId.textboxKeyTyped(c, i); text_BlockMetadata.textboxKeyTyped(c, i); super.keyTyped(c, i); } @Override protected void mouseClicked(int i, int j, int f) { text_BlockId.mouseClicked(i, j, f); text_BlockMetadata.mouseClicked(i, j, f); super.mouseClicked(i, j, f); } @Override public void drawScreen(int x, int y, float f) { drawDefaultBackground(); GL11.glColor4f(1F,1F,1F,1F); posX = (this.width - textureX) / 2; posY = (this.height - textureY) / 2; mc.renderEngine.bindTexture(texture); drawTexturedModalRect(posX, posY, 0, 0, textureX, textureY); text_BlockId.drawTextBox(); text_BlockMetadata.drawTextBox(); fontRendererObj.drawString("BlockID", posX + 5, posY + 7, 0x404040); fontRendererObj.drawString("BlockMetadata", posX + 5, posY + 19, 0x404040); super.drawScreen(x, y, f); } @Override public void onGuiClosed() { //Set blockId and metadata Block b = Block.getBlockById(Integer.parseInt(text_BlockId.getText())); int m = Integer.parseInt(text_BlockMetadata.getText()); world.setBlock(bX, bY, bZ, b, m, 3); super.onGuiClosed(); } }
  11. Sometimes, when I open my customGui, the server shuts down and shows this error: Stacktrace: at net.minecraft.client.gui.GuiScreen.drawWorldBackground(GuiScreen.java:396) at net.minecraft.client.gui.GuiScreen.drawDefaultBackground(GuiScreen.java:391) at com.guje.test_mod.TestBlockGui.drawScreen(TestBlockGui.java:71)
  12. I tried the fix, but it caused my mod to be loaded twice, so i wasn't able to start minecraft. I will just take the easy way and switch to eclipse. Thanks never the less
  13. Hello, I have problems adding custom textures to an item. I have the feeling there is a problem copying the assets, because the item also has the wrong name in game. TestMod.java: package com.guje.testmod; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; @Mod(modid = TestMod.MODID, version = TestMod.VERSION) public class TestMod { public static final String MODID = "testmod"; public static final String VERSION = "0.1"; @EventHandler public static void preinit(FMLInitializationEvent event){ Item usbSword = new TestSword(); usbSword.setUnlocalizedName("testSword"); usbSword.setTextureName(TestMod.MODID + ":testSword"); usbSword.setCreativeTab(CreativeTabs.tabMisc); GameRegistry.registerItem(usbSword, "testSword"); } @EventHandler public static void init(FMLInitializationEvent event) { } @EventHandler public static void postInit(FMLInitializationEvent event) { } } TestSword.java: package com.guje.testmod; import net.minecraft.item.Item; public class TestSword extends Item { public TestSword() { super(); } } en_US.Lang: item.testmod:testSword.name=Test Sword my structure is:

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.