added antibookkick

This commit is contained in:
Bella 2020-03-29 16:41:52 -04:00
parent a35da22f81
commit 2f449f4013
No known key found for this signature in database
GPG Key ID: 815562EA23BFE344
1 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,35 @@
package me.zeroeightsix.kami.module.modules.misc;
import me.zero.alpine.listener.EventHandler;
import me.zero.alpine.listener.Listener;
import me.zeroeightsix.kami.command.Command;
import me.zeroeightsix.kami.event.events.PacketEvent;
import me.zeroeightsix.kami.module.Module;
import net.minecraft.item.ItemWrittenBook;
import net.minecraft.network.play.client.CPacketClickWindow;
/**
* @author IronException
* Used with permission from ForgeHax
* https://github.com/fr1kin/ForgeHax/blob/bb522f8/src/main/java/com/matt/forgehax/mods/AntiBookKick.java
* Permission (and ForgeHax is MIT licensed):
* https://discordapp.com/channels/573954110454366214/634010802403409931/693919755647844352
*/
@Module.Info(name = "AntiBookKick", category = Module.Category.MISC, description = "Prevents being kicked by clicking on books", showOnArray = Module.ShowOnArray.OFF)
public class AntiBookKick extends Module {
@EventHandler
public Listener<PacketEvent.Receive> listener = new Listener<>(event -> {
if (!(event.getPacket() instanceof CPacketClickWindow)) return;
final CPacketClickWindow packet = (CPacketClickWindow) event.getPacket();
if (!(packet.getClickedItem().getItem() instanceof ItemWrittenBook)) return;
event.cancel();
Command.sendWarningMessage(getChatName()
+ "Don't click the book \""
+ packet.getClickedItem().getDisplayName()
+ "\", shift click it instead!");
mc.player.openContainer.slotClick(packet.getSlotId(), packet.getUsedButton(), packet.getClickType(), mc.player);
});
}