net.minecraft.entity.EquipmentSlot Java Examples

The following examples show how to use net.minecraft.entity.EquipmentSlot. 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: PonyStandRenderer.java    From MineLittlePony with MIT License 6 votes vote down vote up
@Override
public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, ArmorStandEntity entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
    if (entity.hasCustomName() && "Ponita".equals(entity.getCustomName().asString())) {

        headPitch = 0.017453292F * entity.getHeadRotation().getPitch();
        headYaw = 0.017453292F * entity.getHeadRotation().getYaw();

        pony.getBody().animateModel(entity, limbDistance, limbAngle, tickDelta);
        pony.getBody().setAngles(entity, limbDistance, limbAngle, age, headYaw, headPitch);

        for (EquipmentSlot i : EquipmentSlot.values()) {
            if (i.getType() == EquipmentSlot.Type.ARMOR) {
                ArmourFeature.renderArmor(pony, stack, renderContext, lightUv, entity, limbDistance, limbAngle, age, headYaw, headPitch, i, ArmourLayer.INNER);
                ArmourFeature.renderArmor(pony, stack, renderContext, lightUv, entity, limbDistance, limbAngle, age, headYaw, headPitch, i, ArmourLayer.OUTER);
            }
        }
    } else {
        super.render(stack, renderContext, lightUv, entity, limbDistance, limbAngle, tickDelta, age, headYaw, headPitch);
    }
}
 
Example #2
Source File: StandardWrenchItem.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
private void use(PlayerEntity player, BlockState state, WorldAccess iWorld, BlockPos pos, ItemStack stack) {
    Block block = state.getBlock();
    if (block instanceof Rotatable) {
        StateManager<Block, BlockState> manager = block.getStateManager();
        Collection<Property<?>> collection = manager.getProperties();
        String string_1 = Registry.BLOCK.getId(block).toString();
        if (!collection.isEmpty()) {
            CompoundTag compoundTag_1 = stack.getOrCreateSubTag("wrenchProp");
            String string_2 = compoundTag_1.getString(string_1);
            Property<?> property = manager.getProperty(string_2);
            if (property == null) {
                property = collection.iterator().next();
            }
            if (property.getName().equals("facing")) {
                BlockState blockState_2 = cycle(state, property, player.isSneaking());
                iWorld.setBlockState(pos, blockState_2, 18);
                stack.damage(2, player, (playerEntity) -> playerEntity.sendEquipmentBreakStatus(EquipmentSlot.MAINHAND));
            }
        }
    }
}
 
Example #3
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 #4
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 #5
Source File: DefaultArmourTextureResolver.java    From MineLittlePony with MIT License 5 votes vote down vote up
@Override
public Identifier getArmourTexture(T entity, ItemStack itemstack, EquipmentSlot slot, ArmourLayer layer,  @Nullable String type) {
    type = Strings.nullToEmpty(type);

    ArmorItem item = (ArmorItem) itemstack.getItem();
    String texture = item.getMaterial().getName();

    String domain = "minecraft";

    int idx = texture.indexOf(':');
    if (idx > -1) {
        domain = texture.substring(0, idx);
        texture = texture.substring(idx + 1);
    }

    String customType = type.isEmpty() ? "" : String.format("_%s", type);

    String res = String.format("%s:textures/models/armor/%s_layer_%s%s.png", domain, texture, layer.name().toLowerCase(), customType);
    String oldRes = String.format("%s:textures/models/armor/%s_layer_%d%s.png", domain, texture, layer == ArmourLayer.INNER ? 2 : 1, customType);

    Identifier human = getArmorTexture(res, type);
    Identifier pony = ponifyResource(human);

    Identifier oldHuman = getArmorTexture(oldRes, type);
    Identifier oldPony = ponifyResource(oldHuman);

    return resolve(oldPony, pony, oldHuman, human);
}
 
Example #6
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 #7
Source File: IArmour.java    From MineLittlePony with MIT License 5 votes vote down vote up
/**
 * Prepares an armour model for rendering, first hiding all the pieces and then incrementally showing them as appropriate.
 *
 * @param slot      The armour slot being rendered
 * @param layer     The layer. INNER/OUTER
 *
 * @return false to skip this render pass.
 */
