Skip to content

Commit da07107

Browse files
committed
added SWIM-handler
1 parent c3f7493 commit da07107

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/java/de/ntcomputer/minecraft/controllablemobs/implementation/ai/AIComponentHandlers.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import net.minecraft.server.v1_6_R3.PathfinderGoal;
77
import net.minecraft.server.v1_6_R3.PathfinderGoalBreakDoor;
88
import net.minecraft.server.v1_6_R3.PathfinderGoalDoorInteract;
9+
import net.minecraft.server.v1_6_R3.PathfinderGoalFloat;
910
import net.minecraft.server.v1_6_R3.PathfinderGoalOpenDoor;
1011
import de.ntcomputer.minecraft.controllablemobs.api.ai.AIType;
1112
import de.ntcomputer.minecraft.controllablemobs.implementation.CraftControllableMob;
@@ -37,6 +38,19 @@ public void onRemoved(CraftControllableMob<?> mob, PathfinderGoalDoorInteract go
3738
};
3839
add(PathfinderGoalOpenDoor.class, closedDoorListener);
3940
add(PathfinderGoalBreakDoor.class, closedDoorListener);
41+
42+
add(PathfinderGoalFloat.class, new AIComponentListener<PathfinderGoalFloat>() {
43+
@Override
44+
public void onAdd(CraftControllableMob<?> mob, PathfinderGoalFloat goal) {
45+
NativeInterfaces.NAVIGATION.FIELD_CANSWIM.set(mob.nmsEntity.getNavigation(), true);
46+
}
47+
@Override
48+
public void onRemoved(CraftControllableMob<?> mob, PathfinderGoalFloat goal) {
49+
if(!mob.getAI().hasBehavior(AIType.MOVE_SWIM)) {
50+
NativeInterfaces.NAVIGATION.FIELD_CANSWIM.set(mob.nmsEntity.getNavigation(), false);
51+
}
52+
}
53+
});
4054
}
4155

4256
@SuppressWarnings("unchecked")

0 commit comments

Comments
 (0)