Skip to content

Commit 37d0d18

Browse files
committed
added moveTo() movement speed multiplactor parameter
1 parent dfeb9fb commit 37d0d18

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

builder/version.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#Fri, 15 Nov 2013 15:02:57 +0100
1+
#Fri, 15 Nov 2013 15:13:02 +0100
22

33
version.number=6
4-
version.build=24
5-
version.timestamp=201311151502
4+
version.build=25
5+
version.timestamp=201311151513

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,39 @@ public interface ControllableMobActions {
2020
* Orders the entity to move to the given location.
2121
* Uses the {@link ControllableMobActions#getDefaultQueuingFlag() default queuing flag}.
2222
*
23-
* @see ControllableMobActions#moveTo(Location, boolean)
23+
* @see #moveTo(Location, boolean, double)
2424
* @param loc the location the entity will move to.
2525
* @return {@link ControllableMobAction}
2626
*/
2727
public ControllableMobAction moveTo(Location loc);
28+
2829
/**
2930
* Orders the entity to move to the given location, optionally adding the action to the queue.
3031
* This action is block accurate, meaning, that the entity will stop once it reached the block the given location is pointing at.
3132
* When the action's execution is started, all other movements or attacks caused by the AI are stopped and overridden.
3233
* If a target is assigned to the entity, it will not be lost and dealing with it will be resumed when this movement is finished.
3334
*
35+
* @see #moveTo(Location, boolean, double)
3436
* @param loc the location the entity will move to.
3537
* @param queue whether this action should be added to the queue (true) or executed directly (false).
3638
* @return {@link ControllableMobAction}
3739
*/
3840
public ControllableMobAction moveTo(Location loc, boolean queue);
3941

42+
/**
43+
* Orders the entity to move to the given location, optionally adding the action to the queue.
44+
* This action is block accurate, meaning, that the entity will stop once it reached the block the given location is pointing at.
45+
* When the action's execution is started, all other movements or attacks caused by the AI are stopped and overridden.
46+
* If a target is assigned to the entity, it will not be lost and dealing with it will be resumed when this movement is finished.
47+
*
48+
* @param loc the location the entity will move to.
49+
* @param queue whether this action should be added to the queue (true) or executed directly (false).
50+
* @param movementSpeedMultiplicator 1.0 for default speed, 2.0 for doubling the movement speed, and so on. Default is 1.0
51+
* @return {@link ControllableMobAction}
52+
* @throws IllegalArgumentException when movementSpeedMultiplicator is zero or negative
53+
*/
54+
public ControllableMobAction moveTo(Location loc, boolean queue, double movementSpeedMultiplicator) throws IllegalArgumentException;
55+
4056
/**
4157
* Orders the entity to move to the given location. Uses the {@link ControllableMobActions#getDefaultQueuingFlag() default queuing flag}.
4258
* This action is block accurate, meaning, that the entity will stop once it reached the block the given location is pointing at.

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,15 @@ public ControllableMobAction moveTo(Location loc) {
5050

5151
@Override
5252
public ControllableMobAction moveTo(Location loc, boolean queue) {
53-
return this.addAction(new ControllableMobActionMove(this.actionManager, loc, 1.0D), queue);
53+
return this.moveTo(loc, queue, 1.0D);
5454
}
55+
56+
@Override
57+
public ControllableMobAction moveTo(Location loc, boolean queue, double movementSpeedMultiplicator) {
58+
if(movementSpeedMultiplicator <= 0) throw new IllegalArgumentException("movementSpeedMultiplicator must be greater than 0.0");
59+
return this.addAction(new ControllableMobActionMove(this.actionManager, loc, movementSpeedMultiplicator), queue);
60+
}
61+
5562

5663
@Override
5764
public ControllableMobAction lookAt(Location loc) {

0 commit comments

Comments
 (0)