mirror of
https://github.com/GeyserExtensionists/GeyserUtils.git
synced 2025-12-19 15:09:24 +00:00
custom entity
This commit is contained in:
@@ -96,6 +96,16 @@ public class GeyserUtils implements Extension {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void addCustomEntity(String id) {
|
||||||
|
LOADED_ENTITY_DEFINITIONS.put(id,
|
||||||
|
EntityDefinition.builder()
|
||||||
|
.identifier(EntityIdentifier.builder().identifier(id)
|
||||||
|
.summonable(true)
|
||||||
|
.spawnEgg(false).build())
|
||||||
|
.height(0.6f)
|
||||||
|
.width(0.6f)
|
||||||
|
.build());
|
||||||
|
}
|
||||||
public void loadEntities() {
|
public void loadEntities() {
|
||||||
|
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
@@ -114,14 +124,7 @@ public class GeyserUtils implements Extension {
|
|||||||
|
|
||||||
for (String s : list) {
|
for (String s : list) {
|
||||||
logger().info("Registered: " + s);
|
logger().info("Registered: " + s);
|
||||||
LOADED_ENTITY_DEFINITIONS.put(s,
|
addCustomEntity(s);
|
||||||
EntityDefinition.builder()
|
|
||||||
.identifier(EntityIdentifier.builder().identifier(s)
|
|
||||||
.summonable(true)
|
|
||||||
.spawnEgg(false).build())
|
|
||||||
.height(0.6f)
|
|
||||||
.width(0.6f)
|
|
||||||
.build());
|
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
@@ -363,10 +366,7 @@ 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());
|
||||||
|
|
||||||
System.out.println("ID: " + event.entityId() + " Type: " + event.entityDefinition().entityIdentifier().identifier());
|
|
||||||
if (def == null) return;
|
if (def == null) return;
|
||||||
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