Search in sources :

Example 1 with ArmorItem

use of net.minecraft.world.item.ArmorItem in project AlexsMobs by Alex-the-666.

the class LayerMimicubeHelmet method getArmorResource.

public static ResourceLocation getArmorResource(net.minecraft.world.entity.Entity entity, ItemStack stack, EquipmentSlot slot, @javax.annotation.Nullable String type) {
    ArmorItem item = (ArmorItem) stack.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 s1 = String.format("%s:textures/models/armor/%s_layer_%d%s.png", domain, texture, (1), type == null ? "" : String.format("_%s", type));
    s1 = net.minecraftforge.client.ForgeHooksClient.getArmorTexture(entity, stack, s1, slot, type);
    ResourceLocation resourcelocation = ARMOR_TEXTURE_RES_MAP.get(s1);
    if (resourcelocation == null) {
        resourcelocation = new ResourceLocation(s1);
        ARMOR_TEXTURE_RES_MAP.put(s1, resourcelocation);
    }
    return resourcelocation;
}
Also used : ArmorItem(net.minecraft.world.item.ArmorItem) ResourceLocation(net.minecraft.resources.ResourceLocation)

Example 2 with ArmorItem

use of net.minecraft.world.item.ArmorItem in project AlexsMobs by Alex-the-666.

the class LayerMimicubeHelmet method render.

public void render(PoseStack matrixStackIn, MultiBufferSource bufferIn, int packedLightIn, EntityMimicube cube, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
    matrixStackIn.pushPose();
    ItemStack itemstack = cube.getItemBySlot(EquipmentSlot.HEAD);
    float helmetSwap = Mth.lerp(partialTicks, cube.prevHelmetSwapProgress, cube.helmetSwapProgress) * 0.2F;
    if (itemstack.getItem() instanceof ArmorItem) {
        ArmorItem armoritem = (ArmorItem) itemstack.getItem();
        if (armoritem.getSlot() == EquipmentSlot.HEAD) {
            HumanoidModel a = defaultBipedModel;
            a = getArmorModelHook(cube, itemstack, EquipmentSlot.HEAD, a);
            boolean notAVanillaModel = a != defaultBipedModel;
            this.setModelSlotVisible(a, EquipmentSlot.HEAD);
            boolean flag = false;
            this.renderer.getModel().root.translateAndRotate(matrixStackIn);
            this.renderer.getModel().innerbody.translateAndRotate(matrixStackIn);
            matrixStackIn.translate(0, notAVanillaModel ? 0.25F : -0.75F, 0F);
            matrixStackIn.scale(1F + 0.3F * (1 - helmetSwap), 1F + 0.3F * (1 - helmetSwap), 1F + 0.3F * (1 - helmetSwap));
            boolean flag1 = itemstack.hasFoil();
            int clampedLight = helmetSwap > 0 ? (int) (-100 * helmetSwap) : packedLightIn;
            matrixStackIn.mulPose(Vector3f.YP.rotationDegrees(360 * helmetSwap));
            if (armoritem instanceof net.minecraft.world.item.DyeableLeatherItem) {
                // Allow this for anything, not only cloth
                int i = ((net.minecraft.world.item.DyeableLeatherItem) armoritem).getColor(itemstack);
                float f = (float) (i >> 16 & 255) / 255.0F;
                float f1 = (float) (i >> 8 & 255) / 255.0F;
                float f2 = (float) (i & 255) / 255.0F;
                renderArmor(cube, matrixStackIn, bufferIn, clampedLight, flag1, a, f, f1, f2, getArmorResource(cube, itemstack, EquipmentSlot.HEAD, null), notAVanillaModel);
                renderArmor(cube, matrixStackIn, bufferIn, clampedLight, flag1, a, 1.0F, 1.0F, 1.0F, getArmorResource(cube, itemstack, EquipmentSlot.HEAD, "overlay"), notAVanillaModel);
            } else {
                renderArmor(cube, matrixStackIn, bufferIn, clampedLight, flag1, a, 1.0F, 1.0F, 1.0F, getArmorResource(cube, itemstack, EquipmentSlot.HEAD, null), notAVanillaModel);
            }
        }
    }
    matrixStackIn.popPose();
}
Also used : HumanoidModel(net.minecraft.client.model.HumanoidModel) ArmorItem(net.minecraft.world.item.ArmorItem) ItemStack(net.minecraft.world.item.ItemStack)

Example 3 with ArmorItem

use of net.minecraft.world.item.ArmorItem in project AlexsMobs by Alex-the-666.

the class LayerKangarooArmor method render.

