Codemetry
Members-
Posts
17 -
Joined
-
Last visited
Everything posted by Codemetry
-
Read items in chest when opened on client side
Codemetry replied to Codemetry's topic in Modder Support
Thanks for helping me. -
Read items in chest when opened on client side
Codemetry replied to Codemetry's topic in Modder Support
How do I check if the chest contents are loaded? -
Read items in chest when opened on client side
Codemetry replied to Codemetry's topic in Modder Support
Read the contents of a chest upon opening, and detect its changes. I wanted the packet name to check the source code and see if there is any way I can detect. -
Read items in chest when opened on client side
Codemetry replied to Codemetry's topic in Modder Support
Do you know the packet type name? Which event should I handle and access the chest contents inside the event handler? -
Read items in chest when opened on client side
Codemetry replied to Codemetry's topic in Modder Support
Firstly, EntityPlayer#openContainer is assigned the container of the opened chest AFTER the initialization (GuiScreen#initGui) of the opened GuiChest (the container is stored in GuiContainer). So, I changed to try to access the chest contents in InitGuiEvent.Post event handler. Secondly, I found that the container stored in GuiContainer is a ContainerChest containing the player inventory AND the chest inventory. Therefore, it is not accurate to access the container and directly get the item stacks via it. Then, I found that ContainerChest#getLowerChestInventory returns the chest inventory (somehow it is called lower inventory). Finally, I checked the runtime type of the inventory returned by ContainerChest#getLowerChestInventory. It turns out to be ContainerLocalMenu. The only place which constructs new ContainerLocalMenus is NetHandlerPlayClient#handleOpenWindow. However, the method accepts a packet that does not store the chest inventory contents. Where did I go wrong? How do I access the chest contents? -
Read items in chest when opened on client side
Codemetry replied to Codemetry's topic in Modder Support
It doesn't work. It seems to always access the player inventory. -
How do I read the items in an opened chest (chest gui opened), on client side?
-
I am working on a client side mod. Sorry I was in a rush and copied from my old java file.
-
Bump. I have updated to 1.14.4 - 28.1.0. I did some testing and found that: EntityJoinWorldEvent is fired once when joining a server (and a world) from the multiplayer menu EntityJoinWorldEvent is fired multiple times (usually 6 - 10) when switching between worlds on a server or servers on a bungee network The Worlds returned by EntityJoinWorldEvents are not the same instance The EntityJoinWorldEvents are not the same instance (that means I did not register more than once) I have already added the following check into EntityJoinWorldEvent handler mc.thePlayer == event.entity Here is my handler in case: @SubscribeEvent public void onEntityJoinWorld(EntityJoinWorldEvent event) { if (mc.thePlayer == event.entity) { mc.thePlayer.addChatMessage( new ChatComponentText("hello")); } } Does anyone know why this is happening?
-
When setting up the project, I executed "gradlew genEclipseRuns" and "gradlew eclipse", but there aren't any run configurations (Client / Server).
-
Updated
-
package com.example.examplemod; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ServerData; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @Mod(modid = ExampleMod.MODID, version = ExampleMod.VERSION) public class ExampleMod { public static final String MODID = "examplemod"; public static final String VERSION = "1.0"; Minecraft mc; @EventHandler public void preInit(FMLPreInitializationEvent event) { mc = Minecraft.getMinecraft(); MinecraftForge.EVENT_BUS.register(this); } @SubscribeEvent public void onEntityJoinWorld(EntityJoinWorldEvent event) { if (!event.world.isRemote) { mc.thePlayer.sendChatMessage("hello"); } } }
-
via the player to the server Minecraft mc; @EventHandler public void preInit(FMLPreInitializationEvent event) { mc = Minecraft.getMinecraft(); MinecraftForge.EVENT_BUS.register(this); } @SubscribeEvent public void onEntityJoinWorld(EntityJoinWorldEvent event) { if (!event.world.isRemote) { mc.thePlayer.sendChatMessage("hello"); } }
-
I am new to forge modding, so please forgive me for my basic questions. I am trying to make the player send a chat message when joined a server world. Before ensuring World#isRemote is false, the chat message is sent 3 times every 3 seconds. When I added the check, no chat message is sent.
-
Why is it fired multiple times when a player joins a server (and a world)? Are there any alternative events?