Posted August 6, 201312 yr Hello! Ive made a portable book enchater but when im in mutiplayer I get a weird glitch the video will show you what i mean. Please help Not new to java >> New to modding.
August 6, 201312 yr Author here code to the GUI: package mod.gmod622.gui; import java.util.Random; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiIngameMenu; import net.minecraft.client.gui.GuiScreen; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentData; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class GUIenchanter extends GuiScreen { private World worldMC; private EntityPlayer entityP; private Minecraft mineC; public static double rand; private static Random random = new Random(); public GUIenchanter(World world, EntityPlayer entityplayer, Minecraft minecraft) { worldMC = world; entityP = entityplayer; mineC = minecraft; } public void initGui() { buttonList.add(new GuiButton(0, width / 2 - 50, height / 2 - 50, 200, 20, "Random Enchanted Book (30 lvls)")); } protected void actionPerformed(GuiButton guiButton) { if(guiButton.id == 0) { if(entityP.experienceLevel >= 30 && entityP.inventory.hasItem(Item.book.itemID)) { EnchantedBook(entityP); entityP.experienceLevel -= 30; entityP.inventory.consumeInventoryItem(Item.book.itemID); }else if(entityP.experienceLevel <= 30) { entityP.addChatMessage("Not enough Levels."); }else { entityP.addChatMessage("Book required"); } } } @Override public boolean doesGuiPauseGame() { return false; } public static void EnchantedBook(EntityPlayer par3EntityPlayer) { Enchantment enchantment = Enchantment.enchantmentsBookList[random.nextInt(Enchantment.enchantmentsBookList.length)]; ItemStack itemstack = new ItemStack(Item.enchantedBook.itemID, 1, 0); int l = MathHelper.getRandomIntegerInRange(random, enchantment.getMinLevel(), enchantment.getMaxLevel()); Item.enchantedBook.getEnchantedItemStack_do(itemstack, new EnchantmentData(enchantment, l)); par3EntityPlayer.inventory.addItemStackToInventory(itemstack); } } Not new to java >> New to modding.
August 6, 201312 yr You have to use packets to send the changes induced by actionPerformed(args) to the server. There are tutorials for PacketHandler and such on the wiki.
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.