Merge pull request '1.20.1' (#1) from Luna/blackilykat-chipmunkmod:1.19 into 1.19

Reviewed-on: #1
This commit is contained in:
Blackilykat 2023-07-01 12:19:15 -04:00
commit 2d4e319c93
16 changed files with 105 additions and 268 deletions

View file

@ -1,5 +1,5 @@
plugins { plugins {
id 'fabric-loom' version '1.0-SNAPSHOT' id 'fabric-loom' version '1.2-SNAPSHOT'
id 'maven-publish' id 'maven-publish'
} }
@ -10,16 +10,6 @@ archivesBaseName = project.archives_base_name
version = project.mod_version version = project.mod_version
group = project.maven_group group = project.maven_group
repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
mavenCentral()
}
dependencies { dependencies {
implementation 'org.apache.commons:commons-text:1.10.0' // Use the version that best suits your project implementation 'org.apache.commons:commons-text:1.10.0' // Use the version that best suits your project
@ -31,9 +21,9 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway. // Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation include("net.kyori:adventure-platform-fabric:5.8.0") // for Minecraft 1.19.4 modImplementation include("net.kyori:adventure-platform-fabric:5.8.0") // still works on 1.20.1
modImplementation include("net.kyori:adventure-text-serializer-legacy:4.13.1") modImplementation include("net.kyori:adventure-text-serializer-legacy:4.14.0")
modImplementation include("org.luaj:luaj-jse:3.0.1") modImplementation include("org.luaj:luaj-jse:3.0.1")
@ -42,11 +32,11 @@ dependencies {
// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}" // modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
compileOnly 'org.projectlombok:lombok:1.18.24' compileOnly 'org.projectlombok:lombok:1.18.28'
annotationProcessor 'org.projectlombok:lombok:1.18.24' annotationProcessor 'org.projectlombok:lombok:1.18.28'
testCompileOnly 'org.projectlombok:lombok:1.18.24' testCompileOnly 'org.projectlombok:lombok:1.18.28'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.24' testAnnotationProcessor 'org.projectlombok:lombok:1.18.28'
} }
processResources { processResources {
@ -62,32 +52,8 @@ tasks.withType(JavaCompile).configureEach {
it.options.release = 17 it.options.release = 17
} }
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
}
jar { jar {
from("LICENSE") { from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"} rename { "${it}_${project.archivesBaseName}"}
} }
} }
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}

View file

@ -4,9 +4,9 @@ org.gradle.parallel=true
# Fabric Properties # Fabric Properties
# check these on https://fabricmc.net/develop # check these on https://fabricmc.net/develop
minecraft_version=1.19.4 minecraft_version=1.20.1
yarn_mappings=1.19.4+build.2 yarn_mappings=1.20.1+build.9
loader_version=0.14.19 loader_version=0.14.21
# Mod Properties # Mod Properties
mod_version = 1.0.1 mod_version = 1.0.1
@ -14,5 +14,5 @@ org.gradle.parallel=true
archives_base_name = chipmunkmod archives_base_name = chipmunkmod
# Dependencies # Dependencies
fabric_version=0.81.1+1.19.4 fabric_version=0.84.0+1.20.1

Binary file not shown.

View file

@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

16
gradlew vendored
View file

@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum
@ -133,10 +130,13 @@ location of your Java installation."
fi fi
else else
JAVACMD=java JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the Please set the JAVA_HOME variable in your environment to match the
location of your Java installation." location of your Java installation."
fi
fi fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.
@ -144,7 +144,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #( case $MAX_FD in #(
max*) max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045 # shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) || MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit" warn "Could not query maximum file descriptor limit"
esac esac
@ -152,7 +152,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #( '' | soft) :;; #(
*) *)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045 # shellcheck disable=SC3045
ulimit -n "$MAX_FD" || ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD" warn "Could not set maximum file descriptor limit to $MAX_FD"
esac esac
@ -197,6 +197,10 @@ if "$cygwin" || "$msys" ; then
done done
fi fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command; # Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in # shell script including quotes and variable substitutions, so put them in

View file

