Skip to content

Commit

Permalink
fix #44
Browse files Browse the repository at this point in the history
  • Loading branch information
CammiePone committed Jan 10, 2025
1 parent 8a49ac7 commit 52a39c0
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.DyeableArmorItem;
import net.minecraft.world.item.DyeableLeatherItem;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.SupportType;
import net.minecraft.world.level.block.state.BlockState;
Expand Down Expand Up @@ -162,15 +162,11 @@ public void onInitializeClient() {
ArcanusItems.MAGE_PISTOL.get()
);

ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex == 0 ? ((DyeableArmorItem) stack.getItem()).getColor(stack) : -1,
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex == 0 ? ((DyeableLeatherItem) stack.getItem()).getColor(stack) : -1,
ArcanusItems.WIZARD_HAT.get(),
ArcanusItems.WIZARD_ROBES.get(),
ArcanusItems.WIZARD_PANTS.get(),
ArcanusItems.WIZARD_BOOTS.get(),
ArcanusItems.BATTLE_MAGE_HELMET.get(),
ArcanusItems.BATTLE_MAGE_CHESTPLATE.get(),
ArcanusItems.BATTLE_MAGE_LEGGINGS.get(),
ArcanusItems.BATTLE_MAGE_BOOTS.get()
ArcanusItems.WIZARD_BOOTS.get()
);

