Skip to content

Commit

Permalink
0.9.1 InstaSafetyBox Added, code cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
etianl authored Apr 5, 2024
1 parent 9e0d459 commit f1c0933
Show file tree
Hide file tree
Showing 8 changed files with 1,824 additions and 1,494 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ This will return the lowest block placed with AutoMountain until AutoLavacast is
- **Inventory Dupe (1.17):** Duplicates things in your crafting slots when the module is enabled and the Dupe button is pressed in your inventory. Only works on Minecraft servers on the version 1.17, not any version before or after.(Credit to ItsVen and Da0neDatGotAway for original creation of the dupe, and to B2H990 for making the fabric mod. Credits to etianl for porting to Meteor.)
- **InstaKill:** Shoots arrows and tridents with incredible power and velocity. Enabling multiple buttons causes the amount of packets to add up. (Credits to Saturn5Vfive)
- **InstaMineNuker:** Sends packets to instantly mine the blocks around you until they are gone. There is an option in it to make it only target instamineable blocks such as crops, grass, slimeblocks, and more.. (Credits to etianl and to Meteor Client, as well as Meteor Rejects for some borrowed code)
- **InstaSafetyBox:** Places a box around you for safety using the hardest blocks available in your hotbar. Also with adjustable range for thic box. (Credits to etianl :D)
- **LavaAura:** Automatically places and picks up lava buckets at an entity's position on a tick delay, or sets the entity on fire using flint and steel or fire charges. Also has the option of placing lavabuckets or fire on every block face which may be useful in creative mode. (Credits to etianl :D)
- **LecternCrash:** Crash 1.18.X vanilla servers and possibly below. (Credits to Coderx-Gamer)
- **NbtEditor:** Requires Creative mode. Generates custom entities in the form of a custom spawn egg, and it can also generate items with custom enchantments and potions with custom effects all based on the settings you configure. (Credits to etianl :D)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ yarn_mappings=1.20.4+build.3
loader_version=0.15.3

# Mod Properties
mod_version=0.9.0-1.20.4
mod_version=0.9.1-1.20.4
maven_group=pwn.noobs
archives_base_name=1trouser-streak

