Search in sources :

Example 1 with PacketPortalParticles

use of com.integral.enigmaticlegacy.packets.clients.PacketPortalParticles in project Enigmatic-Legacy by Aizistral-Studios.

the class WormholePotion method onItemUseFinish.

@Override
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, LivingEntity entityLiving) {
    if (!(entityLiving instanceof PlayerEntity))
        return stack;
    PlayerEntity player = (PlayerEntity) entityLiving;
    if (player instanceof ServerPlayerEntity) {
        CriteriaTriggers.CONSUME_ITEM.trigger((ServerPlayerEntity) player, stack);
    }
    PlayerEntity receiver = this.getBoundPlayer(worldIn, stack);
    if (!worldIn.isRemote && receiver != null) {
        Vec3d vec = receiver.getPositionVector();
        while (vec.distanceTo(receiver.getPositionVector()) < 1.0D) vec = receiver.getPositionVector().add((random.nextDouble() - 0.5D) * 4D, 0, (random.nextDouble() - 0.5D) * 4D);
        worldIn.playSound(null, player.getPosition(), SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 1.0F, (float) (0.8F + (Math.random() * 0.2)));
        EnigmaticLegacy.packetInstance.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(player.posX, player.posY, player.posZ, 128, player.dimension)), new PacketPortalParticles(player.posX, player.posY + (player.getHeight() / 2), player.posZ, 100, 1.25F, false));
        player.setPositionAndUpdate(vec.x, vec.y + 0.25, vec.z);
        worldIn.playSound(null, player.getPosition(), SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 1.0F, (float) (0.8F + (Math.random() * 0.2)));
        EnigmaticLegacy.packetInstance.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(player.posX, player.posY, player.posZ, 128, player.dimension)), new PacketRecallParticles(player.posX, player.posY + (player.getHeight() / 2), player.posZ, 48, false));
    }
    if (!player.abilities.isCreativeMode) {
        stack.shrink(1);
        if (stack.isEmpty()) {
            return new ItemStack(Items.GLASS_BOTTLE);
        }
        player.inventory.addItemStackToInventory(new ItemStack(Items.GLASS_BOTTLE));
    }
    return stack;
}
Also used : PacketRecallParticles(com.integral.enigmaticlegacy.packets.clients.PacketRecallParticles) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) PacketPortalParticles(com.integral.enigmaticlegacy.packets.clients.PacketPortalParticles) ItemStack(net.minecraft.item.ItemStack) Vec3d(net.minecraft.util.math.Vec3d) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity)

Example 2 with PacketPortalParticles

use of com.integral.enigmaticlegacy.packets.clients.PacketPortalParticles in project Enigmatic-Legacy by Aizistral-Studios.

the class EnigmaticEventHandler method onEntityAttacked.

