mirror of https://github.com/kami-blue/client
Merge branch 'master' into add-issues
This commit is contained in:
commit
31ec2c5e66
|
@ -1,6 +1,6 @@
|
|||
# KAMI
|
||||
[![Issues](https://img.shields.io/github/issues/zeroeightysix/kami.svg)](https://github.com/zeroeightysix/kami/issues)
|
||||
[![Discord](https://img.shields.io/badge/chat-on%20discord-brightgreen.svg)](http://discord.gg/gmBRk2s)
|
||||
[![Discord](https://img.shields.io/badge/chat-on%20discord-brightgreen.svg)](http://discord.gg/9hvwgeg)
|
||||
|
||||
A minecraft utility mod for anarchy servers.
|
||||
|
||||
|
|
|
@ -58,7 +58,6 @@ public class KamiMod {
|
|||
ModuleManager.getModules().stream().filter(module -> module.alwaysListening).forEach(EVENT_BUS::subscribe);
|
||||
MinecraftForge.EVENT_BUS.register(new ForgeEventProcessor());
|
||||
LagCompensator.INSTANCE = new LagCompensator();
|
||||
EVENT_BUS.subscribe(LagCompensator.INSTANCE);
|
||||
|
||||
Wrapper.init();
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ public abstract class Command {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static final char SECTIONSIGN() {
|
||||
public static char SECTIONSIGN() {
|
||||
return '\u00A7';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public class CommandManager {
|
|||
}
|
||||
|
||||
|
||||
public static String strip(String str, String key){
|
||||
private static String strip(String str, String key){
|
||||
if (str.startsWith(key) && str.endsWith(key)) return str.substring(key.length(), str.length()-key.length());
|
||||
return str;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
|||
import net.minecraftforge.event.entity.living.LivingDamageEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.world.ChunkEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
@ -87,7 +89,8 @@ public class ForgeEventProcessor {
|
|||
if (event.isCanceled()) return;
|
||||
|
||||
RenderGameOverlayEvent.ElementType target = RenderGameOverlayEvent.ElementType.EXPERIENCE;
|
||||
if (!Wrapper.getPlayer().isCreative() && Wrapper.getPlayer().getRidingEntity() instanceof EntityHorse) target = RenderGameOverlayEvent.ElementType.HEALTHMOUNT;
|
||||
if (!Wrapper.getPlayer().isCreative() && Wrapper.getPlayer().getRidingEntity() instanceof EntityHorse)
|
||||
target = RenderGameOverlayEvent.ElementType.HEALTHMOUNT;
|
||||
|
||||
if (event.getType() == target) {
|
||||
ModuleManager.onRender();
|
||||
|
@ -95,14 +98,13 @@ public class ForgeEventProcessor {
|
|||
UIRenderer.renderAndUpdateFrames();
|
||||
GL11.glPopMatrix();
|
||||
KamiTessellator.releaseGL();
|
||||
}else if (event.getType() == RenderGameOverlayEvent.ElementType.BOSSINFO && ModuleManager.isModuleEnabled("BossStack")) {
|
||||
} else if (event.getType() == RenderGameOverlayEvent.ElementType.BOSSINFO && ModuleManager.isModuleEnabled("BossStack")) {
|
||||
BossStack.render(event);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority= EventPriority.NORMAL, receiveCanceled=true)
|
||||
public void onKeyInput(InputEvent.KeyInputEvent event)
|
||||
{
|
||||
@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
|
||||
public void onKeyInput(InputEvent.KeyInputEvent event) {
|
||||
if (Keyboard.getEventKeyState())
|
||||
ModuleManager.onBind(Keyboard.getEventKey());
|
||||
}
|
||||
|
@ -111,14 +113,14 @@ public class ForgeEventProcessor {
|
|||
public void onChatSent(ClientChatEvent event) {
|
||||
if (event.getMessage().startsWith(Command.COMMAND_PREFIX)) {
|
||||
event.setCanceled(true);
|
||||
try{
|
||||
try {
|
||||
Wrapper.getMinecraft().ingameGUI.getChatGUI().addToSentMessages(event.getMessage());
|
||||
|
||||
if (event.getMessage().length() > 1)
|
||||
KamiMod.getInstance().commandManager.callCommand(event.getMessage().substring(Command.COMMAND_PREFIX.length()-1));
|
||||
KamiMod.getInstance().commandManager.callCommand(event.getMessage().substring(Command.COMMAND_PREFIX.length() - 1));
|
||||
else
|
||||
Command.sendChatMessage("Please enter a command.");
|
||||
}catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Command.sendChatMessage("Error occured while running command! (" + e.getMessage() + ")");
|
||||
}
|
||||
|
@ -130,31 +132,55 @@ public class ForgeEventProcessor {
|
|||
public void onPlayerDrawn(RenderPlayerEvent.Pre event) {
|
||||
KamiMod.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerDrawn(RenderPlayerEvent.Post event) {
|
||||
KamiMod.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
@SubscribeEvent()
|
||||
public void onChunkLoaded(ChunkEvent.Load event) { KamiMod.EVENT_BUS.post(event); }
|
||||
public void onChunkLoaded(ChunkEvent.Load event) {
|
||||
KamiMod.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
@SubscribeEvent()
|
||||
public void onChunkLoaded(ChunkEvent.Unload event) { KamiMod.EVENT_BUS.post(event); }
|
||||
public void onChunkLoaded(ChunkEvent.Unload event) {
|
||||
KamiMod.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onInputUpdate(InputUpdateEvent event) { KamiMod.EVENT_BUS.post(event); }
|
||||
public void onInputUpdate(InputUpdateEvent event) {
|
||||
KamiMod.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLivingEntityUseItemEventTick(LivingEntityUseItemEvent.Start entityUseItemEvent) {
|
||||
KamiMod.EVENT_BUS.post(entityUseItemEvent);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLivingDamageEvent(LivingDamageEvent event) {
|
||||
KamiMod.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onEntityJoinWorldEvent(EntityJoinWorldEvent entityJoinWorldEvent) {
|
||||
KamiMod.EVENT_BUS.post(entityJoinWorldEvent);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerPush(PlayerSPPushOutOfBlocksEvent event) {
|
||||
KamiMod.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLeftClickBlock(PlayerInteractEvent.LeftClickBlock event) {
|
||||
KamiMod.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onAttackEntity(AttackEntityEvent entityEvent) {
|
||||
KamiMod.EVENT_BUS.post(entityEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ import me.zeroeightsix.kami.util.Wrapper;
|
|||
*/
|
||||
public class KamiEvent extends Cancellable {
|
||||
|
||||
public Era era = Era.PRE;
|
||||
final float partialTicks;
|
||||
private Era era = Era.PRE;
|
||||
private final float partialTicks;
|
||||
|
||||
public KamiEvent() {
|
||||
partialTicks = Wrapper.getMinecraft().getRenderPartialTicks();
|
||||
|
|
|
@ -8,8 +8,8 @@ import net.minecraft.world.chunk.Chunk;
|
|||
* @author 086
|
||||
*/
|
||||
public class ChunkEvent extends KamiEvent {
|
||||
Chunk chunk;
|
||||
SPacketChunkData packet;
|
||||
private Chunk chunk;
|
||||
private SPacketChunkData packet;
|
||||
|
||||
public ChunkEvent(Chunk chunk, SPacketChunkData packet) {
|
||||
this.chunk = chunk;
|
||||
|
|
|
@ -8,7 +8,7 @@ import net.minecraft.entity.Entity;
|
|||
*/
|
||||
public class EntityEvent extends KamiEvent {
|
||||
|
||||
Entity entity;
|
||||
private Entity entity;
|
||||
|
||||
public EntityEvent(Entity entity) {
|
||||
super();
|
||||
|
|
|
@ -7,7 +7,7 @@ import net.minecraft.client.gui.GuiScreen;
|
|||
*/
|
||||
public class GuiScreenEvent {
|
||||
|
||||
GuiScreen screen;
|
||||
private GuiScreen screen;
|
||||
|
||||
public GuiScreenEvent(GuiScreen screen) {
|
||||
super();
|
||||
|
|
|
@ -8,7 +8,7 @@ import net.minecraft.network.Packet;
|
|||
*/
|
||||
public class PacketEvent extends KamiEvent {
|
||||
|
||||
final Packet packet;
|
||||
private final Packet packet;
|
||||
|
||||
public PacketEvent(Packet packet) {
|
||||
super();
|
||||
|
|
|
@ -8,8 +8,8 @@ import net.minecraft.entity.MoverType;
|
|||
*/
|
||||
public class PlayerMoveEvent extends KamiEvent {
|
||||
|
||||
MoverType type;
|
||||
double x, y, z;
|
||||
private MoverType type;
|
||||
private double x, y, z;
|
||||
|
||||
public PlayerMoveEvent(MoverType type, double x, double y, double z) {
|
||||
this.type = type;
|
||||
|
|
|
@ -14,9 +14,9 @@ import java.util.TreeMap;
|
|||
|
||||
public class KamiGuiChat extends GuiChat {
|
||||
|
||||
String startString;
|
||||
String currentFillinLine;
|
||||
int cursor;
|
||||
private String startString;
|
||||
private String currentFillinLine;
|
||||
private int cursor;
|
||||
|
||||
public KamiGuiChat(String startString, String historybuffer, int sentHistoryCursor) {
|
||||
super(startString);
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.util.Map;
|
|||
|
||||
public class MixinLoaderForge implements IFMLLoadingPlugin {
|
||||
|
||||
public static boolean isObfuscatedEnvironment = false;
|
||||
private static boolean isObfuscatedEnvironment = false;
|
||||
|
||||
public MixinLoaderForge() {
|
||||
KamiMod.log.info("KAMI mixins initialized");
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package me.zeroeightsix.kami.module.modules.combat;
|
||||
|
||||
import me.zeroeightsix.kami.module.Module;
|
||||
import me.zeroeightsix.kami.module.ModuleManager;
|
||||
import me.zeroeightsix.kami.module.modules.misc.AutoTool;
|
||||
import me.zeroeightsix.kami.setting.Setting;
|
||||
import me.zeroeightsix.kami.util.EntityUtil;
|
||||
import me.zeroeightsix.kami.util.Friends;
|
||||
|
@ -53,6 +55,7 @@ public class Aura extends Module {
|
|||
return;
|
||||
}else{
|
||||
if (EntityUtil.isPassive(target) ? animals : (EntityUtil.isMobAggressive(target) && mobs)) {
|
||||
if (ModuleManager.isModuleEnabled("AutoTool")) AutoTool.equipBestWeapon();
|
||||
attack(target);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
package me.zeroeightsix.kami.module.modules.misc;
|
||||
|
||||
import me.zero.alpine.listener.EventHandler;
|
||||
import me.zero.alpine.listener.Listener;
|
||||
import me.zeroeightsix.kami.module.Module;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.EnumCreatureAttribute;
|
||||
import net.minecraft.init.Enchantments;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import net.minecraft.item.ItemTool;
|
||||
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
|
||||
/**
|
||||
* Created by 086 on 2/10/2018.
|
||||
*/
|
||||
@Module.Info(name = "AutoTool", description = "Automatically switch to the best tools when mining or attacking", category = Module.Category.MISC)
|
||||
public class AutoTool extends Module {
|
||||
|
||||
@EventHandler
|
||||
private Listener<PlayerInteractEvent.LeftClickBlock> leftClickListener = new Listener<>(event -> {
|
||||
equipBestTool(mc.world.getBlockState(event.getPos()));
|
||||
});
|
||||
|
||||
@EventHandler
|
||||
private Listener<AttackEntityEvent> attackListener = new Listener<>(event -> {
|
||||
equipBestWeapon();
|
||||
});
|
||||
|
||||
private void equipBestTool(IBlockState blockState) {
|
||||
int bestSlot = -1;
|
||||
double max = 0;
|
||||
for (int i = 0; i < 9; i++) {
|
||||
ItemStack stack = mc.player.inventory.getStackInSlot(i);
|
||||
if (stack.isEmpty) continue;
|
||||
float speed = stack.getDestroySpeed(blockState);
|
||||
int eff;
|
||||
if (speed > 1) {
|
||||
speed += ((eff = EnchantmentHelper.getEnchantmentLevel(Enchantments.EFFICIENCY, stack)) > 0 ? (Math.pow(eff, 2) + 1) : 0);
|
||||
if (speed > max) {
|
||||
max = speed;
|
||||
bestSlot = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bestSlot != -1) equip(bestSlot);
|
||||
}
|
||||
|
||||
public static void equipBestWeapon() {
|
||||
int bestSlot = -1;
|
||||
double maxDamage = 0;
|
||||
for (int i = 0; i < 9; i++) {
|
||||
ItemStack stack = mc.player.inventory.getStackInSlot(i);
|
||||
if (stack.isEmpty) continue;
|
||||
if (stack.getItem() instanceof ItemTool) {
|
||||
double damage = (((ItemTool) stack.getItem()).attackDamage + (double) EnchantmentHelper.getModifierForCreature(stack, EnumCreatureAttribute.UNDEFINED));
|
||||
if (damage > maxDamage) {
|
||||
maxDamage = damage;
|
||||
bestSlot = i;
|
||||
}
|
||||
} else if (stack.getItem() instanceof ItemSword) {
|
||||
double damage = (((ItemSword) stack.getItem()).getAttackDamage() + (double) EnchantmentHelper.getModifierForCreature(stack, EnumCreatureAttribute.UNDEFINED));
|
||||
if (damage > maxDamage) {
|
||||
maxDamage = damage;
|
||||
bestSlot = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bestSlot != -1) equip(bestSlot);
|
||||
}
|
||||
|
||||
private static void equip(int slot) {
|
||||
mc.player.inventory.currentItem = slot;
|
||||
mc.playerController.syncCurrentPlayItem();
|
||||
}
|
||||
|
||||
}
|
|
@ -12,11 +12,11 @@ import org.lwjgl.input.Keyboard;
|
|||
*/
|
||||
public class Wrapper {
|
||||
|
||||
static FontRenderer cfr;
|
||||
private static FontRenderer fontRenderer;
|
||||
|
||||
public static void init() {
|
||||
// cfr = new CFontRenderer(new Font("Segoe UI", Font.PLAIN, 19), true, false);
|
||||
cfr = KamiGUI.fontRenderer;
|
||||
// fontRenderer = new CFontRenderer(new Font("Segoe UI", Font.PLAIN, 19), true, false);
|
||||
fontRenderer = KamiGUI.fontRenderer;
|
||||
}
|
||||
public static Minecraft getMinecraft() {
|
||||
return Minecraft.getMinecraft();
|
||||
|
@ -32,6 +32,6 @@ public class Wrapper {
|
|||
}
|
||||
|
||||
public static FontRenderer getFontRenderer() {
|
||||
return cfr;
|
||||
return fontRenderer;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue