Skip to content

Commit

Permalink
Add "delay" meta for MOB_SPAWNER
Browse files Browse the repository at this point in the history
  • Loading branch information
PseudoKnight committed Apr 26, 2018
1 parent a7b6d8c commit 314146e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
Expand Up @@ -4,8 +4,8 @@
import com.laytonsmith.abstraction.enums.MCEntityType;

public interface MCCreatureSpawner extends MCBlockState {

MCEntityType getSpawnedType();

void setSpawnedType(MCEntityType type);
int getDelay();
void setDelay(int delay);
}
Expand Up @@ -25,4 +25,15 @@ public void setSpawnedType(MCEntityType type) {
cs.setSpawnedType(((BukkitMCEntityType) type).getConcrete());
cs.update();
}

@Override
public int getDelay() {
return cs.getDelay();
}

@Override
public void setDelay(int delay) {
cs.setDelay(delay);
cs.update();
}
}
9 changes: 7 additions & 2 deletions src/main/java/com/laytonsmith/core/ObjectGenerator.java
Expand Up @@ -400,6 +400,7 @@ public Construct itemMeta(MCItemStack is, Target t) {
} else if(bs instanceof MCCreatureSpawner) {
MCCreatureSpawner mccs = (MCCreatureSpawner) bs;
ma.set("spawntype", mccs.getSpawnedType().name());
ma.set("delay", new CInt(mccs.getDelay(), t), t);
} else if(bs instanceof MCBrewingStand) {
MCBrewingStand brewStand = (MCBrewingStand) bs;
ma.set("brewtime", new CInt(brewStand.getBrewingTime(), t), t);
Expand Down Expand Up @@ -679,12 +680,16 @@ public MCItemMeta itemMeta(Construct c, MCMaterial mat, Target t) throws ConfigR
banner.update();
bsm.setBlockState(banner);
} else if(bs instanceof MCCreatureSpawner) {
MCCreatureSpawner mccs = (MCCreatureSpawner) bs;
if(ma.containsKey("spawntype")) {
MCCreatureSpawner mccs = (MCCreatureSpawner) bs;
MCEntityType type = MCEntityType.valueOf(ma.get("spawntype", t).val().toUpperCase());
mccs.setSpawnedType(type);
bsm.setBlockState(bs);
}
if(ma.containsKey("delay")) {
int delay = Static.getInt32(ma.get("delay", t), t);
mccs.setDelay(delay);
}
bsm.setBlockState(bs);
} else if(bs instanceof MCBrewingStand) {
MCBrewingStand brewStand = (MCBrewingStand) bs;
if(ma.containsKey("brewtime")) {
Expand Down

0 comments on commit 314146e

Please sign in to comment.