public void render(PoseStack matrixStackIn, MultiBufferSource bufferIn, int packedLightIn, EntityKangaroo roo, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
    matrixStackIn.pushPose();
    if (roo.isRoger()) {
        ItemStack haloStack = new ItemStack(AMItemRegistry.HALO);
        matrixStackIn.pushPose();
        translateToHead(matrixStackIn);
        float f = 0.1F * (float) Math.sin((roo.tickCount + partialTicks) * 0.1F) + (roo.isBaby() ? 0.2F : 0F);
        matrixStackIn.translate(0.0F, -0.75F - f, -0.2F);
        matrixStackIn.mulPose(Vector3f.XP.rotationDegrees(90F));
        matrixStackIn.scale(1.3F, 1.3F, 1.3F);
        Minecraft.getInstance().getItemInHandRenderer().renderItem(roo, haloStack, ItemTransforms.TransformType.GROUND, false, matrixStackIn, bufferIn, packedLightIn);
        matrixStackIn.popPose();
    }
    if (!roo.isBaby()) {
        {
            matrixStackIn.pushPose();
            ItemStack itemstack = roo.getItemBySlot(EquipmentSlot.HEAD);
            if (itemstack.getItem() instanceof ArmorItem) {
                ArmorItem armoritem = (ArmorItem) itemstack.getItem();
                if (itemstack.canEquip(EquipmentSlot.HEAD, roo)) {
                    HumanoidModel a = defaultBipedModel;
                    a = getArmorModelHook(roo, itemstack, EquipmentSlot.HEAD, a);
                    boolean notAVanillaModel = a != defaultBipedModel;
                    this.setModelSlotVisible(a, EquipmentSlot.HEAD);
                    translateToHead(matrixStackIn);
                    matrixStackIn.translate(0, 0.015F, -0.05F);
                    if (itemstack.getItem() == AMItemRegistry.FEDORA) {
                        matrixStackIn.translate(0, 0.05F, 0F);
                    }
                    matrixStackIn.scale(0.7F, 0.7F, 0.7F);
                    boolean flag1 = itemstack.hasFoil();
                    int clampedLight = packedLightIn;
                    if (armoritem instanceof net.minecraft.world.item.DyeableLeatherItem) {
                        // Allow this for anything, not only cloth
                        int i = ((net.minecraft.world.item.DyeableLeatherItem) armoritem).getColor(itemstack);
                        float f = (float) (i >> 16 & 255) / 255.0F;
                        float f1 = (float) (i >> 8 & 255) / 255.0F;
                        float f2 = (float) (i & 255) / 255.0F;
                        renderHelmet(roo, matrixStackIn, bufferIn, clampedLight, flag1, a, f, f1, f2, getArmorResource(roo, itemstack, EquipmentSlot.HEAD, null), notAVanillaModel);
                        renderHelmet(roo, matrixStackIn, bufferIn, clampedLight, flag1, a, 1.0F, 1.0F, 1.0F, getArmorResource(roo, itemstack, EquipmentSlot.HEAD, "overlay"), notAVanillaModel);
                    } else {
                        renderHelmet(roo, matrixStackIn, bufferIn, clampedLight, flag1, a, 1.0F, 1.0F, 1.0F, getArmorResource(roo, itemstack, EquipmentSlot.HEAD, null), notAVanillaModel);
                    }
                }
            } else {
                translateToHead(matrixStackIn);
                matrixStackIn.translate(0, -0.2, -0.1F);
                matrixStackIn.mulPose(new Quaternion(Vector3f.XP, 180, true));
                matrixStackIn.mulPose(new Quaternion(Vector3f.YP, 180, true));
                matrixStackIn.scale(1.0F, 1.0F, 1.0F);
                Minecraft.getInstance().getItemRenderer().renderStatic(itemstack, ItemTransforms.TransformType.FIXED, packedLightIn, OverlayTexture.NO_OVERLAY, matrixStackIn, bufferIn, 0);
            }
            matrixStackIn.popPose();
        }
        {
            matrixStackIn.pushPose();
            ItemStack itemstack = roo.getItemBySlot(EquipmentSlot.CHEST);
            if (itemstack.getItem() instanceof ArmorItem) {
                ArmorItem armoritem = (ArmorItem) itemstack.getItem();
                if (armoritem.getSlot() == EquipmentSlot.CHEST) {
                    HumanoidModel a = defaultBipedModel;
                    a = getArmorModelHook(roo, itemstack, EquipmentSlot.CHEST, a);
                    boolean notAVanillaModel = a != defaultBipedModel;
                    this.setModelSlotVisible(a, EquipmentSlot.CHEST);
                    translateToChest(matrixStackIn);
                    matrixStackIn.translate(0, 0.25F, 0F);
                    matrixStackIn.scale(1F, 1F, 1F);
                    boolean flag1 = itemstack.hasFoil();
                    int clampedLight = packedLightIn;
                    if (armoritem instanceof net.minecraft.world.item.DyeableLeatherItem) {
                        // Allow this for anything, not only cloth
                        int i = ((net.minecraft.world.item.DyeableLeatherItem) armoritem).getColor(itemstack);
                        float f = (float) (i >> 16 & 255) / 255.0F;
                        float f1 = (float) (i >> 8 & 255) / 255.0F;
                        float f2 = (float) (i & 255) / 255.0F;
                        renderChestplate(roo, matrixStackIn, bufferIn, clampedLight, flag1, a, f, f1, f2, getArmorResource(roo, itemstack, EquipmentSlot.CHEST, null), notAVanillaModel);
                        renderChestplate(roo, matrixStackIn, bufferIn, clampedLight, flag1, a, 1.0F, 1.0F, 1.0F, getArmorResource(roo, itemstack, EquipmentSlot.CHEST, "overlay"), notAVanillaModel);
                    } else {
                        renderChestplate(roo, matrixStackIn, bufferIn, clampedLight, flag1, a, 1.0F, 1.0F, 1.0F, getArmorResource(roo, itemstack, EquipmentSlot.CHEST, null), notAVanillaModel);
                    }
                }
            }
            matrixStackIn.popPose();
        }
    }
    matrixStackIn.popPose();
}
Also used : HumanoidModel(net.minecraft.client.model.HumanoidModel) ArmorItem(net.minecraft.world.item.ArmorItem) Quaternion(com.mojang.math.Quaternion) ItemStack(net.minecraft.world.item.ItemStack)