Expand Down
1 change: 1 addition & 0 deletions src/main/java/pwn/noobs/trouserstreak/Trouser.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public void onInitialize() {
Modules.get().add(new NewerNewChunks());
Modules.get().add(new SuperInstaMine());
Modules.get().add(new InstaMineNuker());
Modules.get().add(new InstaSafetyBox());
Modules.get().add(new BaseFinder());
Modules.get().add(new Teleport());
Modules.get().add(new TPFly());
Expand Down
374 changes: 205 additions & 169 deletions src/main/java/pwn/noobs/trouserstreak/modules/AutoLavaCaster.java

Large diffs are not rendered by default.

905 changes: 466 additions & 439 deletions src/main/java/pwn/noobs/trouserstreak/modules/AutoMountain.java

Large diffs are not rendered by default.

233 changes: 233 additions & 0 deletions src/main/java/pwn/noobs/trouserstreak/modules/InstaSafetyBox.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
//Written By etianll
package pwn.noobs.trouserstreak.modules;

import meteordevelopment.meteorclient.events.game.GameLeftEvent;
import meteordevelopment.meteorclient.events.game.OpenScreenEvent;
import meteordevelopment.meteorclient.events.world.TickEvent;
import meteordevelopment.meteorclient.settings.*;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.utils.player.PlayerUtils;
import meteordevelopment.meteorclient.utils.player.Rotations;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.block.*;
import net.minecraft.client.gui.screen.DeathScreen;
import net.minecraft.client.gui.screen.DisconnectedScreen;
import net.minecraft.item.*;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
import pwn.noobs.trouserstreak.Trouser;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

public class InstaSafetyBox extends Module {
private final SettingGroup sgGeneral = settings.getDefaultGroup();
private final Setting<List<Block>> skippableBlox = sgGeneral.add(new BlockListSetting.Builder()
.name("Blocks to not use")
.description("Do not use these blocks for building.")
.build()
);
private final Setting<Double> reach = sgGeneral.add(new DoubleSetting.Builder()
.name("Range")
.description("Your Range, in blocks.")
.defaultValue(1)
.sliderRange(1,6)
.min (1)
.max (6)
.build()
);
private final Setting<Integer> blockpertick = sgGeneral.add(new IntSetting.Builder()
.name("Blocks per Tick")
.description("How many blocks to place per tick.")
.defaultValue(4)
.sliderRange(1,10)
.min (1)
.max (5)
.build()
);
private final Setting<Integer> tickdelay = sgGeneral.add(new IntSetting.Builder()
.name("TickDelay")
.description("Delays placement by this many ticks.")
.defaultValue(1)
.sliderRange(0, 10)
.build()
);
public final Setting<Boolean> rotate = sgGeneral.add(new BoolSetting.Builder()
.name("Rotate Player")
.description("Rotates the player to the direction of the blocks being placed.")
.defaultValue(true)
.build()
);
public final Setting<Boolean> swing = sgGeneral.add(new BoolSetting.Builder()
.name("Swing Arm")
.description("Swings arm or not.")
.defaultValue(true)
.build()
);
public final Setting<Boolean> hard = sgGeneral.add(new BoolSetting.Builder()
.name("Always choose hardest block")
.description("Always chooses the hardest block even if you are already holding a valid block.")
.defaultValue(true)
.build()
);
public final Setting<Boolean> toggle = sgGeneral.add(new BoolSetting.Builder()
.name("Toggle on blocks placed")
.description("Toggles module when all blocks have been attempted to be placed once.")
.defaultValue(true)
.build()
);
private int ticks;
private boolean playerneedstosneak = false;
public InstaSafetyBox() {
super(Trouser.Main, "InstaSafetyBox", "Makes you safe by building box.");
}
@Override
public void onDeactivate() {
if (playerneedstosneak)mc.options.sneakKey.setPressed(false);
}
@EventHandler
private void onPreTick(TickEvent.Pre event) {
PlayerUtils.centerPlayer();
if (mc.player.isOnGround() && mc.player.getY() >= Math.floor(mc.player.getY()) + 0.2) {
mc.options.sneakKey.setPressed(true);
playerneedstosneak = true;
}
if (ticks >= tickdelay.get()) {
// Create a list of all the blocks within the specified range
List<BlockPos> blocks = new ArrayList<>();
int bottomlimit = (int) (mc.player.getBlockY() - Math.round(Math.ceil(reach.get())));

for (int x = (int) (mc.player.getBlockX() - Math.round(Math.ceil(reach.get()))); x <= mc.player.getBlockX() + reach.get(); x++) {
for (int y = bottomlimit; y <= (mc.player.getBlockY()+1) + reach.get(); y++) {
for (int z = (int) (mc.player.getBlockZ() - Math.round(Math.ceil(reach.get()))); z <= mc.player.getBlockZ() + reach.get(); z++) {
BlockPos blockPos = new BlockPos(x, y, z);
Vec3d playerPos1 = new BlockPos(mc.player.getBlockX(), mc.player.getBlockY(), mc.player.getBlockZ()).toCenterPos();
Vec3d playerPos2 = new BlockPos(mc.player.getBlockX(), mc.player.getBlockY()+1, mc.player.getBlockZ()).toCenterPos();
double distance1 = playerPos1.distanceTo(blockPos.toCenterPos());
double distance2 = playerPos2.distanceTo(blockPos.toCenterPos());
if (distance1 <= reach.get() || distance2 <= reach.get() ) {
if (blockPos != new BlockPos(mc.player.getBlockX(), mc.player.getBlockY(), mc.player.getBlockZ()) && blockPos != new BlockPos(mc.player.getBlockX(), mc.player.getBlockY()+1, mc.player.getBlockZ()) && mc.world.getBlockState(blockPos).getBlock().getDefaultState().isReplaceable()) {
blocks.add(blockPos);
}
}
}
}
}

// Sort the blocks by distance from the player
blocks.sort(Comparator.comparingDouble(pos -> pos.getSquaredDistance(mc.player.getPos())));

int count = 0;
for (BlockPos blockPos : blocks) {
if (count >= blockpertick.get()) {
break;
}
if (hard.get() || isInvalidBlock(mc.player.getMainHandStack().getItem().getDefaultStack())) cascadingpileof();

if (blockPos != new BlockPos(mc.player.getBlockX(), mc.player.getBlockY(), mc.player.getBlockZ()) && blockPos != new BlockPos(mc.player.getBlockX(), mc.player.getBlockY()+1, mc.player.getBlockZ()) && mc.world.getBlockState(blockPos).getBlock().getDefaultState().isReplaceable() && !isInvalidBlock(mc.player.getMainHandStack().getItem().getDefaultStack())) {
if (rotate.get())Rotations.rotate(Rotations.getYaw(blockPos), Rotations.getPitch(blockPos));
if (swing.get())mc.player.swingHand(Hand.MAIN_HAND);
mc.interactionManager.interactBlock(mc.player, Hand.MAIN_HAND, new BlockHitResult(Vec3d.of(blockPos), Direction.DOWN, blockPos, false));
count++;
}
if (count >= blocks.size() && toggle.get()) {
toggle();
}
}

ticks = 0;
}
ticks++;
}
@EventHandler
private void onScreenOpen(OpenScreenEvent event) {
if (event.screen instanceof DisconnectedScreen) {
toggle();
}
if (event.screen instanceof DeathScreen) {
toggle();
}
}
@EventHandler
private void onGameLeft(GameLeftEvent event) {
toggle();
}
private void cascadingpileof() {
List<ItemStack> validBlocks = new ArrayList<>();
for (int i = 0; i < 9; i++) {
ItemStack stack = mc.player.getInventory().getStack(i);
if (stack.getItem() instanceof BlockItem && !isInvalidBlock(stack)) {
validBlocks.add(stack);
}
}

if (validBlocks.isEmpty()) {
return;
}

// Find the hardest block
ItemStack hardestBlock = validBlocks.stream()
.max(Comparator.comparingDouble(stack -> {
Block block = ((BlockItem) stack.getItem()).getBlock();
return block.getHardness() < 0 ? Double.MAX_VALUE : block.getHardness();
}))
.orElse(null);

if (hardestBlock != null) {
mc.player.getInventory().selectedSlot = mc.player.getInventory().indexOf(hardestBlock);
}
}
private boolean isInvalidBlock(ItemStack stack) {
return !(stack.getItem() instanceof BlockItem)
|| stack.getItem() instanceof BedItem
|| stack.getItem() instanceof PowderSnowBucketItem
|| stack.getItem() instanceof ScaffoldingItem
|| stack.getItem() instanceof TallBlockItem
|| stack.getItem() instanceof VerticallyAttachableBlockItem
|| stack.getItem() instanceof PlaceableOnWaterItem
|| ((BlockItem) stack.getItem()).getBlock() instanceof PlantBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof TorchBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof AbstractRedstoneGateBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof RedstoneWireBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof FenceBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof WallBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof FenceGateBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof FallingBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof AbstractRailBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof AbstractSignBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof BellBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof CarpetBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof ConduitBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof CoralParentBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof TripwireHookBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof PointedDripstoneBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof TripwireBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof PressurePlateBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof WallMountedBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof ShulkerBoxBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof AmethystClusterBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof BuddingAmethystBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof ChorusFlowerBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof ChorusPlantBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof LanternBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof CandleBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof TntBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof CakeBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof CobwebBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof SugarCaneBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof SporeBlossomBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof KelpBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof GlowLichenBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof CactusBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof BambooBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof FlowerPotBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof LadderBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof SlabBlock
|| ((BlockItem) stack.getItem()).getBlock() instanceof TrapdoorBlock
|| skippableBlox.get().contains(((BlockItem) stack.getItem()).getBlock());
}
}
Loading

0 comments on commit f1c0933

Please sign in to comment.