Jump to content

baegmon

Members
  • Posts

    7
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

baegmon's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Finally got it working on the server and client thanks to your posts (both on this and previous answers!) Thanks for all your help.
  2. Sorry for bumping the thread, I thought it was working but it was only working in single player mode. It is a container-less GUI so I'm trying to get it working by sending a custom packet from the server to the client and calling "Minecraft::displayGuiScreen" but it seems to crash the server during startup phase. I've made the following changes: In my message handler: public static class Handler implements IMessageHandler<OpenGUI, IMessage> { @Override public IMessage onMessage(OpenGUI message, MessageContext ctx) { /* EntityPlayerMP player = ctx.getServerHandler().playerEntity; World world = player.worldObj; if(!world.isRemote){ Minecraft.getMinecraft().displayGuiScreen(new TutorialGUI()); } */ System.out.println("MESSAGE"); return null; } } The command to open the GUI on the client: @Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if(args.length > 0){ throw new WrongUsageException(getCommandUsage(sender)); } else { World world = sender.getEntityWorld(); if(world.isRemote){ EntityPlayerMP player = (EntityPlayerMP) sender; Main.network.sendTo(new OpenGUI(), player); } } } Printing a message is delivered to the client but as soon as I try to call "Minecraft::displayGuiScreen", it crashes. Is there something that I'm doing wrong? Also, I noticed a previous post http://www.minecraftforge.net/forum/index.php?topic=25821.msg131607#msg131607 where it says "You need to redirect any code that contains client references through your client proxy." How do I go about doing that?
  3. Oh, I must've been looking up the wrong examples. Calling Minecraft::displayGuiScreen has opened it up. Thanks for your help.
  4. I am creating my custom GUI for a quiz mod and have run into some trouble. When I right click my block to open up the quiz GUI, it opens nicely. However when I try to open it using a command, it does not work. After some googling, I have found that it is required to send a packet from the server to the client to inform it to open the GUI. As such, I have implemented a SimpleNetworkWrapper as found in this tutorial. I initialize my network wrapper within the FMLPreInitializationEvent with: network = NetworkRegistry.INSTANCE.newSimpleChannel("GUIChannel"); network.registerMessage(MyMessage.Handler.class, MyMessage.class, 0, Side.SERVER); Then from my command, I send the packet: @Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { Main.network.sendTo(new MyMessage("ASDF"), (EntityPlayerMP) sender); My Handler class attempts to open the gui: public static class Handler implements IMessageHandler<MyMessage, IMessage> { @Override public IMessage onMessage(MyMessage message, MessageContext ctx) { EntityPlayer player = ctx.getServerHandler().playerEntity; player.openGui(Main.INSTANCE, GUIHandler.TUTGUID, player.getEntityWorld(), player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ()); return null; } } This does not seem to open the GUI and I'm not quite sure what I'm doing wrong. How do I modify this to make it functional via a command? Thanks.
  5. Alright will have to research abit more for how to properly implement chunks and stuff but on to the actual question, how do you tell another player that they can't use a chest through the PlayerOpenContainer event?
  6. Currently working on a custom party system but I can't seem to figure out chests. I have a HashMap which tracks all the players and the blocks they have placed (have made sure this also allows Chests): private HashMap<String, ArrayList<Block>> ownedBlocks = new HashMap<String, ArrayList<Block>>(); Now, I'm trying to handle an event where a user who did not place the block cannot access the contents of the chests. @SubscribeEvent public void playerOpenChest(PlayerOpenContainerEvent event){ EntityPlayer player = event.getEntityPlayer(); if(player.openContainer instanceof ContainerChest){ ContainerChest chest = (ContainerChest) player.openContainer; String playerName = player.getName(); // if HashMap contains player name if(ownedBlocks.containsKey(playerName)){ ArrayList<Block> playerPlacedBlocks = ownedBlocks.get(playerName); if(playerPlacedBlocks.contains(chest)){ System.out.println("I made this chest! I can open this chest!"); } else { System.out.println("This chest is not mine! I shouldn't open other peoples chests!"); } } } } Whenever I try to open my chests, it fires "This chest is not mine! I shouldn't open other peoples chests!" This is what I have so far, I'm completely lost on how to handle the "if~else" interactions with chests and would love any direction you guys could give me. Thanks!
×
×
  • Create New...

Important Information

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