Skip to content
Permalink
Browse files
Manage baby state for piglin, zoglin, and hoglin.
Fixes wrapper class for zombified piglin.
  • Loading branch information
PseudoKnight committed Jun 28, 2020
1 parent deab85b commit 093c41e00c22c37b86e8007bb7391fe6dd448a75
Showing 10 changed files with 145 additions and 15 deletions.
@@ -0,0 +1,11 @@
package com.laytonsmith.abstraction.bukkit.entities;

import com.laytonsmith.abstraction.entities.MCHoglin;
import org.bukkit.entity.Entity;

public class BukkitMCHoglin extends BukkitMCAgeable implements MCHoglin {

public BukkitMCHoglin(Entity be) {
super(be);
}
}
@@ -0,0 +1,32 @@
package com.laytonsmith.abstraction.bukkit.entities;

import com.laytonsmith.abstraction.AbstractionObject;
import com.laytonsmith.abstraction.entities.MCPiglin;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Piglin;

public class BukkitMCPiglin extends BukkitMCLivingEntity implements MCPiglin {

public BukkitMCPiglin(Entity zombie) {
super(zombie);
}

public BukkitMCPiglin(AbstractionObject ao) {
this((Piglin) ao.getHandle());
}

@Override
public Piglin getHandle() {
return (Piglin) super.getHandle();
}

@Override
public boolean isBaby() {
return getHandle().isBaby();
}

@Override
public void setBaby(boolean baby) {
getHandle().setBaby(baby);
}
}
@@ -2,14 +2,10 @@

import com.laytonsmith.abstraction.entities.MCStrider;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Strider;

public class BukkitMCStrider extends BukkitMCAgeable implements MCStrider {

Strider s;

public BukkitMCStrider(Entity be) {
super(be);
s = (Strider) be;
}
}
@@ -0,0 +1,32 @@
package com.laytonsmith.abstraction.bukkit.entities;

import com.laytonsmith.abstraction.AbstractionObject;
import com.laytonsmith.abstraction.entities.MCZoglin;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Zoglin;

public class BukkitMCZoglin extends BukkitMCLivingEntity implements MCZoglin {

public BukkitMCZoglin(Entity zombie) {
super(zombie);
}

public BukkitMCZoglin(AbstractionObject ao) {
this((Zoglin) ao.getHandle());
}

@Override
public Zoglin getHandle() {
return (Zoglin) super.getHandle();
}

@Override
public boolean isBaby() {
return getHandle().isBaby();
}

@Override
public void setBaby(boolean baby) {
getHandle().setBaby(baby);
}
}
@@ -0,0 +1,5 @@
package com.laytonsmith.abstraction.entities;

public interface MCHoglin extends MCAgeable {

}
@@ -0,0 +1,8 @@
package com.laytonsmith.abstraction.entities;

import com.laytonsmith.abstraction.MCLivingEntity;

public interface MCPiglin extends MCLivingEntity {
boolean isBaby();
void setBaby(boolean baby);
}
@@ -0,0 +1,8 @@
package com.laytonsmith.abstraction.entities;

import com.laytonsmith.abstraction.MCLivingEntity;

