Skip to content

Commit

Permalink
Add option to disable golden texture on basic armor
Browse files Browse the repository at this point in the history
  • Loading branch information
KnightMiner committed Jan 17, 2023
1 parent d632345 commit cd733a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ private static <T> T add(List<? super T> list, T item) {
public static final ItemType<FlexBasicArmorItem> BASIC_ARMOR = register("basic_armor", data -> {
ResourceLocation name = JsonHelper.getResourceLocation(data, "texture_name");
boolean dyeable = GsonHelper.getAsBoolean(data, "dyeable", false);
boolean hasGolden = GsonHelper.getAsBoolean(data, "has_golden", true);
ArmorSlotType slot = JsonHelper.getAsEnum(data, "slot", ArmorSlotType.class);
SoundEvent equipSound = JsonHelper.getAsEntry(ForgeRegistries.SOUND_EVENTS, data, "equip_sound");
IToolStatProvider statProvider = data.has("stat_provider") ? ToolStatProviders.REGISTRY.deserialize(data, "stat_provider") : ToolStatProviders.NO_PARTS;
return (props, builder) -> new FlexBasicArmorItem(new DummyArmorMaterial(name, equipSound), slot.getEquipmentSlot(), props, ToolDefinition.builder(builder.getRegistryName()).setStatsProvider(statProvider).build(), name, dyeable);
return (props, builder) -> new FlexBasicArmorItem(new DummyArmorMaterial(name, equipSound), slot.getEquipmentSlot(), props, ToolDefinition.builder(builder.getRegistryName()).setStatsProvider(statProvider).build(), name, dyeable, hasGolden);
});

/** Register a modifiable armor part that supports embellishments */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,23 @@ public class FlexBasicArmorItem extends ModifiableArmorItem implements IFlexItem
private final Set<CreativeModeTab> tabs = new HashSet<>();
private final ResourceLocation name;
private final boolean dyeable;
@Nullable
private final String golden;
public FlexBasicArmorItem(ArmorMaterial materialIn, EquipmentSlot slot, Properties builderIn, ToolDefinition toolDefinition, ResourceLocation name, boolean dyeable) {
public FlexBasicArmorItem(ArmorMaterial materialIn, EquipmentSlot slot, Properties builderIn, ToolDefinition toolDefinition, ResourceLocation name, boolean dyeable, boolean hasGolden) {
super(materialIn, slot, builderIn, toolDefinition);
this.name = name;
this.dyeable = dyeable;
this.golden = name.getNamespace() + ":textures/models/armor/" + name.getPath() + "_golden_" + (slot == EquipmentSlot.LEGS ? 2 : 1) + ".png";
if (hasGolden) {
this.golden = name.getNamespace() + ":textures/models/armor/" + name.getPath() + "_golden_" + (slot == EquipmentSlot.LEGS ? 2 : 1) + ".png";
} else {
this.golden = null;
}
}

@Nullable
@Override
public String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, String type) {
if (ModifierUtil.getModifierLevel(stack, TinkerModifiers.golden.getId()) > 0) {
if (golden != null && ModifierUtil.getModifierLevel(stack, TinkerModifiers.golden.getId()) > 0) {
return golden;
}
return null;
Expand Down

0 comments on commit cd733a5

Please sign in to comment.