Skip to content

Commit 0d2f6f5

Browse files
committed
fixed fortress finder crashing servers
closes #372
1 parent a4f9dd0 commit 0d2f6f5

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/main/java/de/ellpeck/naturesaura/items/ItemStructureFinder.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@ public class ItemStructureFinder extends ItemImpl {
1818

1919
private final ResourceKey<Structure> structure;
2020
private final int color;
21-
private final int radius;
2221

23-
public ItemStructureFinder(String baseName, ResourceKey<Structure> structure, int color, int radius) {
22+
public ItemStructureFinder(String baseName, ResourceKey<Structure> structure, int color) {
2423
super(baseName);
2524
this.structure = structure;
2625
this.color = color;
27-
this.radius = radius;
2826
}
2927

3028
@Override
@@ -34,7 +32,8 @@ public InteractionResultHolder<ItemStack> use(Level levelIn, Player playerIn, In
3432
var registry = levelIn.registryAccess().registryOrThrow(Registries.STRUCTURE);
3533
var holderSet = registry.getHolder(this.structure).map(HolderSet::direct).orElse(null);
3634
if (holderSet != null) {
37-
var pos = ((ServerLevel) levelIn).getChunkSource().getGenerator().findNearestMapStructure((ServerLevel) levelIn, holderSet, playerIn.blockPosition(), this.radius, false);
35+
// 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
36+
var pos = ((ServerLevel) levelIn).getChunkSource().getGenerator().findNearestMapStructure((ServerLevel) levelIn, holderSet, playerIn.blockPosition(), 100, false);
3837
if (pos != null) {
3938
var entity = new EntityStructureFinder(ModEntities.STRUCTURE_FINDER, levelIn);
4039
entity.setPos(playerIn.getX(), playerIn.getY(0.5D), playerIn.getZ());

src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ public static void register(RegisterEvent event) {
219219
new ItemArmor("sky_chest", ModArmorMaterial.SKY, ArmorItem.Type.CHESTPLATE),
220220
new ItemArmor("sky_pants", ModArmorMaterial.SKY, ArmorItem.Type.LEGGINGS),
221221
new ItemArmor("sky_shoes", ModArmorMaterial.SKY, ArmorItem.Type.BOOTS),
222-
new ItemStructureFinder("fortress_finder", BuiltinStructures.FORTRESS, 0xba2800, 1024),
223-
new ItemStructureFinder("end_city_finder", BuiltinStructures.END_CITY, 0xca5cd6, 1024),
224-
new ItemStructureFinder("outpost_finder", BuiltinStructures.PILLAGER_OUTPOST, 0xab9f98, 2048),
222+
new ItemStructureFinder("fortress_finder", BuiltinStructures.FORTRESS, 0xba2800),
223+
new ItemStructureFinder("end_city_finder", BuiltinStructures.END_CITY, 0xca5cd6),
224+
new ItemStructureFinder("outpost_finder", BuiltinStructures.PILLAGER_OUTPOST, 0xab9f98),
225225
new ItemBreakPrevention(),
226226
new ItemPetReviver(),
227227
new ItemNetheriteFinder(),

0 commit comments

Comments
 (0)