Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public final class AutoSoupMod
- extends Mod
- implements UpdateListener
- {
- private final SliderSetting health = new SliderSetting("Health", 6.5D, 0.5D, 9.5D, 0.5D, SliderSetting.ValueDisplay.DECIMAL);
- private final CheckboxSetting ignoreScreen = new CheckboxSetting("Ignore screen", true);
- private int oldSlot = -1;
- public AutoSoupMod() {
- super("AutoSoup", "Automatically eats soup if your health is lower than or equal to the set value.\n\n�lNote:�r This mod ignores hunger and assumes that eating soup directly refills your health.\nIf the server you are playing on is not configured to do that, use AutoEat instead.");
- setCategory(Category.OTHER);
- }
- public void initSettings() {
- addSetting(this.health);
- addSetting(this.ignoreScreen);
- }
- public Feature[] getSeeAlso() {
- return new Feature[] { wurst.mods.autoSplashPotMod,
- wurst.mods.autoEatMod };
- }
- public void onEnable() { wurst.events.add(UpdateListener.class, this); }
- public void onDisable() {
- wurst.events.remove(UpdateListener.class, this);
- stopIfEating();
- }
- public void onUpdate() {
- for (int i = 0; i < 36; i++) {
- ItemStack stack =
- (WMinecraft.getPlayer()).inventory.getStackInSlot(i);
- if (stack != null && stack.getItem() == Items.BOWL && i != 9) {
- ItemStack emptyBowlStack =
- (WMinecraft.getPlayer()).inventory.getStackInSlot(9);
- boolean swap = (!WItem.isNullOrEmpty(emptyBowlStack) &&
- emptyBowlStack.getItem() != Items.BOWL);
- WPlayerController.windowClick_PICKUP((i < 9) ? (36 + i) : i);
- WPlayerController.windowClick_PICKUP(9);
- if (swap) {
- WPlayerController.windowClick_PICKUP((i < 9) ? (36 + i) : i);
- }
- }
- }
- int soupInHotbar = findSoup(0, 9);
- if (soupInHotbar != -1) {
- if (!shouldEatSoup()) {
- stopIfEating();
- return;
- }
- if (this.oldSlot == -1) {
- this.oldSlot = (WMinecraft.getPlayer()).inventory.currentItem;
- }
- (WMinecraft.getPlayer()).inventory.currentItem = soupInHotbar;
- mc.gameSettings.keyBindUseItem.pressed = true;
- WPlayerController.processRightClick();
- return;
- }
- stopIfEating();
- int soupInInventory = findSoup(9, 36);
- if (soupInInventory != -1) {
- WPlayerController.windowClick_QUICK_MOVE(soupInInventory);
- }
- }
- public void onYesCheatUpdate(YesCheatSpf.Profile profile) {
- switch ($SWITCH_TABLE$net$wurstclient$features$special_features$YesCheatSpf$Profile()[profile.ordinal()]) {
- case 6:
- this.ignoreScreen.lock(() -> false);
- return;
- }
- this.ignoreScreen.unlock();
- }
- private int findSoup(int startSlot, int endSlot) {
- for (int i = startSlot; i < endSlot; i++) {
- ItemStack stack =
- (WMinecraft.getPlayer()).inventory.getStackInSlot(i);
- if (stack != null && stack.getItem() instanceof net.minecraft.item.ItemSoup) {
- return i;
- }
- }
- return -1;
- }
- private boolean shouldEatSoup() {
- if (WMinecraft.getPlayer().getHealth() > this.health.getValueF() * 2.0F) {
- return false;
- }
- if (!this.ignoreScreen.isChecked() && mc.currentScreen != null) {
- return false;
- }
- if (mc.currentScreen == null && mc.objectMouseOver != null) {
- Entity entity = mc.objectMouseOver.entityHit;
- if (entity instanceof net.minecraft.entity.passive.EntityVillager ||
- entity instanceof net.minecraft.entity.passive.EntityTameable) {
- return false;
- }
- if (mc.objectMouseOver.getBlockPos() != null && WBlock.getBlock(
- mc.objectMouseOver.getBlockPos()) instanceof net.minecraft.block.BlockContainer) {
- return false;
- }
- }
- return true;
- }
- private void stopIfEating() {
- if (this.oldSlot == -1) {
- return;
- }
- mc.gameSettings.keyBindUseItem.pressed = false;
- (WMinecraft.getPlayer()).inventory.currentItem = this.oldSlot;
- this.oldSlot = -1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement