From 3b91e3daf8bed51a4bd6d60d6f29d681110e109e Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Tue, 24 Mar 2020 13:05:03 -0400 Subject: [PATCH] 1.2.5 Fix Casting Table Bug --- CHANGELOG.md | 3 +++ gradle.properties | 2 +- .../com/thebrokenrail/sorcerycraft/client/ModMenu.java | 4 ++++ .../sorcerycraft/client/SorceryCraftClient.java | 4 ++++ .../sorcerycraft/mixin/MixinPlayerEntity.java | 5 +++++ .../sorcerycraft/mixin/MixinServerPlayerEntity.java | 9 +++------ .../sorcerycraft/packet/UpdateKnownSpellsS2CPacket.java | 4 ---- 7 files changed, 20 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fee8a2..cdd00fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +**1.2.5** +* Fix Casting Table Bug + **1.2.4** * Optimize Packets * Allow Command Blocks to use ```/spell``` Command diff --git a/gradle.properties b/gradle.properties index b332105..a27b7c8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ org.gradle.jvmargs = -Xmx1G fabric_loader_version = 0.7.8+build.189 # Mod Properties - mod_version = 1.2.4 + mod_version = 1.2.5 maven_group = com.thebrokenrail archives_base_name = sorcerycraft diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/client/ModMenu.java b/src/main/java/com/thebrokenrail/sorcerycraft/client/ModMenu.java index d14d9bf..94efe8a 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/client/ModMenu.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/client/ModMenu.java @@ -5,8 +5,12 @@ import com.thebrokenrail.sorcerycraft.SorceryCraft; import io.github.prospector.modmenu.api.ConfigScreenFactory; import io.github.prospector.modmenu.api.ModMenuApi; import me.sargunvohra.mcmods.autoconfig1u.AutoConfig; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.client.gui.screen.Screen; +@SuppressWarnings("unused") +@Environment(EnvType.CLIENT) public class ModMenu implements ModMenuApi { @Override public String getModId() { diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/client/SorceryCraftClient.java b/src/main/java/com/thebrokenrail/sorcerycraft/client/SorceryCraftClient.java index 39428a5..bcc3520 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/client/SorceryCraftClient.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/client/SorceryCraftClient.java @@ -11,6 +11,8 @@ import me.sargunvohra.mcmods.autoconfig1u.gui.registry.GuiRegistry; import me.sargunvohra.mcmods.autoconfig1u.util.Utils; import me.shedaniel.clothconfig2.api.ConfigEntryBuilder; import net.fabricmc.api.ClientModInitializer; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry; import net.fabricmc.fabric.api.client.screen.ScreenProviderRegistry; import net.fabricmc.fabric.impl.networking.ClientSidePacketRegistryImpl; @@ -21,6 +23,8 @@ import net.minecraft.util.math.MathHelper; import java.util.Collections; +@SuppressWarnings("unused") +@Environment(EnvType.CLIENT) public class SorceryCraftClient implements ClientModInitializer { @Override public void onInitializeClient() { diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/mixin/MixinPlayerEntity.java b/src/main/java/com/thebrokenrail/sorcerycraft/mixin/MixinPlayerEntity.java index b1880a6..34417b1 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/mixin/MixinPlayerEntity.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/mixin/MixinPlayerEntity.java @@ -1,5 +1,6 @@ package com.thebrokenrail.sorcerycraft.mixin; +import com.thebrokenrail.sorcerycraft.gui.CastingTableScreenHandler; import com.thebrokenrail.sorcerycraft.spell.util.SpellHelper; import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity; import net.minecraft.entity.player.PlayerEntity; @@ -35,6 +36,10 @@ public class MixinPlayerEntity implements SpellPlayerEntity { @Override public void setDiscoveredSpells(Map spells) { this.sorceryCraftDiscoveredSpells = spells; + if (currentScreenHandler instanceof CastingTableScreenHandler) { + //noinspection ConstantConditions + ((CastingTableScreenHandler) currentScreenHandler).setSpells((PlayerEntity) (Object) this); + } } @Override diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/mixin/MixinServerPlayerEntity.java b/src/main/java/com/thebrokenrail/sorcerycraft/mixin/MixinServerPlayerEntity.java index 493abbe..8cc42ad 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/mixin/MixinServerPlayerEntity.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/mixin/MixinServerPlayerEntity.java @@ -30,7 +30,9 @@ public abstract class MixinServerPlayerEntity extends MixinPlayerEntity implemen @Override public void setDiscoveredSpells(Map spells) { super.setDiscoveredSpells(spells); - sync(); + if (currentScreenHandler instanceof CastingTableScreenHandler) { + sync(); + } } @Override @@ -39,10 +41,5 @@ public abstract class MixinServerPlayerEntity extends MixinPlayerEntity implemen tag.put(SpellHelper.SPELL_TAG, SpellHelper.createSpellsTag(getDiscoveredSpells())); //noinspection ConstantConditions UpdateKnownSpellsS2CPacket.send((ServerPlayerEntity) (Object) this, tag); - - if (currentScreenHandler instanceof CastingTableScreenHandler) { - //noinspection ConstantConditions - ((CastingTableScreenHandler) currentScreenHandler).setSpells((PlayerEntity) (Object) this); - } } } \ No newline at end of file diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/packet/UpdateKnownSpellsS2CPacket.java b/src/main/java/com/thebrokenrail/sorcerycraft/packet/UpdateKnownSpellsS2CPacket.java index 24ca673..5ff6e8b 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/packet/UpdateKnownSpellsS2CPacket.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/packet/UpdateKnownSpellsS2CPacket.java @@ -1,7 +1,6 @@ package com.thebrokenrail.sorcerycraft.packet; import com.thebrokenrail.sorcerycraft.SorceryCraft; -import com.thebrokenrail.sorcerycraft.gui.CastingTableScreenHandler; import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity; import com.thebrokenrail.sorcerycraft.spell.util.SpellHelper; import io.netty.buffer.Unpooled; @@ -18,9 +17,6 @@ public class UpdateKnownSpellsS2CPacket { if (context.getPlayer() != null) { SpellPlayerEntity spellPlayer = (SpellPlayerEntity) context.getPlayer(); spellPlayer.setDiscoveredSpells(SpellHelper.getSpells(tag)); - if (context.getPlayer().currentScreenHandler instanceof CastingTableScreenHandler) { - ((CastingTableScreenHandler) context.getPlayer().currentScreenHandler).setSpells(context.getPlayer()); - } } }