Skip to content
Permalink
Browse files
Add Strider's 'saddled'; Item Frame's 'fixed' and 'visible' to entity…
…_spec()
  • Loading branch information
PseudoKnight committed Jun 30, 2020
1 parent 6ecc8df commit 4b7613f99e91dc25a203f70705e175f29f90b504
Showing 6 changed files with 100 additions and 25 deletions.
@@ -27,12 +27,7 @@ public ItemFrame getHandle() {

@Override
public MCItemStack getItem() {
ItemStack item = getHandle().getItem();
if(item != null) {
return new BukkitMCItemStack(getHandle().getItem());
} else {
return null;
}
return new BukkitMCItemStack(getHandle().getItem());
}

@Override
@@ -53,4 +48,42 @@ public MCRotation getRotation() {
public void setRotation(MCRotation rotation) {
getHandle().setRotation(BukkitMCRotation.getConvertor().getConcreteEnum(rotation));
}

@Override
public boolean isVisible() {
try {
return getHandle().isVisible();
} catch (NoSuchMethodError ex) {
// prior to 1.16
}
return true;
}

@Override
public void setVisible(boolean visible) {
try {
getHandle().setVisible(visible);
} catch (NoSuchMethodError ex) {
// prior to 1.16
}
}

@Override
public boolean isFixed() {
try {
return getHandle().isFixed();
} catch (NoSuchMethodError ex) {
// prior to 1.16
}
return false;
}

@Override
public void setFixed(boolean fixed) {
try {
getHandle().setFixed(fixed);
} catch (NoSuchMethodError ex) {
// prior to 1.16
}
}
}
@@ -2,10 +2,24 @@

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

public class BukkitMCStrider extends BukkitMCAgeable implements MCStrider {

private final Strider s;

public BukkitMCStrider(Entity be) {
super(be);
s = (Strider) be;
}

@Override
public boolean isSaddled() {
return s.hasSaddle();
}

@Override
public void setSaddled(boolean saddled) {
s.setSaddle(saddled);
}
}
@@ -12,4 +12,12 @@ public interface MCItemFrame extends MCHanging {
MCRotation getRotation();

void setRotation(MCRotation rotation);

boolean isVisible();

void setVisible(boolean visible);

boolean isFixed();

void setFixed(boolean fixed);
}
@@ -1,5 +1,6 @@
package com.laytonsmith.abstraction.entities;

public interface MCStrider extends MCAgeable, MCVehicle {

boolean isSaddled();
void setSaddled(boolean saddled);
}
@@ -71,6 +71,7 @@
import com.laytonsmith.abstraction.entities.MCSlime;
import com.laytonsmith.abstraction.entities.MCSnowman;
import com.laytonsmith.abstraction.entities.MCSpectralArrow;
import com.laytonsmith.abstraction.entities.MCStrider;
import com.laytonsmith.abstraction.entities.MCTNT;
import com.laytonsmith.abstraction.entities.MCThrownPotion;
import com.laytonsmith.abstraction.entities.MCTippedArrow;
@@ -1901,13 +1902,10 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
break;
case ITEM_FRAME:
MCItemFrame frame = (MCItemFrame) entity;
MCItemStack itemstack = frame.getItem();
if(itemstack != null) {
specArray.set(entity_spec.KEY_ITEM_FRAME_ITEM, ObjectGenerator.GetGenerator().item(frame.getItem(), t), t);
} else {
specArray.set(entity_spec.KEY_ITEM_FRAME_ITEM, CNull.NULL, t);
}
specArray.set(entity_spec.KEY_ITEM_FRAME_FIXED, CBoolean.get(frame.isFixed()), t);
specArray.set(entity_spec.KEY_ITEM_FRAME_ITEM, ObjectGenerator.GetGenerator().item(frame.getItem(), t), t);
specArray.set(entity_spec.KEY_ITEM_FRAME_ROTATION, new CString(frame.getRotation().name(), t), t);
specArray.set(entity_spec.KEY_ITEM_FRAME_VISIBLE, CBoolean.get(frame.isVisible()), t);
break;
case LIGHTNING:
MCLightningStrike lightning = (MCLightningStrike) entity;
@@ -1976,7 +1974,7 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
break;
case PIG:
MCPig pig = (MCPig) entity;
specArray.set(entity_spec.KEY_PIG_SADDLED, CBoolean.get(pig.isSaddled()), t);
specArray.set(entity_spec.KEY_STEERABLE_SADDLED, CBoolean.get(pig.isSaddled()), t);
break;
case PIGLIN:
MCPiglin piglin = (MCPiglin) entity;
@@ -2038,6 +2036,10 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
MCThrownPotion potion = (MCThrownPotion) entity;
specArray.set(entity_spec.KEY_SPLASH_POTION_ITEM, ObjectGenerator.GetGenerator().item(potion.getItem(), t), t);
break;
case STRIDER:
MCStrider strider = (MCStrider) entity;
specArray.set(entity_spec.KEY_STEERABLE_SADDLED, CBoolean.get(strider.isSaddled()), t);
break;
case TIPPED_ARROW: // 1.13 only
MCTippedArrow tippedarrow = (MCTippedArrow) entity;
specArray.set(entity_spec.KEY_ARROW_CRITICAL, CBoolean.get(tippedarrow.isCritical()), t);
@@ -2176,8 +2178,10 @@ public MSVersion since() {
private static final String KEY_HORSE_ARMOR = "armor";
private static final String KEY_HORSE_SADDLE = "saddle";
private static final String KEY_IRON_GOLEM_PLAYERCREATED = "playercreated";
private static final String KEY_ITEM_FRAME_FIXED = "fixed";
private static final String KEY_ITEM_FRAME_ITEM = "item";
private static final String KEY_ITEM_FRAME_ROTATION = "rotation";
private static final String KEY_ITEM_FRAME_VISIBLE = "visible";
private static final String KEY_LIGHTNING_EFFECT = "effect";
private static final String KEY_MINECART_BLOCK = "block";
private static final String KEY_MINECART_OFFSET = "offset";
@@ -2190,7 +2194,6 @@ public MSVersion since() {
private static final String KEY_PANDA_HIDDENGENE = "hiddengene";
private static final String KEY_PARROT_TYPE = "type";
private static final String KEY_PHANTOM_SIZE = "size";
private static final String KEY_PIG_SADDLED = "saddled";
private static final String KEY_ZOMBIFIED_PIGLIN_ANGRY = "angry";
private static final String KEY_ZOMBIFIED_PIGLIN_ANGER = "anger";
private static final String KEY_RABBIT_TYPE = "type";
@@ -2204,6 +2207,7 @@ public MSVersion since() {
private static final String KEY_SNOWMAN_DERP = "derp";
private static final String KEY_SPECTRAL_ARROW_GLOWING_TICKS = "glowingticks";
private static final String KEY_SPLASH_POTION_ITEM = "item";
private static final String KEY_STEERABLE_SADDLED = "saddled";
private static final String KEY_TIPPEDARROW_POTIONMETA = "potionmeta";
private static final String KEY_TROPICALFISH_COLOR = "color";
private static final String KEY_TROPICALFISH_PATTERN = "pattern";
@@ -2888,13 +2892,11 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
MCItemFrame frame = (MCItemFrame) entity;
for(String index : specArray.stringKeySet()) {
switch(index.toLowerCase()) {
case entity_spec.KEY_ITEM_FRAME_FIXED:
frame.setFixed(ArgumentValidation.getBoolean(specArray.get(index, t), t));
break;
case entity_spec.KEY_ITEM_FRAME_ITEM:
frame.setItem(ObjectGenerator.GetGenerator().item(specArray.get(index, t), t));
if(specArray.get(index, t) instanceof CNull) {
frame.setItem(null);
} else {
frame.setItem(ObjectGenerator.GetGenerator().item(specArray.get(index, t), t));
}
break;
case entity_spec.KEY_ITEM_FRAME_ROTATION:
try {
@@ -2903,6 +2905,9 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
throw new CREFormatException("Invalid rotation type: " + specArray.get(index, t).val(), t);
}
break;
case entity_spec.KEY_ITEM_FRAME_VISIBLE:
frame.setVisible(ArgumentValidation.getBoolean(specArray.get(index, t), t));
break;
default:
throwException(index, t);
}
@@ -3112,7 +3117,7 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
MCPig pig = (MCPig) entity;
for(String index : specArray.stringKeySet()) {
switch(index.toLowerCase()) {
case entity_spec.KEY_PIG_SADDLED:
case entity_spec.KEY_STEERABLE_SADDLED:
pig.setSaddled(ArgumentValidation.getBoolean(specArray.get(index, t), t));
break;
default:
@@ -3302,6 +3307,18 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
}
}
break;
case STRIDER:
MCStrider strider = (MCStrider) entity;
for(String index : specArray.stringKeySet()) {
switch(index.toLowerCase()) {
case entity_spec.KEY_STEERABLE_SADDLED:
strider.setSaddled(ArgumentValidation.getBoolean(specArray.get(index, t), t));
break;
default:
throwException(index, t);
}
}
break;
case TIPPED_ARROW:
MCTippedArrow tippedarrow = (MCTippedArrow) entity;
for(String index : specArray.stringKeySet()) {
@@ -95,7 +95,7 @@ without knowing the rotations on the other axis or of other body parts beforehan
|-
| ENDERMAN
|
* %KEY_ENDERMAN_CARRIED%: The block that the Enderman is carring.
* %KEY_ENDERMAN_CARRIED%: The block that the Enderman is carrying.
|-
| EVOKER_FANGS
|
@@ -142,8 +142,10 @@ without knowing the rotations on the other axis or of other body parts beforehan
|-
| ITEM_FRAME
|
* %KEY_ITEM_FRAME_FIXED%: If true, the item frame cannot be manipulated. (destroyed, rotated, removed, etc) (default false)
* %KEY_ITEM_FRAME_ITEM%: The item in the frame.
* %KEY_ITEM_FRAME_ROTATION%: The rotation of the frame's item (can be %ROTATION%).
* %KEY_ITEM_FRAME_VISIBLE%: If the frame is visible. (default true)
|-
| LLAMA, TRADER_LLAMA
|
@@ -200,9 +202,9 @@ without knowing the rotations on the other axis or of other body parts beforehan
|
* %KEY_PHANTOM_SIZE%: The size of the phantom. Clamped to 0 - 64 (default: 0). Phantoms deal (6 + size) damage.
|-
| PIG
| PIG, STRIDER
|
* %KEY_PIG_SADDLED%: If the pig has a saddle.
* %KEY_STEERABLE_SADDLED%: If the steerable mob has a saddle.
|-
| PRIMED_TNT
|
@@ -301,7 +303,7 @@ without knowing the rotations on the other axis or of other body parts beforehan
* %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)
| ZOMBIFIED_PIGLIN (PIG_ZOMBIE before 1.16)
|
* %KEY_ZOMBIFIED_PIGLIN_ANGER%: The piglin zombie's anger level.
* %KEY_ZOMBIFIED_PIGLIN_ANGRY%: Whether the piglin zombie is angry.

0 comments on commit 4b7613f

Please sign in to comment.