-
Recently Browsing
- No registered users viewing this page.
-
Posts
-
By diesieben07 · Posted
Why are you sending the stack to the server? The server knows your currently held item. -
@SubscribeEvent public static void gauntletGUI(final TickEvent.ClientTickEvent event) { PlayerEntity player = Minecraft.getInstance().player; if(player != null) { ItemStack stack = player.getMainHandItem(); if (keyOpenGauntlet.isDown() && stack.getItem().equals(ItemInit.INFINITY_GAUNTLET.get())) { Main.NETWORK.sendToServer(new InputMessage(stack)); } } } It works. Thanks!
-
on client you always can use Minecraft.getInstance(), then you be able to get the local player
-
In ClickTickEvent i dont know how to get the player public static void handle(InputMessage message, Supplier<NetworkEvent.Context> contextSupplier) { NetworkEvent.Context context = contextSupplier.get(); ServerPlayerEntity player = context.getSender(); ItemStack gauntlet = player.getMainHandItem(); if(gauntlet.getItem() instanceof InfinityGauntlet) { INamedContainerProvider ncp = new InfinityGauntlet.InfinityGauntletContainerProvider((InfinityGauntlet) gauntlet.getItem(), gauntlet); NetworkHooks.openGui(player, ncp); context.setPacketHandled(false); } } You were right I check the item on the server and this code works Thanks
-
-
Topics
-
Who's Online (See full list)
Recommended Posts
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.