
SebasTheGreat
Members-
Posts
26 -
Joined
-
Last visited
Everything posted by SebasTheGreat
-
[1.7.10] [Solved] How Do I Open a GUI on Server?
SebasTheGreat replied to SebasTheGreat's topic in Modder Support
Nvm I got it working but thanks for your time. -
[1.7.10] [Solved] How Do I Open a GUI on Server?
SebasTheGreat replied to SebasTheGreat's topic in Modder Support
I'm using a key connected to the GUI so when I press a button the GUI opens. In my key handler I have the network.sendToSever(new packetWhatever). In this packet before it opens the GUI it tests to see if the player is wearing armor, which works, but after the tests run it it doesn't open the GUI for some reason. this is in my GUI handler, I'll simplify it a little: public onMessage { if( "Tests to see if armor is worn") { { ctx.getServerHandler().playerEntity.openGui... } } } -
Hey so I've made a GUI in my mod and got it working okay. It is a GUI that isn't attached to a tile entity, and I have a problem right now where I'm trying to open the GUI on the server side but its not working. I'm using packets and the getServerHandler().playerEntity.openGui() but when I go to open it nothing happens, no errors or crash. Is there something I need to use beside openGui(), do I need to do something special with my GUI or my mod class, or does this not work period?
-
[1.7.10] [SOLVED] GUI Option Button?
SebasTheGreat replied to SebasTheGreat's topic in Modder Support
Sometimes I just do and say the dumbest things. I got it working all thanks to you guys . -
[1.7.10] [SOLVED] GUI Option Button?
SebasTheGreat replied to SebasTheGreat's topic in Modder Support
Hey so I made this in my actionPerformed method: boolean on = guiButton.displayString == "On"; if(on) { guiButton.displayString = "Off"; } else if(!on) { guiButton.displayString = "On"; } It toggles just the way I want it to but now I have 1 problem. How do I save what the text is? If I set it to on and leave the GUI, when I come back its back to off. -
Yeah so I have this in my onKeyInput: "ModName".network.sendToServer(new "Packet"); and this in my onMessage method in my packet: if(ctx.getServerHandler().playerEntity.getCurrentArmor(0) != null && ctx.getServerHandler().playerEntity.getCurrentArmor(0).getItem().equals("armorBoots")) if(ctx.getServerHandler().playerEntity.getCurrentArmor(1) != null && ctx.getServerHandler().playerEntity.getCurrentArmor(1).getItem().equals("armorLeggings")) if(ctx.getServerHandler().playerEntity.getCurrentArmor(2) != null && ctx.getServerHandler().playerEntity.getCurrentArmor(2).getItem().equals("armorChestplate")) if(ctx.getServerHandler().playerEntity.getCurrentArmor(3) != null && ctx.getServerHandler().playerEntity.getCurrentArmor(3).getItem().equals("armorHelmet")) { ctx.getServerHandler().playerEntity.openGui... } return null; but when I press the key in game nothing happens.
-
Yeah and this: is what it says on that page. That's what I'm doing in that code in my previous post. I need to use the sendTo method to send the packet to the client telling him to open the GUI if the key is pressed and have the packet check to see if the correct armor is being worn. I'm sorry but linking me to a page I've seen a hundred times ins't going to help me here, I'm not asking for any copy and paste but I would like an explanation of what I'm supposed to do with this situation.
-
[1.7.10] [SOLVED] GUI Option Button?
SebasTheGreat replied to SebasTheGreat's topic in Modder Support
No I know how to make a button, but I need the button that once you press it, turns on. Then the button changes to the turn off button and you can press it again to turn it off. An example would be the clouds button in the option menu. It toggles clouds on and off, that's what I'm trying to make, only for something other than clouds . -
Ok so in order for it to work on a server, I need to use packets. I assume I need a packet where the server sends a message to the client telling it to open the GUI, because GUI's are client side only. I've made the packet but I have the issue of "ModName".network.sendTo(new "Packet", "EntityPlayerMP"); What do I put in for the "EntityPlayerMP"? This is in the onKeyInput method which doesn't simply have a parameter for EntityPlayerMP. Is there a method that gets which player is pressing the key? Sorry for my obvious stupidity on this subject, I'm kinda new to it.
-
Hey so I'm trying to make an Option Button for my GUI that toggles invisibility. I need to know how to set up the Option Button, as it seems very complicated from the vanilla code I've looked at. After looking at the vanilla code and getting nowhere, I decided to come ask. If you have a video or post that teaches how to do it just link it and I'll figure it out from there. If you know how to do it I would be very thankful for your help.
-
Ok so I did what SuperKael said and I got it working so thanks for the help and responses everyone.
-
1. Can I use FMLClientHandler.instance().getClientPlayerEntity() instead. 2. I can't grasp what you're talking about with the ItemStack.getItem(), everytime I try to use it I get the error: Cannot make a static reference to the non-static method getItem() from the type ItemStack
-
So I've changed my code to what you guys said: if(Minecraft.getMinecraft().thePlayer.getEquipmentInSlot(1) != null) { if(ItemStack.areItemStacksEqual(Minecraft.getMinecraft().thePlayer.getEquipmentInSlot(1), new ItemStack("Armor I want"))) { Minecraft.getMinecraft().thePlayer.openGui... } } but it still doesn't work The armor piece I am checking is only an Item and I need an ItemStack to compare them so I make a new ItemStack.
-
Hey so I'm trying to make it so when I press a key and the player is wearing a certain type of armor, it opens a GUI. I have the key set up and when you press the key the GUI opens but when I add the if statement: if(Minecraft.getMinecraft().thePlayer.getEquipmentInSlot(1) == new ItemStack("Armor I want")) { Minecraft.getMinecraft().thePlayer.openGui... } into the if statement that tests to see if the key is pressed, when I press the key in the game the GUI never opens, even if I have the armor specified on. So to re-put that so people can understand it, I press key - GUI opens, I add statement to see if specific armor is on, and press key - GUI doesn't open at all. I think I'm understanding the getEquipmentInSlot Method wrong so any help would be appreciated.
-
It is a client side GUI and the code I could come up with seems logical (to me) but doesn't work. @SubscribeEvent public void onKeyInput(InputEvent.KeyInputEvent event) { if(!FMLClientHandler.instance().isGUIOpen(GuiChat.class)) { int key = Keyboard.getEventKey(); boolean isDown = Keyboard.getEventKeyState(); if(isDown && key == keyValues[AAA_KEY]) { Minecraft.getMinecraft().thePlayer.openGui(MineGrades.instance,MineGrades.guiAAA, Minecraft.getMinecraft().thePlayer.worldObj, (int)Minecraft.getMinecraft().thePlayer.posX, (int)Minecraft.getMinecraft().thePlayer.posY, (int)Minecraft.getMinecraft().thePlayer.posZ); } } }
-
Hey so, as the title has stated, I'm trying to open a GUI by pressing a key. I have the key handler set up but I don't know how to link it to the GUI. I've tried different combinations of things including using packets and just telling the onKeyImput method directly to open the GUI but nothing has worked. If anyone can point me in the right direction I would be very appreciated.
-
Oops the static was me just trying something out, ill remove it. Also, how would I go about having the server remove the potion effect?
-
Ok so I looked into Simple Network Wrapper and I thought I had it sorted out but when it try to remove a poison potion effect via GUI button it just kicks me out of the world. Here is my code for the Simple Network Wrapper. Can someone please tell me what I'm doing wrong. Main Mod Class network.registerMessage(RemovePoison.Handler.class, RemovePoison.class, 0, Side.SERVER); GUI class public void actionPerformed(GuiButton button) { switch(button.id) { case 0: MineGrades.network.sendToServer(new RemovePoison(4)); } } Simple Network Wrapper Remove Poison Class package NetworkWrapper; import net.minecraft.potion.Potion; import io.netty.buffer.ByteBuf; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; public class RemovePoison implements IMessage { private static int id; public RemovePoison() { } public RemovePoison(int id) { this.id = id; } @Override public void fromBytes(ByteBuf buf) { buf.writeByte(id); } @Override public void toBytes(ByteBuf buf) { id = buf.readByte(); } public static class Handler implements IMessageHandler<RemovePoison, IMessage> { @Override public IMessage onMessage(RemovePoison poison, MessageContext ctx) { ctx.getServerHandler().playerEntity.removePotionEffect(id); return null; } } }
-
Ok I looked into it and it seems easy enough. Ill code it in and see if I can get it working, thanks for input and help everyone.
-
Yeah my plan is to use a packet. Right now though this is all I could come up with and it doesn't work. public class DeleteItemPacket extends AbstractPacket{ public DeleteItemPacket() { } @Override public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) { } @Override public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) { } @Override public void handleClientSide(EntityPlayer player) { } @Override public void handlerServerSide(EntityPlayer player) { player.destroyCurrentEquippedItem(); } }
-
Ok so I've changed it so that when you click the button it removes the poison effect, deletes the item used to open the GUI, and closes the GUI. The only problem now is that it deletes the item but it just reappears if you click in the slot it was in. I imagine I have to use a packet to send to the server and tell it to delete the item?
-
Hey so I've encountered another problem with my GUI button. I've successfully fixed my issue earlier where I couldn't get my button to remove the poison effect on the player. I looked into packets and got it to work. Now, when the player clicks on the button, it removes the poison effect but I want the button to be disabled temporarily. After some time passes the button re-enables and the player can use it again. This is what I've got so far but it just disables the button and doesn't re-enable it unless I close the GUI and re-open it. public void actionPerformed(GuiButton button) { switch(button.id) { case 0: button.enabled = true; MineGrades.packetPipeline.sendToServer(new RemovePoisonPacket(Potion.poison.id)); long time = this.mc.theWorld.getWorldInfo().getWorldTime(); for(long i = time; i < (time + 1000); i++) { button.enabled = false; } } } This whole setup is probably terrible so feel free to correct me and thanks for any help in advance.
-
[1.7.10] GUI Button Won't Remove Potion Effect.
SebasTheGreat replied to SebasTheGreat's topic in Modder Support
Yeah that won't for buttons like coolAlias said. I could just use your method but I'm gonna stick with packet's and GUI's so I can extend my knowledge of the two. Thanks for adding though. -
[1.7.10] GUI Button Won't Remove Potion Effect.
SebasTheGreat replied to SebasTheGreat's topic in Modder Support
Okay, my knowledge on packets is very limited so ill look into them. Thanks for the help and very fast reply.