Skip to content

Commit ffefafb

Browse files
Advertise and map custom core_rings entity
1 parent 0ef30bb commit ffefafb

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

core/src/main/java/org/geysermc/geyser/entity/EntityDefinitions.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ public final class EntityDefinitions {
181181
public static final EntityDefinition<ChestBoatEntity> CHERRY_CHEST_BOAT;
182182
public static final EntityDefinition<MinecartEntity> CHEST_MINECART;
183183
public static final EntityDefinition<ChickenEntity> CHICKEN;
184+
public static final EntityDefinition<ArmorStandEntity> CORE_RINGS;
184185
public static final EntityDefinition<AbstractFishEntity> COD;
185186
public static final EntityDefinition<CommandBlockMinecartEntity> COMMAND_BLOCK_MINECART;
186187
public static final EntityDefinition<CowEntity> COW;
@@ -651,6 +652,10 @@ public final class EntityDefinitions {
651652
.addTranslator(MetadataTypes.ROTATIONS, ArmorStandEntity::setLeftLegRotation)
652653
.addTranslator(MetadataTypes.ROTATIONS, ArmorStandEntity::setRightLegRotation)
653654
.build();
655+
CORE_RINGS = EntityDefinition.inherited(ArmorStandEntity::new, ARMOR_STAND)
656+
.identifier("playunlimited:core_rings")
657+
.build(false);
658+
Registries.JAVA_ENTITY_IDENTIFIERS.get().put("playunlimited:core_rings", CORE_RINGS);
654659
PLAYER = EntityDefinition.<PlayerEntity>inherited(null, livingEntityBase)
655660
.type(EntityType.PLAYER)
656661
.height(1.8f).width(0.6f)

core/src/main/java/org/geysermc/geyser/entity/type/living/ArmorStandEntity.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,18 @@ public void setBoots(GeyserItemStack boots) {
293293
public void setHand(GeyserItemStack hand) {
294294
super.setHand(hand);
295295
updateSecondEntityStatus(true);
296+
297+
if (!hand.isEmpty() && hand.asItem() == Items.GRASS_BLOCK) {
298+
if (this.definition != EntityDefinitions.CORE_RINGS) {
299+
despawnEntity();
300+
this.definition = EntityDefinitions.CORE_RINGS;
301+
spawnEntity();
302+
}
303+
} else if (this.definition == EntityDefinitions.CORE_RINGS) {
304+
despawnEntity();
305+
this.definition = EntityDefinitions.ARMOR_STAND;
306+
spawnEntity();
307+
}
296308
}
297309

298310
@Override

core/src/main/java/org/geysermc/geyser/registry/Registries.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,20 @@ public static void load() {
208208
// (by using the Items or Blocks class, which loads all the blocks)
209209

210210
BEDROCK_ENTITY_IDENTIFIERS.load();
211-
// Add custom entity identifier for playunlimited
211+
// Add custom entity identifiers for PlayUnlimited entities
212212
NbtMap identifiers = BEDROCK_ENTITY_IDENTIFIERS.get();
213213
List<NbtMap> idList = new ArrayList<>(identifiers.getList("idlist", NbtType.COMPOUND));
214214
int nextRid = idList.stream().mapToInt(map -> map.getInt("rid")).max().orElse(-1) + 1;
215215
idList.add(NbtMap.builder()
216216
.putString("id", "playunlimited:playunlimited")
217217
.putShort("bid", (short) 0)
218+
.putInt("rid", nextRid++)
219+
.putBoolean("summonable", true)
220+
.putBoolean("hasSpawnEgg", false)
221+
.build());
222+
idList.add(NbtMap.builder()
223+
.putString("id", "playunlimited:core_rings")
224+
.putShort("bid", (short) 0)
218225
.putInt("rid", nextRid)
219226
.putBoolean("summonable", true)
220227
.putBoolean("hasSpawnEgg", false)

0 commit comments

Comments
 (0)