ItemProperties.register(ArcanusItems.BATTLE_MAGE_HELMET.get(), Arcanus.id("oxidation"), (stack, world, entity, seed) -> BattleMageArmorItem.getOxidation(stack).ordinal() / 10f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.animal.Sheep;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemStack;

public class BattleMageArmourRenderer implements ArmorRenderer {
Expand All @@ -36,22 +34,6 @@ public void render(PoseStack matrices, MultiBufferSource vertexConsumers, ItemSt

if(stack.getItem() instanceof BattleMageArmorItem battleMageArmorItem) {
ResourceLocation mainTexture = mainTextures[battleMageArmorItem.getOxidation(stack).ordinal()];
int hexColour = battleMageArmorItem.getColor(stack);
float r = (hexColour >> 16 & 255) / 255F;
float g = (hexColour >> 8 & 255) / 255F;
float b = (hexColour & 255) / 255F;

if(stack.hasCustomHoverName() && stack.getHoverName().getString().equals("jeb_")) {
int m = 15;
int n = entity.tickCount / m + entity.getId();
int o = DyeColor.values().length;
float f = ((entity.tickCount % m) + client.getFrameTime()) / 15F;
float[] fs = Sheep.getColorArray(DyeColor.byId(n % o));
float[] gs = Sheep.getColorArray(DyeColor.byId((n + 1) % o));
r = fs[0] * (1F - f) + gs[0] * f;
g = fs[1] * (1F - f) + gs[1] * f;
b = fs[2] * (1F - f) + gs[2] * f;
}

contextModel.copyPropertiesTo(model);
model.setAllVisible(true);
Expand All @@ -70,7 +52,7 @@ public void render(PoseStack matrices, MultiBufferSource vertexConsumers, ItemSt
model.surcoatBack.xRot = Math.max(contextModel.leftLeg.xRot, contextModel.rightLeg.xRot) + 0.0436f;

model.renderToBuffer(matrices, ItemRenderer.getArmorFoilBuffer(vertexConsumers, RenderType.armorCutoutNoCull(mainTexture), false, false), light, OverlayTexture.NO_OVERLAY, 1f, 1f, 1f, 1f);
model.renderToBuffer(matrices, ItemRenderer.getArmorFoilBuffer(vertexConsumers, RenderType.armorCutoutNoCull(overlayTexture), false, false), light, OverlayTexture.NO_OVERLAY, r, g, b, 1f);
model.renderToBuffer(matrices, ItemRenderer.getArmorFoilBuffer(vertexConsumers, RenderType.armorCutoutNoCull(overlayTexture), false, false), light, OverlayTexture.NO_OVERLAY, 1f, 1f, 1f, 1f);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.mojang.blaze3d.vertex.PoseStack;
import dev.cammiescorner.arcanuscontinuum.Arcanus;
import dev.cammiescorner.arcanuscontinuum.client.models.armour.WizardArmourModel;
import dev.cammiescorner.arcanuscontinuum.common.items.WizardArmorItem;
import dev.cammiescorner.arcanuscontinuum.common.items.WizardRobesArmorItem;
import net.fabricmc.fabric.api.client.rendering.v1.ArmorRenderer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
Expand All @@ -29,7 +29,7 @@ public void render(PoseStack matrices, MultiBufferSource vertexConsumers, ItemSt
if(model == null)
model = new WizardArmourModel<>(client.getEntityModels().bakeLayer(WizardArmourModel.MODEL_LAYER));

if(stack.getItem() instanceof WizardArmorItem wizardArmour) {
if(stack.getItem() instanceof WizardRobesArmorItem wizardArmour) {
int hexColour = wizardArmour.getColor(stack);
float r = (hexColour >> 16 & 255) / 255F;
float g = (hexColour >> 8 & 255) / 255F;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import dev.cammiescorner.arcanuscontinuum.Arcanus;
import dev.cammiescorner.arcanuscontinuum.client.models.entity.living.OpossumEntityModel;
import dev.cammiescorner.arcanuscontinuum.common.entities.living.OpossumEntity;
import dev.cammiescorner.arcanuscontinuum.common.items.WizardArmorItem;
import dev.cammiescorner.arcanuscontinuum.common.items.WizardRobesArmorItem;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
Expand Down Expand Up @@ -33,7 +33,7 @@ public void render(OpossumEntity opossum, float yaw, float tickDelta, PoseStack

super.render(opossum, yaw, tickDelta, matrices, verteces, i);

if(hatStack.getItem() instanceof WizardArmorItem wizardArmour) {
if(hatStack.getItem() instanceof WizardRobesArmorItem wizardArmour) {
int hexColour = wizardArmour.getColor(hatStack);
float r = (hexColour >> 16 & 255) / 255F;
float g = (hexColour >> 8 & 255) / 255F;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ public String getDescriptionId(ItemStack stack) {
return super.getDescriptionId(stack) + s + getOxidation(stack).name().toLowerCase(Locale.ROOT);
}

@Override
public int getColor(ItemStack stack) {
CompoundTag tag = stack.getTagElement(ItemStack.TAG_DAMAGE);
return tag != null && tag.contains(ItemStack.TAG_COLOR, Tag.TAG_ANY_NUMERIC) ? tag.getInt(ItemStack.TAG_COLOR) : 0xb38ef3;
}

public static boolean isWaxed(ItemStack stack) {
CompoundTag tag = stack.getTagElement(ItemStack.TAG_DISPLAY);
return tag != null && tag.getBoolean("waxed");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@
import dev.cammiescorner.arcanuscontinuum.api.entities.ArcanusEntityAttributes;
import dev.cammiescorner.arcanuscontinuum.common.registry.ArcanusComponents;
import net.minecraft.core.cauldron.CauldronInteraction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.DyeableArmorItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
Expand All @@ -24,7 +22,7 @@
import java.util.UUID;
import java.util.function.Supplier;

public class WizardArmorItem extends DyeableArmorItem {
public class WizardArmorItem extends ArmorItem {
private static final Map<Type, UUID> MODIFIER_IDS = Map.of(
Type.BOOTS, UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"),
Type.LEGGINGS, UUID.fromString("D8499B04-0E66-4726-AB29-64469D734E0D"),
Expand Down Expand Up @@ -61,12 +59,6 @@ public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot,
stack.setDamageValue(stack.getDamageValue() - 1);
}

@Override
public int getColor(ItemStack stack) {
CompoundTag tag = stack.getTagElement(ItemStack.TAG_DISPLAY);
return tag != null && tag.contains(ItemStack.TAG_COLOR, Tag.TAG_ANY_NUMERIC) ? tag.getInt(ItemStack.TAG_COLOR) : 0x52392a;
}

@Override
public Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(EquipmentSlot slot) {
return slot == getEquipmentSlot() ? attributeModifiers.get() : super.getDefaultAttributeModifiers(slot);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package dev.cammiescorner.arcanuscontinuum.common.items;

import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.DyeableLeatherItem;
import net.minecraft.world.item.ItemStack;

public class WizardRobesArmorItem extends WizardArmorItem implements DyeableLeatherItem {
public WizardRobesArmorItem(ArmorMaterial armorMaterial, Type equipmentSlot, double manaRegen, double magicResist, double spellPotency, double manaCostMultiplier, double spellCoolDown) {
super(armorMaterial, equipmentSlot, manaRegen, magicResist, spellPotency, manaCostMultiplier, spellCoolDown);
}

@Override
public int getColor(ItemStack stack) {
CompoundTag tag = stack.getTagElement(ItemStack.TAG_DISPLAY);
return tag != null && tag.contains(ItemStack.TAG_COLOR, Tag.TAG_ANY_NUMERIC) ? tag.getInt(ItemStack.TAG_COLOR) : 0x52392a;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public class ArcanusItems {
public static final RegistrySupplier<Item> MAGIC_TOME = ITEMS.register("magic_tome", () -> new StaffItem(StaffType.BOOK, Color.fromRGB(139, 69, 19), Color.fromRGB(30, 27, 27), true));
public static final RegistrySupplier<Item> MAGE_PISTOL = ITEMS.register("mage_pistol", () -> new StaffItem(StaffType.GUN, Color.fromRGB(255, 255, 255), Color.fromRGB(255, 255, 255), true));

public static final RegistrySupplier<Item> WIZARD_HAT = ITEMS.register("wizard_hat", () -> new WizardArmorItem(ArcanusArmourMaterials.WIZARD, ArmorItem.Type.HELMET, 1, 0.1, 0, 0, -0.06));
public static final RegistrySupplier<Item> WIZARD_ROBES = ITEMS.register("wizard_robes", () -> new WizardArmorItem(ArcanusArmourMaterials.WIZARD, ArmorItem.Type.CHESTPLATE, 2, 0.2, 0, 0, -0.12));
public static final RegistrySupplier<Item> WIZARD_PANTS = ITEMS.register("wizard_pants", () -> new WizardArmorItem(ArcanusArmourMaterials.WIZARD, ArmorItem.Type.LEGGINGS, 2, 0.2, 0, 0, -0.1));
public static final RegistrySupplier<Item> WIZARD_BOOTS = ITEMS.register("wizard_boots", () -> new WizardArmorItem(ArcanusArmourMaterials.WIZARD, ArmorItem.Type.BOOTS, 1, 0.1, 0, 0, -0.05));
public static final RegistrySupplier<Item> WIZARD_HAT = ITEMS.register("wizard_hat", () -> new WizardRobesArmorItem(ArcanusArmourMaterials.WIZARD, ArmorItem.Type.HELMET, 1, 0.1, 0, 0, -0.06));
public static final RegistrySupplier<Item> WIZARD_ROBES = ITEMS.register("wizard_robes", () -> new WizardRobesArmorItem(ArcanusArmourMaterials.WIZARD, ArmorItem.Type.CHESTPLATE, 2, 0.2, 0, 0, -0.12));
public static final RegistrySupplier<Item> WIZARD_PANTS = ITEMS.register("wizard_pants", () -> new WizardRobesArmorItem(ArcanusArmourMaterials.WIZARD, ArmorItem.Type.LEGGINGS, 2, 0.2, 0, 0, -0.1));
public static final RegistrySupplier<Item> WIZARD_BOOTS = ITEMS.register("wizard_boots", () -> new WizardRobesArmorItem(ArcanusArmourMaterials.WIZARD, ArmorItem.Type.BOOTS, 1, 0.1, 0, 0, -0.05));
public static final RegistrySupplier<Item> BATTLE_MAGE_HELMET = ITEMS.register("battle_mage_helmet", () -> new BattleMageArmorItem(ArcanusArmourMaterials.BATTLE_MAGE, ArmorItem.Type.HELMET, 0.25, 0, 0.2, 0.06, 0));
public static final RegistrySupplier<Item> BATTLE_MAGE_CHESTPLATE = ITEMS.register("battle_mage_chestplate", () -> new BattleMageArmorItem(ArcanusArmourMaterials.BATTLE_MAGE, ArmorItem.Type.CHESTPLATE, 0.75, 0, 0.3, 0.12, 0));
public static final RegistrySupplier<Item> BATTLE_MAGE_LEGGINGS = ITEMS.register("battle_mage_leggings", () -> new BattleMageArmorItem(ArcanusArmourMaterials.BATTLE_MAGE, ArmorItem.Type.LEGGINGS, 0.75, 0, 0.3, 0.1, 0));
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 52a39c0

Please sign in to comment.