Search in sources :

Example 6 with ShulkerDefault

use of simplepets.brainsynder.pet.types.ShulkerDefault in project SimplePets by brainsynder-Dev.

the class SpawnUtil method spawn.

public IEntityPet spawn(Location l, IPet pet, String className) {
    try {
        World mcWorld = ((CraftWorld) l.getWorld()).getHandle();
        EntityTypes<?> types = EntityUtils.getType((className.equals("EntityControllerPet")) ? EntityWrapper.ZOMBIE : pet.getEntityType());
        EntityPet customEntity = (EntityPet) petMap.get(className).getDeclaredConstructor(EntityTypes.class, World.class, IPet.class).newInstance(types, mcWorld, pet);
        customEntity.setInvisible(false);
        customEntity.setLocation(l.getX(), l.getY(), l.getZ(), l.getYaw(), l.getPitch());
        mcWorld.addEntity(customEntity, CreatureSpawnEvent.SpawnReason.CUSTOM);
        if (customEntity instanceof IEntityControllerPet) {
            if (pet.getPetType() instanceof ArmorStandDefault) {
                ArmorStand stand = EntityArmorStandPet.spawn(l, ((EntityControllerPet) customEntity));
                stand.setGravity(false);
                stand.setArms(true);
                stand.setCollidable(false);
                stand.setLeftLegPose(new EulerAngle(0.0D, 0.0D, 0.0D));
                stand.setRightLegPose(new EulerAngle(0.0D, 0.0D, 0.0D));
                stand.setLeftArmPose(new EulerAngle(0.0D, 0.0D, 0.0D));
                stand.setRightArmPose(new EulerAngle(0.0D, 0.0D, 0.0D));
                ((IEntityControllerPet) customEntity).setDisplayEntity(stand);
            } else if (pet.getPetType() instanceof ShulkerDefault) {
                ArmorStand stand = EntityGhostStandPet.spawn(l, pet);
                stand.setGravity(false);
                stand.setCollidable(false);
                stand.setSmall(true);
                Shulker shulker = EntityShulkerPet.spawn(l, (EntityControllerPet) customEntity);
                shulker.setAI(false);
                shulker.setCollidable(false);
                stand.addPassenger(shulker);
                ((IEntityControllerPet) customEntity).setDisplayEntity(stand);
            }
        }
        return customEntity;
    } catch (Exception e) {
        e.printStackTrace();
        throw new SimplePetsException("Could not summon the " + pet.getPetType().getConfigName() + " Pet", e);
    }
}
Also used : ShulkerDefault(simplepets.brainsynder.pet.types.ShulkerDefault) World(net.minecraft.server.v1_14_R1.World) CraftWorld(org.bukkit.craftbukkit.v1_14_R1.CraftWorld) Shulker(org.bukkit.entity.Shulker) SimplePetsException(simplepets.brainsynder.errors.SimplePetsException) IEntityControllerPet(simplepets.brainsynder.api.entity.IEntityControllerPet) IEntityPet(simplepets.brainsynder.api.entity.IEntityPet) IEntityControllerPet(simplepets.brainsynder.api.entity.IEntityControllerPet) EntityControllerPet(simplepets.brainsynder.nms.v1_14_R1.entities.list.EntityControllerPet) ArmorStand(org.bukkit.entity.ArmorStand) ArmorStandDefault(simplepets.brainsynder.pet.types.ArmorStandDefault) SimplePetsException(simplepets.brainsynder.errors.SimplePetsException) EulerAngle(org.bukkit.util.EulerAngle) CraftWorld(org.bukkit.craftbukkit.v1_14_R1.CraftWorld)

Example 7 with ShulkerDefault

use of simplepets.brainsynder.pet.types.ShulkerDefault in project SimplePets by brainsynder-Dev.

the class SpawnUtil method spawn.

