Search in sources :

Example 6 with PacketPortalParticles

use of com.integral.enigmaticlegacy.packets.clients.PacketPortalParticles 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)

Example 7 with PacketPortalParticles

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

the class SuperMagnetRing method onCurioTick.

@Override
public void onCurioTick(String identifier, LivingEntity living) {
    if (ConfigHandler.INVERT_MAGNETS_SHIFT.getValue() ? !living.isSneaking() : living.isSneaking() || living.world.isRemote || !(living instanceof PlayerEntity))
        return;
    PlayerEntity player = (PlayerEntity) living;
    double x = living.posX;
    double y = living.posY + 0.75;
    double z = living.posZ;
    List<ItemEntity> items = living.world.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(x - ConfigHandler.SUPER_MAGNET_RING_RANGE.getValue(), y - ConfigHandler.SUPER_MAGNET_RING_RANGE.getValue(), z - ConfigHandler.SUPER_MAGNET_RING_RANGE.getValue(), x + ConfigHandler.SUPER_MAGNET_RING_RANGE.getValue(), y + ConfigHandler.SUPER_MAGNET_RING_RANGE.getValue(), z + ConfigHandler.SUPER_MAGNET_RING_RANGE.getValue()));
    int pulled = 0;
    for (ItemEntity item : items) if (canPullItem(item)) {
        if (pulled > 512)
            break;
        if (!SuperpositionHandler.canPickStack(player, item.getItem()))
            continue;
        EnigmaticLegacy.packetInstance.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(item.posX, item.posY, item.posZ, 24, item.dimension)), new PacketPortalParticles(item.posX, item.posY + (item.getHeight() / 2), item.posZ, 24, 0.75D, true));
        if (ConfigHandler.SUPER_MAGNET_RING_SOUND.getValue())
            item.world.playSound(null, item.getPosition(), SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 1.0F, (float) (0.8F + (Math.random() * 0.2D)));
        // item.setPositionAndUpdate(x, y, z);
        item.setNoPickupDelay();
        item.onCollideWithPlayer(player);
        pulled++;
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) ItemEntity(net.minecraft.entity.item.ItemEntity) PacketDistributor(net.minecraftforge.fml.network.PacketDistributor) PacketPortalParticles(com.integral.enigmaticlegacy.packets.clients.PacketPortalParticles) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 8 with PacketPortalParticles

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

the class Megasponge method onCurioTick.

@Override
public void onCurioTick(String identifier, LivingEntity living) {
    if (living instanceof PlayerEntity & !living.world.isRemote) {
        PlayerEntity player = (PlayerEntity) living;
        cooldownMap.tick(living);
        if (!cooldownMap.hasCooldown(player)) {
            List<BlockPos> doomedWaterBlocks = new ArrayList<BlockPos>();
            BlockPos initialPos = getCollidedWater(FluidTags.WATER, player);
            BlockState initialState = initialPos != null ? player.world.getBlockState(initialPos) : null;
            if (initialPos != null)
                if (initialState.getFluidState() != null && initialState.getFluidState().isTagged(FluidTags.WATER)) {
                    doomedWaterBlocks.add(initialPos);
                    List<BlockPos> processedBlocks = new ArrayList<BlockPos>();
                    processedBlocks.add(initialPos);
                    for (int counter = 0; counter <= ConfigHandler.EXTRAPOLATED_MEGASPONGE_RADIUS.getValue(); counter++) {
                        List<BlockPos> outputBlocks = new ArrayList<BlockPos>();
                        for (BlockPos checkedPos : processedBlocks) {
                            outputBlocks.addAll(getNearbyWater(player.world, checkedPos));
                        }
                        processedBlocks.clear();
                        for (BlockPos thePos : outputBlocks) {
                            if (!doomedWaterBlocks.contains(thePos)) {
                                processedBlocks.add(thePos);
                                doomedWaterBlocks.add(thePos);
                            }
                        }
                        outputBlocks.clear();
                    }
                    processedBlocks.clear();
                    for (BlockPos exterminatedBlock : doomedWaterBlocks) absorbWaterBlock(exterminatedBlock, player.world.getBlockState(exterminatedBlock), player.world);
                    doomedWaterBlocks.clear();
                    player.world.playSound(null, player.getPosition(), SoundEvents.ITEM_BUCKET_FILL, 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, 64, player.dimension)), new PacketPortalParticles(player.posX, player.posY + (player.getHeight() / 2), player.posZ, 40, 1.0D, false));
                    cooldownMap.put(player, 20);
                }
        }
    }
}
Also used : BlockState(net.minecraft.block.BlockState) PacketDistributor(net.minecraftforge.fml.network.PacketDistributor) ArrayList(java.util.ArrayList) BlockPos(net.minecraft.util.math.BlockPos) ArrayList(java.util.ArrayList) List(java.util.List) PacketPortalParticles(com.integral.enigmaticlegacy.packets.clients.PacketPortalParticles) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

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