From b269edcbd942651f1273453ab50966d71ce8dd13 Mon Sep 17 00:00:00 2001 From: austin Date: Sun, 8 Jun 2025 18:30:31 -0400 Subject: [PATCH] fix client deleting item --- docs/src/progress/renderertodo.md | 4 ++++ .../state/equip/ClientToolbarState.java | 2 ++ .../state/inventory/ClientInventoryState.java | 22 +++++++++++-------- .../client/ClientSynchronizationManager.java | 5 ++++- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index a5fb5d9d..eae1740b 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -2129,6 +2129,7 @@ Sim range update (06/08/2025) Fix scene re-adding tree that was previously removed +Fix client toolbar update deleting entity that shouldn't be deleted @@ -2320,6 +2321,9 @@ Foliage Manager upgrades - Add wind simulation if relevant +UI + - UI changes look and feel based on season/biome of client's player + Server Content Engine - On reloading a chunk with macro objects like structures, apply appropriate modifiers to align micro object with macro object diff --git a/src/main/java/electrosphere/entity/state/equip/ClientToolbarState.java b/src/main/java/electrosphere/entity/state/equip/ClientToolbarState.java index ddc717d1..fa3c875c 100644 --- a/src/main/java/electrosphere/entity/state/equip/ClientToolbarState.java +++ b/src/main/java/electrosphere/entity/state/equip/ClientToolbarState.java @@ -91,6 +91,8 @@ public class ClientToolbarState implements BehaviorTree { * @param toEquip The entity to equip */ public void attemptEquip(Entity toEquip){ + // + //getting data for the attempt RelationalInventoryState equipInventoryState = InventoryUtils.getEquipInventory(parent); boolean targetHasWhitelist = ItemUtils.hasEquipList(toEquip); String equipItemClass = ItemUtils.getEquipClass(toEquip); diff --git a/src/main/java/electrosphere/entity/state/inventory/ClientInventoryState.java b/src/main/java/electrosphere/entity/state/inventory/ClientInventoryState.java index c9617ee3..e6a765a2 100644 --- a/src/main/java/electrosphere/entity/state/inventory/ClientInventoryState.java +++ b/src/main/java/electrosphere/entity/state/inventory/ClientInventoryState.java @@ -203,11 +203,13 @@ public class ClientInventoryState implements BehaviorTree { } if(InventoryUtils.hasToolbarInventory(existingContainerEnt)){ RelationalInventoryState toolbarInventory = InventoryUtils.getToolbarInventory(existingContainerEnt); - if(ClientToolbarState.hasClientToolbarState(existingContainerEnt)){ - ClientToolbarState toolbarState = ClientToolbarState.getClientToolbarState(existingContainerEnt); - toolbarInventory.getEquipPointFromSlot(toolbarState.getSelectedSlot() + ""); + Entity removed = toolbarInventory.tryRemoveItem(itemEnt); + if(removed != null){ + if(ClientToolbarState.hasClientToolbarState(containerEnt)){ + ClientToolbarState toolbarState = ClientToolbarState.getClientToolbarState(containerEnt); + toolbarState.update(); + } } - toolbarInventory.tryRemoveItem(itemEnt); } if(InventoryUtils.hasEquipInventory(existingContainerEnt)){ RelationalInventoryState equipInventory = InventoryUtils.getEquipInventory(existingContainerEnt); @@ -234,11 +236,13 @@ public class ClientInventoryState implements BehaviorTree { } if(InventoryUtils.hasToolbarInventory(containerEnt)){ RelationalInventoryState toolbarInventory = InventoryUtils.getToolbarInventory(containerEnt); - toolbarInventory.tryRemoveItem(itemEnt); - } - if(ClientToolbarState.hasClientToolbarState(containerEnt)){ - ClientToolbarState toolbarState = ClientToolbarState.getClientToolbarState(containerEnt); - toolbarState.update(); + Entity removed = toolbarInventory.tryRemoveItem(itemEnt); + if(removed != null){ + if(ClientToolbarState.hasClientToolbarState(containerEnt)){ + ClientToolbarState toolbarState = ClientToolbarState.getClientToolbarState(containerEnt); + toolbarState.update(); + } + } } // //store in new container diff --git a/src/main/java/electrosphere/net/synchronization/client/ClientSynchronizationManager.java b/src/main/java/electrosphere/net/synchronization/client/ClientSynchronizationManager.java index 6da7e468..e2d16a86 100644 --- a/src/main/java/electrosphere/net/synchronization/client/ClientSynchronizationManager.java +++ b/src/main/java/electrosphere/net/synchronization/client/ClientSynchronizationManager.java @@ -48,7 +48,7 @@ public class ClientSynchronizationManager { /** * Number of frames to keep an entity deletion key around */ - static final int DELETED_KEY_STORAGE_FRAMES = 10; + static final int DELETED_KEY_STORAGE_FRAMES = 1000; /** * The list of messages to loop through @@ -189,6 +189,9 @@ public class ClientSynchronizationManager { "Type of entity on server: " + serverTypeId + "\n" + "Client contains an entity that maps to that server id: " + clientContainsServerId + "\n" + "Entity on the client that was resolved from the server id: " + entityFromServerId + "\n" + + "Message btree id: " + message.getbTreeId() + "\n" + + "Message field id: " + message.getfieldId() + "\n" + + "Deleted keys stores entity id: " + this.deletedEntityIds.get(message.getentityId()) + "\n" + "" ; LoggerInterface.loggerNetworking.WARNING(warningMessage);