This commit is contained in:
LZX committed 2026-07-08 22:34:42 +08:00
1 parent f5378eaa38
commit a99646bcd8
2 files changed
+7 -1

No files matched your search

+1 -1
View File
@@ -32,7 +32,7 @@ mod_name=Lzxnone Terraria
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=All Rights Reserved mod_license=All Rights Reserved
# The mod version. See https://semver.org/ # The mod version. See https://semver.org/
mod_version=1.2.1 mod_version=1.2.2
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources. # This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html # See https://maven.apache.org/guides/mini/guide-naming-conventions.html
@@ -12,6 +12,8 @@ import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.event.entity.living.MobEffectEvent; import net.neoforged.neoforge.event.entity.living.MobEffectEvent;
import net.neoforged.neoforge.event.tick.EntityTickEvent; import net.neoforged.neoforge.event.tick.EntityTickEvent;
import java.util.Objects;
@EventBusSubscriber(modid = LzxnoneTerraria.MODID) @EventBusSubscriber(modid = LzxnoneTerraria.MODID)
public class EffectLogicHandler { public class EffectLogicHandler {
@@ -31,22 +33,26 @@ public class EffectLogicHandler {
LivingEntity entity = event.getEntity(); LivingEntity entity = event.getEntity();
if(!entity.level().isClientSide() && !(entity instanceof Player)) { if(!entity.level().isClientSide() && !(entity instanceof Player)) {
if(entity.level() instanceof ServerLevel serverLevel) { if(entity.level() instanceof ServerLevel serverLevel) {
if(event.getEffectInstance() != null) {
serverLevel.getChunkSource().broadcast(entity, serverLevel.getChunkSource().broadcast(entity,
new ClientboundRemoveMobEffectPacket(entity.getId(), event.getEffectInstance().getEffect())); new ClientboundRemoveMobEffectPacket(entity.getId(), event.getEffectInstance().getEffect()));
} }
} }
} }
}
@SubscribeEvent @SubscribeEvent
public static void onEffectExpired(MobEffectEvent.Expired event) { public static void onEffectExpired(MobEffectEvent.Expired event) {
LivingEntity entity = event.getEntity(); LivingEntity entity = event.getEntity();
if (!entity.level().isClientSide() && !(entity instanceof Player)) { if (!entity.level().isClientSide() && !(entity instanceof Player)) {
if (entity.level() instanceof ServerLevel serverLevel) { if (entity.level() instanceof ServerLevel serverLevel) {
if(event.getEffectInstance() != null) {
serverLevel.getChunkSource().broadcast(entity, serverLevel.getChunkSource().broadcast(entity,
new ClientboundRemoveMobEffectPacket(entity.getId(), event.getEffectInstance().getEffect())); new ClientboundRemoveMobEffectPacket(entity.getId(), event.getEffectInstance().getEffect()));
} }
} }
} }
}
@SubscribeEvent @SubscribeEvent
public static void onLivingTick(EntityTickEvent.Post event) { public static void onLivingTick(EntityTickEvent.Post event) {