Posted October 6, 20195 yr Hello, so I'm attempting to create a keybinding. I've done it in 1.12.2, but have no idea how to do it in 1.14.4. Any assistance would be appreciated. Thanks.
October 7, 20195 yr Author Ok, so I've figured out the keybinds but now i'm having trouble with packets. I don't understand the parameters of registerMessage.
October 7, 20195 yr 36 minutes ago, TesterTesting135 said: I don't understand the parameters of registerMessage. The first one is it's mod unique ID. The second is a class that will be created by your decoder. (It needs to store all the information you want accessible on the other side(Server/Client)). The third is a BIConsumer that takes in an instance of that class and a PacketBuffer. Use this to write the data sent over the network to the PacketBuffer. The fourth is a Function that takes in a PacketBuffer and returns an instance of the class. Use this to read the data from the PacketBuffer into a new instance of the class. The fifth and final parameter is a BiConsumer that takes in an instance of the class and a Supplier of NetworkEvent.Context. Use this to handle the information you sent over whether it be syncing data to the client or performing an action on the server. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
October 7, 20195 yr Author Ok, thank you! Also, by any chance do you know how to add a tooltip to another item that you didn't create? (I'm trying to when you press a key, it will do stuff and also add a tooltip to that item that you're holding)
October 7, 20195 yr 11 minutes ago, TesterTesting135 said: Ok, thank you! Also, by any chance do you know how to add a tooltip to another item that you didn't create? (I'm trying to when you press a key, it will do stuff and also add a tooltip to that item that you're holding) There is an event for it. I believe it is called RenderTooltipEvent. You'll have to use Pre sub event to modify the lines List VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
October 7, 20195 yr Author Sorry to bother you, but I'm trying to cancel the item drop event, and it works, but only if i have the inventory open, and then drag and drop out or press q inside the inventory menu. However, it doesn't work when i "q" inside the hotbar, without the inventory open. It just "deletes" the item, but when I click on the slot with the inventory open it reappears. Do you know why? Thanks. Code: @SubscribeEvent public static void onToss(ItemTossEvent event) { PlayerEntity player = event.getPlayer(); //player.sendMessage(new StringTextComponent("1nd Stage.")); if (ItemItemLock.hasLock(player)) { //player.sendMessage(new StringTextComponent("2nd Stage.")); ItemStack droppedItem = event.getEntityItem().getItem(); CompoundNBT nbt; if (droppedItem.hasTag()) { nbt = droppedItem.getTag(); } else { nbt = new CompoundNBT(); } // player.sendMessage(new StringTextComponent("3nd Stage.")); if (nbt.contains(ItemItemLock.NBT_LOCK)) { // player.sendMessage(new StringTextComponent("4nd Stage.")); if (nbt.getBoolean(ItemItemLock.NBT_LOCK)) { // player.sendMessage(new StringTextComponent("5nd Stage.")); event.setCanceled(true); ItemStack copy = droppedItem.copy(); player.inventory.add(1, copy); } } } }
October 7, 20195 yr 11 minutes ago, TesterTesting135 said: if (nbt.contains(ItemItemLock.NBT_LOCK)) { Firstly there is no point in checking if it contains it. It will return getBoolean will return false if it doesn't contain it. 15 minutes ago, TesterTesting135 said: Do you know why? Sounds like a client server desync. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
October 7, 20195 yr 3 minutes ago, TesterTesting135 said: Do you know how I could fix it? It worked in 1.12.2. Thanks. Not off the top of my head. I will need more information. Is the event being called on the server or the client? If it's on the server you'll need to send a packet to the client specifically SSetSlotPacket I believe. There might be an easier way however. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
October 7, 20195 yr Author I’m not sure if it’s on the server or client. I just created a class and annotated it event bus subscriber, and put that method in.
October 7, 20195 yr 12 minutes ago, TesterTesting135 said: I’m not sure if it’s on the server or client. I just created a class and annotated it event bus subscriber, and put that method in. Put a println or log message in the event method and have it print out World#isRemote. True means client and false means server. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
October 7, 20195 yr Author Ok, I’m not currently at my environment but I think I have a solution: however, I don’t know player.inventoryContainer in 1.14.
October 7, 20195 yr Author Ok, so I did player.container.detectandsendchanges but it still isn’t working. Also, if the item is not in slot 1 and the slot before is not occupied, it will push the item to the slot before and work.
October 7, 20195 yr 2 minutes ago, TesterTesting135 said: Ok, so I did player.container.detectandsendchanges but it still isn’t working. That's not gonna work because the Container isn't open I believe. 3 minutes ago, TesterTesting135 said: Also, if the item is not in slot 1 and the slot before is not occupied, it will push the item to the slot before and work. That's gotta be because it detected a change in the inventory. Like I said you will need to send a packet to the client. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
October 7, 20195 yr 7 minutes ago, TesterTesting135 said: Ok, so i made a packet handler. What should i send to the client? Thanks. No i said you could use the vanilla packet. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
October 7, 20195 yr Author Ok, i did this: NetworkManager manager = new NetworkManager(PacketDirection.CLIENTBOUND); WorkingPacketHandler.channel.sendTo(new SSetSlotPacket(), manager, NetworkDirection.PLAY_TO_CLIENT); but it still doesn't work. Am i doing it wrong?
October 7, 20195 yr Author Ok, I didn't realize there were parameters. What am i supposed to put for windowIn and how do i get the current slot?
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.