Add implementation of the elder Guardian API

This commit is contained in:
md_5 2014-12-12 10:56:20 +11:00
parent 3b1c7d708e
commit 9fa497cd55
5 changed files with 81 additions and 4 deletions

View File

@ -50,6 +50,16 @@
public int getId() {
return this.id;
@@ -135,7 +169,8 @@
this.dead = true;
}
- protected void a(float f, float f1) {
+ // PAIL: Access + rename please
+ public void a(float f, float f1) { // CraftBukkit - protected to public
if (f != this.width || f1 != this.length) {
float f2 = this.width;
@@ -150,6 +184,33 @@
}

View File

@ -1,5 +1,5 @@
--- ../work/decompile-8eb82bde//net/minecraft/server/EntityAgeable.java 2014-11-28 17:43:43.061707436 +0000
+++ src/main/java/net/minecraft/server/EntityAgeable.java 2014-11-28 17:38:22.000000000 +0000
--- ../work/decompile-8eb82bde//net/minecraft/server/EntityAgeable.java Thu Dec 4 19:00:43 2014
+++ src/main/java/net/minecraft/server/EntityAgeable.java Thu Dec 4 18:45:16 2014
@@ -7,6 +7,7 @@
protected int c;
private float bk = -1.0F;
@ -46,3 +46,12 @@
if (this.c > 0) {
if (this.c % 4 == 0) {
this.world.addParticle(EnumParticle.VILLAGER_HAPPY, this.locX + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, this.locY + 0.5D + (double) (this.random.nextFloat() * this.length), this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, 0.0D, 0.0D, 0.0D, new int[0]);
@@ -146,7 +149,7 @@
this.a(flag ? 0.5F : 1.0F);
}
- protected final void a(float f, float f1) {
+ public final void a(float f, float f1) { // CraftBukkit - protected to public
boolean flag = this.bk > 0.0F;
this.bk = f;

View File

@ -0,0 +1,21 @@
--- ../work/decompile-8eb82bde//net/minecraft/server/EntityGuardian.java Thu Dec 11 13:57:14 2014
+++ src/main/java/net/minecraft/server/EntityGuardian.java Thu Dec 11 13:55:14 2014
@@ -14,7 +14,7 @@
private EntityLiving bn;
private int bo;
private boolean bp;
- private PathfinderGoalRandomStroll bq;
+ public PathfinderGoalRandomStroll bq; // CraftBukkit - private to public
public EntityGuardian(World world) {
super(world);
@@ -35,7 +35,8 @@
this.c = this.b = this.random.nextFloat();
}
- protected void aW() {
+ // PAIL: Access + rename please
+ public void aW() { // CraftBukkit - protected to public
super.aW();
this.getAttributeInstance(GenericAttributes.e).setValue(6.0D);
this.getAttributeInstance(GenericAttributes.d).setValue(0.5D);

View File

@ -1,5 +1,5 @@
--- ../work/decompile-8eb82bde//net/minecraft/server/EntityZombie.java 2014-11-28 17:43:43.185707433 +0000
+++ src/main/java/net/minecraft/server/EntityZombie.java 2014-11-28 17:38:22.000000000 +0000
--- ../work/decompile-8eb82bde//net/minecraft/server/EntityZombie.java Thu Dec 11 13:57:17 2014
+++ src/main/java/net/minecraft/server/EntityZombie.java Thu Dec 11 13:56:17 2014
@@ -4,6 +4,14 @@
import java.util.List;
import java.util.UUID;
@ -106,3 +106,13 @@
entityvillager.addEffect(new MobEffect(MobEffectList.CONFUSION.id, 200, 0));
this.world.a((EntityHuman) null, 1017, new BlockPosition((int) this.locX, (int) this.locY, (int) this.locZ), 0);
}
@@ -487,7 +516,8 @@
this.a(flag ? 0.5F : 1.0F);
}
- protected final void a(float f, float f1) {
+ // PAIL: Access + rename please
+ public final void a(float f, float f1) { // CraftBukkit - protected to public
boolean flag = this.bo > 0.0F && this.bp > 0.0F;
this.bo = f;

View File

@ -1,6 +1,7 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityGuardian;
import net.minecraft.server.GenericAttributes;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Guardian;
@ -20,4 +21,30 @@ public class CraftGuardian extends CraftMonster implements Guardian {
public EntityType getType() {
return EntityType.GUARDIAN;
}
@Override
public boolean isElder() {
return ((EntityGuardian)entity).cl();
}
@Override
public void setElder( boolean shouldBeElder ) {
EntityGuardian entityGuardian = (EntityGuardian) entity;
if (!isElder() && shouldBeElder) {
entityGuardian.a( true );
} else if (isElder() && !shouldBeElder) {
entityGuardian.a( false );
// Since minecraft does not reset the elder Guardian to a guardian we have to do that
entity.a(0.85F, 0.85F);
entityGuardian.aW();
// Update pathfinding (random stroll back to 80)
entityGuardian.bq.b(80);
// Tell minecraft that we need persistence since the guardian changed
entityGuardian.bW();
}
}
}