Search in sources :

Example 1 with PermanentItemEntity

use of com.integral.enigmaticlegacy.entities.PermanentItemEntity 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

PermanentItemEntity (com.integral.enigmaticlegacy.entities.PermanentItemEntity)1 PacketPortalParticles (com.integral.enigmaticlegacy.packets.clients.PacketPortalParticles)1 PacketRecallParticles (com.integral.enigmaticlegacy.packets.clients.PacketRecallParticles)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)1 ItemStack (net.minecraft.item.ItemStack)1 Vec3d (net.minecraft.util.math.Vec3d)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1