Skip to content

Commit

Permalink
Small change I forgot to commit earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielMChristiansen committed Jan 18, 2024
1 parent 0a96969 commit b40edeb
Showing 1 changed file with 35 additions and 4 deletions.
39 changes: 35 additions & 4 deletions src/main/java/ravenweave/client/module/modules/beta/Scaffold.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,26 @@
import net.minecraft.util.Vec3;
import net.weavemc.loader.api.event.RenderGameOverlayEvent;
import net.weavemc.loader.api.event.SubscribeEvent;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.lwjgl.input.Keyboard;
import ravenweave.client.event.LookEvent;
import ravenweave.client.event.UpdateEvent;
import ravenweave.client.module.Module;
import ravenweave.client.module.modules.player.BedAura;
import ravenweave.client.module.setting.impl.DescriptionSetting;
import ravenweave.client.module.setting.impl.SliderSetting;
import ravenweave.client.module.setting.impl.TickSetting;
import ravenweave.client.utils.CaterpillowUtils;
import ravenweave.client.utils.Utils;

import java.security.KeyPair;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class Scaffold extends Module {

private final TickSetting disableSprint, noSwing, slotSwap, sameY;
private final TickSetting disableSprint, noSwing, slotSwap, sameY, doRots;
private final SliderSetting pitch;

private float yaw, prevYaw;
Expand All @@ -34,9 +42,10 @@ public Scaffold() {
this.registerSetting(new DescriptionSetting("Helps you make bridges/scaffold walk.")); // bad description, but manthe wrote it
this.registerSetting(pitch = new SliderSetting("Pitch", 81, 70, 90, 1));
this.registerSetting(noSwing = new TickSetting("No Swing", false));
this.registerSetting(sameY = new TickSetting("Same Y", true));
this.registerSetting(sameY = new TickSetting("Same Y", false));
this.registerSetting(disableSprint = new TickSetting("Disable sprint", true));
this.registerSetting(slotSwap = new TickSetting("Swap to blocks", true));
this.registerSetting(doRots = new TickSetting("Do Rotations", true));
}

public void onDisable() {
Expand Down Expand Up @@ -73,6 +82,28 @@ public void lookEvent(LookEvent e) {
e.setPrevPitch(mc.gameSettings.keyBindJump.isKeyDown() && !mc.gameSettings.keyBindForward.isKeyDown() ? 90 : (float) pitch.getInput());
}

public MovingObjectPosition getMouseOverWithoutRots() {
BlockPos blockUnder = new BlockPos(mc.thePlayer).down();
List<ImmutablePair<BlockPos, EnumFacing>> blockstoPlaceOn = new ArrayList<>();
for (int x = -1; x < 1; x++) {
for (int y = -1; y < 1; y++) {
for (int z = -1; z < 1; z++) {
BlockPos pos = blockUnder.add(x,y,z);
if (CaterpillowUtils.isAirBlock(pos)) continue; // Yes I'm using caterpillow's code, fight me it's a raven skid
blockstoPlaceOn.add(new ImmutablePair<>(pos, EnumFacing.getFacingFromVector(x, y, z)));
}
}
}
blockstoPlaceOn.sort((o1, o2) -> (int) (mc.thePlayer.getDistanceSq(o2.left) - mc.thePlayer.getDistanceSq(o1.left)));

if (blockstoPlaceOn.isEmpty()) return null;
BlockPos blockPos = blockstoPlaceOn.get(0).left;

EnumFacing enumFacing = blockstoPlaceOn.get(0).right;
EnumFacing side2 = enumFacing.getOpposite();
Vec3 hitVec = new Vec3(blockPos).addVector(0.5, 0.5, 0.5).add(new Vec3(side2.getDirectionVec()));
return new MovingObjectPosition(MovingObjectPosition.MovingObjectType.BLOCK, hitVec, enumFacing, blockPos);
}

@SubscribeEvent
public void onRender(RenderGameOverlayEvent event) {
Expand All @@ -81,8 +112,8 @@ public void onRender(RenderGameOverlayEvent event) {

if (mc.currentScreen != null || mc.thePlayer.getHeldItem() == null) return;

MovingObjectPosition mop = mc.objectMouseOver;

MovingObjectPosition mop = doRots.isToggled() ? mc.objectMouseOver : getMouseOverWithoutRots();
if (mop == null) return;

if (shouldClickBlock(mop)) {
clickBlock(mop.getBlockPos(), mop.sideHit, mop.hitVec);
Expand Down

0 comments on commit b40edeb

Please sign in to comment.