default boolean prepareToRender(EquipmentSlot slot, ArmourLayer layer) {
    setInVisible();

    switch (layer) {
        case OUTER:
            switch (slot) {
                case HEAD:
                    showHelmet();
                    return true;
                case FEET:
                    showBoots();
                    return true;
                case CHEST:
                    showSaddle();
                    return true;
                default:
                    return false;
            }
        case INNER:
            switch (slot) {
                case LEGS:
                    showLeggings();
                    return true;
                case CHEST:
                    showChestplate();
                    return true;
                default:
                    return false;
            }
    }

    return false;
}
 
Example #8
Source File: AutoArmorHack.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
private int getArmorValue(ArmorItem item, ItemStack stack)
{
	int armorPoints = item.getProtection();
	int prtPoints = 0;
	int armorToughness = (int)((IArmorItem)item).getToughness();
	int armorType =
		item.getMaterial().getProtectionAmount(EquipmentSlot.LEGS);
	
	if(useEnchantments.isChecked())
	{
		Enchantment protection = Enchantments.PROTECTION;
		int prtLvl = EnchantmentHelper.getLevel(protection, stack);
		
		ClientPlayerEntity player = MC.player;
		DamageSource dmgSource = DamageSource.player(player);
		prtPoints = protection.getProtectionAmount(prtLvl, dmgSource);
	}
	
	return armorPoints * 5 + prtPoints * 3 + armorToughness + armorType;
}
 
Example #9
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();
    }
}
 
Example #10
Source File: AbstractSkeletonEntityMixin.java    From the-hallow with MIT License 5 votes vote down vote up
@Inject(method = "initEquipment(Lnet/minecraft/world/LocalDifficulty;)V", at = @At(value = "TAIL"))
protected void initEquipment(LocalDifficulty ld, CallbackInfo cb) {
	Random random = new Random();
	if (HallowedConfig.TrumpetSkeleton.enabled && random.nextInt(HallowedConfig.TrumpetSkeleton.chance) == 0) {
		//noinspection ConstantConditions
		((AbstractSkeletonEntity) (Object) this).equipStack(EquipmentSlot.MAINHAND, new ItemStack(HallowedItems.TRUMPET));
	}
}
 
Example #11
Source File: SkullFeature.java    From MineLittlePony with MIT License 5 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.HEAD);
    if (!itemstack.isEmpty()) {
        M model = getContext().getModelWrapper().getBody();
        Item item = itemstack.getItem();

        stack.push();

        model.transform(BodyPart.HEAD, stack);
        model.getHead().rotate(stack);

        if (model instanceof AbstractPonyModel) {
            stack.translate(0, 0.225F, 0);
        } else {
            stack.translate(0, 0, 0.15F);
        }

        if (item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof AbstractSkullBlock) {
            boolean isVillager = entity instanceof VillagerDataContainer;

            renderSkull(stack, renderContext, itemstack, isVillager, limbDistance, lightUv);
        } else if (!(item instanceof ArmorItem) || ((ArmorItem)item).getSlotType() != EquipmentSlot.HEAD) {
            renderBlock(stack, renderContext, entity, itemstack, lightUv);
        }

        stack.pop();
    }

}
 
Example #12
Source File: SkeletonEntityMixin.java    From the-hallow with MIT License 5 votes vote down vote up
@Inject(method = "getAmbientSound()Lnet/minecraft/sound/SoundEvent;", at = @At("RETURN"), cancellable = true)
protected void getAmbientSound(CallbackInfoReturnable<SoundEvent> cb) {
	//noinspection ConstantConditions
	if (((SkeletonEntity) (Object) this).getEquippedStack(EquipmentSlot.MAINHAND).getItem() == HallowedItems.TRUMPET) {
		cb.setReturnValue(HallowedSounds.DOOT);
	}
}
 
Example #13
Source File: ArmourFeature.java    From MineLittlePony with MIT License 5 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) {
    ModelWrapper<T, M> pony = getContext().getModelWrapper();

    for (EquipmentSlot i : EquipmentSlot.values()) {
        if (i.getType() == EquipmentSlot.Type.ARMOR) {
            renderArmor(pony, stack, renderContext, lightUv, entity, limbDistance, limbAngle, age, headYaw, headPitch, i, ArmourLayer.INNER);
            renderArmor(pony, stack, renderContext, lightUv, entity, limbDistance, limbAngle, age, headYaw, headPitch, i, ArmourLayer.OUTER);
        }
    }
}
 
