diff options
Diffstat (limited to 'src/main/java/com/ambientaddons/mixin')
3 files changed, 44 insertions, 1 deletions
diff --git a/src/main/java/com/ambientaddons/mixin/MixinGuiContainer.java b/src/main/java/com/ambientaddons/mixin/MixinGuiContainer.java index ee4b432..88e9048 100644 --- a/src/main/java/com/ambientaddons/mixin/MixinGuiContainer.java +++ b/src/main/java/com/ambientaddons/mixin/MixinGuiContainer.java @@ -14,7 +14,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; // credit Harry282/Skyblock-Client, under AGPL 3.0 @Mixin(GuiContainer.class) -public class MixinGuiContainer extends GuiScreen { +public abstract class MixinGuiContainer extends GuiScreen { private final GuiContainer gui = (GuiContainer) (Object) this; @Shadow diff --git a/src/main/java/com/ambientaddons/mixin/MixinGuiScreen.java b/src/main/java/com/ambientaddons/mixin/MixinGuiScreen.java new file mode 100644 index 0000000..8a9aa6c --- /dev/null +++ b/src/main/java/com/ambientaddons/mixin/MixinGuiScreen.java @@ -0,0 +1,21 @@ +package com.ambientaddons.mixin; + +import com.ambientaddons.events.GuiContainerEvent; +import com.ambientaddons.events.MessageSentEvent; +import net.minecraft.client.gui.GuiScreen; +import net.minecraftforge.common.MinecraftForge; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(GuiScreen.class) +public abstract class MixinGuiScreen { + + @Inject(method = "sendChatMessage(Ljava/lang/String;)V", at = @At("HEAD"), cancellable = true) + public void sendChatMessage(String msg, CallbackInfo ci) { + if (MinecraftForge.EVENT_BUS.post(new MessageSentEvent(msg))) { + ci.cancel(); + } + } +} diff --git a/src/main/java/com/ambientaddons/mixin/MixinRenderItem.java b/src/main/java/com/ambientaddons/mixin/MixinRenderItem.java new file mode 100644 index 0000000..8068291 --- /dev/null +++ b/src/main/java/com/ambientaddons/mixin/MixinRenderItem.java @@ -0,0 +1,22 @@ +package com.ambientaddons.mixin; + +import com.ambientaddons.events.GuiContainerEvent; +import com.ambientaddons.events.ItemOverlayEvent; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.MinecraftForge; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(RenderItem.class) +public abstract class MixinRenderItem { + @Inject(method = "renderItemOverlayIntoGUI", at = @At("HEAD"),cancellable = true) + public void renderItemOverlayIntoGui(FontRenderer fr, ItemStack stack, int xPosition, int yPosition, String text, CallbackInfo ci) { + if (MinecraftForge.EVENT_BUS.post(new ItemOverlayEvent(stack, xPosition, yPosition))) { + ci.cancel(); + } + } +} |