Permalink
Browse files

Add "source" for EVOKER_FANGS in entity_spec() and make them spawnable

  • Loading branch information...
PseudoKnight committed Jun 4, 2018
1 parent 377fc5f commit fbd63c094e432938505a9263f5f6cb12f3d4305b
@@ -1,12 +1,35 @@
package com.laytonsmith.abstraction.bukkit.entities;
import com.laytonsmith.abstraction.MCLivingEntity;
import com.laytonsmith.abstraction.bukkit.BukkitConvertor;
import com.laytonsmith.abstraction.entities.MCEvokerFangs;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EvokerFangs;
import org.bukkit.entity.LivingEntity;
public class BukkitMCEvokerFangs extends BukkitMCEntity implements MCEvokerFangs {
private EvokerFangs ef;
public BukkitMCEvokerFangs(Entity ent) {
super(ent);
ef = (EvokerFangs) ent;
}
@Override
public MCLivingEntity getOwner() {
if(ef.getOwner() == null) {
return null;
}
return (MCLivingEntity) BukkitConvertor.BukkitGetCorrectEntity(ef.getOwner());
}
@Override
public void setOwner(MCLivingEntity owner) {
if(owner == null) {
ef.setOwner(null);
} else {
ef.setOwner((LivingEntity) owner.getHandle());
}
}
}
@@ -1,6 +1,9 @@
package com.laytonsmith.abstraction.entities;
import com.laytonsmith.abstraction.MCEntity;
import com.laytonsmith.abstraction.MCLivingEntity;
public interface MCEvokerFangs extends MCEntity {
MCLivingEntity getOwner();
void setOwner(MCLivingEntity owner);
}
@@ -132,7 +132,7 @@ public boolean isSpawnable() {
ENDER_EYE(true),
ENDER_PEARL(true),
EVOKER(true, MCVersion.MC1_11),
EVOKER_FANGS(false, MCVersion.MC1_11),
EVOKER_FANGS(true, MCVersion.MC1_11),
EXPERIENCE_ORB(true),
/**
* Spawn with world.spawnFallingBlock() I'm not sure what version we switched to FALLING_BLOCK from
@@ -41,6 +41,7 @@
import com.laytonsmith.abstraction.entities.MCCreeper;
import com.laytonsmith.abstraction.entities.MCEnderDragon;
import com.laytonsmith.abstraction.entities.MCEnderman;
import com.laytonsmith.abstraction.entities.MCEvokerFangs;
import com.laytonsmith.abstraction.entities.MCFallingBlock;
import com.laytonsmith.abstraction.entities.MCFirework;
import com.laytonsmith.abstraction.entities.MCGuardian;
@@ -1854,6 +1855,15 @@ public Construct exec(Target t, Environment environment, Construct... args) thro
specArray.set(entity_spec.KEY_ENDERMAN_CARRIED, CNull.NULL, t);
}
break;
case EVOKER_FANGS:
MCEvokerFangs fangs = (MCEvokerFangs) entity;
MCLivingEntity fangsource = fangs.getOwner();
if(fangsource == null) {
specArray.set(entity_spec.KEY_EVOKERFANGS_SOURCE, CNull.NULL, t);
} else {
specArray.set(entity_spec.KEY_EVOKERFANGS_SOURCE, new CString(fangsource.getUniqueId().toString(), t), t);
}
break;
case EXPERIENCE_ORB:
MCExperienceOrb orb = (MCExperienceOrb) entity;
specArray.set(entity_spec.KEY_EXPERIENCE_ORB_AMOUNT, new CInt(orb.getExperience(), t), t);
@@ -2090,6 +2100,7 @@ public CHVersion since() {
private static final String KEY_ENDERDRAGON_PHASE = "phase";
private static final String KEY_ENDERMAN_CARRIED = "carried";
private static final String KEY_EXPERIENCE_ORB_AMOUNT = "amount";
private static final String KEY_EVOKERFANGS_SOURCE = "source";
private static final String KEY_FALLING_BLOCK_BLOCK = "block";
private static final String KEY_FALLING_BLOCK_DROPITEM = "dropitem";
private static final String KEY_FALLING_BLOCK_DAMAGE = "damage";
@@ -2447,6 +2458,23 @@ public Construct exec(Target t, Environment environment, Construct... args) thro
}
}
break;
case EVOKER_FANGS:
MCEvokerFangs fangs = (MCEvokerFangs) entity;
for(String index : specArray.stringKeySet()) {
switch(index.toLowerCase()) {
case entity_spec.KEY_EVOKERFANGS_SOURCE:
Construct source = specArray.get(index, t);
if(source instanceof CNull) {
fangs.setOwner(null);
} else {
fangs.setOwner(Static.getLivingEntity(source, t));
}
break;
default:
throwException(index, t);
}
}
break;
case EXPERIENCE_ORB:
MCExperienceOrb orb = (MCExperienceOrb) entity;
for(String index : specArray.stringKeySet()) {
@@ -70,6 +70,10 @@ without knowing the rotations on the other axis or of other body parts beforehan
|
* %KEY_ENDERMAN_CARRIED%: The block that the Enderman is carring.
|-
| EVOKER_FANGS
|
* %KEY_EVOKERFANGS_SOURCE%: The UUID of the living entity, usually an Evoker, that is the source of the fangs. Can be null.
|-
| EXPERIENCE_ORB
|
* %KEY_EXPERIENCE_ORB_AMOUNT%: How much experience is contained within the orb.

0 comments on commit fbd63c0

Please sign in to comment.