Skip to content

Commit fbd63c0

Browse files
committed
Add "source" for EVOKER_FANGS in entity_spec() and make them spawnable
1 parent 377fc5f commit fbd63c0

5 files changed

Lines changed: 59 additions & 1 deletion

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,35 @@
11
package com.laytonsmith.abstraction.bukkit.entities;
22

3+
import com.laytonsmith.abstraction.MCLivingEntity;
4+
import com.laytonsmith.abstraction.bukkit.BukkitConvertor;
35
import com.laytonsmith.abstraction.entities.MCEvokerFangs;
46
import org.bukkit.entity.Entity;
7+
import org.bukkit.entity.EvokerFangs;
8+
import org.bukkit.entity.LivingEntity;
59

610
public class BukkitMCEvokerFangs extends BukkitMCEntity implements MCEvokerFangs {
711

12+
private EvokerFangs ef;
13+
814
public BukkitMCEvokerFangs(Entity ent) {
915
super(ent);
16+
ef = (EvokerFangs) ent;
17+
}
18+
19+
@Override
20+
public MCLivingEntity getOwner() {
21+
if(ef.getOwner() == null) {
22+
return null;
23+
}
24+
return (MCLivingEntity) BukkitConvertor.BukkitGetCorrectEntity(ef.getOwner());
1025
}
1126

27+
@Override
28+
public void setOwner(MCLivingEntity owner) {
29+
if(owner == null) {
30+
ef.setOwner(null);
31+
} else {
32+
ef.setOwner((LivingEntity) owner.getHandle());
33+
}
34+
}
1235
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package com.laytonsmith.abstraction.entities;
22

33
import com.laytonsmith.abstraction.MCEntity;
4+
import com.laytonsmith.abstraction.MCLivingEntity;
45

56
public interface MCEvokerFangs extends MCEntity {
7+
MCLivingEntity getOwner();
8+
void setOwner(MCLivingEntity owner);
69
}

src/main/java/com/laytonsmith/abstraction/enums/MCEntityType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public enum MCVanillaEntityType {
132132
ENDER_EYE(true),
133133
ENDER_PEARL(true),
134134
EVOKER(true, MCVersion.MC1_11),
135-
EVOKER_FANGS(false, MCVersion.MC1_11),
135+
EVOKER_FANGS(true, MCVersion.MC1_11),
136136
EXPERIENCE_ORB(true),
137137
/**
138138
* Spawn with world.spawnFallingBlock() I'm not sure what version we switched to FALLING_BLOCK from

src/main/java/com/laytonsmith/core/functions/EntityManagement.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import com.laytonsmith.abstraction.entities.MCCreeper;
4242
import com.laytonsmith.abstraction.entities.MCEnderDragon;
4343
import com.laytonsmith.abstraction.entities.MCEnderman;
44+
import com.laytonsmith.abstraction.entities.MCEvokerFangs;
4445
import com.laytonsmith.abstraction.entities.MCFallingBlock;
4546
import com.laytonsmith.abstraction.entities.MCFirework;
4647
import com.laytonsmith.abstraction.entities.MCGuardian;
@@ -1854,6 +1855,15 @@ public Construct exec(Target t, Environment environment, Construct... args) thro
18541855
specArray.set(entity_spec.KEY_ENDERMAN_CARRIED, CNull.NULL, t);
18551856
}
18561857
break;
1858+
case EVOKER_FANGS:
1859+
MCEvokerFangs fangs = (MCEvokerFangs) entity;
1860+
MCLivingEntity fangsource = fangs.getOwner();
1861+
if(fangsource == null) {
1862+
specArray.set(entity_spec.KEY_EVOKERFANGS_SOURCE, CNull.NULL, t);
1863+
} else {
1864+
specArray.set(entity_spec.KEY_EVOKERFANGS_SOURCE, new CString(fangsource.getUniqueId().toString(), t), t);
1865+
}
1866+
break;
18571867
case EXPERIENCE_ORB:
18581868
MCExperienceOrb orb = (MCExperienceOrb) entity;
18591869
specArray.set(entity_spec.KEY_EXPERIENCE_ORB_AMOUNT, new CInt(orb.getExperience(), t), t);
@@ -2090,6 +2100,7 @@ public CHVersion since() {
20902100
private static final String KEY_ENDERDRAGON_PHASE = "phase";
20912101
private static final String KEY_ENDERMAN_CARRIED = "carried";
20922102
private static final String KEY_EXPERIENCE_ORB_AMOUNT = "amount";
2103+
private static final String KEY_EVOKERFANGS_SOURCE = "source";
20932104
private static final String KEY_FALLING_BLOCK_BLOCK = "block";
20942105
private static final String KEY_FALLING_BLOCK_DROPITEM = "dropitem";
20952106
private static final String KEY_FALLING_BLOCK_DAMAGE = "damage";
@@ -2447,6 +2458,23 @@ public Construct exec(Target t, Environment environment, Construct... args) thro
24472458
}
24482459
}
24492460
break;
2461+
case EVOKER_FANGS:
2462+
MCEvokerFangs fangs = (MCEvokerFangs) entity;
2463+
for(String index : specArray.stringKeySet()) {
2464+
switch(index.toLowerCase()) {
2465+
case entity_spec.KEY_EVOKERFANGS_SOURCE:
2466+
Construct source = specArray.get(index, t);
2467+
if(source instanceof CNull) {
2468+
fangs.setOwner(null);
2469+
} else {
2470+
fangs.setOwner(Static.getLivingEntity(source, t));
2471+
}
2472+
break;
2473+
default:
2474+
throwException(index, t);
2475+
}
2476+
}
2477+
break;
24502478
case EXPERIENCE_ORB:
24512479
MCExperienceOrb orb = (MCExperienceOrb) entity;
24522480
for(String index : specArray.stringKeySet()) {

src/main/resources/functionDocs/entity_spec

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ without knowing the rotations on the other axis or of other body parts beforehan
7070
|
7171
* %KEY_ENDERMAN_CARRIED%: The block that the Enderman is carring.
7272
|-
73+
| EVOKER_FANGS
74+
|
75+
* %KEY_EVOKERFANGS_SOURCE%: The UUID of the living entity, usually an Evoker, that is the source of the fangs. Can be null.
76+
|-
7377
| EXPERIENCE_ORB
7478
|
7579
* %KEY_EXPERIENCE_ORB_AMOUNT%: How much experience is contained within the orb.

0 commit comments

Comments
 (0)