Skip to content

Commit 46e997d

Browse files
author
Smartin
committed
crown, banner adjustment, fix buster skin not showing, config adjustments to clear cache on change
1 parent 1f558eb commit 46e997d

38 files changed

+157
-162
lines changed

archery

arsenal

Submodule arsenal updated 22 files

common/libs/archery-local.jar

-389 KB
Binary file not shown.

common/libs/armory-local.jar

-381 KB
Binary file not shown.

common/libs/arsenal-local.jar

-389 KB
Binary file not shown.

common/src/main/java/smartin/miapi/client/gui/crafting/CraftingScreenHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ public CraftingScreenHandler getScreenHandler() {
196196
this.onContentChanged(inventory);
197197
} else {
198198
Miapi.LOGGER.warn("ERROR - Couldn`t verify craft action from client " + player.getUuidAsString() + " " + player.getDisplayName().getString() + " This might be a bug or somebody is trying to exploit");
199-
Miapi.DEBUG_LOGGER.warn(String.valueOf(current));
200-
Miapi.DEBUG_LOGGER.warn(position.toString());
199+
Miapi.LOGGER.warn(String.valueOf(current));
200+
Miapi.LOGGER.warn(position.toString());
201201
}
202202
});
203203
}

common/src/main/java/smartin/miapi/client/modelrework/BakedMiapiGlintModel.java

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public BakedMiapiGlintModel(BakedMiapiModel.ModelHolder holder, ItemModule.Modul
4343

4444
@Override
4545
public void render(MatrixStack matrices, ItemStack stack, ModelTransformationMode transformationMode, float tickDelta, VertexConsumerProvider vertexConsumerProvider, LivingEntity entity, int light, int overlay) {
46-
if (!(vertexConsumerProvider instanceof VertexConsumerProvider.Immediate)) return;
4746
MinecraftClient.getInstance().world.getProfiler().push("BakedGlintModel");
4847
matrices.push();
4948
matrices.multiplyPositionMatrix(modelMatrix);
@@ -56,15 +55,29 @@ public void render(MatrixStack matrices, ItemStack stack, ModelTransformationMod
5655
Color glintColor = settings.getColor();
5756
VertexConsumer materialConsumer = modelHolder.colorProvider().getConsumer(vertexConsumerProvider, stack, instance, transformationMode);
5857
for (Direction direction : Direction.values()) {
59-
currentModel.getQuads(null, direction, random).forEach(bakedQuad -> {
60-
materialConsumer.quad(matrices.peek(), bakedQuad, color.redAsFloat(), color.greenAsFloat(), color.blueAsFloat(), light, overlay);
61-
});
58+
currentModel.getQuads(null, direction, random)
59+
.forEach(bakedQuad ->
60+
materialConsumer.quad(
61+
matrices.peek(),
62+
bakedQuad,
63+
color.redAsFloat(),
64+
color.greenAsFloat(),
65+
color.blueAsFloat(),
66+
light,
67+
overlay));
6268
}
6369
VertexConsumer glintConsumer = vertexConsumerProvider.getBuffer(RegistryInventory.Client.modularItemGlint);
6470
for (Direction direction : Direction.values()) {
65-
currentModel.getQuads(null, direction, random).forEach(bakedQuad -> {
66-
glintConsumer.quad(matrices.peek(), bakedQuad, glintColor.redAsFloat(), glintColor.greenAsFloat(), glintColor.blueAsFloat(), light, overlay);
67-
});
71+
currentModel.getQuads(null, direction, random)
72+
.forEach(bakedQuad ->
73+
glintConsumer.quad(
74+
matrices.peek(),
75+
bakedQuad,
76+
glintColor.redAsFloat(),
77+
glintColor.greenAsFloat(),
78+
glintColor.blueAsFloat(),
79+
light,
80+
overlay));
6881
}
6982
MinecraftClient.getInstance().world.getProfiler().pop();
7083
matrices.pop();

common/src/main/java/smartin/miapi/client/modelrework/BakedMiapiModel.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public BakedMiapiModel(ModelHolder holder, ItemModule.ModuleInstance instance, I
4040

4141
@Override
4242
public void render(MatrixStack matrices, ItemStack stack, ModelTransformationMode transformationMode, float tickDelta, VertexConsumerProvider vertexConsumers, LivingEntity entity, int light, int overlay) {
43-
if (!(vertexConsumers instanceof VertexConsumerProvider.Immediate)) return;
4443
assert MinecraftClient.getInstance().world != null;
4544
MinecraftClient.getInstance().world.getProfiler().push("BakedModel");
4645
matrices.push();
@@ -53,9 +52,8 @@ public void render(MatrixStack matrices, ItemStack stack, ModelTransformationMod
5352
VertexConsumer consumer = modelHolder.colorProvider.getConsumer(vertexConsumers, stack, instance, transformationMode);
5453
assert currentModel != null;
5554
for (Direction direction : Direction.values()) {
56-
currentModel.getQuads(null, direction, random).forEach(bakedQuad -> {
57-
consumer.quad(matrices.peek(), bakedQuad, colors[0], colors[1], colors[2], light, overlay);
58-
});
55+
currentModel.getQuads(null, direction, random)
56+
.forEach(bakedQuad -> consumer.quad(matrices.peek(), bakedQuad, colors[0], colors[1], colors[2], light, overlay));
5957
}
6058

6159
MinecraftClient.getInstance().world.getProfiler().pop();

common/src/main/java/smartin/miapi/config/MiapiConfig.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import smartin.miapi.config.oro_config.ConfigItemGroup;
88
import smartin.miapi.config.oro_config.IntegerConfigItem;
99
import smartin.miapi.datapack.ReloadEvents;
10+
import smartin.miapi.modules.cache.ModularItemCache;
1011

1112
import java.io.File;
1213
import java.util.List;
@@ -67,7 +68,13 @@ public static class CompatGroup extends ConfigItemGroup {
6768
"send_warning", true, "Send chat warning is Iris was detected");
6869

6970
protected CompatGroup() {
70-
super(of(fallbackRenderer,forceFallbackRenderer,sendWarningOnWorldLoad), "Fallback Compat");
71+
super(of(fallbackRenderer, forceFallbackRenderer, sendWarningOnWorldLoad), "Fallback Compat");
72+
fallbackRenderer.changeListener.add((change) -> {
73+
ModularItemCache.discardCache();
74+
});
75+
forceFallbackRenderer.changeListener.add((change) -> {
76+
ModularItemCache.discardCache();
77+
});
7178
}
7279
}
7380

@@ -91,7 +98,7 @@ public static class OtherConfigGroup extends ConfigItemGroup {
9198
"Auto reloads on Servers to fix Forge having buggy classloading");
9299

93100
protected OtherConfigGroup() {
94-
super(of(developmentMode,forgeAutoReloads), "other");
101+
super(of(developmentMode, forgeAutoReloads), "other");
95102
}
96103
}
97104

common/src/main/java/smartin/miapi/config/oro_config/ConfigItem.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import com.google.gson.JsonObject;
2929
import org.jetbrains.annotations.Nullable;
3030

31+
import java.util.ArrayList;
32+
import java.util.List;
3133
import java.util.function.Consumer;
3234

3335
/**
@@ -46,6 +48,7 @@ public abstract class ConfigItem<T> {
4648
@Nullable
4749
protected final Consumer<ConfigItem<T>> onChange;
4850
protected T value;
51+
public List<Consumer<ConfigItem<T>>> changeListener = new ArrayList<>();
4952

5053
/**
5154
* Creates a new config with the name, defaultValue, and details
@@ -131,6 +134,9 @@ public void setValue(T value) {
131134
if (this.onChange != null) {
132135
this.onChange.accept(this);
133136
}
137+
changeListener.forEach(listener -> {
138+
listener.accept(this);
139+
});
134140
}
135141

136142
@Override

common/src/main/java/smartin/miapi/datapack/ReloadEvents.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private static void clientSetup() {
142142
}
143143
int dataPackSize = buffer.readInt();
144144
Map<String, String> tempDataPack = new HashMap<>(dataPackSize);
145-
for (int i = 0; i < dataPackSize - 1; i++) {
145+
for (int i = 0; i < dataPackSize; i++) {
146146
String key = buffer.readString();
147147
String value = buffer.readString();
148148
tempDataPack.put(key, value);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package smartin.miapi.item.modular.items;
2+
3+
import net.minecraft.item.Item;
4+
import net.minecraft.item.ItemStack;
5+
import net.minecraft.text.Text;
6+
import smartin.miapi.item.modular.ModularItem;
7+
import smartin.miapi.modules.properties.DisplayNameProperty;
8+
9+
import java.util.UUID;
10+
11+
public class ExampleModularStrackableItem extends Item implements ModularItem {
12+
public static Item modularItem;
13+
14+
public ExampleModularStrackableItem() {
15+
super(new Settings().maxCount(64).maxDamage(50));
16+
modularItem = this;
17+
}
18+
19+
@Override
20+
public Text getName(ItemStack stack) {
21+
return DisplayNameProperty.getDisplayText(stack);
22+
}
23+
24+
/**
25+
* Accessor for Properties
26+
*/
27+
public static UUID attackDamageUUID() {
28+
return ATTACK_DAMAGE_MODIFIER_ID;
29+
}
30+
31+
public static UUID attackSpeedUUID() {
32+
return ATTACK_SPEED_MODIFIER_ID;
33+
}
34+
}

common/src/main/java/smartin/miapi/modules/ItemModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ public Map<ModuleProperty, JsonElement> getPropertiesMerged() {
474474
try {
475475
map.put(property, property.merge(map.get(property), element, MergeType.SMART));
476476
} catch (Exception e) {
477-
DEBUG_LOGGER.error("coudlnt merge " + property, e);
477+
LOGGER.error("coudlnt merge " + property, e);
478478
map.put(property, element);
479479
}
480480
} else {

common/src/main/java/smartin/miapi/modules/edit_options/CosmeticEditOption.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ public boolean isVisible(EditContext editContext) {
107107
return SlotProperty.getSlots(editContext.getInstance()).values().stream()
108108
.anyMatch(moduleSlot -> moduleSlot.slotType.equals(slotType));
109109
}
110-
Miapi.LOGGER.info(String.valueOf(editContext.getSlot()));
111110
return false;
112111
}
113112

common/src/main/java/smartin/miapi/modules/edit_options/skins/Skin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public static Skin fromJson(JsonElement element) {
2424
Skin skin = new Skin();
2525
skin.module = RegistryInventory.modules.get(jsonObject.get("module").getAsString());
2626
skin.condition = ConditionManager.get(jsonObject.get("condition"));
27-
skin.propertyHolder = SynergyManager.getFrom(jsonObject);
2827
skin.path = jsonObject.get("path").getAsString();
28+
skin.propertyHolder = SynergyManager.getFrom(jsonObject, "skin for " + skin.module + " skinpath " + skin.path);
2929
skin.textureOptions = TextureOptions.fromJson(jsonObject.get("texture"), new Identifier(Miapi.MOD_ID, "textures/gui/skin/skin_button.png"), 100, 16, 3, ColorHelper.Argb.getArgb(255, 255, 255, 255));
3030
return skin;
3131
}

common/src/main/java/smartin/miapi/modules/edit_options/skins/SkinOptions.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ public ItemStack preview(PacketByteBuf buffer, EditContext context) {
8484

8585
@Override
8686
public boolean isVisible(EditContext context) {
87-
return context.getInstance() != null && skins.get(context.getInstance().module) != null;
87+
return context.getInstance() != null &&
88+
skins.get(context.getInstance().module) != null;
8889
}
8990

9091
@Environment(EnvType.CLIENT)
@@ -96,6 +97,6 @@ public InteractAbleWidget getGui(int x, int y, int width, int height, EditContex
9697
@Environment(EnvType.CLIENT)
9798
@Override
9899
public InteractAbleWidget getIconGui(int x, int y, int width, int height, Consumer<EditOption> select, Supplier<EditOption> getSelected) {
99-
return new EditOptionIcon(x, y, width, height, select, getSelected, CraftingScreen.BACKGROUND_TEXTURE, 339 + 32, 25 + 28 * 2, 512, 512,"miapi.ui.edit_option.hover.skin", this);
100+
return new EditOptionIcon(x, y, width, height, select, getSelected, CraftingScreen.BACKGROUND_TEXTURE, 339 + 32, 25 + 28 * 2, 512, 512, "miapi.ui.edit_option.hover.skin", this);
100101
}
101102
}

common/src/main/java/smartin/miapi/modules/material/GeneratedMaterial.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public void addSmithingRecipe(Material sourceMaterial, ItemStack templateItem, S
162162
((SmithingTransformRecipeAccessor) smithingTransformRecipe).getAddition(),
163163
this.key
164164
));
165-
Miapi.DEBUG_LOGGER.warn("added Smithing Recipe for " + sourceMaterial.getKey() + " to " + this.key + " via " + templateItem.getItem());
165+
Miapi.LOGGER.warn("added Smithing Recipe for " + sourceMaterial.getKey() + " to " + this.key + " via " + templateItem.getItem());
166166
this.groups.clear();
167167
this.groups.add(this.key);
168168
this.groups.add("smithing");

common/src/main/java/smartin/miapi/modules/material/MaterialInscribeDataProperty.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import net.minecraft.nbt.NbtCompound;
88
import net.minecraft.nbt.NbtElement;
99
import net.minecraft.nbt.StringNbtReader;
10-
import smartin.miapi.Miapi;
1110
import smartin.miapi.events.MiapiEvents;
1211
import smartin.miapi.modules.ItemModule;
1312
import smartin.miapi.modules.properties.util.ModuleProperty;
@@ -45,7 +44,6 @@ public static void inscribeModuleInstance(ItemModule.ModuleInstance moduleInstan
4544

4645
public static ItemStack readStackFromModuleInstance(ItemModule.ModuleInstance moduleInstance, String key) {
4746
String itemStackString = moduleInstance.moduleData.get(key);
48-
Miapi.LOGGER.info("reading data from ModuleInstance : " + itemStackString);
4947
if (itemStackString != null) {
5048
try {
5149
return ItemStack.fromNbt(StringNbtReader.parse(itemStackString));

common/src/main/java/smartin/miapi/modules/material/palette/MaterialPaletteFromTexture.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public MaterialPaletteFromTexture(Material material, Supplier<NativeImage> img)
9898
nativeImage.untrack();
9999
return new SpriteContents(id, new SpriteDimensions(256, 1), nativeImage, AnimationResourceMetadata.EMPTY);
100100
} catch (Exception e) {
101-
Miapi.DEBUG_LOGGER.warn("Material Palette generation for " + id + " failed.", e);
101+
Miapi.LOGGER.warn("Material Palette generation for " + id + " failed.", e);
102102
NativeImage nativeImage = new NativeImage(256, 1, false);
103103
nativeImage.untrack();
104104
return new SpriteContents(id, new SpriteDimensions(256, 1), nativeImage, AnimationResourceMetadata.EMPTY);

common/src/main/java/smartin/miapi/modules/properties/LoreProperty.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727
public class LoreProperty extends CodecBasedProperty<LoreProperty.Holder> {
2828
public static final String KEY = "itemLore";
29-
//TODO: maybe add more points to it? also add diret text to the json
29+
//TODO: maybe add more points to it? also add direct text to the json
3030
public static final Codec<LoreProperty.Holder> codec = AutoCodec.of(LoreProperty.Holder.class).codec();
3131
public static LoreProperty property;
3232
public static List<LoreSupplier> bottomLoreSuppliers = new ArrayList<>();
@@ -77,8 +77,8 @@ public void appendLoreTop(List<Text> oldLore, ItemStack itemStack) {
7777
loreSuppliers.forEach(loreSupplier -> oldLore.addAll(loreSupplier.getLore(itemStack)));
7878
Holder holder = get(itemStack);
7979
if (holder != null) {
80-
if ("top".equals(holder.position) && holder.lang != null) {
81-
oldLore.add(Text.translatable(holder.lang));
80+
if ("top".equals(holder.position)) {
81+
oldLore.add(holder.getText());
8282
}
8383
}
8484
}
@@ -88,17 +88,30 @@ public void appendLoreBottom(List<Text> oldLore, ItemStack itemStack) {
8888
bottomLoreSuppliers.forEach(loreSupplier -> oldLore.addAll(loreSupplier.getLore(itemStack)));
8989
Holder holder = get(itemStack);
9090
if (holder != null) {
91-
if ("bottom".equals(holder.position) && holder.lang != null) {
92-
oldLore.add(Text.translatable(holder.lang));
91+
if ("bottom".equals(holder.position)) {
92+
oldLore.add(holder.getText());
9393
}
9494
}
9595
}
9696

9797
public static class Holder {
98-
@AutoCodec.Mandatory
98+
@AutoCodec.Optional
9999
public String lang;
100+
@AutoCodec.Optional
101+
public Text text;
100102
@AutoCodec.Mandatory
101103
public String position;
104+
105+
public Text getText() {
106+
if (lang != null) {
107+
return Text.translatable(lang);
108+
}
109+
if (text != null) {
110+
return text;
111+
//return Codecs.TEXT.parse(JsonOps.INSTANCE, text).result().orElse(Text.empty());
112+
}
113+
return Text.empty();
114+
}
102115
}
103116

104117
@Environment(EnvType.CLIENT)

common/src/main/java/smartin/miapi/modules/properties/render/BannerModelProperty.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public BannerModelProperty() {
4646
yield () -> ItemStack.EMPTY;
4747
}
4848
case "module_data": {
49-
Miapi.LOGGER.info("reading Module data");
5049
if (ModelProperty.isAllowedKey(modelJson.modelType, key)) {
5150
yield () -> MaterialInscribeDataProperty.readStackFromModuleInstance(moduleInstance, "banner");
5251
}

common/src/main/java/smartin/miapi/modules/synergies/SynergyManager.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ public static void loadSynergy(ItemModule itemModule, JsonObject entryData) {
8585
return new ArrayList<>();
8686
});
8787
synergies.add(synergy);
88-
synergy.holder = PropertyHolderJsonAdapter.readFromObject(entryData);
88+
synergy.holder = PropertyHolderJsonAdapter.readFromObject(entryData, "synergy" + entryData);
8989
}
9090

91-
public static PropertyHolder getFrom(JsonElement element) {
92-
return PropertyHolderJsonAdapter.readFromObject(element);
91+
public static PropertyHolder getFrom(JsonElement element, String context) {
92+
return PropertyHolderJsonAdapter.readFromObject(element, context);
9393
}
9494

9595
public static class Synergy {
@@ -183,16 +183,17 @@ public void write(JsonWriter jsonWriter, PropertyHolder propertyHolder) throws I
183183

184184
@Override
185185
public PropertyHolder read(JsonReader jsonReader) throws IOException {
186-
return readFromObject(Miapi.gson.fromJson(jsonReader, JsonElement.class));
186+
return readFromObject(Miapi.gson.fromJson(jsonReader, JsonElement.class), "context missing");
187187
}
188188

189-
public static PropertyHolder readFromObject(JsonElement jsonElement) {
189+
public static PropertyHolder readFromObject(JsonElement jsonElement, String context) {
190190
JsonObject entryData = jsonElement.getAsJsonObject();
191191
PropertyHolder propertyHolder = new PropertyHolder();
192192
JsonElement replaceProperty = entryData.get("replace");
193193
if (entryData.has("properties")) {
194194
replaceProperty = entryData.get("properties");
195195
Miapi.LOGGER.warn("The raw use of the Field `properties` should be replaced with the field `replace`");
196+
Miapi.LOGGER.warn(context);
196197
}
197198
propertyHolder.replace = getProperties(replaceProperty);
198199
propertyHolder.merge = getProperties(entryData.get("merge"));

common/src/main/java/smartin/miapi/registries/RegistryInventory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ public static void setup() {
265265
register(modularItems, "modular_large_crossbow", ModularCrossbow::new);
266266
register(modularItems, "modular_crossbow_part", ExampleModularItem::new);
267267
register(modularItems, "modular_arrow", ModularArrow::new);
268-
register(modularItems, "modular_arrow_part", ExampleModularItem::new);
268+
register(modularItems, "modular_arrow_part", ExampleModularStrackableItem::new);
269269

270270
register(modularItems, "modular_helmet", ModularHelmet::new);
271271
register(modularItems, "modular_chestplate", ModularChestPlate::new);

0 commit comments

Comments
 (0)