fix issues with spawners and entity parsing

This commit is contained in:
Zoë Gidiere
2023-12-10 18:40:43 -07:00
parent 22c46f2f80
commit fc764a0fb3
3 changed files with 22 additions and 1 deletions

View File

@@ -61,6 +61,13 @@ public class BukkitWorldHandle implements WorldHandle {
@Override
public @NotNull EntityType getEntity(@NotNull String id) {
if (!id.contains(":")) { //TODO: remove in 7.0
String newid = "minecraft:" + id.toLowerCase();;
logger.warn(
"Translating " + id + " to " + newid + ". In 1.20.3 entity parsing was reworked" +
". You are advised to preform this rename in your config backs as this translation will be removed in the next major " +
"version of Terra.");
}
if(!id.startsWith("minecraft:")) throw new IllegalArgumentException("Invalid entity identifier " + id);
String entityID = id.toUpperCase(Locale.ROOT).substring(10);

View File

@@ -64,6 +64,14 @@ public class MinecraftWorldHandle implements WorldHandle {
@Override
public @NotNull EntityType getEntity(@NotNull String id) {
if (!id.contains(":")) { //TODO: remove in 7.0
String newid = "minecraft:" + id.toLowerCase();;
logger.warn(
"Translating " + id + " to " + newid + ". In 1.20.3 entity parsing was reworked" +
". You are advised to preform this rename in your config backs as this translation will be removed in the next major " +
"version of Terra.");
}
if(!id.startsWith("minecraft:")) throw new IllegalArgumentException("Invalid entity identifier " + id);
Identifier identifier = Identifier.tryParse(id);
if(identifier == null) identifier = Identifier.tryParse(id);
return (EntityType) Registries.ENTITY_TYPE.get(identifier);

View File

@@ -58,7 +58,13 @@ public abstract class MobSpawnerBlockEntityMixin extends BlockEntity {
}
public void terra$setSpawnedType(@NotNull EntityType creatureType) {
method_46408((net.minecraft.entity.EntityType<?>) creatureType, world.getRandom());
Random rand;
if (hasWorld()) {
rand = world.getRandom();
} else {
rand = Random.create();
}
method_46408((net.minecraft.entity.EntityType<?>) creatureType, rand);
}
public int terra$getDelay() {