@SubscribeEvent
public void onEntityAttacked(LivingAttackEvent event) {
    if (event.getEntityLiving().world.isRemote)
        return;
    if (event.getEntityLiving() instanceof PlayerEntity) {
        PlayerEntity player = (PlayerEntity) event.getEntityLiving();
        if (EtheriumArmor.hasShield(player)) {
            if (event.getSource().getImmediateSource() instanceof DamagingProjectileEntity || event.getSource().getImmediateSource() instanceof AbstractArrowEntity) {
                event.setCanceled(true);
                player.world.playSound(null, player.getPosition(), EnigmaticLegacy.SHIELD_TRIGGER, SoundCategory.PLAYERS, 1.0F, 0.9F + (float) (Math.random() * 0.1D));
                player.world.playSound(null, player.getPosition(), EnigmaticLegacy.SHIELD_TRIGGER, SoundCategory.PLAYERS, 1.0F, 0.9F + (float) (Math.random() * 0.1D));
            }
        }
        if (SuperpositionHandler.hasCurio(player, EnigmaticLegacy.enigmaticItem))
            if (EnigmaticItem.immunityList.contains(event.getSource().damageType))
                event.setCanceled(true);
        if (SuperpositionHandler.hasCurio(player, EnigmaticLegacy.angelBlessing))
            if (AngelBlessing.immunityList.contains(event.getSource().damageType))
                event.setCanceled(true);
        if (SuperpositionHandler.hasCurio(player, EnigmaticLegacy.oceanStone))
            if (OceanStone.immunityList.contains(event.getSource().damageType))
                event.setCanceled(true);
        if (SuperpositionHandler.hasCurio(player, EnigmaticLegacy.magmaHeart))
            if (MagmaHeart.immunityList.contains(event.getSource().damageType))
                event.setCanceled(true);
        if (SuperpositionHandler.hasCurio(player, EnigmaticLegacy.golemHeart))
            if (GolemHeart.immunityList.contains(event.getSource().damageType))
                event.setCanceled(true);
        if (SuperpositionHandler.hasCurio(player, EnigmaticLegacy.voidPearl)) {
            if (VoidPearl.immunityList.contains(event.getSource().damageType))
                event.setCanceled(true);
            else if (VoidPearl.healList.contains(event.getSource().damageType)) {
                player.heal(event.getAmount());
                event.setCanceled(true);
            } else {
            }
        }
        if (SuperpositionHandler.hasCurio(player, EnigmaticLegacy.eyeOfNebula)) {
            if (EyeOfNebula.immunityList.contains(event.getSource().damageType)) {
                event.setCanceled(true);
            } else if (Math.random() <= ConfigHandler.EYE_OF_NEBULA_DODGE_PROBABILITY.getValue().asMultiplier(false) && player.hurtResistantTime <= 10 && event.getSource().getTrueSource() instanceof LivingEntity) {
                for (int counter = 0; counter <= 32; counter++) {
                    if (SuperpositionHandler.validTeleportRandomly(player, player.world, (int) ConfigHandler.EYE_OF_NEBULA_DODGE_RANGE.getValue()))
                        break;
                }
                player.hurtResistantTime = 20;
                event.setCanceled(true);
            }
        }
    } else if (event.getSource().getImmediateSource() instanceof PlayerEntity) {
        PlayerEntity player = (PlayerEntity) event.getSource().getImmediateSource();
        if (player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() == EnigmaticLegacy.extradimensionalEye)
            if (ItemNBTHelper.verifyExistance(player.getHeldItemMainhand(), "BoundDimension"))
                if (ItemNBTHelper.getInt(player.getHeldItemMainhand(), "BoundDimension", 0) == event.getEntityLiving().dimension.getId()) {
                    event.setCanceled(true);
                    ItemStack stack = player.getHeldItemMainhand();
                    EnigmaticLegacy.packetInstance.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ, 128, event.getEntityLiving().dimension)), new PacketPortalParticles(event.getEntityLiving().posX, event.getEntityLiving().posY + (event.getEntityLiving().getHeight() / 2), event.getEntityLiving().posZ, 96, 1.5D, false));
                    event.getEntityLiving().world.playSound(null, event.getEntityLiving().getPosition(), SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 1.0F, (float) (0.8F + (Math.random() * 0.2)));
                    event.getEntityLiving().setPositionAndUpdate(ItemNBTHelper.getDouble(stack, "BoundX", 0D), ItemNBTHelper.getDouble(stack, "BoundY", 0D), ItemNBTHelper.getDouble(stack, "BoundZ", 0D));
                    event.getEntityLiving().world.playSound(null, event.getEntityLiving().getPosition(), SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 1.0F, (float) (0.8F + (Math.random() * 0.2)));
                    EnigmaticLegacy.packetInstance.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ, 128, event.getEntityLiving().dimension)), new PacketRecallParticles(event.getEntityLiving().posX, event.getEntityLiving().posY + (event.getEntityLiving().getHeight() / 2), event.getEntityLiving().posZ, 48, false));
                    if (!player.abilities.isCreativeMode)
                        stack.shrink(1);
                }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) PacketDistributor(net.minecraftforge.fml.network.PacketDistributor) PacketRecallParticles(com.integral.enigmaticlegacy.packets.clients.PacketRecallParticles) DamagingProjectileEntity(net.minecraft.entity.projectile.DamagingProjectileEntity) PacketPortalParticles(com.integral.enigmaticlegacy.packets.clients.PacketPortalParticles) ItemStack(net.minecraft.item.ItemStack) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) AbstractArrowEntity(net.minecraft.entity.projectile.AbstractArrowEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 3 with PacketPortalParticles

use of com.integral.enigmaticlegacy.packets.clients.PacketPortalParticles in project Enigmatic-Legacy by Aizistral-Studios.

the class EyeOfNebula method triggerActiveAbility.

public void triggerActiveAbility(World world, ServerPlayerEntity player, ItemStack stack) {
    if (SuperpositionHandler.hasSpellstoneCooldown(player))
        return;
    LivingEntity target = SuperpositionHandler.getObservedEntity(player, world, 3.0F, (int) ConfigHandler.EYE_OF_NEBULA_PHASE_RANGE.getValue());
    if (target != null) {
        Vector3 targetPos = Vector3.fromEntityCenter(target);
        Vector3 chaserPos = Vector3.fromEntityCenter(player);
        // Vector3 targetSight = new Vector3(target.getLookVec());
        Vector3 dir = targetPos.subtract(chaserPos);
        dir = dir.normalize();
        dir = dir.multiply(1.5D);
        dir = targetPos.add(dir);
        // player.
        world.playSound(null, player.getPosition(), SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 1.0F, (float) (0.8F + (Math.random() * 0.2D)));
        EnigmaticLegacy.packetInstance.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(player.posX, player.posY, player.posZ, 128, player.dimension)), new PacketPortalParticles(player.posX, player.posY + (player.getHeight() / 2), player.posZ, 72, 1.0F, false));
        player.setPositionAndUpdate(dir.x, target.posY + 0.25D, dir.z);
        EnigmaticLegacy.packetInstance.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), new PacketPlayerSetlook(target.posX, target.posY - 1.0D + (target.getHeight() / 2), target.posZ));
        world.playSound(null, player.getPosition(), SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 1.0F, (float) (0.8F + (Math.random() * 0.2D)));
        EnigmaticLegacy.packetInstance.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(player.posX, player.posY, player.posZ, 128, player.dimension)), new PacketRecallParticles(player.posX, player.posY + (player.getHeight() / 2), player.posZ, 24, false));
        SuperpositionHandler.setSpellstoneCooldown(player, ConfigHandler.EYE_OF_NEBULA_COOLDOWN.getValue());
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) PacketPlayerSetlook(com.integral.enigmaticlegacy.packets.clients.PacketPlayerSetlook) PacketRecallParticles(com.integral.enigmaticlegacy.packets.clients.PacketRecallParticles) Vector3(com.integral.enigmaticlegacy.helpers.Vector3) PacketPortalParticles(com.integral.enigmaticlegacy.packets.clients.PacketPortalParticles) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity)

