added a comment ModelListener issue in regards of pig spawning (such a thing issue) - mainly for those who want to know why it has a delay on the player join, i didn't know this when forked it and took it off but added it back now and should hopefully fix the issue

This commit is contained in:
TheLividaProject
2025-07-22 17:23:06 +01:00
parent 4679fa6f2b
commit 03f27514ef
3 changed files with 14 additions and 10 deletions

9
.idea/workspace.xml generated
View File

@@ -4,10 +4,7 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="ff2e9770-ec88-4715-adeb-b9dbda130e1a" name="Changes" comment=""> <list default="true" id="ff2e9770-ec88-4715-adeb-b9dbda130e1a" name="Changes" comment="" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/re/imc/geysermodelengine/listener/ModelListener.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/re/imc/geysermodelengine/listener/ModelListener.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -102,7 +99,7 @@
<recent name="D:\Coding\Forks\Minecraft\GeyserModelEngine\libs" /> <recent name="D:\Coding\Forks\Minecraft\GeyserModelEngine\libs" />
</key> </key>
</component> </component>
<component name="RunManager" selected="Gradle.GeyserModelEngine [jar]"> <component name="RunManager" selected="Gradle.GeyserModelEngine [build]">
<configuration name="GeyserModelEngine [build]" type="GradleRunConfiguration" factoryName="Gradle" temporary="true"> <configuration name="GeyserModelEngine [build]" type="GradleRunConfiguration" factoryName="Gradle" temporary="true">
<ExternalSystemSettings> <ExternalSystemSettings>
<option name="executionName" /> <option name="executionName" />
@@ -149,8 +146,8 @@
</configuration> </configuration>
<recent_temporary> <recent_temporary>
<list> <list>
<item itemvalue="Gradle.GeyserModelEngine [jar]" />
<item itemvalue="Gradle.GeyserModelEngine [build]" /> <item itemvalue="Gradle.GeyserModelEngine [build]" />
<item itemvalue="Gradle.GeyserModelEngine [jar]" />
</list> </list>
</recent_temporary> </recent_temporary>
</component> </component>

View File

@@ -19,7 +19,6 @@ import re.imc.geysermodelengine.GeyserModelEngine;
import re.imc.geysermodelengine.managers.model.data.ModelEntityData; import re.imc.geysermodelengine.managers.model.data.ModelEntityData;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit;
public class ModelListener implements Listener { public class ModelListener implements Listener {
@@ -61,11 +60,21 @@ public class ModelListener implements Listener {
world.getEntities().forEach(entity -> plugin.getModelManager().processEntities(entity)); world.getEntities().forEach(entity -> plugin.getModelManager().processEntities(entity));
} }
/*
/ Temp fix till a better solution is found -
/ the issue is when a player logs out and the mob is there,
/ the player logs back in sometimes it can display as a pig only
/ this issues mainly comes from the functions from EntityTaskManager
/ sendSpawnPacket() and canSee()
/
/ TheLividaProject - conclusion:
/ I'm assuming when a player joins the server the packet for mob spawning is instant so the client resyncs itself
/ hence why the pig is shown instead of going invisible and not displaying the texture of the modeled mob
*/
@EventHandler @EventHandler
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!FloodgateApi.getInstance().isFloodgatePlayer(player.getUniqueId())) return; if (!FloodgateApi.getInstance().isFloodgatePlayer(player.getUniqueId())) return;
// Temp fix till a better solution is found - the issue is when a player logs out and the mob is there, the player logs back in sometimes it can display as a pig only
Bukkit.getGlobalRegionScheduler().runDelayed(plugin, scheduledTask -> plugin.getModelManager().getPlayerJoinedCache().add(player.getUniqueId()), 10); Bukkit.getGlobalRegionScheduler().runDelayed(plugin, scheduledTask -> plugin.getModelManager().getPlayerJoinedCache().add(player.getUniqueId()), 10);
} }

View File

@@ -96,7 +96,6 @@ public class EntityTaskManager {
} }
} }
// Issue here - start: See ModelListener.class and look at function onPlayerJoin
private void sendSpawnPacket(ModelEntityData model, Player onlinePlayer) { private void sendSpawnPacket(ModelEntityData model, Player onlinePlayer) {
EntityTaskRunnable task = model.getEntityTask(); EntityTaskRunnable task = model.getEntityTask();
boolean firstJoined = !plugin.getModelManager().getPlayerJoinedCache().contains(onlinePlayer.getUniqueId()); boolean firstJoined = !plugin.getModelManager().getPlayerJoinedCache().contains(onlinePlayer.getUniqueId());
@@ -122,7 +121,6 @@ public class EntityTaskManager {
return true; return true;
} }
// Issue here - end
public void sendHitBoxToAll(ModelEntityData model) { public void sendHitBoxToAll(ModelEntityData model) {
for (Player viewer : model.getViewers()) { for (Player viewer : model.getViewers()) {