fixed fortress finder crashing servers

closes #372
This commit is contained in:
Ell 2024-11-20 21:48:20 +01:00
parent a4f9dd0f95
commit 0d2f6f5389
2 changed files with 6 additions and 7 deletions

View file

@ -18,13 +18,11 @@ public class ItemStructureFinder extends ItemImpl {
private final ResourceKey<Structure> structure;
private final int color;
private final int radius;
public ItemStructureFinder(String baseName, ResourceKey<Structure> structure, int color, int radius) {
public ItemStructureFinder(String baseName, ResourceKey<Structure> 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());

View file

@ -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(),