Skip to content

Commit d98a7f6

Browse files
committed
disable powers (for now); if this works we build
1 parent 9f315e4 commit d98a7f6

File tree

9 files changed

+35
-206
lines changed

9 files changed

+35
-206
lines changed

src/main/java/net/diamonddev/simpletrims/common/SimpleTrims.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package net.diamonddev.simpletrims.common;
22

3-
import net.diamonddev.simpletrims.common.command.CmdInit;
43
import net.diamonddev.simpletrims.common.data.SimpleTrimsDataLoader;
54
import net.fabricmc.api.ModInitializer;
5+
import net.fabricmc.fabric.api.gamerule.v1.GameRuleFactory;
6+
import net.fabricmc.fabric.api.gamerule.v1.GameRuleRegistry;
67
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
78
import net.minecraft.resource.ResourceType;
89
import net.minecraft.util.Identifier;
10+
import net.minecraft.world.GameRules;
911
import org.slf4j.Logger;
1012
import org.slf4j.LoggerFactory;
1113

@@ -25,23 +27,27 @@ public class SimpleTrims implements ModInitializer {
2527
"don't try to send textures over packets worst mistake of my life",
2628
"this solves a very specific problem no one probably ever had",
2729
"what the hell is an encoded palette",
28-
"niinku viulunkieli ?!",
30+
"niinku viulunkieli !?",
2931
"now with apoli!",
3032
"trims but simpler",
3133
"simple the trim",
3234
"you're welcome, i fixed the extra space",
33-
//"try /trim!",
3435
"also try terraria!",
3536
"so i added some more of these",
3637
"try adding an emissive trim!",
37-
"@diamonddevv (discord, twitter) was here"
38+
"@diamonddevv (discord, twitter) was here",
39+
"i paid for the whole two megabytes im gonna use the whole two megabytes",
40+
"can we go much higher (yes, we can)"
3841
};
3942

43+
public GameRules.Key<GameRules.BooleanRule> SHOULD_PROVIDE_TRIM_POWERS;
4044

4145
@Override
4246
public void onInitialize() {
4347
ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(TRIM_DATA);
44-
// CmdInit.register(); // todo: fix ig lol
48+
49+
SHOULD_PROVIDE_TRIM_POWERS = // gamerule
50+
GameRuleRegistry.register("shouldSimpleTrimsProvideApoliPowers", GameRules.Category.PLAYER, GameRuleFactory.createBooleanRule(true));
4551

4652
LOGGER.info("{} (initialized simpletrims)", getGoofyMessage());
4753
}

src/main/java/net/diamonddev/simpletrims/common/command/ArmorTrimMaterialArgument.java

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/main/java/net/diamonddev/simpletrims/common/command/ArmorTrimPatternArgument.java

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/main/java/net/diamonddev/simpletrims/common/command/CmdInit.java

Lines changed: 0 additions & 52 deletions
This file was deleted.

src/main/java/net/diamonddev/simpletrims/common/command/TrimCommand.java

Lines changed: 0 additions & 63 deletions
This file was deleted.

src/main/java/net/diamonddev/simpletrims/common/data/SimpleTrimsDataLoader.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class SimpleTrimsDataLoader implements SimpleSynchronousResourceReloadLis
2727

2828
private static final String MATERIAL_PALETTE_FILEPATH = "encodable_palettes";
2929
private static final String MATERIAL_FILEPATH = "simple_trim_material";
30-
private static final String PATTERN_FILEPATH = "simple_trim_patten";
30+
private static final String PATTERN_FILEPATH = "simple_trim_pattern";
3131

