Search in sources :

Example 6 with PacketRecallParticles

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

the class RecallPotion method onItemUseFinish.

@Override
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, LivingEntity entityLiving) {
    PlayerEntity player = entityLiving instanceof PlayerEntity ? (PlayerEntity) entityLiving : null;
    if (player instanceof ServerPlayerEntity) {
        CriteriaTriggers.CONSUME_ITEM.trigger((ServerPlayerEntity) player, stack);
    }
    if (!worldIn.isRemote) {
        Vec3d vec = SuperpositionHandler.getValidSpawn(worldIn, player);
        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, 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 == null || !player.abilities.isCreativeMode) {
        stack.shrink(1);
        if (stack.isEmpty()) {
            return new ItemStack(Items.GLASS_BOTTLE);
        }
        if (player != null) {
            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)

Aggregations

PacketPortalParticles (com.integral.enigmaticlegacy.packets.clients.PacketPortalParticles)6 PacketRecallParticles (com.integral.enigmaticlegacy.packets.clients.PacketRecallParticles)6 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)6 PlayerEntity (net.minecraft.entity.player.PlayerEntity)4 ItemStack (net.minecraft.item.ItemStack)4 Vec3d (net.minecraft.util.math.Vec3d)3 LivingEntity (net.minecraft.entity.LivingEntity)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 BlockState (net.minecraft.block.BlockState)1 AbstractArrowEntity (net.minecraft.entity.projectile.AbstractArrowEntity)1 DamagingProjectileEntity (net.minecraft.entity.projectile.DamagingProjectileEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1 PacketDistributor (net.minecraftforge.fml.network.PacketDistributor)1