@ -56,7 +56,7 @@ public class UsernameCommand {
final ServerInfo info = client.getCurrentServerEntry(); final ServerInfo info = client.getCurrentServerEntry();
client.world.disconnect(); client.world.disconnect();
client.disconnect(); client.disconnect();
ConnectScreen.connect(new MultiplayerScreen(new TitleScreen()), client, ServerAddress.parse(info.address), info); ConnectScreen.connect(new MultiplayerScreen(new TitleScreen()), client, ServerAddress.parse(info.address), info, false);
return Command.SINGLE_SUCCESS; return Command.SINGLE_SUCCESS;
} }

View file

@ -1,11 +1,17 @@
package land.chipmunk.chipmunkmod.mixin; package land.chipmunk.chipmunkmod.mixin;
import land.chipmunk.chipmunkmod.testclient.modules.antip2w.DelayPacketsModule; import land.chipmunk.chipmunkmod.testclient.modules.antip2w.DelayPacketsModule;
import land.chipmunk.chipmunkmod.testclient.modules.utility.GuiMoveModule;
import net.minecraft.client.Keyboard; import net.minecraft.client.Keyboard;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.Slice;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(Keyboard.class) @Mixin(Keyboard.class)
@ -20,4 +26,20 @@ public class KeyboardMixin {
ci.cancel(); ci.cancel();
} }
} }
// Don't @ me. It half-works
@Redirect(method = "onKey(JIIII)V",
at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;", opcode = Opcodes.GETFIELD),
slice = @Slice(
from = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;wrapScreenError(Ljava/lang/Runnable;Ljava/lang/String;Ljava/lang/String;)V"),
to = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/InputUtil;fromKeyCode(II)Lnet/minecraft/client/util/InputUtil$Key;")
)
)
private Screen currentScreen(MinecraftClient instance) {
if (GuiMoveModule.instance.isEnabled) {
return null;
} else {
return instance.currentScreen;
}
}
} }

View file

