Skip to content

Commit 2d36852

Browse files
committed
added AIDoorBreak and AIDoorOpen
1 parent da07107 commit 2d36852

File tree

4 files changed

+101
-4
lines changed

4 files changed

+101
-4
lines changed

builder/version.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#Thu, 14 Nov 2013 13:23:59 +0100
1+
#Thu, 14 Nov 2013 18:19:16 +0100
22

33
version.number=6
4-
version.build=18
5-
version.timestamp=201311141323
4+
version.build=20
5+
version.timestamp=201311141819

src/java/de/ntcomputer/minecraft/controllablemobs/api/ai/behaviors/AIBehavior.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
public abstract class AIBehavior<E extends LivingEntity> {
2121
private final int priority;
2222

23-
protected AIBehavior(int priority) {
23+
public AIBehavior(int priority) {
2424
this.priority = priority;
2525
}
2626

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package de.ntcomputer.minecraft.controllablemobs.api.ai.behaviors;
2+
3+
import net.minecraft.server.v1_6_R3.PathfinderGoal;
4+
import net.minecraft.server.v1_6_R3.PathfinderGoalBreakDoor;
5+
6+
import org.bukkit.entity.LivingEntity;
7+
8+
import de.ntcomputer.minecraft.controllablemobs.api.ai.AIType;
9+
import de.ntcomputer.minecraft.controllablemobs.implementation.CraftControllableMob;
10+
11+
/**
12+
* If added, this behavior lets entities break wooden doors when needed.
13+
*
14+
* @author DevCybran
15+
* @version v6
16+
*
17+
*/
18+
public final class AIDoorBreak extends AIBehavior<LivingEntity> {
19+
20+
/**
21+
* Create with an automatically given priority.
22+
*/
23+
public AIDoorBreak() {
24+
this(0);
25+
}
26+
27+
/**
28+
* Create with a custom priority.
29+
*
30+
* @param priority the priority of this behavior. Specify 0 to auto-generate it
31+
*/
32+
public AIDoorBreak(int priority) {
33+
super(priority);
34+
}
35+
36+
@Override
37+
public AIType getType() {
38+
return AIType.ACTION_DOORBREAK;
39+
}
40+
41+
@Override
42+
public PathfinderGoal createPathfinderGoal(CraftControllableMob<? extends LivingEntity> mob) {
43+
return new PathfinderGoalBreakDoor(mob.nmsEntity);
44+
}
45+
46+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package de.ntcomputer.minecraft.controllablemobs.api.ai.behaviors;
2+
3+
import net.minecraft.server.v1_6_R3.PathfinderGoal;
4+
import net.minecraft.server.v1_6_R3.PathfinderGoalOpenDoor;
5+
6+
import org.bukkit.entity.LivingEntity;
7+
8+
import de.ntcomputer.minecraft.controllablemobs.api.ai.AIType;
9+
import de.ntcomputer.minecraft.controllablemobs.implementation.CraftControllableMob;
10+
11+
public final class AIDoorOpen extends AIBehavior<LivingEntity> {
12+
private final boolean closeDoorAfterwards;
13+
14+
/**
15+
* Create with an automatically given priority.
16+
*/
17+
public AIDoorOpen() {
18+
this(0);
19+
}
20+
21+
/**
22+
* Create with a custom priority.
23+
*
24+
* @param priority the priority of this behavior. Specify 0 to auto-generate it
25+
*/
26+
public AIDoorOpen(int priority) {
27+
this(priority, false);
28+
}
29+
30+
/**
31+
* Create with a custom priority.
32+
*
33+
* @param priority the priority of this behavior. Specify 0 to auto-generate it
34+
* @param closeDoorAfterwards whether the entity shall close the door after passing through it. default is false
35+
*/
36+
public AIDoorOpen(int priority, boolean closeDoorAfterwards) {
37+
super(priority);
38+
this.closeDoorAfterwards = closeDoorAfterwards;
39+
}
40+
41+
@Override
42+
public AIType getType() {
43+
return AIType.ACTION_DOOROPEN;
44+
}
45+
46+
@Override
47+
public PathfinderGoal createPathfinderGoal(CraftControllableMob<? extends LivingEntity> mob) {
48+
return new PathfinderGoalOpenDoor(mob.nmsEntity, this.closeDoorAfterwards);
49+
}
50+
51+
}

0 commit comments

Comments
 (0)