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));
}
}
}
Aggregations