Skip to content

Commit

Permalink
fix issues with spawners and entity parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
duplexsystem committed Dec 11, 2023
1 parent 22c46f2 commit fc764a0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ public BukkitWorldHandle() {

@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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ private MobSpawnerBlockEntityMixin(BlockEntityType<?> type, BlockPos pos, BlockS
}

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() {
Expand Down

0 comments on commit fc764a0

Please sign in to comment.