forked from RepoMirrors/kami-blue
Add Nametags to AutoWither and add NoSoundLag (#188)
* Add NoSoundLag * Added Nametag option to AutoWither * Fix issue when name tags are off
This commit is contained in:
parent
d631b1e729
commit
8f920c4dee
|
@ -0,0 +1,29 @@
|
|||
package me.zeroeightsix.kami.module.modules.sdashb.experimental;
|
||||
|
||||
import me.zero.alpine.listener.EventHandler;
|
||||
import me.zero.alpine.listener.Listener;
|
||||
import me.zeroeightsix.kami.event.events.PacketEvent;
|
||||
import me.zeroeightsix.kami.module.Module;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.network.play.server.SPacketSoundEffect;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
|
||||
/**
|
||||
* Created by cats on 1/12/2019
|
||||
*/
|
||||
|
||||
@Module.Info(name = "NoSoundLag", category = Module.Category.EXPERIMENTAL, description = "Prevents sound lag")
|
||||
public class NoSoundLag extends Module {
|
||||
|
||||
@EventHandler
|
||||
Listener<PacketEvent.Receive> receiveListener = new Listener<>(event -> {
|
||||
if (mc.player == null) return;
|
||||
if (event.getPacket() instanceof SPacketSoundEffect) {
|
||||
final SPacketSoundEffect soundPacket = (SPacketSoundEffect) event.getPacket();
|
||||
if (soundPacket.getCategory() == SoundCategory.PLAYERS && soundPacket.getSound() == SoundEvents.ITEM_ARMOR_EQUIP_GENERIC) {
|
||||
event.cancel();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
|
@ -13,13 +13,14 @@ import net.minecraft.block.BlockLiquid;
|
|||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.boss.EntityWither;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.ClickType;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemNameTag;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.play.client.CPacketEntityAction;
|
||||
import net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
|
@ -36,6 +37,7 @@ import static me.zeroeightsix.kami.module.modules.player.Scaffold.faceVectorPack
|
|||
/**
|
||||
* @author hub/blockparole
|
||||
* Created by @S-B99 on 25/11/19
|
||||
* Updated by cats on 1/12/19
|
||||
*/
|
||||
@Module.Info(name = "AutoWither", category = Module.Category.MISC, description = "Automatically creates withers")
|
||||
public class AutoWither extends Module {
|
||||
|
@ -74,10 +76,11 @@ public class AutoWither extends Module {
|
|||
|
||||
private static final DecimalFormat df = new DecimalFormat("#.#");
|
||||
|
||||
private Setting<Double> placeRange = this.register(Settings.doubleBuilder("Place range").withMinimum(1.0).withValue(4.0).withMaximum(10.0).build());
|
||||
private Setting<Double> placeRange = register(Settings.doubleBuilder("Place range").withMinimum(1.0).withValue(4.0).withMaximum(10.0).build());
|
||||
private Setting<Boolean> placeCloseToEnemy = register(Settings.b("Place close to enemy", false));
|
||||
private Setting<Boolean> fastMode = register(Settings.b("Disable after placing", true));
|
||||
private Setting<Boolean> debugMessages = register(Settings.b("Debug Messages", true));
|
||||
private Setting<Boolean> nametag = register(Settings.b("Name Wither", false));
|
||||
|
||||
private int swordSlot;
|
||||
private static boolean isSneaking;
|
||||
|
@ -256,7 +259,9 @@ public class AutoWither extends Module {
|
|||
}
|
||||
mc.player.inventory.currentItem = swordSlot;
|
||||
|
||||
if (fastMode.getValue()) {
|
||||
if (nametag.getValue()) {
|
||||
return;
|
||||
} else if (fastMode.getValue()) {
|
||||
this.disable();
|
||||
return;
|
||||
}
|
||||
|
@ -264,6 +269,43 @@ public class AutoWither extends Module {
|
|||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
if (nametag.getValue()) {
|
||||
int tagslot = -1;
|
||||
for (int i = 0; i < 9; i++) {
|
||||
ItemStack stack = mc.player.inventory.getStackInSlot(i);
|
||||
|
||||
if (stack == ItemStack.EMPTY || stack.getItem() instanceof ItemBlock) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Item tag = stack.getItem();
|
||||
|
||||
if (tag instanceof ItemNameTag) {
|
||||
tagslot = i;
|
||||
}
|
||||
}
|
||||
if (tagslot == -1 && fastMode.getValue()) {
|
||||
Command.sendChatMessage("[AutoWither] Error: No nametags in inventory, disabling module");
|
||||
this.disable();
|
||||
return;
|
||||
}
|
||||
for (Entity w : mc.world.getLoadedEntityList()) {
|
||||
if (w instanceof EntityWither) {
|
||||
final EntityWither wither = (EntityWither) w;
|
||||
if (mc.player.getDistance(wither) <= placeRange.getValue()) {
|
||||
if (debugMessages.getValue()) {Command.sendChatMessage("Registered Wither");}
|
||||
if (tagslot != -1) {
|
||||
mc.player.inventory.currentItem = tagslot;
|
||||
mc.playerController.interactWithEntity(mc.player, wither, EnumHand.MAIN_HAND);
|
||||
if (fastMode.getValue()) {
|
||||
this.disable();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mc.player.inventory.currentItem = swordSlot;
|
||||
}
|
||||
|
||||
if (isDisabled() || mc.player == null || ModuleManager.isModuleEnabled("Freecam")) {
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue