Skip to content

Commit

Permalink
2.4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishisherewithhh committed May 29, 2023
1 parent 39a389c commit ff7da47
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 101 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ yarn_mappings=1.19.4+build.2
loader_version=0.14.19

# Mod Properties
mod_version = 2.4.4
mod_version = 2.4.5
maven_group = net.smphack
archives_base_name = smp-hack

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package net.fabricmc.smphack.Hacks.Fakeplayer;

import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.client.MinecraftClient;

public class FakePlayerCommand {
private static String fakeplayername="FakePlayer";
public static void register() {
ClientCommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> {
LiteralArgumentBuilder<FabricClientCommandSource> fakeplayer = ClientCommandManager.literal("fakeplayer")
.then(ClientCommandManager.literal("spawn")
.then(ClientCommandManager.argument("name", StringArgumentType.string())
.executes(context -> {
assert MinecraftClient.getInstance().player != null;
fakeplayername = StringArgumentType.getString(context, "name");
System.out.println("Called Spawn with name: " + fakeplayername);
FakePlayerEntity.getInstance(fakeplayername).spawn(MinecraftClient.getInstance().player);
return 1;
})))
.then(ClientCommandManager.literal("clear").executes(context -> {
FakePlayerEntity.getInstance(fakeplayername).clear();
return 1;
}));

dispatcher.register(fakeplayer);
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package net.fabricmc.smphack.Hacks.Fakeplayer;

import com.mojang.authlib.GameProfile;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.OtherClientPlayerEntity;
import net.minecraft.entity.player.PlayerEntity;

import java.util.Objects;
import java.util.UUID;

public class FakePlayerEntity extends OtherClientPlayerEntity {
private static FakePlayerEntity instance;
private static final MinecraftClient mc = MinecraftClient.getInstance();

public static FakePlayerEntity getInstance(String name) {
if (instance != null) {
instance.clear();
}
instance = new FakePlayerEntity(name);
return instance;
}
private FakePlayerEntity(String name) {
super(Objects.requireNonNull(mc.world), new GameProfile(UUID.randomUUID(), name));
this.setHealth(20f);
this.setInvisible(false);
this.setInvulnerable(true);
}

public void spawn(PlayerEntity player) {
this.copyPositionAndRotation(player);
Byte playerModel = player.getDataTracker().get(PlayerEntity.PLAYER_MODEL_PARTS);
dataTracker.set(PlayerEntity.PLAYER_MODEL_PARTS, playerModel);
this.getAttributes().setFrom(player.getAttributes());
this.setPose(player.getPose());
this.getInventory().clone(player.getInventory());
assert mc.world != null;
mc.world.addEntity(getId(), this);
System.out.println("FakePlayer Spawned Instance: " + this);
}
public void clear() {
this.kill();
assert mc.world != null;
mc.world.removeEntity(getId(), RemovalReason.DISCARDED);
setRemoved(RemovalReason.DISCARDED);
instance = null;
}
}



Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static void tryRefill(PlayerEntity player, ItemStack stack, EquipmentSlot
if (!GeneralConfig.getConfig().getAutoHotbar() || player.isCreative()) {
return;
}
if (stack.isEmpty() || stack.isStackable() && stack.getCount() > 1 || stack.isDamageable() && stack.getMaxDamage() - stack.getDamage() > 1 || stack.getItem() == Items.TOTEM_OF_UNDYING) {
if (stack.isEmpty() || stack.isStackable() && stack.getCount() > 5 || stack.isDamageable() && stack.getMaxDamage() - stack.getDamage() > 1 || stack.getItem() == Items.TOTEM_OF_UNDYING) {
return;
}
// if open screen don't do anything
Expand All @@ -56,11 +56,12 @@ public static void tryRefill(PlayerEntity player, ItemStack stack, EquipmentSlot
EXEC.schedule(() -> {
manager.clickSlot(0, current, 0, SlotActionType.PICKUP, player);
// rollback if set it wrong or can set empty back
EXEC.schedule(() -> manager.clickSlot(0, next, 0, SlotActionType.PICKUP, player), 100, TimeUnit.MILLISECONDS);
}, 100, TimeUnit.MILLISECONDS);
EXEC.schedule(() -> manager.clickSlot(0, next, 0, SlotActionType.PICKUP, player), 10, TimeUnit.MILLISECONDS);
}, 10, TimeUnit.MILLISECONDS);
}, player, stack, slot);
}


private static void ifRefill(BiConsumer<Integer, Integer> refillSetter, PlayerEntity player, ItemStack stack, EquipmentSlot slot) {
int current = getEquipmentSlotInScreen(slot, player.getInventory().selectedSlot);
if (stack.getItem()==Items.TOTEM_OF_UNDYING)
Expand Down
90 changes: 0 additions & 90 deletions src/main/java/net/fabricmc/smphack/Hacks/Scaffold/BlockUtils.java
Original file line number Diff line number Diff line change
@@ -1,116 +1,32 @@
package net.fabricmc.smphack.Hacks.Scaffold;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.client.MinecraftClient;
import net.minecraft.registry.Registries;
import net.minecraft.util.Identifier;
import net.minecraft.util.InvalidIdentifierException;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;

import java.util.ArrayList;
import java.util.stream.Stream;

public enum BlockUtils
{;


private static final MinecraftClient MC = MinecraftClient.getInstance();

public static BlockState getState(BlockPos pos)
{
assert MC.world != null;
return MC.world.getBlockState(pos);
}

public static Block getBlock(BlockPos pos)
{
return getState(pos).getBlock();
}

public static int getId(BlockPos pos)
{
return Block.getRawIdFromState(getState(pos));
}

public static String getName(BlockPos pos)
{
return getName(getBlock(pos));
}

public static String getName(Block block)
{
return Registries.BLOCK.getId(block).toString();
}

/**
* @param name
* a String containing the block's name ({@link Identifier})
* @return the requested block, or <code>minecraft:air</code> if the block
* doesn't exist.
*/
public static Block getBlockFromName(String name)
{
try
{
return Registries.BLOCK.get(new Identifier(name));

}catch(InvalidIdentifierException e)
{
return Blocks.AIR;
}
}




public static float getHardness(BlockPos pos)
{
return getState(pos).calcBlockBreakingDelta(MC.player, MC.world, pos);
}

private static VoxelShape getOutlineShape(BlockPos pos)
{
return getState(pos).getOutlineShape(MC.world, pos);
}

public static Box getBoundingBox(BlockPos pos)
{
return getOutlineShape(pos).getBoundingBox().offset(pos);
}

public static boolean canBeClicked(BlockPos pos)
{
return getOutlineShape(pos) != VoxelShapes.empty();
}

public static ArrayList<BlockPos> getAllInBox(BlockPos from, BlockPos to)
{
ArrayList<BlockPos> blocks = new ArrayList<>();

BlockPos min = new BlockPos(Math.min(from.getX(), to.getX()),
Math.min(from.getY(), to.getY()), Math.min(from.getZ(), to.getZ()));
BlockPos max = new BlockPos(Math.max(from.getX(), to.getX()),
Math.max(from.getY(), to.getY()), Math.max(from.getZ(), to.getZ()));

for(int x = min.getX(); x <= max.getX(); x++)
for(int y = min.getY(); y <= max.getY(); y++)
for(int z = min.getZ(); z <= max.getZ(); z++)
blocks.add(new BlockPos(x, y, z));

return blocks;
}

public static ArrayList<BlockPos> getAllInBox(BlockPos center, int range)
{
return getAllInBox(center.add(-range, -range, -range),
center.add(range, range, range));
}

public static Stream<BlockPos> getAllInBoxStream(BlockPos from, BlockPos to)
{
BlockPos min = new BlockPos(Math.min(from.getX(), to.getX()),
Expand Down Expand Up @@ -149,10 +65,4 @@ public static Stream<BlockPos> getAllInBoxStream(BlockPos from, BlockPos to)

return stream.limit(limit);
}

public static Stream<BlockPos> getAllInBoxStream(BlockPos center, int range)
{
return getAllInBoxStream(center.add(-range, -range, -range),
center.add(range, range, range));
}
}
23 changes: 20 additions & 3 deletions src/main/java/net/fabricmc/smphack/Hacks/Scaffold/Scaffold.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package net.fabricmc.smphack.Hacks.Scaffold;

import net.fabricmc.smphack.Hacks.RefillUtil.RefillUtil;
import net.fabricmc.smphack.MainGui;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.FallingBlock;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.network.ClientPlayerInteractionManager;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -55,6 +57,13 @@ public void update() {
if (!BlockUtils.getState(belowPlayer).getMaterial().isReplaceable())
return;

// check if player has block in main hand
ItemStack mainHandStack = MC.player.getMainHandStack();
if (!mainHandStack.isEmpty() && mainHandStack.getItem() instanceof BlockItem) {
scaffoldTo(belowPlayer);
return;
}

// search blocks in hotbar
int newSlot = -1;
for (int i = 0; i < 9; i++) {
Expand Down Expand Up @@ -92,18 +101,23 @@ public void update() {
MC.player.getInventory().selectedSlot = oldSlot;
}


private void scaffoldTo(BlockPos belowPlayer) {
// tries to place a block directly under the player
if (placeBlock(belowPlayer))
if (placeBlock(belowPlayer)) {
RefillUtil.tryRefill(MC.player, MC.player.getMainHandStack(), EquipmentSlot.MAINHAND);
return;
}

// if that doesn't work, tries to place a block next to the block that's
// under the player
Direction[] sides = Direction.values();
for (Direction side : sides) {
BlockPos neighbor = belowPlayer.offset(side);
if (placeBlock(neighbor))
if (placeBlock(neighbor)) {
RefillUtil.tryRefill(MC.player, MC.player.getMainHandStack(), EquipmentSlot.MAINHAND);
return;
}
}

// if that doesn't work, tries to place a block next to a block that's
Expand All @@ -114,11 +128,14 @@ private void scaffoldTo(BlockPos belowPlayer) {
continue;

BlockPos neighbor = belowPlayer.offset(side).offset(side2);
if (placeBlock(neighbor))
if (placeBlock(neighbor)) {
RefillUtil.tryRefill(MC.player, MC.player.getMainHandStack(), EquipmentSlot.MAINHAND);
return;
}
}
}


private boolean placeBlock(BlockPos pos) {
Vec3d eyesPos = new Vec3d(MC.player.getX(),
MC.player.getY() + MC.player.getEyeHeight(MC.player.getPose()),
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/net/fabricmc/smphack/Hacks/Speed/Speed.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.fabricmc.smphack.Hacks.Speed;

import net.fabricmc.smphack.GeneralConfig;
import net.fabricmc.smphack.Hacks.AntiHunger.AntiHunger;
import net.fabricmc.smphack.MainGui;
import net.fabricmc.smphack.config.ConfigUtil;
import net.minecraft.client.MinecraftClient;
Expand Down Expand Up @@ -34,6 +35,9 @@ public void update() {
Speed = GeneralConfig.getConfig().getSpeed_multiplier();
Speedmode = String.valueOf(ConfigUtil.config.Speedmode);
}
AntiHunger antiHunger = new AntiHunger();
antiHunger.update();

assert MinecraftClient.getInstance().player != null;
HungerManager hungerManager = MinecraftClient.getInstance().player.getHungerManager();
hungerManager.add(2, 5);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/fabricmc/smphack/MainHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.fabricmc.smphack.Hacks.Fakeplayer.FakePlayerCommand;
import net.fabricmc.smphack.RGBtext.CharacterMode;
import net.fabricmc.smphack.config.ConfigScreen;
import net.minecraft.client.MinecraftClient;
Expand All @@ -15,6 +16,7 @@ public class MainHack implements ModInitializer {
@Override
public void onInitialize() {
assert MinecraftClient.getInstance().player != null;
FakePlayerCommand.register();
HudRenderCallback.EVENT.register(new HUDoverlay());
CharacterMode.init();
LOGGER.info("Smphack Initialised");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public static void init() {
int x_offset = 0;
//End of initializing variables;
String text = "XYZ " + xp + " " + yp + " " + zp;
String LOGO = "SMP-Hack v2-4-4";
String LOGO = "SMP-Hack v2-4-5";

int stringWidth = font.getWidth(LOGO);
for (int i = 0; i < LOGO.length(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,10 @@ public enum MouseKeybind
private int playernametagcolour = 0xFF;



public int getPlayernametagcolour() {
return playernametagcolour;
}



public float getJETPACK_MAX_SPEED() {
return JETPACK_MAX_SPEED;
}
Expand Down

0 comments on commit ff7da47

Please sign in to comment.