Skip to content

Commit eec9d95

Browse files
committed
1 parent d826630 commit eec9d95

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

src/main/java/twilightforest/entity/ai/EntityAITFThrowRider.java

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package twilightforest.entity.ai;
22

3+
import net.minecraft.entity.Entity;
34
import net.minecraft.entity.EntityCreature;
4-
import net.minecraft.entity.EntityLivingBase;
55
import net.minecraft.entity.ai.EntityAIBase;
66
import net.minecraft.entity.player.EntityPlayerMP;
77
import net.minecraft.util.math.Vec3d;
@@ -10,24 +10,19 @@
1010
import twilightforest.network.PacketThrowPlayer;
1111

1212
public class EntityAITFThrowRider extends EntityAIBase {
13-
14-
15-
private EntityCreature theEntityCreature;
13+
private final EntityCreature theEntityCreature;
1614
private int throwTimer;
1715

18-
1916
public EntityAITFThrowRider(EntityCreature par1EntityCreature, float par2)
2017
{
2118
this.theEntityCreature = par1EntityCreature;
2219
this.setMutexBits(1);
2320
}
24-
/**
25-
* Returns whether the EntityAIBase should begin execution.
26-
*/
21+
2722
@Override
2823
public boolean shouldExecute()
2924
{
30-
if (this.theEntityCreature.getRidingEntity() == null || this.theEntityCreature.getRNG().nextInt(5) > 0)
25+
if (this.theEntityCreature.getPassengers().isEmpty() || this.theEntityCreature.getRNG().nextInt(5) > 0)
3126
{
3227
return false;
3328
}
@@ -37,23 +32,17 @@ public boolean shouldExecute()
3732
}
3833
}
3934

40-
/**
41-
* Execute a one shot task or start executing a continuous task
42-
*/
4335
@Override
4436
public void startExecuting()
4537
{
46-
EntityLivingBase rider = (EntityLivingBase) this.theEntityCreature.getRidingEntity();
47-
rider.dismountEntity(theEntityCreature);
38+
Entity rider = this.theEntityCreature.getPassengers().get(0);
39+
rider.dismountRidingEntity();
4840

4941
Vec3d throwVec = this.theEntityCreature.getLookVec().scale(2);
50-
51-
// let's throw the player a fixed value in the air
5242
throwVec = new Vec3d(throwVec.xCoord, 0.9, throwVec.zCoord);
5343

5444
rider.addVelocity(throwVec.xCoord, throwVec.yCoord, throwVec.zCoord);
5545

56-
// if we're throwing a player (probably!), send a packet with the velocity
5746
if (rider instanceof EntityPlayerMP) {
5847
EntityPlayerMP player = (EntityPlayerMP)rider;
5948

@@ -64,13 +53,10 @@ public void startExecuting()
6453
this.throwTimer = 0;
6554
}
6655

67-
/**
68-
* Returns whether an in-progress EntityAIBase should continue executing
69-
*/
7056
@Override
7157
public boolean shouldContinueExecuting()
7258
{
73-
if (this.theEntityCreature.getRidingEntity() == null) {
59+
if (this.theEntityCreature.getPassengers().isEmpty()) {
7460
this.throwTimer++;
7561
}
7662

0 commit comments

Comments
 (0)