use of org.bukkit.entity.Zombie in project MagicPlugin by elBukkit.
the class EntityZombieData method apply.
@Override
public void apply(Entity entity) {
if (!(entity instanceof Zombie))
return;
Zombie zombie = (Zombie) entity;
zombie.setBaby(isBaby);
}
use of org.bukkit.entity.Zombie in project MagicPlugin by elBukkit.
the class ShrinkSpell method onCast.
@Override
public SpellResult onCast(ConfigurationSection parameters) {
String giveName = parameters.getString("name");
if (giveName != null) {
String itemName = giveName + "'s Head";
Player player = Bukkit.getPlayer(giveName);
if (player != null) {
dropPlayerHead(getLocation(), player, itemName);
} else {
dropPlayerHead(getLocation(), giveName, itemName);
}
return SpellResult.CAST;
}
Target target = getTarget();
if (target.hasEntity()) {
Entity targetEntity = target.getEntity();
if (controller.isElemental(targetEntity)) {
double elementalSize = controller.getElementalScale(targetEntity);
if (elementalSize < 0.1) {
int elementalDamage = parameters.getInt("elemental_damage", DEFAULT_ENTITY_DAMAGE);
controller.damageElemental(targetEntity, elementalDamage, 0, mage.getCommandSender());
} else {
elementalSize /= 2;
controller.setElementalScale(targetEntity, elementalSize);
}
return SpellResult.CAST;
}
if (!(targetEntity instanceof LivingEntity))
return SpellResult.NO_TARGET;
// Register for undo in advance to catch entity death.
registerForUndo();
int damage = parameters.getInt("entity_damage", DEFAULT_ENTITY_DAMAGE);
LivingEntity li = (LivingEntity) targetEntity;
boolean alreadyDead = li.isDead() || li.getHealth() <= 0;
String ownerName = null;
String itemName = null;
byte data = 3;
if (li instanceof Player) {
damage = parameters.getInt("player_damage", DEFAULT_PLAYER_DAMAGE);
ownerName = ((Player) li).getName();
} else {
itemName = li.getType().getName() + " Head";
switch(li.getType()) {
case CREEPER:
data = 4;
break;
case ZOMBIE:
data = 2;
break;
case SKELETON:
Skeleton skeleton = (Skeleton) li;
data = (byte) (skeleton.getSkeletonType() == SkeletonType.NORMAL ? 0 : 1);
break;
default:
ownerName = getMobSkin(li.getType());
}
}
if (itemName == null && ownerName != null) {
itemName = ownerName + "'s Head";
}
Location targetLocation = targetEntity.getLocation();
if (li instanceof Player) {
CompatibilityUtils.magicDamage(li, damage, mage.getEntity());
if (li.isDead() && !alreadyDead) {
dropPlayerHead(targetEntity.getLocation(), (Player) li, itemName);
}
} else if (li.getType() == EntityType.GIANT) {
UndoList spawnedList = com.elmakers.mine.bukkit.block.UndoList.getUndoList(li);
registerModified(li);
li.remove();
Entity zombie = targetLocation.getWorld().spawnEntity(targetLocation, EntityType.ZOMBIE);
if (zombie instanceof Zombie) {
((Zombie) zombie).setBaby(false);
}
registerForUndo(zombie);
if (spawnedList != null) {
spawnedList.add(zombie);
}
} else if (li instanceof Ageable && ((Ageable) li).isAdult() && !(li instanceof Player)) {
registerModified(li);
((Ageable) li).setBaby();
} else if (li instanceof Zombie && !((Zombie) li).isBaby()) {
registerModified(li);
((Zombie) li).setBaby(true);
} else if (li instanceof PigZombie && !((PigZombie) li).isBaby()) {
registerModified(li);
((PigZombie) li).setBaby(true);
} else if (li instanceof Slime && ((Slime) li).getSize() > 1) {
registerModified(li);
Slime slime = (Slime) li;
slime.setSize(slime.getSize() - 1);
} else {
CompatibilityUtils.magicDamage(li, damage, mage.getEntity());
if ((ownerName != null || data != 3) && (li.isDead() || li.getHealth() == 0) && !alreadyDead) {
dropHead(targetEntity.getLocation(), ownerName, itemName, data);
}
}
} else {
Block targetBlock = target.getBlock();
if (targetBlock == null) {
return SpellResult.NO_TARGET;
}
String blockSkin = getBlockSkin(targetBlock.getType());
if (blockSkin == null)
return SpellResult.NO_TARGET;
if (!hasBreakPermission(targetBlock)) {
return SpellResult.INSUFFICIENT_PERMISSION;
}
if (mage.isIndestructible(targetBlock)) {
return SpellResult.NO_TARGET;
}
registerForUndo(targetBlock);
registerForUndo();
dropHead(targetBlock.getLocation(), blockSkin, targetBlock.getType().name(), (byte) 3);
targetBlock.setType(Material.AIR);
}
return SpellResult.CAST;
}
use of org.bukkit.entity.Zombie in project MagicPlugin by elBukkit.
the class ShrinkEntityAction method perform.
@Override
public SpellResult perform(CastContext context) {
Entity targetEntity = context.getTargetEntity();
MageController controller = context.getController();
if (controller.isElemental(targetEntity)) {
double elementalSize = controller.getElementalScale(targetEntity);
if (elementalSize < 0.1) {
return super.perform(context);
}
elementalSize /= 2;
controller.setElementalScale(targetEntity, elementalSize);
return SpellResult.CAST;
}
if (!(targetEntity instanceof LivingEntity))
return SpellResult.NO_TARGET;
LivingEntity li = (LivingEntity) targetEntity;
boolean alreadyDead = li.isDead() || li.getHealth() <= 0;
String ownerName = null;
String itemName = null;
byte data = 3;
if (li instanceof Player) {
ownerName = ((Player) li).getName();
} else {
itemName = DeprecatedUtils.getName(li.getType()) + " Head";
switch(li.getType()) {
case CREEPER:
data = 4;
break;
case ZOMBIE:
data = 2;
break;
case SKELETON:
Skeleton skeleton = (Skeleton) li;
data = (byte) (skeleton.getSkeletonType() == SkeletonType.NORMAL ? 0 : 1);
break;
default:
ownerName = controller.getMobSkin(li.getType());
}
}
if (itemName == null && ownerName != null) {
itemName = ownerName + "'s Head";
}
Location targetLocation = targetEntity.getLocation();
if (li instanceof Player) {
super.perform(context);
if (li.isDead() && !alreadyDead) {
dropPlayerHead(targetEntity.getLocation(), (Player) li, itemName);
}
} else if (li.getType() == EntityType.GIANT) {
UndoList spawnedList = com.elmakers.mine.bukkit.block.UndoList.getUndoList(li);
context.registerModified(li);
li.remove();
Entity zombie = targetLocation.getWorld().spawnEntity(targetLocation, EntityType.ZOMBIE);
if (zombie instanceof Zombie) {
((Zombie) zombie).setBaby(false);
}
context.registerForUndo(zombie);
if (spawnedList != null) {
spawnedList.add(zombie);
}
} else if (li instanceof Ageable && ((Ageable) li).isAdult() && !(li instanceof Player)) {
context.registerModified(li);
((Ageable) li).setBaby();
} else if (li instanceof Zombie && !((Zombie) li).isBaby()) {
context.registerModified(li);
((Zombie) li).setBaby(true);
} else if (li instanceof PigZombie && !((PigZombie) li).isBaby()) {
context.registerModified(li);
((PigZombie) li).setBaby(true);
} else if (li instanceof Slime && ((Slime) li).getSize() > 1) {
context.registerModified(li);
Slime slime = (Slime) li;
slime.setSize(slime.getSize() - 1);
} else if (li instanceof Skeleton && skeletons && ((Skeleton) li).getSkeletonType() == SkeletonType.WITHER) {
context.registerModified(li);
Skeleton skeleton = (Skeleton) li;
skeleton.setSkeletonType(SkeletonType.NORMAL);
} else {
super.perform(context);
if ((ownerName != null || data != 3) && (li.isDead() || li.getHealth() == 0) && !alreadyDead) {
dropHead(targetEntity.getLocation(), ownerName, itemName, data);
}
}
return SpellResult.CAST;
}
use of org.bukkit.entity.Zombie in project Village_Defense by Plajer.
the class ArenaInitializer1_12_R1 method spawnPlayerBuster.
public void spawnPlayerBuster(Random random) {
Location location = zombieSpawns.get(random.nextInt(zombieSpawns.size()));
net.minecraft.server.v1_12_R1.World McWorld = ((CraftWorld) location.getWorld()).getHandle();
PlayerBuster fastZombie = new PlayerBuster(location.getWorld());
fastZombie.setPosition(location.getX(), location.getY(), location.getZ());
McWorld.addEntity(fastZombie, CreatureSpawnEvent.SpawnReason.CUSTOM);
Zombie zombie = (Zombie) fastZombie.getBukkitEntity();
zombie.getEquipment().setHelmet(new ItemStack(Material.TNT));
zombie.getEquipment().setHelmetDropChance(0.0F);
zombie.getEquipment().setItemInHandDropChance(0F);
zombie.getEquipment().setBoots(new ItemStack(Material.GOLD_BOOTS));
zombie.getEquipment().setLeggings(new ItemStack(Material.GOLD_LEGGINGS));
zombie.getEquipment().setChestplate(new ItemStack(Material.GOLD_CHESTPLATE));
CreatureUtils.applyHealthBar(zombie);
this.addZombie(zombie);
CreatureUtils.applyMetadata(fastZombie.getBukkitEntity(), this);
super.subtractZombiesToSpawn();
}
use of org.bukkit.entity.Zombie in project Village_Defense by Plajer.
the class ArenaInitializer1_12_R1 method spawnSoftHardZombie.
@Override
public void spawnSoftHardZombie(Random random) {
Location location = zombieSpawns.get(random.nextInt(zombieSpawns.size()));
net.minecraft.server.v1_12_R1.World McWorld = ((CraftWorld) location.getWorld()).getHandle();
HardZombie fastZombie = new HardZombie(location.getWorld());
fastZombie.setPosition(location.getX(), location.getY(), location.getZ());
McWorld.addEntity(fastZombie, CreatureSpawnEvent.SpawnReason.CUSTOM);
Zombie zombie = (Zombie) fastZombie.getBukkitEntity();
zombie.getEquipment().setBoots(new ItemStack(Material.IRON_BOOTS));
zombie.getEquipment().setLeggings(new ItemStack(Material.IRON_LEGGINGS));
zombie.getEquipment().setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
zombie.getEquipment().setHelmet(new ItemStack(Material.IRON_HELMET));
zombie.setRemoveWhenFarAway(false);
CreatureUtils.applyHealthBar(zombie);
this.addZombie(zombie);
CreatureUtils.applyMetadata(fastZombie.getBukkitEntity(), this);
super.subtractZombiesToSpawn();
}
Aggregations