Question: I am trying to make a fire creeper, problem is that the block looping doesn't seem to work. Does someone know how I could fix this?
Java:
@EventHandler
public void onExplode(EntityExplodeEvent e){
if(e.getEntity() instanceof Creeper){
Creeper c = (Creeper) e.getEntity();
if(c.getCustomName() != null){
if(c.getCustomName().equalsIgnoreCase("Fire Creeper")){
Location blockLoc = c.getLocation().add(6, 6, 6);
Location blockLoc2 = c.getLocation().add(6, 6, 6);
List<Block> blocks = getRegionBlocks(c.getWorld(), blockLoc, blockLoc2);
for(Block block : blocks) {
block.setType(Material.DIAMOND_BLOCK);
}
}
}
}
}
public List<Block> getRegionBlocks(World world, Location loc1, Location loc2) {
List<Block> blocks = new ArrayList<Block>();
for(double x = loc1.getX(); x <= loc2.getX(); x++) {
for(double y = loc1.getY(); y <= loc2.getY(); y++) {
for(double z = loc1.getZ(); z <= loc2.getZ(); z++) {
Location loc = new Location(world, x, y, z);
blocks.add(loc.getBlock());
}
}
}
return blocks;
}