Fixed zap blocks destroying item drops

This commit is contained in:
Sollace 2024-02-08 14:25:40 +00:00
parent adb07cc586
commit 6fd124ed81
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB

View file

@ -5,6 +5,7 @@ import com.minelittlepony.unicopia.particle.LightningBoltParticleEffect;
import com.minelittlepony.unicopia.particle.ParticleUtils; import com.minelittlepony.unicopia.particle.ParticleUtils;
import net.minecraft.block.*; import net.minecraft.block.*;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.LightningEntity; import net.minecraft.entity.LightningEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext; import net.minecraft.item.ItemPlacementContext;
@ -66,6 +67,9 @@ public class ZapBlock extends Block {
Vec3d center = Vec3d.ofCenter(pos); Vec3d center = Vec3d.ofCenter(pos);
LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(world); LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(world);
world.getOtherEntities(null, Box.from(center).expand(7)).forEach(other -> { world.getOtherEntities(null, Box.from(center).expand(7)).forEach(other -> {
if (other instanceof ItemEntity) {
return;
}
float dist = (float)other.getPos().distanceTo(center); float dist = (float)other.getPos().distanceTo(center);
if (dist < 4) { if (dist < 4) {
other.onStruckByLightning(serverWorld, lightning); other.onStruckByLightning(serverWorld, lightning);