From 4852f9cb1fcc352dcddb3e18c5136aa9a308d828 Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Sun, 29 Dec 2024 23:35:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=9B=B7=E8=BE=BE=E5=8F=91?= =?UTF-8?q?=E5=85=89=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../block/entity/FuMO25BlockEntity.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/block/entity/FuMO25BlockEntity.java b/src/main/java/com/atsuishio/superbwarfare/block/entity/FuMO25BlockEntity.java index 5e86c9976..7380aaa7e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/block/entity/FuMO25BlockEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/block/entity/FuMO25BlockEntity.java @@ -4,6 +4,7 @@ import com.atsuishio.superbwarfare.block.FuMO25Block; import com.atsuishio.superbwarfare.init.ModBlockEntities; import com.atsuishio.superbwarfare.menu.FuMO25Menu; import com.atsuishio.superbwarfare.network.dataslot.ContainerEnergyData; +import com.atsuishio.superbwarfare.tools.SeekTool; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; @@ -11,6 +12,10 @@ import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; import net.minecraft.util.Mth; import net.minecraft.world.MenuProvider; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; @@ -24,6 +29,8 @@ import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.EnergyStorage; import org.jetbrains.annotations.Nullable; +import java.util.List; + public class FuMO25BlockEntity extends BlockEntity implements MenuProvider { public static final int MAX_ENERGY = 1000000; @@ -107,7 +114,9 @@ public class FuMO25BlockEntity extends BlockEntity implements MenuProvider { } else { blockEntity.energyHandler.ifPresent(handler -> handler.extractEnergy(energyCost, false)); if (blockEntity.time > 0) { - blockEntity.setGlowEffect(); + if (blockEntity.time % 100 == 0) { + blockEntity.setGlowEffect(); + } blockEntity.time--; blockEntity.setChanged(); } @@ -129,8 +138,13 @@ public class FuMO25BlockEntity extends BlockEntity implements MenuProvider { Level level = this.level; if (level == null) return; - - + BlockPos pos = this.getBlockPos(); + List entities = SeekTool.getEntitiesWithinRange(pos, level, GLOW_RANGE); + entities.forEach(e -> { + if (e instanceof LivingEntity living) { + living.addEffect(new MobEffectInstance(MobEffects.GLOWING, 100, 0, true, false)); + } + }); } @Override