Fixed crystal shard entities attaching to blocks outside the world bounds

This commit is contained in:
Sollace 2023-09-14 18:06:08 +01:00
parent 352f6588d4
commit 5cc2bcc0e4
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB

View file

@ -9,6 +9,7 @@ import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.USounds; import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.item.UItems;
import com.minelittlepony.unicopia.particle.ParticleUtils;
import net.minecraft.block.SideShapeType; import net.minecraft.block.SideShapeType;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
@ -19,6 +20,7 @@ import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement; import net.minecraft.nbt.NbtElement;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.predicate.entity.EntityPredicates; import net.minecraft.predicate.entity.EntityPredicates;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -71,7 +73,7 @@ public class CrystalShardsEntity extends StationaryObjectEntity {
} }
static boolean isInvalid(World world, BlockPos crystalPos, Direction attachmentFace) { static boolean isInvalid(World world, BlockPos crystalPos, Direction attachmentFace) {
if (!world.isAir(crystalPos)) { if (!world.isAir(crystalPos) || world.isOutOfHeightLimit(crystalPos)) {
return true; return true;
} }
BlockPos attachmentPos = crystalPos.offset(attachmentFace.getOpposite()); BlockPos attachmentPos = crystalPos.offset(attachmentFace.getOpposite());
@ -172,6 +174,7 @@ public class CrystalShardsEntity extends StationaryObjectEntity {
if (isDead() || isInvalid(getWorld(), getBlockPos(), getAttachmentFace())) { if (isDead() || isInvalid(getWorld(), getBlockPos(), getAttachmentFace())) {
kill(); kill();
ParticleUtils.spawnParticles(ParticleTypes.CLOUD, this, 10);
} }
} }