Permalink
Browse files

Add maxfuseticks and explosionradius to Creeper entity_spec()

  • Loading branch information...
PseudoKnight committed Nov 11, 2017
1 parent f4832fd commit 5dd9e82eb5befc4f978f4740cc70c20f657e0711
@@ -6,10 +6,6 @@
import org.bukkit.entity.Creeper;
import org.bukkit.entity.Entity;
/**
*
* @author Jason Unger <entityreborn@gmail.com>
*/
public class BukkitMCCreeper extends BukkitMCLivingEntity implements MCCreeper {
Creeper creeper;
@@ -31,4 +27,42 @@ public boolean isPowered() {
public void setPowered(boolean powered) {
creeper.setPowered(powered);
}
@Override
public int getMaxFuseTicks() {
try {
return creeper.getMaxFuseTicks();
} catch(NoSuchMethodError ex) {
// Probably prior to 1.12.2
return 30;
}
}
@Override
public void setMaxFuseTicks(int ticks) {
try {
creeper.setMaxFuseTicks(ticks);
} catch(NoSuchMethodError ex){
// Probably prior to 1.12.2
}
}
@Override
public int getExplosionRadius() {
try {
return creeper.getExplosionRadius();
} catch(NoSuchMethodError ex) {
// Probably prior to 1.12.2
return 3;
}
}
@Override
public void setExplosionRadius(int radius) {
try {
creeper.setExplosionRadius(radius);
} catch(NoSuchMethodError ex) {
// Probably prior to 1.12.2
}
}
}
@@ -1,11 +1,11 @@
package com.laytonsmith.abstraction.entities;
/**
*
* @author Jason Unger <entityreborn@gmail.com>
*/
public interface MCCreeper {
boolean isPowered();
void setPowered(boolean powered);
int getMaxFuseTicks();
void setMaxFuseTicks(int ticks);
int getExplosionRadius();
void setExplosionRadius(int radius);
}
@@ -2677,6 +2677,8 @@ public Construct exec(Target t, Environment environment, Construct... args) thro
case CREEPER:
MCCreeper creeper = (MCCreeper) entity;
specArray.set(entity_spec.KEY_CREEPER_POWERED, CBoolean.get(creeper.isPowered()), t);
specArray.set(entity_spec.KEY_CREEPER_MAXFUSETICKS, new CInt(creeper.getMaxFuseTicks(), t), t);
specArray.set(entity_spec.KEY_CREEPER_EXPLOSIONRADIUS, new CInt(creeper.getExplosionRadius(), t), t);
break;
case DONKEY:
case MULE:
@@ -2938,6 +2940,8 @@ public CHVersion since() {
private static final String KEY_ARMORSTAND_SMALLSIZE = "small";
private static final String KEY_ARMORSTAND_VISIBLE = "visible";
private static final String KEY_CREEPER_POWERED = "powered";
private static final String KEY_CREEPER_MAXFUSETICKS = "maxfuseticks";
private static final String KEY_CREEPER_EXPLOSIONRADIUS = "explosionradius";
private static final String KEY_DROPPED_ITEM_ITEMSTACK = "itemstack";
private static final String KEY_DROPPED_ITEM_PICKUPDELAY = "pickupdelay";
private static final String KEY_ENDERCRYSTAL_BASE = "base";
@@ -3188,6 +3192,20 @@ public Construct exec(Target t, Environment environment, Construct... args) thro
case entity_spec.KEY_CREEPER_POWERED:
creeper.setPowered(Static.getBoolean(specArray.get(index, t)));
break;
case entity_spec.KEY_CREEPER_MAXFUSETICKS:
try {
creeper.setMaxFuseTicks(Static.getInt32(specArray.get(index, t), t));
} catch(IllegalArgumentException ex) {
throw new CRERangeException("Ticks must not be negative.", t);
}
break;
case entity_spec.KEY_CREEPER_EXPLOSIONRADIUS:
try {
creeper.setExplosionRadius(Static.getInt32(specArray.get(index, t), t));
} catch(IllegalArgumentException ex) {
throw new CRERangeException("Radius must not be negative.", t);
}
break;
default:
throwException(index, t);
}
@@ -41,6 +41,8 @@ without knowing the rotations on the other axis or of other body parts beforehan
| CREEPER
|
* %KEY_CREEPER_POWERED%: If the Creeper is powered or not.
* %KEY_CREEPER_MAXFUSETICKS%: The max amount of time in server ticks that the Creeper can be primed before exploding.
* %KEY_CREEPER_EXPLOSIONRADIUS%: The radius of the Creeper's explosion.
|-
| DONKEY, MULE
|

0 comments on commit 5dd9e82

Please sign in to comment.