mirror of
https://github.com/xSquishyLiam/mc-GeyserModelEngine-plugin.git
synced 2025-12-19 23:09:25 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13c0b45d2a | ||
|
|
8f67ade51c | ||
|
|
d0fd719753 | ||
|
|
16e0dfcdfd | ||
|
|
b1969646e6 | ||
|
|
501eaaa37a | ||
|
|
f67ee6d9f8 | ||
|
|
3adb965697 |
44
.gitignore
vendored
44
.gitignore
vendored
@@ -1,2 +1,42 @@
|
|||||||
# 项目排除路径
|
.gradle
|
||||||
/target/
|
build/
|
||||||
|
!gradle/wrapper/gradle-wrapper.jar
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea/modules.xml
|
||||||
|
.idea/jarRepositories.xml
|
||||||
|
.idea/compiler.xml
|
||||||
|
.idea/libraries/
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
out/
|
||||||
|
!**/src/main/**/out/
|
||||||
|
!**/src/test/**/out/
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
bin/
|
||||||
|
!**/src/main/**/bin/
|
||||||
|
!**/src/test/**/bin/
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,2 +0,0 @@
|
|||||||
#Tue May 27 16:38:57 BST 2025
|
|
||||||
gradle.version=8.12
|
|
||||||
Binary file not shown.
Binary file not shown.
10
.idea/workspace.xml
generated
10
.idea/workspace.xml
generated
@@ -5,8 +5,8 @@
|
|||||||
</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/managers/model/data/ModelEntityData.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/re/imc/geysermodelengine/managers/model/data/ModelEntityData.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/java/re/imc/geysermodelengine/commands/geysermodelenginecommands/GeyserModelEngineReloadCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/re/imc/geysermodelengine/commands/geysermodelenginecommands/GeyserModelEngineReloadCommand.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main/java/re/imc/geysermodelengine/runnables/EntityTaskRunnable.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/re/imc/geysermodelengine/runnables/EntityTaskRunnable.java" afterDir="false" />
|
||||||
</list>
|
</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" />
|
||||||
@@ -63,6 +63,9 @@
|
|||||||
<component name="MavenRunner">
|
<component name="MavenRunner">
|
||||||
<option name="delegateBuildToMaven" value="true" />
|
<option name="delegateBuildToMaven" value="true" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="ProblemsViewState">
|
||||||
|
<option name="selectedTabId" value="DEPENDENCY_CHECKER_PROBLEMS_TAB" />
|
||||||
|
</component>
|
||||||
<component name="ProjectColorInfo">{
|
<component name="ProjectColorInfo">{
|
||||||
"associatedIndex": 8
|
"associatedIndex": 8
|
||||||
}</component>
|
}</component>
|
||||||
@@ -94,6 +97,9 @@
|
|||||||
<key name="CopyFile.RECENT_KEYS">
|
<key name="CopyFile.RECENT_KEYS">
|
||||||
<recent name="D:\Coding\Forks\Minecraft\GeyserModelEngine" />
|
<recent name="D:\Coding\Forks\Minecraft\GeyserModelEngine" />
|
||||||
</key>
|
</key>
|
||||||
|
<key name="MoveFile.RECENT_KEYS">
|
||||||
|
<recent name="D:\Coding\Forks\Minecraft\GeyserModelEngine\libs" />
|
||||||
|
</key>
|
||||||
</component>
|
</component>
|
||||||
<component name="RunManager">
|
<component name="RunManager">
|
||||||
<configuration name="GeyserModelEngine [jar]" type="GradleRunConfiguration" factoryName="Gradle" temporary="true">
|
<configuration name="GeyserModelEngine [jar]" type="GradleRunConfiguration" factoryName="Gradle" temporary="true">
|
||||||
|
|||||||
@@ -13,24 +13,23 @@ repositories {
|
|||||||
|
|
||||||
maven("https://mvn.lumine.io/repository/maven-public/")
|
maven("https://mvn.lumine.io/repository/maven-public/")
|
||||||
|
|
||||||
maven("https://repo.opencollab.dev/maven-releases/")
|
maven("https://repo.opencollab.dev/main/")
|
||||||
maven("https://repo.opencollab.dev/maven-snapshots/")
|
|
||||||
|
|
||||||
maven("https://repo.codemc.io/repository/maven-public/")
|
maven("https://repo.codemc.io/repository/maven-public/")
|
||||||
maven("https://repo.codemc.io/repository/maven-releases/")
|
maven("https://repo.codemc.io/repository/maven-releases/")
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("io.papermc.paper:paper-api:1.21.7-R0.1-SNAPSHOT")
|
compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")
|
||||||
|
implementation("dev.jorel:commandapi-bukkit-shade-mojang-mapped:10.1.2")
|
||||||
|
|
||||||
implementation("dev.jorel:commandapi-bukkit-shade-mojang-mapped:10.1.1")
|
compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.9")
|
||||||
|
|
||||||
compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.4")
|
|
||||||
|
|
||||||
compileOnly(files("libs/geyserutils-spigot-1.0-SNAPSHOT.jar"))
|
compileOnly(files("libs/geyserutils-spigot-1.0-SNAPSHOT.jar"))
|
||||||
compileOnly("org.geysermc.floodgate:api:2.2.4-SNAPSHOT")
|
compileOnly("org.geysermc.floodgate:api:2.2.4-SNAPSHOT")
|
||||||
|
|
||||||
implementation("com.github.retrooper:packetevents-spigot:2.9.0-SNAPSHOT")
|
|
||||||
|
implementation("com.github.retrooper:packetevents-spigot:2.9.3")
|
||||||
|
|
||||||
implementation("org.reflections:reflections:0.10.2")
|
implementation("org.reflections:reflections:0.10.2")
|
||||||
}
|
}
|
||||||
@@ -52,6 +51,6 @@ tasks.shadowJar {
|
|||||||
relocate("org.reflections", "re.imc.geysermodelengine.libs.reflections")
|
relocate("org.reflections", "re.imc.geysermodelengine.libs.reflections")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.jar {
|
tasks.build {
|
||||||
dependsOn(tasks.shadowJar)
|
dependsOn("shadowJar")
|
||||||
}
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
@@ -1,4 +0,0 @@
|
|||||||
|
|
||||||
commands:
|
|
||||||
reload:
|
|
||||||
successfully-reloaded: "<#55FF55>GeyserModelEngine configuration reloaded!"
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
data-send-delay: 5
|
|
||||||
entity-view-distance: 50
|
|
||||||
join-send-delay: 20
|
|
||||||
entity-position-update-period: 35
|
|
||||||
model-entity-type: BAT # must be a living entity
|
|
||||||
enable-part-visibility-models:
|
|
||||||
- example
|
|
||||||
debug: false
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
main: re.imc.geysermodelengine.GeyserModelEngine
|
|
||||||
name: GeyserModelEngine
|
|
||||||
version: '1.0.0'
|
|
||||||
api-version: '1.21'
|
|
||||||
|
|
||||||
authors:
|
|
||||||
- zimzaza4
|
|
||||||
- willem.dev
|
|
||||||
- TheLividaProject
|
|
||||||
|
|
||||||
load: STARTUP
|
|
||||||
|
|
||||||
dependencies:
|
|
||||||
server:
|
|
||||||
GeyserUtils:
|
|
||||||
required: true
|
|
||||||
packetevents:
|
|
||||||
required: true
|
|
||||||
ModelEngine:
|
|
||||||
required: true
|
|
||||||
floodgate:
|
|
||||||
required: true
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,2 +0,0 @@
|
|||||||
Manifest-Version: 1.0
|
|
||||||
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
Manifest-Version: 1.0
|
|
||||||
|
|
||||||
@@ -30,6 +30,8 @@ public class GeyserModelEngine extends JavaPlugin {
|
|||||||
private ModelManager modelManager;
|
private ModelManager modelManager;
|
||||||
private EntityTaskManager entityTaskManager;
|
private EntityTaskManager entityTaskManager;
|
||||||
|
|
||||||
|
private ScheduledExecutorService schedulerPool;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
PacketEvents.setAPI(SpigotPacketEventsBuilder.build(this));
|
PacketEvents.setAPI(SpigotPacketEventsBuilder.build(this));
|
||||||
@@ -77,6 +79,8 @@ public class GeyserModelEngine extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadRunnables() {
|
private void loadRunnables() {
|
||||||
|
this.schedulerPool = Executors.newScheduledThreadPool(configManager.getConfig().getInt("thread-pool-size", 4));
|
||||||
|
|
||||||
Bukkit.getAsyncScheduler().runAtFixedRate(this, new UpdateTaskRunnable(this), 10, configManager.getConfig().getLong("entity-position-update-period", 35), TimeUnit.MILLISECONDS);
|
Bukkit.getAsyncScheduler().runAtFixedRate(this, new UpdateTaskRunnable(this), 10, configManager.getConfig().getLong("entity-position-update-period", 35), TimeUnit.MILLISECONDS);
|
||||||
Bukkit.getAsyncScheduler().runAtFixedRate(this, new BedrockMountControlRunnable(this), 1, 1, TimeUnit.MILLISECONDS);
|
Bukkit.getAsyncScheduler().runAtFixedRate(this, new BedrockMountControlRunnable(this), 1, 1, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
@@ -96,4 +100,8 @@ public class GeyserModelEngine extends JavaPlugin {
|
|||||||
public EntityTaskManager getEntityTaskManager() {
|
public EntityTaskManager getEntityTaskManager() {
|
||||||
return entityTaskManager;
|
return entityTaskManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ScheduledExecutorService getSchedulerPool() {
|
||||||
|
return schedulerPool;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,10 +15,12 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.event.world.WorldInitEvent;
|
import org.bukkit.event.world.WorldInitEvent;
|
||||||
import org.bukkit.event.world.WorldLoadEvent;
|
import org.bukkit.event.world.WorldLoadEvent;
|
||||||
|
import org.geysermc.floodgate.api.FloodgateApi;
|
||||||
import re.imc.geysermodelengine.GeyserModelEngine;
|
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 {
|
||||||
|
|
||||||
@@ -43,14 +45,14 @@ public class ModelListener implements Listener {
|
|||||||
ModelEntityData model = map.get(event.getVehicle());
|
ModelEntityData model = map.get(event.getVehicle());
|
||||||
|
|
||||||
if (model != null && event.getPassenger() instanceof Player player) {
|
if (model != null && event.getPassenger() instanceof Player player) {
|
||||||
plugin.getModelManager().getDriversCache().put(player, Pair.of(event.getVehicle(), event.getSeat()));
|
plugin.getModelManager().getDriversCache().put(player.getUniqueId(), Pair.of(event.getVehicle(), event.getSeat()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onModelDismount(ModelDismountEvent event) {
|
public void onModelDismount(ModelDismountEvent event) {
|
||||||
if (event.getPassenger() instanceof Player player) {
|
if (event.getPassenger() instanceof Player player) {
|
||||||
plugin.getModelManager().getDriversCache().remove(player);
|
plugin.getModelManager().getDriversCache().remove(player.getUniqueId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,12 +65,15 @@ public class ModelListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
plugin.getModelManager().getPlayerJoinedCache().add(player.getUniqueId());
|
if (!FloodgateApi.getInstance().isFloodgatePlayer(player.getUniqueId())) return;
|
||||||
|
//TODO temp fix bc like why? - 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.getAsyncScheduler().runDelayed(plugin, scheduledTask -> plugin.getModelManager().getPlayerJoinedCache().add(player.getUniqueId()), 10, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
if (!FloodgateApi.getInstance().isFloodgatePlayer(player.getUniqueId())) return;
|
||||||
plugin.getModelManager().getPlayerJoinedCache().remove(player.getUniqueId());
|
plugin.getModelManager().getPlayerJoinedCache().remove(player.getUniqueId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class MountPacketListener implements PacketListener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
WrapperPlayClientEntityAction action = new WrapperPlayClientEntityAction(event);
|
WrapperPlayClientEntityAction action = new WrapperPlayClientEntityAction(event);
|
||||||
Pair<ActiveModel, Mount> seat = plugin.getModelManager().getDriversCache().get(player);
|
Pair<ActiveModel, Mount> seat = plugin.getModelManager().getDriversCache().get(player.getUniqueId());
|
||||||
|
|
||||||
if (seat == null) return;
|
if (seat == null) return;
|
||||||
if (action.getAction() != WrapperPlayClientEntityAction.Action.START_SNEAKING) return;
|
if (action.getAction() != WrapperPlayClientEntityAction.Action.START_SNEAKING) return;
|
||||||
|
|||||||
@@ -60,9 +60,7 @@ public class EntityTaskManager {
|
|||||||
for (Player player : players) {
|
for (Player player : players) {
|
||||||
EntityUtils.sendCustomScale(player, model.getEntity().getEntityId(), average);
|
EntityUtils.sendCustomScale(player, model.getEntity().getEntityId(), average);
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable ignored) {}
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendColor(ModelEntityData model, Collection<Player> players, Color lastColor, boolean firstSend) {
|
public void sendColor(ModelEntityData model, Collection<Player> players, Color lastColor, boolean firstSend) {
|
||||||
@@ -82,24 +80,23 @@ public class EntityTaskManager {
|
|||||||
|
|
||||||
public void checkViewers(ModelEntityData model, Set<Player> viewers) {
|
public void checkViewers(ModelEntityData model, Set<Player> viewers) {
|
||||||
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||||
if (FloodgateApi.getInstance().isFloodgatePlayer(onlinePlayer.getUniqueId())) {
|
if (!FloodgateApi.getInstance().isFloodgatePlayer(onlinePlayer.getUniqueId())) continue;
|
||||||
|
|
||||||
if (canSee(onlinePlayer, model.getEntity())) {
|
if (canSee(onlinePlayer, model.getEntity())) {
|
||||||
|
if (!viewers.contains(onlinePlayer)) {
|
||||||
if (!viewers.contains(onlinePlayer)) {
|
sendSpawnPacket(model, onlinePlayer);
|
||||||
sendSpawnPacket(model, onlinePlayer);
|
viewers.add(onlinePlayer);
|
||||||
viewers.add(onlinePlayer);
|
}
|
||||||
}
|
} else {
|
||||||
} else {
|
if (viewers.contains(onlinePlayer)) {
|
||||||
if (viewers.contains(onlinePlayer)) {
|
model.getEntity().sendEntityDestroyPacket(Collections.singletonList(onlinePlayer));
|
||||||
model.getEntity().sendEntityDestroyPacket(Collections.singletonList(onlinePlayer));
|
viewers.remove(onlinePlayer);
|
||||||
viewers.remove(onlinePlayer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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());
|
||||||
@@ -125,6 +122,7 @@ 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()) {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import com.ticxo.modelengine.api.model.ModeledEntity;
|
|||||||
import com.ticxo.modelengine.api.model.bone.type.Mount;
|
import com.ticxo.modelengine.api.model.bone.type.Mount;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import re.imc.geysermodelengine.GeyserModelEngine;
|
import re.imc.geysermodelengine.GeyserModelEngine;
|
||||||
import re.imc.geysermodelengine.managers.model.data.ModelEntityData;
|
import re.imc.geysermodelengine.managers.model.data.ModelEntityData;
|
||||||
|
|
||||||
@@ -22,7 +21,7 @@ public class ModelManager {
|
|||||||
private final ConcurrentHashMap<Integer, Map<ActiveModel, ModelEntityData>> entitiesCache = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<Integer, Map<ActiveModel, ModelEntityData>> entitiesCache = new ConcurrentHashMap<>();
|
||||||
private final ConcurrentHashMap<Integer, ModelEntityData> modelEntitiesCache = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<Integer, ModelEntityData> modelEntitiesCache = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private final ConcurrentHashMap<Player, Pair<ActiveModel, Mount>> driversCache = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<UUID, Pair<ActiveModel, Mount>> driversCache = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public ModelManager(GeyserModelEngine plugin) {
|
public ModelManager(GeyserModelEngine plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
@@ -65,7 +64,7 @@ public class ModelManager {
|
|||||||
return modelEntitiesCache;
|
return modelEntitiesCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentHashMap<Player, Pair<ActiveModel, Mount>> getDriversCache() {
|
public ConcurrentHashMap<UUID, Pair<ActiveModel, Mount>> getDriversCache() {
|
||||||
return driversCache;
|
return driversCache;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
|
|||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||||
import com.ticxo.modelengine.api.model.ModeledEntity;
|
import com.ticxo.modelengine.api.model.ModeledEntity;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import re.imc.geysermodelengine.GeyserModelEngine;
|
import re.imc.geysermodelengine.GeyserModelEngine;
|
||||||
@@ -12,7 +11,6 @@ import re.imc.geysermodelengine.packet.entity.PacketEntity;
|
|||||||
import re.imc.geysermodelengine.runnables.EntityTaskRunnable;
|
import re.imc.geysermodelengine.runnables.EntityTaskRunnable;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
public class ModelEntityData {
|
public class ModelEntityData {
|
||||||
|
|
||||||
@@ -50,7 +48,6 @@ public class ModelEntityData {
|
|||||||
|
|
||||||
public void runEntityTask() {
|
public void runEntityTask() {
|
||||||
entityTask = new EntityTaskRunnable(plugin, this);
|
entityTask = new EntityTaskRunnable(plugin, this);
|
||||||
Bukkit.getAsyncScheduler().runAtFixedRate(plugin, entityTask, 0, 20, TimeUnit.MILLISECONDS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketEntity getEntity() {
|
public PacketEntity getEntity() {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class BedrockMountControlRunnable implements Consumer<ScheduledTask> {
|
|||||||
if (!FloodgateApi.getInstance().isFloodgatePlayer(player.getUniqueId())) continue;
|
if (!FloodgateApi.getInstance().isFloodgatePlayer(player.getUniqueId())) continue;
|
||||||
|
|
||||||
float pitch = player.getLocation().getPitch();
|
float pitch = player.getLocation().getPitch();
|
||||||
Pair<ActiveModel, Mount> seat = plugin.getModelManager().getDriversCache().get(player);
|
Pair<ActiveModel, Mount> seat = plugin.getModelManager().getDriversCache().get(player.getUniqueId());
|
||||||
|
|
||||||
if (seat == null) continue;
|
if (seat == null) continue;
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,7 @@ import com.ticxo.modelengine.api.generator.blueprint.BlueprintBone;
|
|||||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||||
import com.ticxo.modelengine.api.model.ModeledEntity;
|
import com.ticxo.modelengine.api.model.ModeledEntity;
|
||||||
import com.ticxo.modelengine.api.model.bone.ModelBone;
|
import com.ticxo.modelengine.api.model.bone.ModelBone;
|
||||||
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
|
|
||||||
import me.zimzaza4.geyserutils.spigot.api.EntityUtils;
|
import me.zimzaza4.geyserutils.spigot.api.EntityUtils;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import re.imc.geysermodelengine.GeyserModelEngine;
|
import re.imc.geysermodelengine.GeyserModelEngine;
|
||||||
import re.imc.geysermodelengine.managers.model.data.ModelEntityData;
|
import re.imc.geysermodelengine.managers.model.data.ModelEntityData;
|
||||||
@@ -21,10 +19,10 @@ import java.awt.*;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
public class EntityTaskRunnable implements Consumer<ScheduledTask> {
|
public class EntityTaskRunnable {
|
||||||
|
|
||||||
private final GeyserModelEngine plugin;
|
private final GeyserModelEngine plugin;
|
||||||
|
|
||||||
@@ -43,16 +41,19 @@ public class EntityTaskRunnable implements Consumer<ScheduledTask> {
|
|||||||
|
|
||||||
private final BooleanPacker booleanPacker = new BooleanPacker();
|
private final BooleanPacker booleanPacker = new BooleanPacker();
|
||||||
|
|
||||||
|
private final ScheduledFuture scheduledFuture;
|
||||||
|
|
||||||
public EntityTaskRunnable(GeyserModelEngine plugin, ModelEntityData model) {
|
public EntityTaskRunnable(GeyserModelEngine plugin, ModelEntityData model) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
|
||||||
this.model = model;
|
this.model = model;
|
||||||
|
|
||||||
plugin.getEntityTaskManager().sendHitBoxToAll(model);
|
plugin.getEntityTaskManager().sendHitBoxToAll(model);
|
||||||
|
|
||||||
|
scheduledFuture = plugin.getSchedulerPool().scheduleAtFixedRate(this::runAsync, 0, 20, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void runAsync() {
|
||||||
public void accept(ScheduledTask scheduledTask) {
|
|
||||||
plugin.getEntityTaskManager().checkViewers(model, model.getViewers());
|
plugin.getEntityTaskManager().checkViewers(model, model.getViewers());
|
||||||
|
|
||||||
PacketEntity entity = model.getEntity();
|
PacketEntity entity = model.getEntity();
|
||||||
@@ -70,7 +71,7 @@ public class EntityTaskRunnable implements Consumer<ScheduledTask> {
|
|||||||
|
|
||||||
plugin.getModelManager().getEntitiesCache().remove(modeledEntity.getBase().getEntityId());
|
plugin.getModelManager().getEntitiesCache().remove(modeledEntity.getBase().getEntityId());
|
||||||
plugin.getModelManager().getModelEntitiesCache().remove(entity.getEntityId());
|
plugin.getModelManager().getModelEntitiesCache().remove(entity.getEntityId());
|
||||||
scheduledTask.cancel();
|
cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,20 +97,25 @@ public class EntityTaskRunnable implements Consumer<ScheduledTask> {
|
|||||||
plugin.getEntityTaskManager().sendColor(model, viewers, lastColor, false);
|
plugin.getEntityTaskManager().sendColor(model, viewers, lastColor, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void cancel() {
|
||||||
|
scheduledFuture.cancel(true);
|
||||||
|
}
|
||||||
|
|
||||||
public void sendEntityData(ModelEntityData model, Player player, int delay) {
|
public void sendEntityData(ModelEntityData model, Player player, int delay) {
|
||||||
|
//TODO with ModelEngine, you can define the namespace inside the config, make an option to change it here as well? if i'm right about this
|
||||||
EntityUtils.setCustomEntity(player, model.getEntity().getEntityId(), "modelengine:" + model.getActiveModel().getBlueprint().getName().toLowerCase());
|
EntityUtils.setCustomEntity(player, model.getEntity().getEntityId(), "modelengine:" + model.getActiveModel().getBlueprint().getName().toLowerCase());
|
||||||
|
|
||||||
Bukkit.getAsyncScheduler().runDelayed(plugin, scheduledTask -> {
|
plugin.getSchedulerPool().schedule(() -> {
|
||||||
model.getEntity().sendSpawnPacket(Collections.singletonList(player));
|
model.getEntity().sendSpawnPacket(Collections.singletonList(player));
|
||||||
|
|
||||||
Bukkit.getAsyncScheduler().runDelayed(plugin, scheduledTask1 -> {
|
plugin.getSchedulerPool().schedule(() -> {
|
||||||
plugin.getEntityTaskManager().sendHitBox(model, player);
|
plugin.getEntityTaskManager().sendHitBox(model, player);
|
||||||
plugin.getEntityTaskManager().sendScale(model, Collections.singleton(player), lastScale, true);
|
plugin.getEntityTaskManager().sendScale(model, Collections.singleton(player), lastScale, true);
|
||||||
plugin.getEntityTaskManager().sendColor(model, Collections.singleton(player), lastColor, true);
|
plugin.getEntityTaskManager().sendColor(model, Collections.singleton(player), lastColor, true);
|
||||||
|
|
||||||
updateEntityProperties(model, Collections.singleton(player), true);
|
updateEntityProperties(model, Collections.singleton(player), true);
|
||||||
}, 500, TimeUnit.MILLISECONDS);
|
}, delay * 50L, TimeUnit.MILLISECONDS);
|
||||||
}, delay * 50L, TimeUnit.MILLISECONDS);
|
}, 500, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateEntityProperties(ModelEntityData model, Collection<Player> players, boolean firstSend, String... forceAnims) {
|
public void updateEntityProperties(ModelEntityData model, Collection<Player> players, boolean firstSend, String... forceAnims) {
|
||||||
@@ -255,4 +261,8 @@ public class EntityTaskRunnable implements Consumer<ScheduledTask> {
|
|||||||
public Cache<String, Boolean> getLastPlayedAnim() {
|
public Cache<String, Boolean> getLastPlayedAnim() {
|
||||||
return lastPlayedAnim;
|
return lastPlayedAnim;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ScheduledFuture getScheduledFuture() {
|
||||||
|
return scheduledFuture;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ data-send-delay: 5
|
|||||||
entity-view-distance: 50
|
entity-view-distance: 50
|
||||||
join-send-delay: 20
|
join-send-delay: 20
|
||||||
entity-position-update-period: 35
|
entity-position-update-period: 35
|
||||||
|
thread-pool-size: 4
|
||||||
model-entity-type: BAT # must be a living entity
|
model-entity-type: BAT # must be a living entity
|
||||||
enable-part-visibility-models:
|
enable-part-visibility-models:
|
||||||
- example
|
- example
|
||||||
|
|||||||
Reference in New Issue
Block a user