Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AutoPlaceHack #1048

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/net/wurstclient/hack/HackList.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public final class HackList implements UpdateListener
public final AutoLeaveHack autoLeaveHack = new AutoLeaveHack();
public final AutoLibrarianHack autoLibrarianHack = new AutoLibrarianHack();
public final AutoEatHack autoEatHack = new AutoEatHack();
public final AutoPlaceHack autoPlaceHack = new AutoPlaceHack();
public final AutoFarmHack autoFarmHack = new AutoFarmHack();
public final AutoFishHack autoFishHack = new AutoFishHack();
public final AutoMineHack autoMineHack = new AutoMineHack();
Expand Down
105 changes: 105 additions & 0 deletions src/main/java/net/wurstclient/hacks/AutoPlaceHack.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Copyright (c) 2014-2024 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
*/
package net.wurstclient.hacks;

import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.wurstclient.Category;
import net.wurstclient.SearchTags;
import net.wurstclient.events.UpdateListener;
import net.wurstclient.hack.Hack;
import net.wurstclient.settings.CheckboxSetting;
import net.wurstclient.util.BlockUtils;

@SearchTags({"bridge", "auto place"})
public final class AutoPlaceHack extends Hack implements UpdateListener
{
private final CheckboxSetting onlyBelowFeet =
new CheckboxSetting("Only Below Feet",
"Only place blocks when target block is 1 block below your feet.",
false);
private final CheckboxSetting fastPlace =
new CheckboxSetting("Always FastPlace",
"Builds as if FastPlace was enabled, even if it's not.", true);

public AutoPlaceHack()
{
super("AutoPlace");
setCategory(Category.BLOCKS);
addSetting(onlyBelowFeet);
addSetting(fastPlace);
}

@Override
public void onEnable()
{
EVENTS.add(UpdateListener.class, this);
}

@Override
public void onDisable()
{
EVENTS.remove(UpdateListener.class, this);
}

@Override
public void onUpdate()
{
if(MC.currentScreen instanceof HandledScreen)
return;

if(MC.itemUseCooldown != 0 && !fastPlace.isChecked())
return;

ClientPlayerEntity player = MC.player;
assert player != null;

// Item in hand is not a block
if(!(player.getInventory().getStack(player.getInventory().selectedSlot)
.getItem() instanceof BlockItem))
return;

HitResult hitResult = MC.crosshairTarget;
if(hitResult == null || hitResult.getType() != HitResult.Type.BLOCK)
return;

BlockHitResult blockHitResult = (BlockHitResult)hitResult;
if(blockHitResult.getSide() == Direction.UP
|| blockHitResult.getSide() == Direction.DOWN)
return;

if(!BlockUtils.canBeClicked(blockHitResult.getBlockPos()))
return;

BlockPos blockToPlacePos =
blockHitResult.getBlockPos().offset(blockHitResult.getSide());
if(!BlockUtils.getState(blockToPlacePos).isReplaceable())
return;
Alexander01998 marked this conversation as resolved.
Show resolved Hide resolved

// Option: only below feet
if(blockToPlacePos.getY() != BlockPos.ofFloored(MC.player.getPos())
.down().getY() && onlyBelowFeet.isChecked())
return;

assert MC.interactionManager != null;
MC.interactionManager.interactItem(player, Hand.MAIN_HAND);
ActionResult actionResult = MC.interactionManager.interactBlock(player,
Hand.MAIN_HAND, blockHitResult);
if(actionResult.isAccepted())
MC.player.swingHand(Hand.MAIN_HAND);

MC.itemUseCooldown = 4;
}
}
1 change: 1 addition & 0 deletions src/main/resources/assets/wurst/translations/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"description.wurst.hack.autoleave": "Automatically leaves the server when your health is low.",
"description.wurst.hack.autolibrarian": "Automatically trains a villager to become a librarian that sells a specific enchanted book. You can set up an entire trading hall in no time by using this hack.",
"description.wurst.hack.autoeat": "Automatically eats food when necessary.",
"description.wurst.hack.autoplace": "Right click when your crosshair is pointing to a side face of a block.",
"description.wurst.setting.autoeat.target_hunger": "Tries to keep the hunger bar at or above this level, but only if it doesn't waste any hunger points.",
"description.wurst.setting.autoeat.min_hunger": "Always keeps the hunger bar at or above this level, even if it wastes some hunger points.\n6.5 - Cannot cause any waste with vanilla food items.\n10.0 - Completely ignores waste and just keeps the hunger bar full.",
"description.wurst.setting.autoeat.injured_hunger": "Fills the hunger bar to at least this level when you are injured, even if it wastes some hunger points.\n10.0 - fastest healing\n9.0 - slowest healing\n<9.0 - no healing\n<3.5 - no sprinting",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/wurst/translations/zh_tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"description.wurst.hack.autodrop": "自動丟棄你不想要的物品(有預設)。",
"description.wurst.hack.autoleave": "如果你的血量低於設定值,將會自動退出伺服器。",
"description.wurst.hack.autoeat": "當必要的時候將會自動進食。",
"description.wurst.hack.bridgeclick": "當你的準心對準方塊側面時自動按右鍵。",
"description.wurst.setting.autoeat.target_hunger": "嘗試將飢餓值保持在或高於此水平,但前提是它不會浪費任何飢餓值。",
"description.wurst.setting.autoeat.min_hunger": "始終將飢餓條保持在此水平或以上,即使它會浪費一些飢餓點。\n6.5 - 不會對香草食品造成任何浪費。\n10.0 - 完全忽略浪費並保持飢餓條充滿。",
"description.wurst.setting.autoeat.injured_hunger": "當你受傷時,將飢餓條填充到至少這個水平,即使它會浪費一些飢餓點。\n10.0 - 最快的治療\n9.0 - 最慢的治療\n<9.0 - 沒有治療\n<3.5 - 沒有衝刺",
Expand Down