fix various issues
This commit is contained in:
@@ -28,7 +28,9 @@ import net.minecraftforge.event.entity.living.MobSpawnEvent;
|
||||
import net.minecraftforge.event.level.BlockEvent;
|
||||
import net.minecraftforge.event.level.ExplosionEvent;
|
||||
import net.minecraftforge.event.level.LevelEvent;
|
||||
import net.minecraftforge.event.level.BlockEvent.EntityPlaceEvent;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.event.server.ServerStoppingEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
public class AdaptiveMobsEvents {
|
||||
@@ -97,6 +99,9 @@ public class AdaptiveMobsEvents {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onBlockBreak(BlockEvent.BreakEvent event) {
|
||||
if (event.getLevel() instanceof ServerLevel level) {
|
||||
AdaptiveSpecialAbilities.invalidateTemporaryBlock(level, event.getPos());
|
||||
}
|
||||
if (AMConfig.enabled && AMConfig.ENABLE_SOUND_INVESTIGATION_AI.get()
|
||||
&& event.getLevel() instanceof ServerLevel level) {
|
||||
if (event.getPlayer() instanceof ServerPlayer player
|
||||
@@ -107,6 +112,13 @@ public class AdaptiveMobsEvents {
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onBlockPlace(EntityPlaceEvent event) {
|
||||
if (event.getLevel() instanceof ServerLevel level) {
|
||||
AdaptiveSpecialAbilities.invalidateTemporaryBlock(level, event.getPos());
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onItemUseFinish(LivingEntityUseItemEvent.Finish event) {
|
||||
if (AMConfig.enabled && AMConfig.ENABLE_SOUND_INVESTIGATION_AI.get()
|
||||
@@ -155,6 +167,7 @@ public class AdaptiveMobsEvents {
|
||||
public void onLevelUnload(LevelEvent.Unload event) {
|
||||
if (event.getLevel() instanceof ServerLevel level) {
|
||||
AdaptiveMemory.clear(level);
|
||||
AdaptiveSpecialAbilities.clear(level);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,6 +184,11 @@ public class AdaptiveMobsEvents {
|
||||
AdaptiveSpecialAbilities.onServerTick(event);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onServerStopping(ServerStoppingEvent event) {
|
||||
AdaptiveSpecialAbilities.clear(event.getServer());
|
||||
}
|
||||
|
||||
private static void clearFriendlyFireTolerance(Mob mob) {
|
||||
mob.getPersistentData().remove(FRIENDLY_FIRE_SOURCE_KEY);
|
||||
mob.getPersistentData().remove(FRIENDLY_FIRE_COUNT_KEY);
|
||||
|
||||
Reference in New Issue
Block a user