Search in sources :

Example 1 with ElytraItem

use of net.minecraft.world.item.ElytraItem in project Create by Creators-of-Create.

the class EjectorTileEntity method activateDeferred.

public void activateDeferred() {
    if (cannotLaunch())
        return;
    Direction facing = getFacing();
    List<Entity> entities = level.getEntitiesOfClass(Entity.class, new AABB(worldPosition).inflate(-1 / 16f, 0, -1 / 16f));
    // Launch Items
    boolean doLogic = !level.isClientSide || isVirtual();
    if (doLogic)
        launchItems();
    // Launch Entities
    for (Entity entity : entities) {
        boolean isPlayerEntity = entity instanceof Player;
        if (!entity.isAlive())
            continue;
        if (entity instanceof ItemEntity)
            continue;
        if (entity.getPistonPushReaction() == PushReaction.IGNORE)
            continue;
        entity.setOnGround(false);
        if (isPlayerEntity != level.isClientSide)
            continue;
        entity.setPos(worldPosition.getX() + .5f, worldPosition.getY() + 1, worldPosition.getZ() + .5f);
        launcher.applyMotion(entity, facing);
        if (!isPlayerEntity)
            continue;
        Player playerEntity = (Player) entity;
        if (!(playerEntity.getItemBySlot(EquipmentSlot.CHEST).getItem() instanceof ElytraItem))
            continue;
        playerEntity.setXRot(-35);
        playerEntity.setYRot(facing.toYRot());
        playerEntity.setDeltaMovement(playerEntity.getDeltaMovement().scale(.75f));
        deployElytra(playerEntity);
        AllPackets.channel.sendToServer(new EjectorElytraPacket(worldPosition));
    }
    if (doLogic) {
        lidProgress.chase(1, .8f, Chaser.EXP);
        state = State.LAUNCHING;
        if (!level.isClientSide) {
            level.playSound(null, worldPosition, SoundEvents.WOODEN_TRAPDOOR_CLOSE, SoundSource.BLOCKS, .35f, 1f);
            level.playSound(null, worldPosition, SoundEvents.CHEST_OPEN, SoundSource.BLOCKS, .1f, 1.4f);
        }
    }
}
Also used : ItemEntity(net.minecraft.world.entity.item.ItemEntity) KineticTileEntity(com.simibubi.create.content.contraptions.base.KineticTileEntity) Entity(net.minecraft.world.entity.Entity) Player(net.minecraft.world.entity.player.Player) ItemEntity(net.minecraft.world.entity.item.ItemEntity) ElytraItem(net.minecraft.world.item.ElytraItem) Direction(net.minecraft.core.Direction) AABB(net.minecraft.world.phys.AABB)

Example 2 with ElytraItem

use of net.minecraft.world.item.ElytraItem in project CustomPlayerModels by tom5454.

the class PlayerProfile method updateFromPlayer.

