diff options
author | My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> | 2021-07-28 14:49:55 -0400 |
---|---|---|
committer | My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> | 2021-07-28 14:49:55 -0400 |
commit | d7370050f097d4cdcc1801f11875bb714c079811 (patch) | |
tree | 271a6661c658d7caa62b65bb8b4a5bfbd21b76ef /src/main | |
parent | 2ebc6a13b76dabf29e96e94d34ce2c9ecb22d0ff (diff) | |
download | SkytilsMod-d7370050f097d4cdcc1801f11875bb714c079811.tar.gz SkytilsMod-d7370050f097d4cdcc1801f11875bb714c079811.tar.bz2 SkytilsMod-d7370050f097d4cdcc1801f11875bb714c079811.zip |
Fix IChatComponent GSON Serializer crashing with UTextComponent
Diffstat (limited to 'src/main')
4 files changed, 45 insertions, 1 deletions
diff --git a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinLayerArmorBase.java b/src/main/java/skytils/skytilsmod/mixins/renderer/MixinLayerArmorBase.java index 2b06263a..e91b0080 100644 --- a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinLayerArmorBase.java +++ b/src/main/java/skytils/skytilsmod/mixins/renderer/MixinLayerArmorBase.java @@ -54,6 +54,11 @@ public abstract class MixinLayerArmorBase<T extends ModelBase> implements LayerR @Unique private boolean modifiedAlpha = false; + @Inject(method = "doRenderLayer", at = @At("HEAD"), cancellable = true) + private void onRenderAllArmor(EntityLivingBase entitylivingbaseIn, float p_177141_2_, float p_177141_3_, float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale, CallbackInfo ci) { + if (Skytils.config.transparentArmorLayer == 0 && Utils.inSkyblock && entitylivingbaseIn == getMc().thePlayer) ci.cancel(); + } + @Inject(method = "renderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemArmor;getColor(Lnet/minecraft/item/ItemStack;)I")) private void setAlpha(EntityLivingBase entitylivingbaseIn, float p_177182_2_, float p_177182_3_, float partialTicks, float p_177182_5_, float p_177182_6_, float p_177182_7_, float scale, int armorSlot, CallbackInfo ci) { if (Utils.inSkyblock && entitylivingbaseIn == getMc().thePlayer) { diff --git a/src/main/java/skytils/skytilsmod/mixins/util/MixinIChatComponent$Serializer.java b/src/main/java/skytils/skytilsmod/mixins/util/MixinIChatComponent$Serializer.java new file mode 100644 index 00000000..e682404e --- /dev/null +++ b/src/main/java/skytils/skytilsmod/mixins/util/MixinIChatComponent$Serializer.java @@ -0,0 +1,38 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package skytils.skytilsmod.mixins.util; + +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonSerializer; +import gg.essential.universal.wrappers.message.UTextComponent; +import net.minecraft.util.IChatComponent; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; + +@Mixin(IChatComponent.Serializer.class) +public abstract class MixinIChatComponent$Serializer implements JsonDeserializer<IChatComponent>, JsonSerializer<IChatComponent> { + @ModifyVariable(method = "serialize", at = @At("HEAD"), argsOnly = true) + private IChatComponent fixUTextComponentSerialize(IChatComponent component) { + if (component instanceof UTextComponent) { + return ((UTextComponent)component).getComponent(); + } + return component; + } +} diff --git a/src/main/kotlin/skytils/skytilsmod/Skytils.kt b/src/main/kotlin/skytils/skytilsmod/Skytils.kt index d4d03282..5338afc7 100644 --- a/src/main/kotlin/skytils/skytilsmod/Skytils.kt +++ b/src/main/kotlin/skytils/skytilsmod/Skytils.kt @@ -97,7 +97,7 @@ class Skytils { companion object { const val MODID = "skytils" const val MOD_NAME = "Skytils" - const val VERSION = "1.0-pre20" + const val VERSION = "1.0-pre20.1" @JvmField val gson: Gson = GsonBuilder().setPrettyPrinting().create() diff --git a/src/main/resources/mixins.skytils.json b/src/main/resources/mixins.skytils.json index 2e2bfa04..665c29d8 100644 --- a/src/main/resources/mixins.skytils.json +++ b/src/main/resources/mixins.skytils.json @@ -51,6 +51,7 @@ "renderer.MixinTileEntityChestRenderer", "renderer.MixinTileEntityItemStackRenderer", "renderer.MixinTileEntitySkullRenderer", + "util.MixinIChatComponent$Serializer", "util.MixinUtil", "world.MixinChunk", "world.MixinWorld" |