mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-25 22:44:32 +00:00
Implemented a generic EntityPlayer.openGui system, and the network backend for it to work on server and client.
This commit is contained in:
1 parent
a6f93ed528
commit
54ec1567b2
10 files changed
+271
-6
No files matched your search
@@ -0,0 +1,21 @@
|
||||
package net.minecraft.src.forge;
|
||||
|
||||
import net.minecraft.src.EntityPlayerSP;
|
||||
import net.minecraft.src.GuiScreen;
|
||||
import net.minecraft.src.World;
|
||||
|
||||
public interface IGuiHandler
|
||||
{
|
||||
/**
|
||||
* Returns a GuiScreen to be displayed to the user. This is client side
|
||||
*
|
||||
* @param ID The Gui ID Number
|
||||
* @param player The player viewing the Gui
|
||||
* @param world The current world
|
||||
* @param X X Position
|
||||
* @param Y Y Position
|
||||
* @param Z Z Position
|
||||
* @return A GuiScreen to be displayed to the user, null if none.
|
||||
*/
|
||||
public GuiScreen getGuiScreen(int ID, EntityPlayerSP player, World world, int X, int Y, int Z);
|
||||
}
|
||||
@@ -53,6 +53,12 @@ public class PacketHandlerClient implements IPacketHandler
|
||||
pkt.readData(data);
|
||||
onModIDs((PacketModIDs)pkt);
|
||||
break;
|
||||
|
||||
case ForgePacket.OPEN_GUI:
|
||||
pkt = new PacketOpenGUI();
|
||||
pkt.readData(data);
|
||||
onOpenGui((PacketOpenGUI)pkt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch(IOException e)
|
||||
@@ -192,4 +198,20 @@ public class PacketHandlerClient implements IPacketHandler
|
||||
}
|
||||
//TODO: Display error/confirmation screen
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles opening the Gui for the player.
|
||||
*
|
||||
* @param pkt The Open Gui Packet
|
||||
*/
|
||||
private void onOpenGui(PacketOpenGUI pkt)
|
||||
{
|
||||
NetworkMod mod = MinecraftForge.getModByID(pkt.ModID);
|
||||
if (mod != null)
|
||||
{
|
||||
EntityPlayerSP player = (EntityPlayerSP)ModLoader.getMinecraftInstance().thePlayer;
|
||||
player.openGui(mod, pkt.GuiID, player.worldObj, pkt.X, pkt.Y, pkt.Z);
|
||||
player.craftingInventory.windowId = pkt.WindowID;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user