Example #14
Source File: GalacticraftItems.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override
public boolean postMine(ItemStack stack, World world, BlockState blockState, BlockPos blockPos, LivingEntity entityLiving) {
    //Stronger than vanilla
    if (blockState.getHardness(null, blockPos) > 0.2001F) {
        stack.damage(2, entityLiving, (livingEntity) -> livingEntity.sendEquipmentBreakStatus(EquipmentSlot.MAINHAND));
    }
    return true;
}
 
Example #15
Source File: GalacticraftItems.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override
public boolean postMine(ItemStack stack, World world, BlockState blockState, BlockPos blockPos, LivingEntity entityLiving) {
    //Stronger than vanilla
    if (blockState.getHardness(null, blockPos) > 0.2001F) {
        stack.damage(2, entityLiving, (livingEntity) -> livingEntity.sendEquipmentBreakStatus(EquipmentSlot.MAINHAND));
    }
    return true;
}
 
Example #16
Source File: ThermalArmorItem.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
public int getSlotIdForType(EquipmentSlot slotType) {
    switch (slotType) {
        case HEAD:
            return 0;
        case CHEST:
            return 1;
        case LEGS:
            return 2;
        case FEET:
            return 3;
    }
    return -128; //oh no
}
 
Example #17
Source File: ArmourFeature.java    From MineLittlePony with MIT License 4 votes vote down vote up
public static <T extends LivingEntity, V extends BipedEntityModel<T> & IArmour> void renderArmor(
        ModelWrapper<T, ? extends IPonyModel<T>> pony, MatrixStack stack,
                VertexConsumerProvider renderContext, int lightUv, T entity,
                float limbDistance, float limbAngle,
                float age, float headYaw, float headPitch,
                EquipmentSlot armorSlot, ArmourLayer layer) {

    ItemStack itemstack = entity.getEquippedStack(armorSlot);

    if (!itemstack.isEmpty() && itemstack.getItem() instanceof ArmorItem) {

        V model = pony.<V>getArmor().getArmorForLayer(layer);

        if (model.prepareToRender(armorSlot, layer)) {
            pony.getBody().copyAttributes(model);
            model.setAngles(entity, limbAngle, limbDistance, age, headYaw, headPitch);
            model.synchroniseAngles(pony.getBody());

            ArmorItem item = (ArmorItem) itemstack.getItem();

            float red = 1;
            float green = 1;
            float blue = 1;

            if (item instanceof DyeableArmorItem) {
                int color = ((DyeableArmorItem)item).getColor(itemstack);
                red = Color.r(color);
                green = Color.g(color);
                blue = Color.b(color);
            }

            @SuppressWarnings("unchecked")
            IArmourTextureResolver<T> resolver = model instanceof IArmourTextureResolver ? (IArmourTextureResolver<T>)model : (IArmourTextureResolver<T>)DEFAULT;

            boolean glint = itemstack.hasEnchantmentGlint();

            renderArmourPart(stack, renderContext, lightUv, glint, model, red, green, blue, resolver, layer, resolver.getArmourTexture(entity, itemstack, armorSlot, layer, null));

            if (item instanceof DyeableArmorItem) {
                renderArmourPart(stack, renderContext, lightUv, false, model, 1, 1, 1, resolver, layer, resolver.getArmourTexture(entity, itemstack, armorSlot, layer, "overlay"));
            }
        }
    }
}
 
Example #18
Source File: ThermalArmorItem.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
public ThermalArmorItem(Settings settings, EquipmentSlot slotType) {
    super(settings);
    this.slotType = slotType;
}
 
Example #19
Source File: DummyEnchantments.java    From fabric-carpet with MIT License 4 votes vote down vote up
protected Dummies()
{
    super(Weight.COMMON, EnchantmentTarget.ALL, new EquipmentSlot[]{EquipmentSlot.MAINHAND});
}
 
Example #20
Source File: EnchantmentWrapper.java    From Sandbox with GNU Lesser General Public License v3.0 4 votes vote down vote up
public EnchantmentWrapper(Enchantment enchantment) {
    super(Weight.COMMON, EnchantmentTarget.ALL, EquipmentSlot.values()); //TODO: Allow sandbox enchants to specify these values
    this.enchantment = enchantment;
}
 