public IEntityPet spawn(Location l, IPet pet, String className) {
    try {
        World mcWorld = ((CraftWorld) l.getWorld()).getHandle();
        EntityTypes<?> types = EntityUtils.getType((className.equals("EntityControllerPet")) ? EntityWrapper.ZOMBIE : pet.getEntityType());
        EntityPet customEntity = (EntityPet) petMap.get(className).getDeclaredConstructor(EntityTypes.class, World.class, IPet.class).newInstance(types, mcWorld, pet);
        customEntity.setInvisible(false);
        customEntity.setLocation(l.getX(), l.getY(), l.getZ(), l.getYaw(), l.getPitch());
        mcWorld.addEntity(customEntity, CreatureSpawnEvent.SpawnReason.CUSTOM);
        if (customEntity instanceof IEntityControllerPet) {
            if (pet.getPetType() instanceof ArmorStandDefault) {
                ArmorStand stand = EntityArmorStandPet.spawn(l, ((EntityControllerPet) customEntity));
                stand.setGravity(false);
                stand.setArms(true);
                stand.setCollidable(false);
                stand.setLeftLegPose(new EulerAngle(0.0D, 0.0D, 0.0D));
                stand.setRightLegPose(new EulerAngle(0.0D, 0.0D, 0.0D));
                stand.setLeftArmPose(new EulerAngle(0.0D, 0.0D, 0.0D));
                stand.setRightArmPose(new EulerAngle(0.0D, 0.0D, 0.0D));
                ((IEntityControllerPet) customEntity).setDisplayEntity(stand);
            } else if (pet.getPetType() instanceof ShulkerDefault) {
                ArmorStand stand = EntityGhostStandPet.spawn(l, pet);
                stand.setGravity(false);
                stand.setCollidable(false);
                stand.setSmall(true);
                Shulker shulker = EntityShulkerPet.spawn(l, (EntityControllerPet) customEntity);
                shulker.setAI(false);
                shulker.setCollidable(false);
                ((CraftEntity) stand).getHandle().passengers.add(0, ((CraftEntity) shulker).getHandle());
                ((IEntityControllerPet) customEntity).setDisplayEntity(stand);
            }
        }
        return customEntity;
    } catch (Exception e) {
        e.printStackTrace();
        throw new SimplePetsException("Could not summon the " + pet.getPetType().getConfigName() + " Pet", e);
    }
}
Also used : ShulkerDefault(simplepets.brainsynder.pet.types.ShulkerDefault) CraftEntity(org.bukkit.craftbukkit.v1_13_R1.entity.CraftEntity) CraftWorld(org.bukkit.craftbukkit.v1_13_R1.CraftWorld) World(net.minecraft.server.v1_13_R1.World) Shulker(org.bukkit.entity.Shulker) SimplePetsException(simplepets.brainsynder.errors.SimplePetsException) IEntityControllerPet(simplepets.brainsynder.api.entity.IEntityControllerPet) IEntityPet(simplepets.brainsynder.api.entity.IEntityPet) EntityControllerPet(simplepets.brainsynder.nms.v1_13_R1.entities.list.EntityControllerPet) IEntityControllerPet(simplepets.brainsynder.api.entity.IEntityControllerPet) ArmorStand(org.bukkit.entity.ArmorStand) ArmorStandDefault(simplepets.brainsynder.pet.types.ArmorStandDefault) SimplePetsException(simplepets.brainsynder.errors.SimplePetsException) EulerAngle(org.bukkit.util.EulerAngle) CraftWorld(org.bukkit.craftbukkit.v1_13_R1.CraftWorld)

Example 8 with ShulkerDefault

use of simplepets.brainsynder.pet.types.ShulkerDefault in project SimplePets by brainsynder-Dev.

the class EntityControllerPet method repeatTask.