Example 4 with PacketPortalParticles

use of com.integral.enigmaticlegacy.packets.clients.PacketPortalParticles in project Enigmatic-Legacy by Aizistral-Studios.

the class SuperpositionHandler method validTeleport.

/**
 * Attempts to teleport entity at given coordinates, or nearest valid location on Y axis.
 * @return True if successfull, false otherwise.
 */
public static boolean validTeleport(Entity entity, double x_init, double y_init, double z_init, World world, int checkAxis) {
    int x = (int) x_init;
    int y = (int) y_init;
    int z = (int) z_init;
    BlockState block = world.getBlockState(new BlockPos(x, y - 1, z));
    if (world.isAirBlock(new BlockPos(x, y - 1, z)) & block.isSolid()) {
        for (int counter = 0; counter <= checkAxis; counter++) {
            if (!world.isAirBlock(new BlockPos(x, y + counter - 1, z)) & world.getBlockState(new BlockPos(x, y + counter - 1, z)).isSolid() & world.isAirBlock(new BlockPos(x, y + counter, z)) & world.isAirBlock(new BlockPos(x, y + counter + 1, z))) {
                world.playSound(null, entity.getPosition(), SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.HOSTILE, 1.0F, (float) (0.8F + (Math.random() * 0.2D)));
                EnigmaticLegacy.packetInstance.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(entity.posX, entity.posY, entity.posZ, 128, entity.dimension)), new PacketPortalParticles(entity.posX, entity.posY + (entity.getHeight() / 2), entity.posZ, 72, 1.0F, false));
                if (entity instanceof ServerPlayerEntity) {
                    ServerPlayerEntity player = (ServerPlayerEntity) entity;
                    player.setPositionAndUpdate(x + 0.5, y + counter, z + 0.5);
                } else
                    ((LivingEntity) entity).setPositionAndUpdate(x + 0.5, y + counter, z + 0.5);
                world.playSound(null, entity.getPosition(), SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.HOSTILE, 1.0F, (float) (0.8F + (Math.random() * 0.2D)));
                EnigmaticLegacy.packetInstance.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(entity.posX, entity.posY, entity.posZ, 128, entity.dimension)), new PacketRecallParticles(entity.posX, entity.posY + (entity.getHeight() / 2), entity.posZ, 48, false));
                return true;
            }
        }
    } else {
        for (int counter = 0; counter <= checkAxis; counter++) {
            if (!world.isAirBlock(new BlockPos(x, y - counter - 1, z)) & world.getBlockState(new BlockPos(x, y - counter - 1, z)).isSolid() & world.isAirBlock(new BlockPos(x, y - counter, z)) & world.isAirBlock(new BlockPos(x, y - counter + 1, z))) {
                world.playSound(null, entity.getPosition(), SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.HOSTILE, 1.0F, (float) (0.8F + (Math.random() * 0.2D)));
                EnigmaticLegacy.packetInstance.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(entity.posX, entity.posY, entity.posZ, 128, entity.dimension)), new PacketRecallParticles(entity.posX, entity.posY + (entity.getHeight() / 2), entity.posZ, 48, false));
                if (entity instanceof ServerPlayerEntity) {
                    ServerPlayerEntity player = (ServerPlayerEntity) entity;
                    player.setPositionAndUpdate(x + 0.5, y - counter, z + 0.5);
                } else
                    ((LivingEntity) entity).setPositionAndUpdate(x + 0.5, y - counter, z + 0.5);
                world.playSound(null, entity.getPosition(), SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.HOSTILE, 1.0F, (float) (0.8F + (Math.random() * 0.2D)));
                EnigmaticLegacy.packetInstance.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(entity.posX, entity.posY, entity.posZ, 128, entity.dimension)), new PacketRecallParticles(entity.posX, entity.posY + (entity.getHeight() / 2), entity.posZ, 48, false));
                return true;
            }
        }
    }
    return false;
}
Also used : BlockState(net.minecraft.block.BlockState) PacketRecallParticles(com.integral.enigmaticlegacy.packets.clients.PacketRecallParticles) BlockPos(net.minecraft.util.math.BlockPos) PacketPortalParticles(com.integral.enigmaticlegacy.packets.clients.PacketPortalParticles) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity)