Example #21
Source File: IForgeItem.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * ItemStack sensitive version of {@link Item#getModifiers}.
 */
default Multimap<String, EntityAttributeModifier> getAttributeModifiers(EquipmentSlot slot, ItemStack stack) {
	return getItem().getModifiers(slot);
}
 
Example #22
Source File: ZombieEntityMixin.java    From the-hallow with MIT License 4 votes vote down vote up
@Redirect(method = "initialize(Lnet/minecraft/world/IWorld;Lnet/minecraft/world/LocalDifficulty;Lnet/minecraft/entity/SpawnType;Lnet/minecraft/entity/EntityData;Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/entity/EntityData;", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/mob/ZombieEntity;getEquippedStack(Lnet/minecraft/entity/EquipmentSlot;)Lnet/minecraft/item/ItemStack;"))
private ItemStack getStack(ZombieEntity zombieEntity, EquipmentSlot equipmentSlot) {
	return MixinHelpers.getEquippedOrPumpkin(zombieEntity, equipmentSlot);
}
 
Example #23
Source File: AbstractSkeletonEntityMixin.java    From the-hallow with MIT License 4 votes vote down vote up
@Redirect(method = "initialize(Lnet/minecraft/world/IWorld;Lnet/minecraft/world/LocalDifficulty;Lnet/minecraft/entity/SpawnType;Lnet/minecraft/entity/EntityData;Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/entity/EntityData;", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/mob/AbstractSkeletonEntity;getEquippedStack(Lnet/minecraft/entity/EquipmentSlot;)Lnet/minecraft/item/ItemStack;"))
private ItemStack getStack(AbstractSkeletonEntity entity, EquipmentSlot equipmentSlot) {
	return MixinHelpers.getEquippedOrPumpkin(entity, equipmentSlot);
}
 
Example #24
Source File: LifestealEnchantment.java    From the-hallow with MIT License 4 votes vote down vote up
public LifestealEnchantment(Enchantment.Weight weight, EnchantmentTarget target, EquipmentSlot[] slots) {
	super(weight, target, slots);
}
 
Example #25
Source File: BeheadingEnchantment.java    From the-hallow with MIT License 4 votes vote down vote up
public BeheadingEnchantment(Enchantment.Weight weight, EnchantmentTarget target, EquipmentSlot[] slots) {
	super(weight, target, slots);
}
 
Example #26
Source File: ThermalArmorItem.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
public EquipmentSlot getSlotType() {
    return slotType;
}
 
Example #27
Source File: PlayerInventoryGCScreenHandler.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
private EquipmentSlot getPreferredEquipmentSlot(ItemStack itemStack_1) {
    Item item_1 = itemStack_1.getItem();
    return ((ThermalArmorItem) item_1).getSlotType();
}
 
Example #28
Source File: IForgeItem.java    From patchwork-api with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Override this method to have an item handle its own armor rendering.
 *
 * @param entityLiving The entity wearing the armor
 * @param itemStack    The itemStack to render the model of
 * @param armorSlot    The slot the armor is in
 * @param _default     Original armor model. Will have attributes set.
 * @return A BipedEntityModel to render instead of the default
 */
@Environment(EnvType.CLIENT)
@Nullable
default <A extends BipedEntityModel<?>> A getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlot armorSlot, A _default) {
	return null;
}
 
Example #29
Source File: IForgeItem.java    From patchwork-api with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Called to determine the armor texture that should be use for the currently
 * equipped item. This will only be called on instances of {@link net.minecraft.item.ArmorItem}
 *
 * <p>Returning null from this function will use the default value.
 *
 * @param stack  ItemStack for the equipped armor
 * @param entity The entity wearing the armor
 * @param slot   The slot the armor is in
 * @param type   The subtype, can be null or "overlay"
 * @return Path of texture to bind, or null to use default
 */
@Nullable
default String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, String type) {
	return null;
}
 
Example #30
Source File: IForgeItem.java    From patchwork-api with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Override this to set a non-default armor slot for an ItemStack, but <em>do
 * not use this to get the armor slot of said stack; for that, use
 * {@link MobEntity#getPreferredEquipmentSlot(ItemStack)}.</em>
 *
 * @param stack the ItemStack
 * @return the armor slot of the ItemStack, or {@code null} to let the default
 * vanilla logic as per {@link MobEntity#getPreferredEquipmentSlot(ItemStack)}
 * decide
 */
@Nullable
default EquipmentSlot getEquipmentSlot(ItemStack stack) {
	return null;
}