Skip to content

Commit

Permalink
Avoid error messages/mod compat on duplicate entities (#9914)
Browse files Browse the repository at this point in the history
Avoid error messages/mod compat on duplicate entities
  • Loading branch information
someaddons authored and Raycoms committed Apr 21, 2024
1 parent 43ec67f commit 0c83235
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/java/com/minecolonies/core/event/EventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.minecolonies.api.entity.ModEntities;
import com.minecolonies.api.entity.ai.statemachine.tickratestatemachine.TickRateStateMachine;
import com.minecolonies.api.entity.citizen.AbstractEntityCitizen;
import com.minecolonies.api.entity.other.AbstractFastMinecoloniesEntity;
import com.minecolonies.api.items.ModTags;
import com.minecolonies.api.util.*;
import com.minecolonies.core.MineColonies;
Expand Down Expand Up @@ -102,7 +103,7 @@ public static void onCommandsRegister(final RegisterCommandsEvent event)
*
* @param event the event.
*/
@SubscribeEvent
@SubscribeEvent(priority = HIGHEST)
public static void onEntityAdded(@NotNull final EntityJoinLevelEvent event)
{
if (!event.getLevel().isClientSide())
Expand All @@ -111,9 +112,15 @@ public static void onEntityAdded(@NotNull final EntityJoinLevelEvent event)
.getType()
.is(ModTags.mobAttackBlacklist)))
{
((Mob) event.getEntity()).targetSelector.addGoal(6, new NearestAttackableTargetGoal<>((Mob) event.getEntity(), EntityCitizen.class, true, citizen -> !citizen.isInvisible()));
((Mob) event.getEntity()).targetSelector.addGoal(6,
new NearestAttackableTargetGoal<>((Mob) event.getEntity(), EntityCitizen.class, true, citizen -> !citizen.isInvisible()));
((Mob) event.getEntity()).targetSelector.addGoal(7, new NearestAttackableTargetGoal<>((Mob) event.getEntity(), EntityMercenary.class, true));
}

if (event.getEntity() instanceof AbstractFastMinecoloniesEntity && ((ServerLevel) event.getLevel()).getEntity(event.getEntity().getUUID()) != null)
{
event.setCanceled(true);
}
}
}

Expand Down

0 comments on commit 0c83235

Please # to comment.