@Override
public void repeatTask() {
    super.repeatTask();
    if (!this.isInvisible())
        this.setInvisible(true);
    if (getPet() != null)
        if (isBaby())
            setBaby((getPet().getPetType() instanceof ShulkerDefault));
    Player p = getPet().getOwner();
    if (this.displayEntity != null) {
        if (this.displayEntity.isValid()) {
            if (displayEntity.getPassenger() != null) {
                this.displayEntity.getPassenger().setCustomName(getCustomName());
            } else {
                this.displayEntity.setCustomName(getCustomName());
            }
            if (displayEntity.getPassenger() == null) {
                reloadLocation();
                net.minecraft.server.v1_12_R1.Entity displayEntity = ((CraftEntity) this.displayEntity).getHandle();
                if (((CraftPlayer) getOwner()).getHandle().isInvisible() != displayEntity.isInvisible()) {
                    displayEntity.setInvisible(!displayEntity.isInvisible());
                }
                return;
            }
            if (this.displayEntity.getPassenger() != null) {
                net.minecraft.server.v1_12_R1.Entity displayEntity = ((CraftEntity) this.displayEntity.getPassenger()).getHandle();
                if (((CraftPlayer) p).getHandle().isInvisible() != displayEntity.isInvisible()) {
                    displayEntity.setInvisible(!displayEntity.isInvisible());
                }
            }
        }
    }
}
Also used : Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer) ShulkerDefault(simplepets.brainsynder.pet.types.ShulkerDefault) CraftEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity) net.minecraft.server.v1_12_R1(net.minecraft.server.v1_12_R1) CraftPlayer(org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer)

Example 9 with ShulkerDefault

use of simplepets.brainsynder.pet.types.ShulkerDefault in project SimplePets by brainsynder-Dev.

the class SpawnUtil method spawn.

public IEntityPet spawn(Location l, IPet pet, String className) {
    try {
        World mcWorld = ((CraftWorld) l.getWorld()).getHandle();
        EntityTypes<?> types = EntityUtils.getType((className.equals("EntityControllerPet")) ? EntityWrapper.ZOMBIE : pet.getEntityType());
        EntityPet customEntity = (EntityPet) petMap.get(className).getDeclaredConstructor(EntityTypes.class, World.class, IPet.class).newInstance(types, mcWorld, pet);
        customEntity.setInvisible(false);
        customEntity.setLocation(l.getX(), l.getY(), l.getZ(), l.getYaw(), l.getPitch());
        mcWorld.addEntity(customEntity, CreatureSpawnEvent.SpawnReason.CUSTOM);
        if (customEntity instanceof IEntityControllerPet) {
            if (pet.getPetType() instanceof ArmorStandDefault) {
                ArmorStand stand = EntityArmorStandPet.spawn(l, ((EntityControllerPet) customEntity));
                stand.setGravity(false);
                stand.setArms(true);
                stand.setCollidable(false);
                stand.setLeftLegPose(new EulerAngle(0.0D, 0.0D, 0.0D));
                stand.setRightLegPose(new EulerAngle(0.0D, 0.0D, 0.0D));
                stand.setLeftArmPose(new EulerAngle(0.0D, 0.0D, 0.0D));
                stand.setRightArmPose(new EulerAngle(0.0D, 0.0D, 0.0D));
                ((IEntityControllerPet) customEntity).setDisplayEntity(stand);
            } else if (pet.getPetType() instanceof ShulkerDefault) {
                ArmorStand stand = EntityGhostStandPet.spawn(l, pet);
                stand.setGravity(false);
                stand.setCollidable(false);
                stand.setSmall(true);
                Shulker shulker = EntityShulkerPet.spawn(l, (EntityControllerPet) customEntity);
                shulker.setAI(false);
                shulker.setCollidable(false);
                stand.addPassenger(shulker);
                ((IEntityControllerPet) customEntity).setDisplayEntity(stand);
            }
        }
        return customEntity;
    } catch (Exception e) {
        e.printStackTrace();
        throw new SimplePetsException("Could not summon the " + pet.getPetType().getConfigName() + " Pet", e);
    }
}
Also used : ShulkerDefault(simplepets.brainsynder.pet.types.ShulkerDefault) CraftWorld(org.bukkit.craftbukkit.v1_15_R1.CraftWorld) World(net.minecraft.server.v1_15_R1.World) Shulker(org.bukkit.entity.Shulker) SimplePetsException(simplepets.brainsynder.errors.SimplePetsException) IEntityControllerPet(simplepets.brainsynder.api.entity.IEntityControllerPet) IEntityPet(simplepets.brainsynder.api.entity.IEntityPet) EntityControllerPet(simplepets.brainsynder.nms.v1_15_R1.entities.list.EntityControllerPet) IEntityControllerPet(simplepets.brainsynder.api.entity.IEntityControllerPet) ArmorStand(org.bukkit.entity.ArmorStand) ArmorStandDefault(simplepets.brainsynder.pet.types.ArmorStandDefault) SimplePetsException(simplepets.brainsynder.errors.SimplePetsException) EulerAngle(org.bukkit.util.EulerAngle) CraftWorld(org.bukkit.craftbukkit.v1_15_R1.CraftWorld)