Example 5 with PacketPortalParticles

use of com.integral.enigmaticlegacy.packets.clients.PacketPortalParticles in project Enigmatic-Legacy by Aizistral-Studios.

the class EnigmaticEventHandler method onConfirmedDeath.

@SubscribeEvent(priority = EventPriority.LOWEST)
public void onConfirmedDeath(LivingDeathEvent event) {
    if (event.getEntityLiving() instanceof PlayerEntity) {
        PlayerEntity player = (PlayerEntity) event.getEntityLiving();
        if (SuperpositionHandler.hasCurio(player, EnigmaticLegacy.escapeScroll) & !player.world.isRemote) {
            ItemStack tomeStack = SuperpositionHandler.getCurioStack(player, EnigmaticLegacy.escapeScroll);
            PermanentItemEntity droppedTomeStack = new PermanentItemEntity(player.world, player.posX, player.posY + (player.getHeight() / 2), player.posZ, tomeStack.copy());
            droppedTomeStack.setPickupDelay(10);
            player.world.addEntity(droppedTomeStack);
            tomeStack.shrink(1);
            Vec3d vec = SuperpositionHandler.getValidSpawn(player.world, player);
            player.world.playSound(null, player.getPosition(), SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 1.0F, (float) (0.8F + (Math.random() * 0.2)));
            EnigmaticLegacy.packetInstance.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(player.posX, player.posY, player.posZ, 1024, player.dimension)), new PacketPortalParticles(player.posX, player.posY + (player.getHeight() / 2), player.posZ, 72, 1.0F, false));
            player.setPositionAndUpdate(vec.x, vec.y, vec.z);
            player.world.playSound(null, player.getPosition(), SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 1.0F, (float) (0.8F + (Math.random() * 0.2)));
            EnigmaticLegacy.packetInstance.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(player.posX, player.posY, player.posZ, 1024, player.dimension)), new PacketRecallParticles(player.posX, player.posY + (player.getHeight() / 2), player.posZ, 48, false));
        }
    }
}
Also used : PacketRecallParticles(com.integral.enigmaticlegacy.packets.clients.PacketRecallParticles) PacketPortalParticles(com.integral.enigmaticlegacy.packets.clients.PacketPortalParticles) ItemStack(net.minecraft.item.ItemStack) PermanentItemEntity(com.integral.enigmaticlegacy.entities.PermanentItemEntity) Vec3d(net.minecraft.util.math.Vec3d) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

PacketPortalParticles (com.integral.enigmaticlegacy.packets.clients.PacketPortalParticles)8 PacketRecallParticles (com.integral.enigmaticlegacy.packets.clients.PacketRecallParticles)6 PlayerEntity (net.minecraft.entity.player.PlayerEntity)6 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)6 ItemStack (net.minecraft.item.ItemStack)4 Vec3d (net.minecraft.util.math.Vec3d)3 PacketDistributor (net.minecraftforge.fml.network.PacketDistributor)3 BlockState (net.minecraft.block.BlockState)2 LivingEntity (net.minecraft.entity.LivingEntity)2 BlockPos (net.minecraft.util.math.BlockPos)2 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)2 PermanentItemEntity (com.integral.enigmaticlegacy.entities.PermanentItemEntity)1 Vector3 (com.integral.enigmaticlegacy.helpers.Vector3)1 PacketPlayerSetlook (com.integral.enigmaticlegacy.packets.clients.PacketPlayerSetlook)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ItemEntity (net.minecraft.entity.item.ItemEntity)1 AbstractArrowEntity (net.minecraft.entity.projectile.AbstractArrowEntity)1 DamagingProjectileEntity (net.minecraft.entity.projectile.DamagingProjectileEntity)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1