@ -1,6 +1,7 @@
package land.chipmunk.chipmunkmod.mixin; package land.chipmunk.chipmunkmod.mixin;
import land.chipmunk.chipmunkmod.testclient.gui.Gui; import land.chipmunk.chipmunkmod.testclient.gui.Gui;
import net.minecraft.client.gui.screen.SplashTextRenderer;
import net.minecraft.client.gui.screen.TitleScreen; import net.minecraft.client.gui.screen.TitleScreen;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@ -11,11 +12,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(TitleScreen.class) @Mixin(TitleScreen.class)
public class TitleScreenMixin { public class TitleScreenMixin {
@Shadow @Nullable private String splashText; private SplashTextRenderer splashText;
@Inject(method = "init", at = @At("HEAD")) @Inject(method = "init", at = @At("HEAD"))
void testclient$initializeGui(CallbackInfo ci) { void testclient$initializeGui(CallbackInfo ci) {
splashText = "owo"; splashText = new SplashTextRenderer("uwu");
if(Gui.gui == null){ if(Gui.gui == null){
Gui.initAutoRefresher(); Gui.initAutoRefresher();
Gui.addComponents(); Gui.addComponents();

View file

@ -15,6 +15,7 @@ import land.chipmunk.chipmunkmod.testclient.modules.utility.AutoToolsModule;
import land.chipmunk.chipmunkmod.testclient.modules.utility.BlockGuardianParticlesModule; import land.chipmunk.chipmunkmod.testclient.modules.utility.BlockGuardianParticlesModule;
import land.chipmunk.chipmunkmod.testclient.modules.utility.GuiMoveModule; import land.chipmunk.chipmunkmod.testclient.modules.utility.GuiMoveModule;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.Drawable; import net.minecraft.client.gui.Drawable;
import net.minecraft.client.gui.Element; import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.Selectable; import net.minecraft.client.gui.Selectable;
@ -79,10 +80,10 @@ public class Gui extends Screen{
}); });
} }
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { public void render(DrawContext context, int mouseX, int mouseY, float delta) {
// this.renderBackground(matrices); // this.renderBackground(matrices);
super.render(matrices, mouseX, mouseY, delta); super.render(context, mouseX, mouseY, delta);
} }
public static void open() { public static void open() {
@ -181,7 +182,7 @@ public class Gui extends Screen{
.withModule(AutoToolsModule.instance) .withModule(AutoToolsModule.instance)
.withModule(AntiVoidModule.instance) .withModule(AntiVoidModule.instance)
.withModule(BlockGuardianParticlesModule.instance) .withModule(BlockGuardianParticlesModule.instance)
.withModule(new GuiMoveModule()) .withModule(GuiMoveModule.instance)
.withModule(AntiChatSpamModule.instance) .withModule(AntiChatSpamModule.instance)
.register(); .register();
new Category("OP") new Category("OP")

View file

@ -3,6 +3,7 @@ package land.chipmunk.chipmunkmod.testclient.gui;
import land.chipmunk.chipmunkmod.testclient.gui.components.Option; import land.chipmunk.chipmunkmod.testclient.gui.components.Option;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module; import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
@ -21,24 +22,24 @@ public class OptionsScreen extends Screen {
} }
@Override @Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { public void render(DrawContext context, int mouseX, int mouseY, float delta) {
fill(matrices, 40, 40, width-40, height-40, backgroundColor); context.fill(40, 40, width-40, height-40, backgroundColor);
int textWidth = MinecraftClient.getInstance().textRenderer.getWidth(getTitle()); int textWidth = MinecraftClient.getInstance().textRenderer.getWidth(getTitle());
AtomicInteger lineY = new AtomicInteger(70); AtomicInteger lineY = new AtomicInteger(70);
AtomicInteger textY = new AtomicInteger(50); AtomicInteger textY = new AtomicInteger(50);
drawTextWithShadow(matrices, MinecraftClient.getInstance().textRenderer, getTitle(), width/2 - textWidth/2, 50, 0xFFFFFFFF); context.drawTextWithShadow(MinecraftClient.getInstance().textRenderer, getTitle(), width/2 - textWidth/2, 50, 0xFFFFFFFF);
fill(matrices, 45, lineY.get()-1, width-45, lineY.get(), 0x33FFFFFF); context.fill(45, lineY.get()-1, width-45, lineY.get(), 0x33FFFFFF);
for (Option<?> option : optionList) { for (Option<?> option : optionList) {
lineY.addAndGet(30); lineY.addAndGet(30);
drawTextWithShadow(matrices, MinecraftClient.getInstance().textRenderer, option.name, 50, textY.addAndGet(30), 0xFFFFFFFF); context.drawTextWithShadow(MinecraftClient.getInstance().textRenderer, option.name, 50, textY.addAndGet(30), 0xFFFFFFFF);
fill(matrices, 45, lineY.get()-1, width-45, lineY.get(), 0x33FFFFFF); context.fill(45, lineY.get()-1, width-45, lineY.get(), 0x33FFFFFF);
// drawHorizontalLine(matrices, 45, width-45, lineY.addAndGet(30), 0x33FFFFFF); // drawHorizontalLine(matrices, 45, width-45, lineY.addAndGet(30), 0x33FFFFFF);
option.widget.setX(width - 50 - option.widget.getWidth()); option.widget.setX(width - 50 - option.widget.getWidth());
option.widget.setY(textY.get() - ((option.widget.getHeight()-9)/2)); option.widget.setY(textY.get() - ((option.widget.getHeight()-9)/2));
} }
super.render(matrices, mouseX, mouseY, delta); super.render(context, mouseX, mouseY, delta);
} }
} }

View file

@ -4,6 +4,7 @@ import land.chipmunk.chipmunkmod.ChipmunkMod;
import land.chipmunk.chipmunkmod.testclient.gui.Gui; import land.chipmunk.chipmunkmod.testclient.gui.Gui;
import land.chipmunk.chipmunkmod.util.Chat; import land.chipmunk.chipmunkmod.util.Chat;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text; import net.minecraft.text.Text;
@ -99,10 +100,10 @@ public class Category extends ButtonWidget {
// } // }
@Override @Override
public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) { public void renderButton(DrawContext context, int mouseX, int mouseY, float delta) {
boolean hovered = (mouseX>=getX() && mouseY>=getY() && mouseX<getWidth()+getX() && mouseY<getHeight()+getY()); boolean hovered = (mouseX>=getX() && mouseY>=getY() && mouseX<getWidth()+getX() && mouseY<getHeight()+getY());
MinecraftClient minecraftClient = MinecraftClient.getInstance(); MinecraftClient minecraftClient = MinecraftClient.getInstance();
fill(matrices, getX(), getY(), getX()+getWidth(), getY()+getHeight(), hovered ? hoveredColor : defaultColor); context.fill(getX(), getY(), getX()+getWidth(), getY()+getHeight(), hovered ? hoveredColor : defaultColor);
this.drawMessage(matrices, minecraftClient.textRenderer, 0xFFFFFF | MathHelper.ceil(this.alpha * 255.0F) << 24); this.drawMessage(context, minecraftClient.textRenderer, 0xFFFFFF | MathHelper.ceil(this.alpha * 255.0F) << 24);
} }
} }

