Add variant API to MushroomCow

This commit is contained in:
md_5 2019-04-26 14:48:19 +10:00
parent abab38526a
commit 4b9b0f4d5b
2 changed files with 23 additions and 0 deletions

View file

@ -47,3 +47,12 @@
for (i = 0; i < 5; ++i) { for (i = 0; i < 5; ++i) {
this.world.addEntity(new EntityItem(this.world, this.locX, this.locY + (double) this.getHeight(), this.locZ, new ItemStack(this.dV().d.getBlock()))); this.world.addEntity(new EntityItem(this.world, this.locX, this.locY + (double) this.getHeight(), this.locZ, new ItemStack(this.dV().d.getBlock())));
@@ -156,7 +176,7 @@
return Pair.of(blockflowers.d(), blockflowers.e());
}
- private void a(EntityMushroomCow.Type entitymushroomcow_type) {
+ public void a(EntityMushroomCow.Type entitymushroomcow_type) { // PAIL
this.datawatcher.set(EntityMushroomCow.bz, entitymushroomcow_type.c);
}

View file

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.entity; package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions;
import net.minecraft.server.EntityMushroomCow; import net.minecraft.server.EntityMushroomCow;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -15,11 +16,24 @@ public class CraftMushroomCow extends CraftCow implements MushroomCow {
return (EntityMushroomCow) entity; return (EntityMushroomCow) entity;
} }
@Override
public Variant getVariant() {
return Variant.values()[getHandle().dV().ordinal()];
}
@Override
public void setVariant(Variant variant) {
Preconditions.checkArgument(variant != null, "variant");
getHandle().a(EntityMushroomCow.Type.values()[variant.ordinal()]);
}
@Override @Override
public String toString() { public String toString() {
return "CraftMushroomCow"; return "CraftMushroomCow";
} }
@Override
public EntityType getType() { public EntityType getType() {
return EntityType.MUSHROOM_COW; return EntityType.MUSHROOM_COW;
} }