Fixed some types of entities

This commit is contained in:
LCastr0 2016-12-27 00:58:16 -02:00
parent 5198d64ab8
commit c685486086
2 changed files with 62 additions and 1 deletions

View File

@ -1,9 +1,19 @@
package mineplex.core.gadget.gadgets.balloons;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Bat;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Zombie;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.creature.Creature;
import mineplex.core.disguise.disguises.DisguiseArmorStand;
import mineplex.core.disguise.disguises.DisguiseWither;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.BalloonGadget;
@ -24,10 +34,56 @@ public class BalloonItem extends BalloonGadget
@Override
public Entity spawnEntity(Player player)
{
if (_balloonType.equals(BalloonType.BABY_WIDDER))
{
Creature creatureModule = Manager.getPetManager().getCreatureModule();
creatureModule.SetForce(true);
Entity silverfish = player.getWorld().spawnEntity(player.getLocation(), _balloonType.getEntityType());
UtilEnt.silence(silverfish, true);
DisguiseWither witherDisguise = new DisguiseWither(silverfish);
witherDisguise.setInvulTime(530);
org.bukkit.entity.Creature silver = (org.bukkit.entity.Creature) creatureModule.SpawnEntity(player.getLocation(), EntityType.SILVERFISH);
UtilEnt.Vegetate(silver, true);
UtilEnt.silence(silver, true);
silver.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0));
silverfish.setPassenger(silver);
Manager.getDisguiseManager().disguise(witherDisguise);
creatureModule.SetForce(false);
return silver;
}
else if (_balloonType.getEntityType().equals(EntityType.ARMOR_STAND))
{
Entity bat = player.getWorld().spawn(player.getLocation(), Bat.class);
((LivingEntity) bat).addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false, false));
UtilEnt.silence(bat, true);
DisguiseArmorStand disguiseArmorStand = new DisguiseArmorStand(bat);
disguiseArmorStand.setHelmet(_balloonType.getDisplayItem());
disguiseArmorStand.setInvisible(true);
if (_balloonType.isBaby()) disguiseArmorStand.setSmall();
disguiseArmorStand.setGravityEffected();
Manager.getDisguiseManager().disguise(disguiseArmorStand);
return bat;
}
else if (_balloonType.equals(BalloonType.BABY_ZOMBIE))
{
Zombie zombie = player.getWorld().spawn(player.getLocation(), Zombie.class);
zombie.setBaby(true);
return zombie;
}
Entity entity = player.getWorld().spawnEntity(player.getLocation(), _balloonType.getEntityType());
if (_balloonType.isBaby() && entity instanceof Ageable)
((Ageable) entity).setBaby();
//((LivingEntity) entity).setLeashHolder(player);
return entity;
}

View File

@ -624,4 +624,9 @@ public class PetManager extends MiniClientPlugin<PetClient>
return _activePetOwners.values();
}
public mineplex.core.creature.Creature getCreatureModule()
{
return _creatureModule;
}
}