public interface MCZoglin extends MCLivingEntity {
boolean isBaby();
void setBaby(boolean baby);
}
@@ -8,6 +8,7 @@
import com.laytonsmith.abstraction.bukkit.entities.BukkitMCItem;
import com.laytonsmith.abstraction.bukkit.entities.BukkitMCLightningStrike;
import com.laytonsmith.abstraction.bukkit.entities.BukkitMCLlama;
import com.laytonsmith.abstraction.bukkit.entities.BukkitMCPigZombie;
import com.laytonsmith.abstraction.bukkit.entities.BukkitMCStorageMinecart;
import com.laytonsmith.abstraction.bukkit.entities.BukkitMCTNT;
import com.laytonsmith.abstraction.bukkit.entities.BukkitMCThrownPotion;
@@ -145,6 +146,9 @@ private void setWrapperClass() {
case TRADER_LLAMA:
wrapperClass = BukkitMCLlama.class;
break;
case ZOMBIFIED_PIGLIN:
wrapperClass = BukkitMCPigZombie.class;
break;
case UNKNOWN:
wrapperClass = null;
break;
@@ -61,6 +61,7 @@
import com.laytonsmith.abstraction.entities.MCParrot;
import com.laytonsmith.abstraction.entities.MCPhantom;
import com.laytonsmith.abstraction.entities.MCPig;
import com.laytonsmith.abstraction.entities.MCPiglin;
import com.laytonsmith.abstraction.entities.MCPigZombie;
import com.laytonsmith.abstraction.entities.MCProjectile;
import com.laytonsmith.abstraction.entities.MCRabbit;
@@ -79,6 +80,7 @@
import com.laytonsmith.abstraction.entities.MCVillager;
import com.laytonsmith.abstraction.entities.MCWitherSkull;
import com.laytonsmith.abstraction.entities.MCWolf;
import com.laytonsmith.abstraction.entities.MCZoglin;
import com.laytonsmith.abstraction.entities.MCZombie;
import com.laytonsmith.abstraction.entities.MCZombieVillager;
import com.laytonsmith.abstraction.enums.MCArt;
@@ -1976,6 +1978,10 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
MCPig pig = (MCPig) entity;
specArray.set(entity_spec.KEY_PIG_SADDLED, CBoolean.get(pig.isSaddled()), t);
break;
case PIGLIN:
MCPiglin piglin = (MCPiglin) entity;
specArray.set(entity_spec.KEY_GENERIC_BABY, CBoolean.get(piglin.isBaby()), t);
break;
case PRIMED_TNT:
MCTNT tnt = (MCTNT) entity;
specArray.set(entity_spec.KEY_PRIMED_TNT_FUSETICKS, new CInt(tnt.getFuseTicks(), t), t);
@@ -2076,23 +2082,27 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
specArray.set(entity_spec.KEY_WOLF_COLOR, new CString(wolf.getCollarColor().name(), t), t);
specArray.set(entity_spec.KEY_GENERIC_SITTING, CBoolean.get(wolf.isSitting()), t);
break;
case ZOGLIN:
MCZoglin zoglin = (MCZoglin) entity;
specArray.set(entity_spec.KEY_GENERIC_BABY, CBoolean.get(zoglin.isBaby()), t);
break;
case ZOMBIE:
case DROWNED:
case HUSK:
MCZombie zombie = (MCZombie) entity;
specArray.set(entity_spec.KEY_ZOMBIE_BABY, CBoolean.get(zombie.isBaby()), t);
specArray.set(entity_spec.KEY_GENERIC_BABY, CBoolean.get(zombie.isBaby()), t);
break;
case ZOMBIE_VILLAGER:
MCZombieVillager zombievillager = (MCZombieVillager) entity;
specArray.set(entity_spec.KEY_ZOMBIE_BABY, CBoolean.get(zombievillager.isBaby()), t);
specArray.set(entity_spec.KEY_GENERIC_BABY, CBoolean.get(zombievillager.isBaby()), t);
specArray.set(entity_spec.KEY_VILLAGER_PROFESSION, new CString(zombievillager.getProfession().name(), t), t);
break;
case ZOMBIFIED_PIGLIN:
case PIG_ZOMBIE:
MCPigZombie pigZombie = (MCPigZombie) entity;
specArray.set(entity_spec.KEY_ZOMBIFIED_PIGLIN_ANGRY, CBoolean.get(pigZombie.isAngry()), t);
specArray.set(entity_spec.KEY_ZOMBIFIED_PIGLIN_ANGER, new CInt(pigZombie.getAnger(), t), t);
specArray.set(entity_spec.KEY_ZOMBIE_BABY, CBoolean.get(pigZombie.isBaby()), t);
specArray.set(entity_spec.KEY_GENERIC_BABY, CBoolean.get(pigZombie.isBaby()), t);
break;
}
return specArray;
@@ -2105,6 +2115,7 @@ public MSVersion since() {

//used to ensure that the indexes are the same in entity_spec(), set_entity_spec(), and in the documentation.
private static final String KEY_GENERIC_SITTING = "sitting";
private static final String KEY_GENERIC_BABY = "baby";
private static final String KEY_AREAEFFECTCLOUD_COLOR = "color";
private static final String KEY_AREAEFFECTCLOUD_DURATION = "duration";
private static final String KEY_AREAEFFECTCLOUD_DURATIONONUSE = "durationonuse";
@@ -2204,7 +2215,6 @@ public MSVersion since() {
private static final String KEY_WITHER_SKULL_CHARGED = "charged";
private static final String KEY_WOLF_ANGRY = "angry";
private static final String KEY_WOLF_COLOR = "color";
private static final String KEY_ZOMBIE_BABY = "baby";
}

@api(environments = {CommandHelperEnvironment.class})
@@ -3110,6 +3120,18 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
}
}
break;
case PIGLIN:
MCPiglin piglin = (MCPiglin) entity;
for(String index : specArray.stringKeySet()) {
switch(index.toLowerCase()) {
case entity_spec.KEY_GENERIC_BABY:
piglin.setBaby(ArgumentValidation.getBoolean(specArray.get(index, t), t));
break;
default:
throwException(index, t);
}
}
break;
case PRIMED_TNT:
MCTNT tnt = (MCTNT) entity;
for(String index : specArray.stringKeySet()) {
@@ -3470,13 +3492,25 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
}
}
break;
case ZOGLIN:
MCZoglin zoglin = (MCZoglin) entity;
for(String index : specArray.stringKeySet()) {
switch(index.toLowerCase()) {
case entity_spec.KEY_GENERIC_BABY:
zoglin.setBaby(ArgumentValidation.getBoolean(specArray.get(index, t), t));
break;
default:
throwException(index, t);
}
}
break;
case ZOMBIE:
case DROWNED:
case HUSK:
MCZombie zombie = (MCZombie) entity;
for(String index : specArray.stringKeySet()) {
switch(index.toLowerCase()) {
case entity_spec.KEY_ZOMBIE_BABY:
case entity_spec.KEY_GENERIC_BABY:
zombie.setBaby(ArgumentValidation.getBoolean(specArray.get(index, t), t));
break;
default:
@@ -3488,7 +3522,7 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
MCZombieVillager zombievillager = (MCZombieVillager) entity;
for(String index : specArray.stringKeySet()) {
switch(index.toLowerCase()) {
case entity_spec.KEY_ZOMBIE_BABY:
case entity_spec.KEY_GENERIC_BABY:
zombievillager.setBaby(ArgumentValidation.getBoolean(specArray.get(index, t), t));
break;
case entity_spec.KEY_VILLAGER_PROFESSION:
@@ -3508,7 +3542,7 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
MCPigZombie pigZombie = (MCPigZombie) entity;
for(String index : specArray.stringKeySet()) {
switch(index.toLowerCase()) {
case entity_spec.KEY_ZOMBIE_BABY:
case entity_spec.KEY_GENERIC_BABY:
pigZombie.setBaby(ArgumentValidation.getBoolean(specArray.get(index, t), t));
break;
case entity_spec.KEY_ZOMBIFIED_PIGLIN_ANGRY:
@@ -292,18 +292,18 @@ without knowing the rotations on the other axis or of other body parts beforehan
* %KEY_WOLF_COLOR%: The collar color of the wolf (can be %DYE_COLOR%).
* %KEY_GENERIC_SITTING%: If the wolf is sitting.
|-
| ZOMBIE, HUSK, DROWNED
| ZOMBIE, HUSK, DROWNED, ZOGLIN, PIGLIN
|
* %KEY_ZOMBIE_BABY%: Whether the zombie is a baby.
* %KEY_GENERIC_BABY%: Whether the zombie is a baby.
|-
| ZOMBIE_VILLAGER
|
* %KEY_ZOMBIE_BABY%: Whether the zombie is a baby.
* %KEY_GENERIC_BABY%: Whether the zombie is a baby.
* %KEY_VILLAGER_PROFESSION%: The profession of the villager (can be %PROFESSION%).
|-
| ZOMBIFIED_PIGLIN (formerly PIG_ZOMBIE)
|
* %KEY_ZOMBIFIED_PIGLIN_ANGER%: The piglin zombie's anger level.
* %KEY_ZOMBIFIED_PIGLIN_ANGRY%: Whether the piglin zombie is angry.
* %KEY_ZOMBIE_BABY%: Whether the pig zombie is a baby.
* %KEY_GENERIC_BABY%: Whether the pig zombie is a baby.
|}

0 comments on commit 093c41e

Please sign in to comment.