View file

@ -3,6 +3,7 @@ package land.chipmunk.chipmunkmod.testclient.gui.components;
import land.chipmunk.chipmunkmod.testclient.gui.OptionsScreen; import land.chipmunk.chipmunkmod.testclient.gui.OptionsScreen;
import land.chipmunk.chipmunkmod.util.TickRunnableHandler; import land.chipmunk.chipmunkmod.util.TickRunnableHandler;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text; import net.minecraft.text.Text;
@ -127,11 +128,11 @@ public class Module extends ButtonWidget {
private Module getThis() {return this;} private Module getThis() {return this;}
@Override @Override
public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) { public void renderButton(DrawContext context, int mouseX, int mouseY, float delta) {
boolean hovered = (mouseX>=getX() && mouseY>=getY() && mouseX<getWidth()+getX() && mouseY<getHeight()+getY()); boolean hovered = (mouseX>=getX() && mouseY>=getY() && mouseX<getWidth()+getX() && mouseY<getHeight()+getY());
fill(matrices, getX(), getY(), getX()+getWidth(), getY()+getHeight(), hovered ? hoveredColor : defaultColor); context.fill(getX(), getY(), getX()+getWidth(), getY()+getHeight(), hovered ? hoveredColor : defaultColor);
fill(matrices, getX(), getY(), getX()+2, getY()+getHeight(), isEnabled ? enabledBarColor : disabledBarColor); context.fill(getX(), getY(), getX()+2, getY()+getHeight(), isEnabled ? enabledBarColor : disabledBarColor);
drawMessage(matrices, MinecraftClient.getInstance().textRenderer, 0xFFFFFF | MathHelper.ceil(this.alpha * 255.0F) << 24); drawMessage(context, MinecraftClient.getInstance().textRenderer, 0xFFFFFF | MathHelper.ceil(this.alpha * 255.0F) << 24);
} }
// public static class OptionsButton extends WButton { // public static class OptionsButton extends WButton {
@ -185,4 +186,4 @@ TODO:
- translate categories from WButton to vanilla ButtonWidget - translate categories from WButton to vanilla ButtonWidget
- make everything work with vanilla stuff - make everything work with vanilla stuff
The goal is to stop struggling with screen size. It's so annoying with LibGui. The goal is to stop struggling with screen size. It's so annoying with LibGui.
*/ */

View file