Example 4 with ArmorItem

use of net.minecraft.world.item.ArmorItem in project AlexsMobs by Alex-the-666.

the class LayerKangarooArmor method getArmorResource.

public static ResourceLocation getArmorResource(net.minecraft.world.entity.Entity entity, ItemStack stack, EquipmentSlot slot, @javax.annotation.Nullable String type) {
    ArmorItem item = (ArmorItem) stack.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 s1 = String.format("%s:textures/models/armor/%s_layer_%d%s.png", domain, texture, (1), type == null ? "" : String.format("_%s", type));
    s1 = net.minecraftforge.client.ForgeHooksClient.getArmorTexture(entity, stack, s1, slot, type);
    ResourceLocation resourcelocation = ARMOR_TEXTURE_RES_MAP.get(s1);
    if (resourcelocation == null) {
        resourcelocation = new ResourceLocation(s1);
        ARMOR_TEXTURE_RES_MAP.put(s1, resourcelocation);
    }
    return resourcelocation;
}
Also used : ArmorItem(net.minecraft.world.item.ArmorItem) ResourceLocation(net.minecraft.resources.ResourceLocation)

Example 5 with ArmorItem

use of net.minecraft.world.item.ArmorItem in project geckolib by bernie-g.

the class GeoArmorItem method getArmorTexture.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Nullable
@Override
public final String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, String type) {
    Class<? extends ArmorItem> clazz = this.getClass();
    GeoArmorRenderer renderer = GeoArmorRenderer.getRenderer(clazz);
    return renderer.getTextureLocation((ArmorItem) stack.getItem()).toString();
}
Also used : ArmorItem(net.minecraft.world.item.ArmorItem) GeoArmorRenderer(software.bernie.geckolib3.renderers.geo.GeoArmorRenderer) Nullable(javax.annotation.Nullable)

Aggregations

ArmorItem (net.minecraft.world.item.ArmorItem)11 ItemStack (net.minecraft.world.item.ItemStack)5 HumanoidModel (net.minecraft.client.model.HumanoidModel)2 ResourceLocation (net.minecraft.resources.ResourceLocation)2 ArmorMaterial (net.minecraft.world.item.ArmorMaterial)2 Quaternion (com.mojang.math.Quaternion)1 Nullable (javax.annotation.Nullable)1 BootRecyclerBlockEntity (ml.northwestwind.moreboots.init.tileentity.BootRecyclerBlockEntity)1 MutableBlockPos (net.minecraft.core.BlockPos.MutableBlockPos)1 LivingEntity (net.minecraft.world.entity.LivingEntity)1 Player (net.minecraft.world.entity.player.Player)1 BlockState (net.minecraft.world.level.block.state.BlockState)1 AABB (net.minecraft.world.phys.AABB)1 IItemHandler (net.minecraftforge.items.IItemHandler)1 LightningRayEntity (paulevs.edenring.entities.LightningRayEntity)1 GeoArmorRenderer (software.bernie.geckolib3.renderers.geo.GeoArmorRenderer)1