Add code block to get the specified entity type

Started by myshuaibi on

Topic category: Feature requests and ideas for MCreator

Joined May 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Add code block to get the specified entity type

Add code block to get the specified entity type

For example:

Spawn entity:ent at x y z

ent can be a type of entity, and does not have to be selected only in Data list entry selection

Similarly, make such changes in something like Get nearest entity at x: in square cube with size of type ent

if (world instanceof ServerLevel level) {
	EntityType<?> type = entity.getType();
	spawned = type.spawn(level, BlockPos.containing(x, y + 0.3, z), MobSpawnType.MOB_SUMMONED);
	if (spawned != null) {
		spawned.setYRot(world.getRandom().nextFloat() * 360F);
	}
}