Don't create an EntityTrackerEntryStateHandle every tick for all hooked entities

Signed-off-by: Irmo van den Berge <irmo.vandenberge@ziggo.nl>
This commit is contained in:
Irmo van den Berge committed 2023-05-13 23:00:34 +02:00
1 parent e7ba1df452
commit 7cb2f7eadc
2 files changed
+12 -4

No files matched your search

@@ -415,6 +415,15 @@ public abstract class EntityNetworkController<T extends CommonEntity<?>> extends
return entry.getRaw();
}
/**
* Gets the internal Entity Tracker State data
*
* @return state handle
*/
public EntityTrackerEntryStateHandle getStateHandle() {
return state;
}
/**
* Gets a collection of all Players viewing this Entity
*
@@ -77,17 +77,16 @@ public class EntityTrackerEntryHook_1_14 extends ClassHook<EntityTrackerEntryHoo
@ClassHook.HookPackage("net.minecraft.server")
@ClassHook.HookLoadVariables("com.bergerkiller.bukkit.common.Common.TEMPLATE_RESOLVER")
public class StateHook extends ClassHook<StateHook> {
@HookMethod("public void onTick:???()")
public void onTick() {
EntityTrackerEntryStateHandle handle = EntityTrackerEntryStateHandle.createHandle(instance());
handle.setTimeSinceLocationSync(handle.getTimeSinceLocationSync() + 1);
try {
EntityTrackerEntryStateHandle handle = controller.getStateHandle();
handle.setTimeSinceLocationSync(handle.getTimeSinceLocationSync() + 1);
controller.onTick();
handle.setTickCounter(handle.getTickCounter() + 1);
} catch (Throwable t) {
Logging.LOGGER_NETWORK.log(Level.SEVERE, "Failed to synchronize", t);
}
handle.setTickCounter(handle.getTickCounter() + 1);
}
@HookMethod("public void removePairing:???(EntityPlayer entityPlayer)")