@ -2,8 +2,9 @@ package land.chipmunk.chipmunkmod.testclient.modules.movement;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module; import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import land.chipmunk.chipmunkmod.testclient.gui.components.options.DoubleSliderOption; import land.chipmunk.chipmunkmod.testclient.gui.components.options.DoubleSliderOption;
import net.minecraft.block.Blocks;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.block.Material; import net.minecraft.block.Block;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
@ -19,17 +20,17 @@ public class JesusModule extends Module {
// Material material = MinecraftClient.getInstance().player.getBlockStateAtPos().getMaterial(); // Material material = MinecraftClient.getInstance().player.getBlockStateAtPos().getMaterial();
Vec3d pos = MinecraftClient.getInstance().player.getPos(); Vec3d pos = MinecraftClient.getInstance().player.getPos();
pos = new Vec3d(pos.x, pos.y-((double) optionList.get(2).optionValue), pos.z); pos = new Vec3d(pos.x, pos.y-((double) optionList.get(2).optionValue), pos.z);
Material material = MinecraftClient.getInstance().world.getBlockState(BlockPos.ofFloored(pos)).getMaterial(); Block material = MinecraftClient.getInstance().world.getBlockState(BlockPos.ofFloored(pos)).getBlock();
Vec3d posRightAbove = new Vec3d(pos.x, ((int) (pos.y+((double) optionList.get(1).optionValue))), pos.z); Vec3d posRightAbove = new Vec3d(pos.x, ((int) (pos.y+((double) optionList.get(1).optionValue))), pos.z);
Vec3d posRightUnder = new Vec3d(pos.x, ((int) (pos.y-((double) optionList.get(1).optionValue))), pos.z); Vec3d posRightUnder = new Vec3d(pos.x, ((int) (pos.y-((double) optionList.get(1).optionValue))), pos.z);
// posRightAbove.floorAlongAxes(EnumSet.of(Direction.Axis.Y)); // posRightAbove.floorAlongAxes(EnumSet.of(Direction.Axis.Y));
Material materialRightAbove = MinecraftClient.getInstance().world.getBlockState(BlockPos.ofFloored(posRightAbove.x, posRightAbove.y, posRightAbove.z)).getMaterial(); Block materialRightAbove = MinecraftClient.getInstance().world.getBlockState(BlockPos.ofFloored(posRightAbove.x, posRightAbove.y, posRightAbove.z)).getBlock();
Material materialRightUnder = MinecraftClient.getInstance().world.getBlockState(BlockPos.ofFloored(posRightUnder.x, posRightUnder.y, posRightUnder.z)).getMaterial(); Block materialRightUnder = MinecraftClient.getInstance().world.getBlockState(BlockPos.ofFloored(posRightUnder.x, posRightUnder.y, posRightUnder.z)).getBlock();
Vec3d walkOn = new Vec3d(posRightAbove.x, posRightAbove.y+((double) optionList.get(2).optionValue), posRightAbove.z); Vec3d walkOn = new Vec3d(posRightAbove.x, posRightAbove.y+((double) optionList.get(2).optionValue), posRightAbove.z);
if(material == Material.WATER || material == Material.LAVA) { if(material == Blocks.WATER || material == Blocks.LAVA) {
Vec3d v = MinecraftClient.getInstance().player.getVelocity(); Vec3d v = MinecraftClient.getInstance().player.getVelocity();
if(materialRightAbove == Material.AIR || materialRightUnder == Material.AIR) { if(materialRightAbove == Blocks.AIR || materialRightUnder == Blocks.AIR) {
MinecraftClient.getInstance().player.setPosition(walkOn); MinecraftClient.getInstance().player.setPosition(walkOn);
MinecraftClient.getInstance().player.setOnGround(true); MinecraftClient.getInstance().player.setOnGround(true);
MinecraftClient.getInstance().player.setVelocity(v.x, 0, v.z); MinecraftClient.getInstance().player.setVelocity(v.x, 0, v.z);

View file

@ -1,19 +1,12 @@
package land.chipmunk.chipmunkmod.testclient.modules.utility; package land.chipmunk.chipmunkmod.testclient.modules.utility;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module; import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import land.chipmunk.chipmunkmod.util.Chat; import net.minecraft.block.BlockState;
import land.chipmunk.chipmunkmod.util.WorldUtil;
import net.minecraft.client.MinecraftClient;
import net.fabricmc.fabric.api.event.player.AttackBlockCallback; import net.fabricmc.fabric.api.event.player.AttackBlockCallback;
import net.minecraft.block.Material; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import java.util.ArrayList;
public class AutoToolsModule extends Module { public class AutoToolsModule extends Module {
public static AutoToolsModule instance = new AutoToolsModule(); public static AutoToolsModule instance = new AutoToolsModule();
@ -23,177 +16,27 @@ public class AutoToolsModule extends Module {
} }
public static void registerListener() { public static void registerListener() {
Materials.initialize();
Tools.initialize();
AttackBlockCallback.EVENT.register((player, world, hand, pos, direction) -> { AttackBlockCallback.EVENT.register((player, world, hand, pos, direction) -> {
WorldUtil.setBlockBreaking(world.getBlockState(pos).getBlock()); if (!instance.isEnabled) return ActionResult.PASS;
if(instance.isEnabled) { final BlockState blockState = world.getBlockState(pos);
// Chat.send("Breaking: " + WorldUtil.getBlockBreaking().getTranslationKey()); final PlayerInventory inventory = player.getInventory();
switchToToolFor(WorldUtil.getBlockBreaking().getDefaultState().getMaterial());
} // If the player already has the appropriate tool, don't do anything
if (inventory.getMainHandStack().getMiningSpeedMultiplier(blockState) > 1) return ActionResult.PASS;
for (int slot = 0; slot < 9; slot++) {
if (slot == inventory.selectedSlot) continue; // We already checked the current slot
final ItemStack item = inventory.getStack(slot);
if (item.getMiningSpeedMultiplier(blockState) > 1) {
inventory.selectedSlot = slot;
break;
}
}
return ActionResult.PASS; return ActionResult.PASS;
}); });
} }
public static void switchToToolFor(Material material) { static {
/* registerListener();
* 0 = none }
* 1 = pickaxe
* 2 = axe
* 3 = hoe
* 4 = sword
* 5 = shovel
* 6 = shears
*/
int tool = 0;
if(Materials.pickaxe.contains(material)) tool = 1;
if(Materials.axe. contains(material)) tool = 2;
if(Materials.hoe. contains(material)) tool = 3;
if(Materials.sword. contains(material)) tool = 4;
if(Materials.shovel. contains(material)) tool = 5;
if(Materials.shears. contains(material)) tool = 6;
// switch (tool) {
// case 0 -> Chat.send("This block has no tool.");
// case 1 -> Chat.send("This block needs a pickaxe.");
// case 2 -> Chat.send("This block needs an axe.");
// case 3 -> Chat.send("This block needs a hoe.");
// case 4 -> Chat.send("This block needs a sword.");
// case 5 -> Chat.send("This block needs a shovel.");
// case 6 -> Chat.send("This block needs shears.");
// }
switchToTool(tool);
}
public static void switchToTool(int tool) {
ArrayList<Item> tools = new ArrayList<>();
switch(tool) {
case 0 -> {return;}
case 1 -> tools = Tools.pickaxe;
case 2 -> tools = Tools.axe;
case 3 -> tools = Tools.hoe;
case 4 -> tools = Tools.sword;
case 5 -> tools = Tools.shovel;
case 6 -> tools = Tools.shears;
}
int i = 0;
for (ItemStack itemStack : MinecraftClient.getInstance().player.getInventory().main) {
if(tools.contains(itemStack.getItem())) {
// Chat.send(i + "You have that tool!");
if(i < 9) {
MinecraftClient.getInstance().player.getInventory().selectedSlot = i;
// Chat.send(Text.empty()
// .append("Switched to ")
// .append(itemStack.toHoverableText())
// .append(" in slot ")
// .append(""+i)
// .append(" in your hotbar.")
// );
}
}
// else Chat.send(MinecraftClient.getInstance().player.getInventory().main.indexOf(itemStack) + "You do not have that tool!");
i++;
}
}
public static class Tools {
public static final ArrayList<Item> pickaxe = new ArrayList<>();
public static final ArrayList<Item> axe = new ArrayList<>();
public static final ArrayList<Item> sword = new ArrayList<>();
public static final ArrayList<Item> hoe = new ArrayList<>();
public static final ArrayList<Item> shovel = new ArrayList<>();
public static final ArrayList<Item> shears = new ArrayList<>();
public static void initialize() {
/* PICKAXE */ {
pickaxe.add(Items.NETHERITE_PICKAXE);
pickaxe.add(Items. DIAMOND_PICKAXE);
pickaxe.add(Items. GOLDEN_PICKAXE);
pickaxe.add(Items. IRON_PICKAXE);
pickaxe.add(Items. STONE_PICKAXE);
pickaxe.add(Items. WOODEN_PICKAXE);
}
/* AXE */ {
axe.add(Items.NETHERITE_AXE);
axe.add(Items. DIAMOND_AXE);
axe.add(Items. GOLDEN_AXE);
axe.add(Items. IRON_AXE);
axe.add(Items. STONE_AXE);
axe.add(Items. WOODEN_AXE);
}
/* HOE */ {
hoe.add(Items.NETHERITE_HOE);
hoe.add(Items. DIAMOND_HOE);
hoe.add(Items. GOLDEN_HOE);
hoe.add(Items. IRON_HOE);
hoe.add(Items. STONE_HOE);
hoe.add(Items. WOODEN_HOE);
}
/* SWORD */ {
sword.add(Items.NETHERITE_SWORD);
sword.add(Items. DIAMOND_SWORD);
sword.add(Items. GOLDEN_SWORD);
sword.add(Items. IRON_SWORD);
sword.add(Items. STONE_SWORD);
sword.add(Items. WOODEN_SWORD);
}
/* SHUOWEL */ {
shovel.add(Items.NETHERITE_SHOVEL);
shovel.add(Items. DIAMOND_SHOVEL);
shovel.add(Items. GOLDEN_SHOVEL);
shovel.add(Items. IRON_SHOVEL);
shovel.add(Items. STONE_SHOVEL);
shovel.add(Items. WOODEN_SHOVEL);
}
/* SHAEARS */ {
shears.add(Items.SHEARS);
}
}
}
public static class Materials {
public static final ArrayList<Material> pickaxe = new ArrayList<>();
public static final ArrayList<Material> axe = new ArrayList<>();
public static final ArrayList<Material> sword = new ArrayList<>();
public static final ArrayList<Material> hoe = new ArrayList<>();
public static final ArrayList<Material> shovel = new ArrayList<>();
public static final ArrayList<Material> shears = new ArrayList<>();
public static void initialize() {
/* PICKAXE */ {
pickaxe.add(Material.ICE);
pickaxe.add(Material.STONE);
pickaxe.add(Material.DENSE_ICE);
pickaxe.add(Material.AMETHYST);
pickaxe.add(Material.METAL);
pickaxe.add(Material.PISTON);
pickaxe.add(Material.REDSTONE_LAMP);
pickaxe.add(Material.REPAIR_STATION);
pickaxe.add(Material.SCULK);
}
/* AXE */ {
axe.add(Material.WOOD);
axe.add(Material.NETHER_WOOD);
axe.add(Material.NETHER_SHOOTS);
}
/* HOE */ {
hoe.add(Material.MOSS_BLOCK);
hoe.add(Material.ORGANIC_PRODUCT);
hoe.add(Material.LEAVES);
}
/* SWORD */ {
sword.add(Material.BAMBOO);
sword.add(Material.BAMBOO_SAPLING);
sword.add(Material.COBWEB);
}
/* SHUOWEL */ {
shovel.add(Material.SOLID_ORGANIC);
shovel.add(Material.AGGREGATE);
}
/* SHAEARS */ {
shears.add(Material.CARPET);
shears.add(Material.WOOL);
}
}
}
} }

View file

@ -4,11 +4,9 @@ import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
public class GuiMoveModule extends Module { public class GuiMoveModule extends Module {
public static GuiMoveModule instance = new GuiMoveModule();
public GuiMoveModule() { public GuiMoveModule() {
super("GUI Move"); super("GUI Move");
endTickRunnable = () -> {
if (MinecraftClient.getInstance().currentScreen != null)
MinecraftClient.getInstance().currentScreen.passEvents = true;
};
} }
} }

View file

@ -30,12 +30,9 @@
], ],
"depends": { "depends": {
"fabricloader": ">=0.14.11", "fabricloader": ">=0.14.21",
"fabric-api": "*", "fabric-api": "*",
"minecraft": "~1.19.3", "minecraft": "~1.20.1",
"java": ">=17" "java": ">=17"
},
"suggests": {
"another-mod": "*"
} }
} }