Skip to content

Commit

Permalink
Change from mixin GuiScreen to listen to ClientChatEvent (#187)
Browse files Browse the repository at this point in the history
* change to mixin chat

* convert copy to event

* rename method
  • Loading branch information
WaitingIdly authored Jul 6, 2024
1 parent 0a9cdde commit 11ddbdd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 25 deletions.

This file was deleted.

11 changes: 11 additions & 0 deletions src/main/java/com/cleanroommc/groovyscript/event/EventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.cleanroommc.groovyscript.GroovyScript;
import com.cleanroommc.groovyscript.api.GroovyLog;
import com.cleanroommc.groovyscript.command.CustomClickAction;
import com.cleanroommc.groovyscript.compat.WarningScreen;
import com.cleanroommc.groovyscript.compat.content.GroovyBlock;
import com.cleanroommc.groovyscript.compat.content.GroovyFluid;
Expand All @@ -28,6 +29,7 @@
import net.minecraft.item.Item;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.client.event.ClientChatEvent;
import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.event.TextureStitchEvent;
Expand Down Expand Up @@ -109,6 +111,15 @@ public static void playerLogin(PlayerEvent.PlayerLoggedInEvent event) {
}
}

@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void onClientChatEvent(ClientChatEvent event) {
if (event.getOriginalMessage().startsWith(CustomClickAction.PREFIX) &&
CustomClickAction.runActionHook(event.getOriginalMessage().substring(CustomClickAction.PREFIX.length()))) {
event.setCanceled(true);
}
}

@SubscribeEvent
public static void onItemCrafted(PlayerEvent.ItemCraftedEvent event) {
if (event.craftMatrix instanceof InventoryCrafting inventoryCrafting) {
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/mixin.groovyscript.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,5 @@
"client": [
"DefaultResourcePackAccessor",
"GuiCreateWorldMixin",
"GuiScreenMixin"
]
}

0 comments on commit 11ddbdd

Please sign in to comment.