Lucky's Cozy Home: Refurnished!

Lucky's Cozy Home: Refurnished!

1M Downloads

[bug] Breaking Grandfather Clock drops two items in multiplayer - Works fine in singleplayer

Closed this issue ยท 0 comments

commented

Describe the bug
When breaking a Grandfather Clock (or any clock from the Cozy Home mod), it drops two items instead of one. This issue occurs consistently on multiplayer servers.However, this issue does not occur in singleplayer.

The server logs contain the following error when placing a clock:

[ERROR]: Failed to handle packet net.minecraft.network.protocol.game.ServerboundUseItemOnPacket@50250a05, suppressing error
java.lang.NullPointerException: Cannot invoke "net.minecraft.world.entity.Entity.m_146922_(float)" because "_ent" is null
        at net.mcreator.cozyhome.procedures.GrandfatherClockPlacedProcedure.execute(GrandfatherClockPlacedProcedure.java:119) ~[cozy_home-3.0.4-forge-1.20.1.jar%23434!/:?]
        at net.mcreator.cozyhome.procedures.GrandfatherClockPlacedProcedure.onBlockPlace(GrandfatherClockPlacedProcedure.java:36) ~[cozy_home-3.0.4-forge-1.20.1.jar%23434!/:?]
        at net.mcreator.cozyhome.procedures.__GrandfatherClockPlacedProcedure_onBlockPlace_EntityPlaceEvent.invoke(.dynamic) ~[cozy_home-3.0.4-forge-1.20.1.jar%23434!/:?]
        at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) ~[eventbus-6.0.5.jar%23150!/:?]
        at net.minecraftforge.eventbus.EventBus.post(EventBus.java:319) ~[eventbus-6.0.5.jar%23150!/:?]
        at net.minecraftforge.eventbus.EventBus.post(EventBus.java:299) ~[eventbus-6.0.5.jar%23150!/:?]
        at net.minecraftforge.event.ForgeEventFactory.onBlockPlace(ForgeEventFactory.java:183) ~[forge-1.20.1-47.3.22-universal.jar%23515!/:?]
        at net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(ForgeHooks.java:630) ~[forge-1.20.1-47.3.22-universal.jar%23515!/:?]
        at net.minecraft.world.item.ItemStack.m_41661_(ItemStack.java:302) ~[server-1.20.1-20230612.114412-srg.jar%23510!/:?]
        at net.minecraft.server.level.ServerPlayerGameMode.m_7179_(ServerPlayerGameMode.java:507) ~[server-1.20.1-20230612.114412-srg.jar%23510!/:?]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.m_6371_(ServerGamePacketListenerImpl.java:1584) ~[server-1.20.1-20230612.114412-srg.jar%23510!/:?]
        at net.minecraft.network.protocol.game.ServerboundUseItemOnPacket.m_5797_(ServerboundUseItemOnPacket.java:34) ~[server-1.20.1-20230612.114412-srg.jar%23510!/:?]
        at net.minecraft.network.protocol.game.ServerboundUseItemOnPacket.m_5797_(ServerboundUseItemOnPacket.java:8) ~[server-1.20.1-20230612.114412-srg.jar%23510!/:?]
        at net.minecraft.network.protocol.PacketUtils.m_263899_(PacketUtils.java:25) ~[server-1.20.1-20230612.114412-srg.jar%23510!/:?]
        at net.minecraft.server.TickTask.run(TickTask.java:18) ~[server-1.20.1-20230612.114412-srg.jar%23510!/:?]
        at net.minecraft.util.thread.BlockableEventLoop.m_6367_(BlockableEventLoop.java:151) ~[server-1.20.1-20230612.114412-srg.jar%23510!/:?]
        at net.minecraft.util.thread.ReentrantBlockableEventLoop.m_6367_(ReentrantBlockableEventLoop.java:23) ~[server-1.20.1-20230612.114412-srg.jar%23510!/:?]
        at net.minecraft.server.MinecraftServer.m_6367_(MinecraftServer.java:1026) ~[server-1.20.1-20230612.114412-srg.jar%23510!/:?]
        at net.minecraft.server.MinecraftServer.m_6367_(MinecraftServer.java:176) ~[server-1.20.1-20230612.114412-srg.jar%23510!/:?]
        at net.minecraft.util.thread.BlockableEventLoop.m_7245_(BlockableEventLoop.java:124) ~[server-1.20.1-20230612.114412-srg.jar%23510!/:?]
        at net.minecraft.server.MinecraftServer.m_129961_(MinecraftServer.java:1009) ~[server-1.20.1-20230612.114412-srg.jar%23510!/:?]
        at net.minecraft.server.MinecraftServer.m_7245_(MinecraftServer.java:1003) ~[server-1.20.1-20230612.114412-srg.jar%23510!/:?]
        at net.minecraft.util.thread.BlockableEventLoop.m_18699_(BlockableEventLoop.java:112) ~[server-1.20.1-20230612.114412-srg.jar%23510!/:?]
        at net.minecraft.server.MinecraftServer.m_130012_(MinecraftServer.java:988) ~[server-1.20.1-20230612.114412-srg.jar%23510!/:?]
        at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:914) ~[server-1.20.1-20230612.114412-srg.jar%23510!/:?]
        at net.minecraft.server.MinecraftServer.m_206580_(MinecraftServer.java:286) ~[server-1.20.1-20230612.114412-srg.jar%23510!/:?]
        at java.lang.Thread.run(Thread.java:833) [?:?]

This suggests that when placing the clock, an entity-related operation fails, which may be causing the duplication issue when breaking the block.

To Reproduce
Steps to reproduce the behavior:

  1. Place any clock from the Cozy Home mod in the world.
  2. Break the clock.
  3. Observe that two items drop instead of one.

Expected behavior
Only one clock item should drop when breaking the block.

Screenshots
N/A

Environment Information
Minecraft Version: 1.20.1
Forge Version: 47.3.22
Cozy Home Version: 3.0.4
Server Type: Mohist (Multiplayer)

Additional context

  • The NullPointerException in GrandfatherClockPlacedProcedure.execute() suggests that an entity reference (_ent) is missing or incorrectly handled when placing the block.
  • This might cause duplicate block updates or incorrect item drop handling in multiplayer.
  • The issue only occurs in multiplayer, meaning it could be due to server-client desynchronization or improper handling of placement/destruction events on the server side.