Java Code Examples for net.minecraft.item.Items#ELYTRA

The following examples show how to use net.minecraft.item.Items#ELYTRA . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExtraElytraHack.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onUpdate()
{
	if(jumpTimer > 0)
		jumpTimer--;
	
	ItemStack chest = MC.player.getEquippedStack(EquipmentSlot.CHEST);
	if(chest.getItem() != Items.ELYTRA)
		return;
	
	if(MC.player.isFallFlying())
	{
		if(stopInWater.isChecked() && MC.player.isTouchingWater())
		{
			sendStartStopPacket();
			return;
		}
		
		controlSpeed();
		controlHeight();
		return;
	}
	
	if(ElytraItem.isUsable(chest) && MC.options.keyJump.isPressed())
		doInstantFly();
}
 
Example 2
Source File: ElytraFeature.java    From MineLittlePony with MIT License 6 votes vote down vote up
@Override
public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
    ItemStack itemstack = entity.getEquippedStack(EquipmentSlot.CHEST);

    if (itemstack.getItem() == Items.ELYTRA) {
        stack.push();
        preRenderCallback(stack);

        EntityModel<T> elytra = getElytraModel();

        getContextModel().copyStateTo(elytra);
        if (elytra instanceof PonyElytra) {
            ((PonyElytra<T>)elytra).isSneaking = getContext().getEntityPony(entity).isCrouching(entity);
        }

        elytra.setAngles(entity, limbDistance, limbAngle, age, headYaw, headPitch);
        VertexConsumer vertexConsumer = ItemRenderer.method_29711(renderContext, modelElytra.getLayer(getElytraTexture(entity)), false, itemstack.hasEnchantmentGlint());
        modelElytra.render(stack, vertexConsumer, lightUv, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1);

        stack.pop();
    }
}
 
Example 3
Source File: PlayerEntity_antiCheatDisabled.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Inject(method = "method_23668", at = @At("HEAD"), cancellable = true)
private void allowDeploys(CallbackInfoReturnable<Boolean> cir)
{
    if (CarpetSettings.antiCheatDisabled && CarpetServer.minecraft_server != null && CarpetServer.minecraft_server.isDedicated())
    {
        ItemStack itemStack_1 = getEquippedStack(EquipmentSlot.CHEST);
        if (itemStack_1.getItem() == Items.ELYTRA && ElytraItem.isUsable(itemStack_1)) {
            method_23669();
            cir.setReturnValue(true);
        }
    }
}
 
Example 4
Source File: CapeFeature.java    From MineLittlePony with MIT License 5 votes vote down vote up
@Override
public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, AbstractClientPlayerEntity player, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
    M model = getContextModel();

    if (player.hasSkinTexture() && !player.isInvisible()
            && player.isPartVisible(PlayerModelPart.CAPE) && player.getCapeTexture() != null
            && player.getEquippedStack(EquipmentSlot.CHEST).getItem() != Items.ELYTRA) {

        stack.push();

        model.transform(BodyPart.BODY, stack);
        stack.translate(0, 0.24F, 0);
        model.getBodyPart(BodyPart.BODY).rotate(stack);

        double capeX = MathHelper.lerp(tickDelta, player.capeX, player.prevCapeX) - MathHelper.lerp(tickDelta, player.prevX, player.getX());
        double capeY = MathHelper.lerp(tickDelta, player.capeY, player.prevCapeY) - MathHelper.lerp(tickDelta, player.prevY, player.getY());
        double capeZ = MathHelper.lerp(tickDelta, player.capeZ, player.prevCapeZ) - MathHelper.lerp(tickDelta, player.prevZ, player.getZ());

        float motionYaw = player.prevBodyYaw + (player.bodyYaw - player.prevBodyYaw);

        double sin = MathHelper.sin(motionYaw * PI / 180);
        double cos = (-MathHelper.cos(motionYaw * PI / 180));

        float capeMotionY = (float) capeY * 10;

        if (capeMotionY < -6) capeMotionY = -6;
        if (capeMotionY > 32) capeMotionY = 32;

        float capeMotionX = (float) (capeX * sin + capeZ * cos) * 100;

        float diagMotion =  (float) (capeX * cos - capeZ * sin) * 100;

        if (capeMotionX < 0) capeMotionX = 0;

        float camera = MathHelper.lerp(tickDelta, player.prevStrideDistance, player.strideDistance);
        capeMotionY += MathHelper.sin(MathHelper.lerp(tickDelta, player.prevHorizontalSpeed, player.horizontalSpeed) * 6) * 32 * camera;

        stack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(2 + capeMotionX / 12 + capeMotionY));
        stack.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion( diagMotion / 2));
        stack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-diagMotion / 2));
        stack.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(180));
        stack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(90));

        VertexConsumer vertices = renderContext.getBuffer(RenderLayer.getEntitySolid(player.getCapeTexture()));
        model.renderCape(stack, vertices, lightUv, OverlayTexture.DEFAULT_UV);
        stack.pop();
    }
}