Posted January 19, 201510 yr I have a block that lets you add exp levels but when you reopen the block it resets your level package com.mcpixelplex.Gui; import org.lwjgl.opengl.GL11; import com.mcpixelplex.lib.RefStrings; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.item.EntityXPOrb; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; public class TestGui extends GuiScreen { Minecraft mc = Minecraft.getMinecraft(); GuiButton testButton; public String[] levelDisplay = new String[]{"1","2","3","4","5","6","7","8","9","10"}; public int level = 0; public int currentPower = 0; public int maxPower = 1000; public final int xSizeOfTexture = 256; public final int ySizeOfTexture = 156; public TestGui(EntityPlayer player){ } @Override public void drawScreen(int x, int y, float f){ int xPos = (this.width - xSizeOfTexture) / 2; int yPos = (this.height - ySizeOfTexture) / 2; int levelPosX = (xSizeOfTexture) / 2; int levelPosY = (ySizeOfTexture) / 2; GL11.glColor4f(1F, 1F, 1F, 1F); mc.renderEngine.bindTexture(new ResourceLocation(RefStrings.MODID, "/textures/gui/background.png")); drawDefaultBackground(); drawTexturedModalRect(xPos, yPos, 0, 0, xSizeOfTexture, ySizeOfTexture); fontRendererObj.drawString("XP Block", xPos + 20, yPos + 5, 0x000000); fontRendererObj.drawString(String.valueOf(level), levelPosX + 85 , levelPosY + 45, 0x000000); super.drawScreen(xPos, y, f); } public void initGui(){ int xSize = 100; int ySize = 20; int xPos = (xSizeOfTexture) / 2; int yPos = (ySizeOfTexture) / 2; int bottomButton = (ySizeOfTexture - ySize - 2); buttonList.clear(); buttonList.add(new GuiButton(0, xPos + 40, bottomButton + 40, 100, 20, "Give XP")); buttonList.add(new GuiButton(1, xPos + 40, yPos + 40, 20, 20, "+")); buttonList.add(new GuiButton(2, xPos + 120, yPos + 40, 20, 20, "-")); super.initGui(); } public void playerEffects(){ EntityPlayer player = mc.thePlayer; player.addExperienceLevel(level); player.setHealth(1000); } public void actionPerformed(GuiButton button){ switch(button.id){ case 0: playerEffects(); break; case 1: level++; break; case 2: if(level == 0){ }else{ level--; } break; } } @Override public boolean doesGuiPauseGame(){ return false; } }
January 19, 201510 yr Author You don't read what people tell you, do you? To spawn entities you will need packets though, you can't spawn them on the client. How is addExperienceLevel() spawning a entity
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.