3232
static class MaterialKeys {
3333
static final String
@@ -56,7 +56,7 @@ public static class LangBean {
5656
@SerializedName(KEY_TRANSLATIONS_STRING)
5757
public String translation;
5858
}
59-
public static class DesciptionBean {
59+
public static class DescriptionBean {
6060
@SerializedName(KEY_DESC_COLOR)
6161
public String matColorHexcode;
6262

@@ -81,7 +81,7 @@ public static class PropsBean {
8181
public String assetName = null;
8282

8383
@SerializedName(KEY_DESC)
84-
public DesciptionBean desc;
84+
public DescriptionBean desc;
8585

8686
@SerializedName(KEY_PROPERTIES)
8787
public PropsBean properties = null;
@@ -161,6 +161,10 @@ public boolean shouldBeEmissive() {
161161
public String getPower() {
162162
return bean.properties.apoliPower;
163163
}
164+
165+
public boolean usingEncodedPalette() {
166+
return bean.encodedPalette;
167+
}
164168
}
165169

166170
public static ArrayList<MaterialBeanWrapper> SIMPLE_TRIM_MATERIALS = new ArrayList<>();

src/main/java/net/diamonddev/simpletrims/common/data/TrimApoliPowerUtil.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public static void updateSpecificTrimPowerApplication(LivingEntity livingEntity,
5656
if (stack.getOrCreateNbt().contains(ArmorTrim.NBT_KEY)) {
5757
NbtCompound trim = stack.getSubNbt(ArmorTrim.NBT_KEY);
5858
if (trim != null) {
59-
if (trim.contains("Material")) {
60-
Identifier material = new Identifier(trim.getString("Material"));
59+
if (trim.contains("material")) {
60+
Identifier material = new Identifier(trim.getString("material"));
6161

6262
String powerId = null;
6363
if (MEMOIZED_POWERS.containsKey(material)) {
@@ -66,7 +66,9 @@ public static void updateSpecificTrimPowerApplication(LivingEntity livingEntity,
6666
var mbw = SimpleTrimsDataLoader.lookupWrapper(material);
6767
if (mbw != null) {
6868
powerId = mbw.getPower();
69+
MEMOIZED_POWERS.put(material, powerId); // memoize
6970
}
71+
7072
}
7173

7274
if (powerId != null) {

src/main/java/net/diamonddev/simpletrims/mixin/LivingEntityMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ public LivingEntityMixin(EntityType<?> type, World world) {
1818

1919
@Inject(method = "tick", at = @At("HEAD"))
2020
private void simpletrims$applyTrimPowers(CallbackInfo ci) {
21-
TrimApoliPowerUtil.updateAllTrimPowerApplications((LivingEntity)(Object)this);
21+
//TrimApoliPowerUtil.updateAllTrimPowerApplications((LivingEntity)(Object)this); //todo
2222
}
2323
}

src/main/java/net/diamonddev/simpletrims/mixin/PlayerManagerMixin.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public class PlayerManagerMixin {
2727
@Inject(method = "onPlayerConnect", at = @At("TAIL"))
2828
private void simpletrims$onPlayerConnectToServer(ClientConnection connection, ServerPlayerEntity player, CallbackInfo ci) {
2929
String playername = player.getGameProfile().getName();
30+
boolean shouldQuietReload = false;
31+
3032

3133
// Asset Names to Palette Paths
3234
HashMap<String, String> assetsToPaths = new HashMap<>();
@@ -47,6 +49,12 @@ public class PlayerManagerMixin {
4749
HashMap<Identifier, HashMap<String, String>> translations = new HashMap<>();
4850
int translationCount = 0, materialCount = 0;
4951
for (var bean : SimpleTrimsDataLoader.SIMPLE_TRIM_MATERIALS) {
52+
if (!shouldQuietReload) {
53+
if (bean.usingEncodedPalette()) {
54+
shouldQuietReload = true;
55+
}
56+
}
57+
5058
if (bean.usingTranslationMap()) {
5159
var hash = bean.getTranslationHashmap();
5260
var id = new Identifier(bean.getNamespace(), bean.getAssetName());
@@ -59,8 +67,10 @@ public class PlayerManagerMixin {
5967
ServerPlayNetworking.send(player, SendTranslations.SEND_TRANSLATIONS, SendTranslations.write(translations));
6068

6169
// Quiet Reload Request
62-
SimpleTrims.LOGGER.info("Telling user {}'s client to quietly reload..", playername);
63-
ServerPlayNetworking.send(player, SendQuietReload.SEND_QUIET_RELOAD, PacketByteBufs.empty());
70+
if (shouldQuietReload) {
71+
SimpleTrims.LOGGER.info("Telling user {}'s client to quietly reload..", playername);
72+
ServerPlayNetworking.send(player, SendQuietReload.SEND_QUIET_RELOAD, PacketByteBufs.empty());
73+
}
6474

6575

6676
// finish

0 commit comments

Comments
 (0)