Skip to content

Commit 4857fdf

Browse files
committed
added navigation attribute getters & setters
1 parent 71497cd commit 4857fdf

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

src/java/de/ntcomputer/minecraft/controllablemobs/api/ControllableMobAttributes.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,46 @@ public interface ControllableMobAttributes {
4545
*/
4646
public double getMaximumNavigationDistance();
4747

48+
49+
/**
50+
* Determines whether the entity can swim. To change this value, add or remove {@link de.ntcomputer.minecraft.controllablemobs.api.ai.behaviors.AISwim} to {@link ControllableMobAI}
51+
* @return whether the entity can swim.
52+
*/
53+
public boolean canSwim();
54+
55+
/**
56+
* @return whether the entity avoids moving through water (regardless of whether it can swim).
57+
*/
58+
public boolean getAvoidWater();
59+
60+
/**
61+
* Set whether the entity avoids moving through water (regardless of whether it can swim).
62+
* @param avoid true, if the entity should not move through water
63+
*/
64+
public void setAvoidWater(boolean avoid);
65+
66+
67+
/**
68+
* Get whether the entity will move through doors to reach its destination.
69+
* This only shows whether the entity will move through opened doors.
70+
* It does not show whether the entity will move through closed doors. Use {@link #canMoveThroughClosedDoors()} for this case.
71+
* @return whether the entity will move through doors to reach its destination.
72+
*/
73+
public boolean getMoveThroughDoors();
74+
75+
/**
76+
* Set whether the entity will move through doors to reach its destination.
77+
* If set to true, the entity will move through opened doors. For closed doors, see {@link #canMoveThroughClosedDoors()}
78+
* If set to false, the entity will not move through any closed or opened door, regardless of AI behaviors.
79+
* @param moveThroughDoors whether the entity should move through doors to reach its destination.
80+
*/
81+
public void setMoveThroughDoors(boolean moveThroughDoors);
82+
83+
/**
84+
* Get whether the entity can move through closed doors to reach its destination.
85+
* To adjust this behavior, add or remove either {@link de.ntcomputer.minecraft.controllablemobs.api.ai.behaviors.AIDoorOpen} or {@link de.ntcomputer.minecraft.controllablemobs.api.ai.behaviors.AIDoorBreak} to {@link ControllableMobAI}.
86+
* @return whether the entity can somehow move through closed doors to reach its destination.
87+
*/
88+
public boolean canMoveThroughClosedDoors();
89+
4890
}

src/java/de/ntcomputer/minecraft/controllablemobs/implementation/CraftControllableMobAttributes.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,34 @@ void dispose(boolean reset) {
8888
this.nmsEntity = null;
8989
}
9090

91+
@Override
92+
public boolean canSwim() {
93+
return NativeInterfaces.NAVIGATION.FIELD_CANSWIM.get(this.nmsEntity.getNavigation());
94+
}
95+
96+
@Override
97+
public boolean getAvoidWater() {
98+
return NativeInterfaces.NAVIGATION.FIELD_AVOIDWATER.get(this.nmsEntity.getNavigation());
99+
}
100+
101+
@Override
102+
public void setAvoidWater(boolean avoid) {
103+
NativeInterfaces.NAVIGATION.FIELD_AVOIDWATER.set(this.nmsEntity.getNavigation(), avoid);
104+
}
105+
106+
@Override
107+
public boolean getMoveThroughDoors() {
108+
return NativeInterfaces.NAVIGATION.FIELD_USEOPENDOOR.get(this.nmsEntity.getNavigation());
109+
}
110+
111+
@Override
112+
public void setMoveThroughDoors(boolean moveThroughDoors) {
113+
NativeInterfaces.NAVIGATION.FIELD_USEOPENDOOR.set(this.nmsEntity.getNavigation(), moveThroughDoors);
114+
}
115+
116+
@Override
117+
public boolean canMoveThroughClosedDoors() {
118+
return NativeInterfaces.NAVIGATION.FIELD_USECLOSEDDOOR.get(this.nmsEntity.getNavigation());
119+
}
120+
91121
}

0 commit comments

Comments
 (0)