@Override
public void updateFromPlayer(net.minecraft.world.entity.player.Player player) {
    Pose p = player.getPose();
    animState.resetPlayer();
    switch(p) {
        case CROUCHING:
            animState.sneaking = true;
            break;
        case DYING:
            break;
        case FALL_FLYING:
            animState.elytraFlying = true;
            break;
        case SLEEPING:
            animState.sleeping = true;
            break;
        case SPIN_ATTACK:
            animState.tridentSpin = true;
            break;
        case STANDING:
            break;
        case SWIMMING:
            animState.swimming = true;
            break;
        default:
            break;
    }
    if (!player.isAlive())
        animState.dying = true;
    if (player.isPassenger() && (player.getVehicle() != null && player.getVehicle().shouldRiderSit()))
        animState.riding = true;
    if (player.getAbilities().flying)
        animState.creativeFlying = true;
    if (player.isSprinting())
        animState.sprinting = true;
    if (player.isUsingItem()) {
        animState.usingAnimation = HandAnimation.of(player.getUseItem().getUseAnimation());
    }
    animState.fallDistance = player.fallDistance;
    animState.moveAmountX = (float) (player.getX() - player.xo);
    animState.moveAmountY = (float) (player.getY() - player.yo);
    animState.moveAmountZ = (float) (player.getZ() - player.zo);
    animState.yaw = player.getYRot();
    animState.pitch = player.getXRot();
    if (player.isModelPartShown(PlayerModelPart.HAT))
        animState.encodedState |= 1;
    if (player.isModelPartShown(PlayerModelPart.JACKET))
        animState.encodedState |= 2;
    if (player.isModelPartShown(PlayerModelPart.LEFT_PANTS_LEG))
        animState.encodedState |= 4;
    if (player.isModelPartShown(PlayerModelPart.RIGHT_PANTS_LEG))
        animState.encodedState |= 8;
    if (player.isModelPartShown(PlayerModelPart.LEFT_SLEEVE))
        animState.encodedState |= 16;
    if (player.isModelPartShown(PlayerModelPart.RIGHT_SLEEVE))
        animState.encodedState |= 32;
    ItemStack is = player.getItemBySlot(EquipmentSlot.HEAD);
    animState.hasSkullOnHead = is.getItem() instanceof BlockItem && ((BlockItem) is.getItem()).getBlock() instanceof AbstractSkullBlock;
    animState.wearingHelm = !is.isEmpty();
    is = player.getItemBySlot(EquipmentSlot.CHEST);
    animState.wearingElytra = is.getItem() instanceof ElytraItem;
    animState.wearingBody = !is.isEmpty();
    animState.wearingLegs = !player.getItemBySlot(EquipmentSlot.LEGS).isEmpty();
    animState.wearingBoots = !player.getItemBySlot(EquipmentSlot.FEET).isEmpty();
    animState.mainHand = Hand.of(player.getMainArm());
    animState.activeHand = Hand.of(animState.mainHand, player.getUsedItemHand());
    animState.swingingHand = Hand.of(animState.mainHand, player.swingingArm);
    animState.hurtTime = player.hurtTime;
    animState.isOnLadder = player.onClimbable();
    animState.isBurning = player.displayFireAnimation();
    animState.isFreezing = player.getTicksFrozen() > 0;
    if (player.getUseItem().getItem() instanceof CrossbowItem) {
        float f = CrossbowItem.getChargeDuration(player.getUseItem());
        float f1 = MathHelper.clamp(player.getTicksUsingItem(), 0.0F, f);
        animState.crossbowPullback = f1 / f;
    }
    if (player.getUseItem().getItem() instanceof BowItem) {
        float f = 20F;
        float f1 = MathHelper.clamp(player.getTicksUsingItem(), 0.0F, f);
        animState.bowPullback = f1 / f;
    }
    animState.parrotLeft = !player.getShoulderEntityLeft().getString("id").isEmpty();
    animState.parrotRight = !player.getShoulderEntityRight().getString("id").isEmpty();
}
Also used : CrossbowItem(net.minecraft.world.item.CrossbowItem) AbstractSkullBlock(net.minecraft.world.level.block.AbstractSkullBlock) Pose(net.minecraft.world.entity.Pose) ArmPose(com.tom.cpm.shared.model.render.PlayerModelSetup.ArmPose) BowItem(net.minecraft.world.item.BowItem) ElytraItem(net.minecraft.world.item.ElytraItem) ItemStack(net.minecraft.world.item.ItemStack) BlockItem(net.minecraft.world.item.BlockItem)

Aggregations

ElytraItem (net.minecraft.world.item.ElytraItem)2 KineticTileEntity (com.simibubi.create.content.contraptions.base.KineticTileEntity)1 ArmPose (com.tom.cpm.shared.model.render.PlayerModelSetup.ArmPose)1 Direction (net.minecraft.core.Direction)1 Entity (net.minecraft.world.entity.Entity)1 Pose (net.minecraft.world.entity.Pose)1 ItemEntity (net.minecraft.world.entity.item.ItemEntity)1 Player (net.minecraft.world.entity.player.Player)1 BlockItem (net.minecraft.world.item.BlockItem)1 BowItem (net.minecraft.world.item.BowItem)1 CrossbowItem (net.minecraft.world.item.CrossbowItem)1 ItemStack (net.minecraft.world.item.ItemStack)1 AbstractSkullBlock (net.minecraft.world.level.block.AbstractSkullBlock)1 AABB (net.minecraft.world.phys.AABB)1