mirror of
https://github.com/GeyserExtensionists/GeyserUtils.git
synced 2025-12-19 14:59:18 +00:00
custom entity
This commit is contained in:
@@ -32,6 +32,7 @@ import org.geysermc.event.subscribe.Subscribe;
|
|||||||
import org.geysermc.geyser.GeyserImpl;
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
import org.geysermc.geyser.api.bedrock.camera.CameraShake;
|
import org.geysermc.geyser.api.bedrock.camera.CameraShake;
|
||||||
import org.geysermc.geyser.api.command.Command;
|
import org.geysermc.geyser.api.command.Command;
|
||||||
|
import org.geysermc.geyser.api.command.CommandSource;
|
||||||
import org.geysermc.geyser.api.connection.GeyserConnection;
|
import org.geysermc.geyser.api.connection.GeyserConnection;
|
||||||
import org.geysermc.geyser.api.entity.EntityDefinition;
|
import org.geysermc.geyser.api.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.api.entity.EntityIdentifier;
|
import org.geysermc.geyser.api.entity.EntityIdentifier;
|
||||||
@@ -135,6 +136,7 @@ public class GeyserUtils implements Extension {
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void onEntitiesDefine(GeyserDefineEntitiesEvent event) {
|
public void onEntitiesDefine(GeyserDefineEntitiesEvent event) {
|
||||||
loadEntities();
|
loadEntities();
|
||||||
|
|
||||||
for (EntityDefinition value : LOADED_ENTITY_DEFINITIONS.values()) {
|
for (EntityDefinition value : LOADED_ENTITY_DEFINITIONS.values()) {
|
||||||
event.register(value);
|
event.register(value);
|
||||||
}
|
}
|
||||||
@@ -144,6 +146,7 @@ public class GeyserUtils implements Extension {
|
|||||||
public void onLoadCommand(GeyserDefineCommandsEvent event) {
|
public void onLoadCommand(GeyserDefineCommandsEvent event) {
|
||||||
event.register(Command.builder(this)
|
event.register(Command.builder(this)
|
||||||
.name("reloadskin")
|
.name("reloadskin")
|
||||||
|
.source(GeyserConnection.class)
|
||||||
.aliases(List.of("grs"))
|
.aliases(List.of("grs"))
|
||||||
.description("Reload GeyserUtils skin.")
|
.description("Reload GeyserUtils skin.")
|
||||||
.executableOnConsole(true)
|
.executableOnConsole(true)
|
||||||
@@ -364,11 +367,11 @@ public class GeyserUtils implements Extension {
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void onEntitySpawn(ServerSpawnEntityEvent event) {
|
public void onEntitySpawn(ServerSpawnEntityEvent event) {
|
||||||
String def = CUSTOM_ENTITIES.get(event.connection()).getIfPresent(event.entityId());
|
String def = CUSTOM_ENTITIES.get(event.connection()).getIfPresent(event.entityId());
|
||||||
if (event.entityDefinition().entityIdentifier().identifier().contains("bat")) {
|
if (event.entityDefinition().entityIdentifier().identifier().endsWith("bat")) {
|
||||||
logger().info("SPAWN ID:" + event.entityId());
|
System.out.println("GEYSER SPAWN: " + event.entityId());
|
||||||
}
|
}
|
||||||
if (def == null) return;
|
if (def == null) return;
|
||||||
logger().info("SPAWN DEF:" + def);
|
System.out.println("FIND DEF:" + def);
|
||||||
event.entityDefinition(LOADED_ENTITY_DEFINITIONS.getOrDefault(def, event.entityDefinition()));
|
event.entityDefinition(LOADED_ENTITY_DEFINITIONS.getOrDefault(def, event.entityDefinition()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user