From 0d2f6f538971097fb4c3ccec1c3b64e5d31e8232 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 20 Nov 2024 21:48:20 +0100 Subject: [PATCH] fixed fortress finder crashing servers closes #372 --- .../de/ellpeck/naturesaura/items/ItemStructureFinder.java | 7 +++---- src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemStructureFinder.java b/src/main/java/de/ellpeck/naturesaura/items/ItemStructureFinder.java index 1c83dcd7..c6398b24 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemStructureFinder.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemStructureFinder.java @@ -18,13 +18,11 @@ public class ItemStructureFinder extends ItemImpl { private final ResourceKey structure; private final int color; - private final int radius; - public ItemStructureFinder(String baseName, ResourceKey structure, int color, int radius) { + public ItemStructureFinder(String baseName, ResourceKey structure, int color) { super(baseName); this.structure = structure; this.color = color; - this.radius = radius; } @Override @@ -34,7 +32,8 @@ public class ItemStructureFinder extends ItemImpl { var registry = levelIn.registryAccess().registryOrThrow(Registries.STRUCTURE); var holderSet = registry.getHolder(this.structure).map(HolderSet::direct).orElse(null); if (holderSet != null) { - var pos = ((ServerLevel) levelIn).getChunkSource().getGenerator().findNearestMapStructure((ServerLevel) levelIn, holderSet, playerIn.blockPosition(), this.radius, false); + // apparently the radius isn't really the radius anymore and even the locate command uses 100, which still allows it to find structures further away + var pos = ((ServerLevel) levelIn).getChunkSource().getGenerator().findNearestMapStructure((ServerLevel) levelIn, holderSet, playerIn.blockPosition(), 100, false); if (pos != null) { var entity = new EntityStructureFinder(ModEntities.STRUCTURE_FINDER, levelIn); entity.setPos(playerIn.getX(), playerIn.getY(0.5D), playerIn.getZ()); diff --git a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java index 8da3a437..e1e3023d 100644 --- a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java +++ b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java @@ -219,9 +219,9 @@ public final class ModRegistry { new ItemArmor("sky_chest", ModArmorMaterial.SKY, ArmorItem.Type.CHESTPLATE), new ItemArmor("sky_pants", ModArmorMaterial.SKY, ArmorItem.Type.LEGGINGS), new ItemArmor("sky_shoes", ModArmorMaterial.SKY, ArmorItem.Type.BOOTS), - new ItemStructureFinder("fortress_finder", BuiltinStructures.FORTRESS, 0xba2800, 1024), - new ItemStructureFinder("end_city_finder", BuiltinStructures.END_CITY, 0xca5cd6, 1024), - new ItemStructureFinder("outpost_finder", BuiltinStructures.PILLAGER_OUTPOST, 0xab9f98, 2048), + new ItemStructureFinder("fortress_finder", BuiltinStructures.FORTRESS, 0xba2800), + new ItemStructureFinder("end_city_finder", BuiltinStructures.END_CITY, 0xca5cd6), + new ItemStructureFinder("outpost_finder", BuiltinStructures.PILLAGER_OUTPOST, 0xab9f98), new ItemBreakPrevention(), new ItemPetReviver(), new ItemNetheriteFinder(),