Example 10 with ShulkerDefault

use of simplepets.brainsynder.pet.types.ShulkerDefault in project SimplePets by brainsynder-Dev.

the class EntityControllerPet method repeatTask.

@Override
public void repeatTask() {
    super.repeatTask();
    if (!this.isInvisible())
        this.setInvisible(true);
    if (!isSilent())
        this.setSilent(true);
    if (getPet() != null)
        if (isBaby())
            setBaby((getPet().getPetType() instanceof ShulkerDefault));
    Player p = getPet().getOwner();
    if (this.displayEntity != null) {
        if (this.displayEntity.isValid()) {
            net.minecraft.server.v1_15_R1.Entity entity = ((CraftEntity) displayEntity).getHandle();
            if (!displayEntity.getPassengers().isEmpty()) {
                if (displayRider == null)
                    displayRider = displayEntity.getPassengers().get(0);
                entity = ((CraftEntity) displayRider).getHandle();
            }
            updateName(entity);
            reloadLocation();
            if (!canIgnoreVanish()) {
                if (((CraftPlayer) p).getHandle().isInvisible() != entity.isInvisible())
                    entity.setInvisible(!entity.isInvisible());
            }
        }
    }
    PetDefault type = getVisibleEntity().getPet().getPetType();
    double current = getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue();
    double rideSpeed = type.getRideSpeed();
    double walkSpeed = type.getSpeed();
    if (isOwnerRiding()) {
        if (current != rideSpeed)
            getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(rideSpeed);
    } else {
        if (current != walkSpeed)
            getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(walkSpeed);
    }
}
Also used : Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer) net.minecraft.server.v1_15_R1(net.minecraft.server.v1_15_R1) PetDefault(simplepets.brainsynder.pet.PetDefault) ShulkerDefault(simplepets.brainsynder.pet.types.ShulkerDefault) CraftEntity(org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity) CraftPlayer(org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer)

Aggregations

ShulkerDefault (simplepets.brainsynder.pet.types.ShulkerDefault)12 ArmorStand (org.bukkit.entity.ArmorStand)6 Player (org.bukkit.entity.Player)6 Shulker (org.bukkit.entity.Shulker)6 EulerAngle (org.bukkit.util.EulerAngle)6 IEntityControllerPet (simplepets.brainsynder.api.entity.IEntityControllerPet)6 IEntityPet (simplepets.brainsynder.api.entity.IEntityPet)6 SimplePetsException (simplepets.brainsynder.errors.SimplePetsException)6 ArmorStandDefault (simplepets.brainsynder.pet.types.ArmorStandDefault)6 CraftEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity)2 CraftEntity (org.bukkit.craftbukkit.v1_13_R1.entity.CraftEntity)2 CraftEntity (org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity)2 PetDefault (simplepets.brainsynder.pet.PetDefault)2 net.minecraft.server.v1_11_R1 (net.minecraft.server.v1_11_R1)1 World (net.minecraft.server.v1_11_R1.World)1 net.minecraft.server.v1_12_R1 (net.minecraft.server.v1_12_R1)1 World (net.minecraft.server.v1_12_R1.World)1 net.minecraft.server.v1_13_R1 (net.minecraft.server.v1_13_R1)1 World (net.minecraft.server.v1_13_R1.World)1 net.minecraft.server.v1_13_R2 (net.minecraft.server.v1_13_R2)1