Skip to content

Commit

Permalink
Edit
Browse files Browse the repository at this point in the history
  • Loading branch information
Enaium committed Jun 14, 2021
1 parent 0e04240 commit a409920
Show file tree
Hide file tree
Showing 47 changed files with 427 additions and 311 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

A fabric utility mod

VM Options `--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/sun.reflect.annotation=ALL-UNNAMED`

## Dependency

[fabric-api](https://www.curseforge.com/minecraft/mc-mods/fabric-api)
Expand Down
10 changes: 4 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ plugins {
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_16

archivesBaseName = project.archives_base_name
version = project.mod_version
Expand Down Expand Up @@ -56,10 +56,8 @@ tasks.withType(JavaCompile).configureEach {
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
// We'll use that if it's available, but otherwise we'll use the older option.
def targetVersion = 8
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = targetVersion
}
def targetVersion = 16
it.options.release = 16
}

java {
Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/versions.html
minecraft_version=1.16.5
yarn_mappings=1.16.5+build.9
loader_version=0.11.3
minecraft_version=1.17
yarn_mappings=1.17+build.11
loader_version=0.11.6
loom_version=0.7-SNAPSHOT
# Mod Properties
mod_version=1.0.0
mod_version=1.1.0-MC1.17
maven_group=cn.enaium
archives_base_name=vac
# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api (or https://fabricmc.net/versions.html)
fabric_version=0.34.2+1.16
kotlin_version=1.5.0
fabric_kotlin_version=1.6.0+kotlin.1.5.0
cf4m_version=1.8.3
fabric_version=0.35.1+1.17
kotlin_version=1.5.10
fabric_kotlin_version=1.6.1+kotlin.1.5.10
cf4m_version=1.9.5
26 changes: 16 additions & 10 deletions src/main/java/cn/enaium/vac/mixin/ClientPlayerEntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ public abstract class ClientPlayerEntityMixin extends AbstractClientPlayerEntity
@Final
protected MinecraftClient client;

@Shadow
public abstract float getYaw(float tickDelta);

@Shadow
public abstract float getPitch(float tickDelta);

public ClientPlayerEntityMixin(ClientWorld world, GameProfile profile) {
super(world, profile);
}
Expand All @@ -74,7 +80,7 @@ private void sendChatMessage(String message, CallbackInfo ci) {
*/
@Overwrite
private void sendMovementPackets() {
MotioningEvent motioningEvent = new MotioningEvent(this.yaw, this.pitch, this.onGround, new Vec3d(this.getX(), this.getY(), this.getZ()));
MotioningEvent motioningEvent = new MotioningEvent(this.getYaw(), this.getPitch(), this.onGround, new Vec3d(this.getX(), this.getY(), this.getZ()));
CF4M.EVENT.post(motioningEvent);
boolean bl = this.isSprinting();
if (bl != this.lastSprinting) {
Expand Down Expand Up @@ -107,21 +113,21 @@ private void sendMovementPackets() {
boolean bl3 = d * d + e * e + f * f > 9.0E-4D || this.ticksSinceLastPositionPacketSent >= 20;
boolean bl4 = g != 0.0D || h != 0.0D;

this.yaw = motionEventYaw;
this.pitch = motionEventPitch;
this.setYaw(motionEventYaw);
this.setPitch(motionEventPitch);
this.onGround = motionEventGround;
if (this.hasVehicle()) {
Vec3d vec3d = this.getVelocity();
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.Both(vec3d.x, -999.0D, vec3d.z, this.yaw, this.pitch, this.onGround));
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.Full(vec3d.x, -999.0D, vec3d.z, this.getYaw(), this.getPitch(), this.onGround));
bl3 = false;
} else if (bl3 && bl4) {
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.Both(this.getX(), this.getY(), this.getZ(), this.yaw, this.pitch, this.onGround));
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.Full(this.getX(), this.getY(), this.getZ(), this.getYaw(), this.getPitch(), this.onGround));
} else if (bl3) {
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionOnly(this.getX(), this.getY(), this.getZ(), this.onGround));
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(this.getX(), this.getY(), this.getZ(), this.onGround));
} else if (bl4) {
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.LookOnly(this.yaw, this.pitch, this.onGround));
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(this.getYaw(), this.getPitch(), this.onGround));
} else if (this.lastOnGround != this.onGround) {
this.networkHandler.sendPacket(new PlayerMoveC2SPacket(this.onGround));
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(this.onGround));
}

if (bl3) {
Expand All @@ -133,13 +139,13 @@ private void sendMovementPackets() {

if (bl4) {
this.lastYaw = motionEventYaw;
this.lastPitch = this.pitch;
this.lastPitch = motionEventPitch;
}

this.lastOnGround = motioningEvent.getGround();
this.autoJumpEnabled = this.client.options.autoJump;
}
CF4M.EVENT.post(new MotionedEvent(this.yaw, this.pitch, this.onGround, new Vec3d(this.getX(), this.getY(), this.getZ())));
CF4M.EVENT.post(new MotionedEvent(this.getYaw(), this.getPitch(), this.onGround, new Vec3d(this.getX(), this.getY(), this.getZ())));
}

@Redirect(at = @At(value = "INVOKE",
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/cn/enaium/vac/mixin/GameRendererMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
class GameRendererMixin {
@Inject(at = @At(value = "FIELD", target = "Lnet/minecraft/client/render/GameRenderer;renderHand:Z", ordinal = 0), method = "renderWorld")
private void renderWorld(float tickDelta, long limitTime, MatrixStack matrixStack, CallbackInfo ci) {
Render3DUtil.INSTANCE.settings();
Render3DUtil.INSTANCE.settings(matrixStack);
CF4M.EVENT.post(new Render3DEvent(tickDelta, limitTime, matrixStack));
Render3DUtil.INSTANCE.resets();
Render3DUtil.INSTANCE.resets(matrixStack);
}
}
2 changes: 1 addition & 1 deletion src/main/java/cn/enaium/vac/mixin/IKeyBindingMixin.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cn.enaium.vac.mixin;

import net.minecraft.client.options.KeyBinding;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/cn/enaium/vac/mixin/IWorldMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cn.enaium.vac.mixin;

import net.minecraft.world.World;
import net.minecraft.world.chunk.BlockEntityTickInvoker;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

import java.util.List;

/**
* @author Enaium
*/
@Mixin(World.class)
public interface IWorldMixin {
@Accessor
List<BlockEntityTickInvoker> getBlockEntityTickers();
}
7 changes: 7 additions & 0 deletions src/main/java/cn/enaium/vac/mixin/MinecraftClientMixin.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cn.enaium.vac.mixin;

import cn.enaium.cf4m.CF4M;
import cn.enaium.vac.client.VacKt;
import cn.enaium.vac.client.event.AttackEvent;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.RunArgs;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -17,4 +19,9 @@ public class MinecraftClientMixin {
private void MinecraftClient(RunArgs args, CallbackInfo ci) {
VacKt.run();
}

@Inject(at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;crosshairTarget:Lnet/minecraft/util/hit/HitResult;", ordinal = 0), method = "doAttack")
private void doAttack(CallbackInfo ci) {
CF4M.EVENT.post(new AttackEvent());
}
}
4 changes: 2 additions & 2 deletions src/main/java/cn/enaium/vac/mixin/SignEditScreenMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import cn.enaium.cf4m.CF4M;
import cn.enaium.cf4m.provider.ModuleProvider;
import cn.enaium.vac.client.module.player.AutoSign;
import cn.enaium.vac.client.setting.StringSetting;
import net.minecraft.client.gui.screen.ingame.SignEditScreen;
import org.spongepowered.asm.mixin.Final;
Expand Down Expand Up @@ -33,7 +34,7 @@ public abstract class SignEditScreenMixin {

@Inject(at = @At("HEAD"), method = "init")
private void init(CallbackInfo ci) {
ModuleProvider autoSign = CF4M.MODULE.getByName("AutoSign");
ModuleProvider autoSign = CF4M.MODULE.getByClass(AutoSign.class);
if (autoSign.getEnable()) {
String[] texts = autoSign.getSetting().getByName("text").<StringSetting>getSetting().getCurrent().split("/n");
List<String> s = new ArrayList<>();
Expand All @@ -44,7 +45,6 @@ private void init(CallbackInfo ci) {
}
}
text = s.toArray(new String[0]);
System.out.println(Arrays.toString(text));
finishEditing();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/cn/enaium/vac/mixin/TitleScreenMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ protected TitleScreenMixin(Text title) {

@Inject(at = @At("RETURN"), method = "init()V")
private void init(CallbackInfo callbackInfo) {
addButton(new ButtonWidget(5, 5, 20, 20, new LiteralText("Alt"), button -> MinecraftClient.getInstance().openScreen(new AltScreen())));
addButton(new ButtonWidget(35, 5, 40, 20, new LiteralText("Credit"), button -> {
addDrawable(new ButtonWidget(5, 5, 20, 20, new LiteralText("Alt"), button -> MinecraftClient.getInstance().openScreen(new AltScreen())));
addDrawable(new ButtonWidget(35, 5, 40, 20, new LiteralText("Credit"), button -> {
CreditScreen.INSTANCE.setCredit(true);
MinecraftClient.getInstance().openScreen(new CreditsScreen(false, () -> {
}));
Expand Down
4 changes: 4 additions & 0 deletions src/main/kotlin/cn/enaium/vac/client/Vac.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import cn.enaium.cf4m.CF4M
import cn.enaium.vac.client.util.KeyboardUtil
import cn.enaium.vac.mixin.IClientPlayerInteractionManagerMixin
import cn.enaium.vac.mixin.IMinecraftClientMixin
import cn.enaium.vac.mixin.IWorldMixin
import net.minecraft.client.MinecraftClient

/**
Expand All @@ -29,6 +30,9 @@ object IMinecraftClient {
val instance
get() = MinecraftClient.getInstance() as IMinecraftClientMixin

val world
get() = MinecraftClient.getInstance().world as IWorldMixin

val interactionManager
get() = mc.interactionManager as IClientPlayerInteractionManagerMixin
}
2 changes: 2 additions & 0 deletions src/main/kotlin/cn/enaium/vac/client/event/Event.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class RenderTooltipEvent(
val y: Int
)

class AttackEvent

open class Cancel {
var cancel: Boolean = false
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/kotlin/cn/enaium/vac/client/module/combat/Aura.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ import cn.enaium.vac.client.setting.*
import cn.enaium.vac.client.util.RotationUtil
import cn.enaium.vac.client.util.TargetUtil
import net.minecraft.entity.Entity
import net.minecraft.entity.ExperienceOrbEntity
import net.minecraft.entity.ItemEntity
import net.minecraft.entity.LivingEntity
import net.minecraft.entity.projectile.PersistentProjectileEntity
import net.minecraft.server.network.ServerPlayNetworkHandler
import net.minecraft.text.TranslatableText
import net.minecraft.util.Hand
import org.lwjgl.glfw.GLFW
import java.util.stream.Stream
Expand Down Expand Up @@ -73,7 +68,7 @@ class Aura {

@Event
fun onMotion(motioningEvent: MotioningEvent) {
CF4M.MODULE.getByInstance(this).getExtend<Mod>().tag = priority.current
CF4M.MODULE.getByInstance(this).getExtend(Mod::class.java).tag = priority.current

if (mc.player!!.getAttackCooldownProgress(0f) < 1) return

Expand Down Expand Up @@ -107,6 +102,11 @@ class Aura {
fun onMotion(motionedEvent: MotionedEvent) {
if (target == null) return

val critical = CF4M.MODULE.getByClass(Critical::class.java)
if (critical.enable) {
(critical.instance as Critical).critical()
}

mc.interactionManager!!.attackEntity(mc.player, target)
mc.player!!.swingHand(Hand.MAIN_HAND)
target = null
Expand Down
11 changes: 8 additions & 3 deletions src/main/kotlin/cn/enaium/vac/client/module/combat/Critical.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import cn.enaium.cf4m.CF4M
import cn.enaium.cf4m.annotation.Event
import cn.enaium.cf4m.annotation.module.Module
import cn.enaium.cf4m.annotation.module.Setting
import cn.enaium.vac.client.event.AttackEvent
import cn.enaium.vac.client.event.MotioningEvent
import cn.enaium.vac.client.mc
import cn.enaium.vac.client.module.COMBAT
Expand All @@ -24,8 +25,12 @@ class Critical {
private val mode = ModeSetting("Packet", arrayListOf("Packet", "LowJump", "Jump"))

@Event
fun onMotion(motioningEvent: MotioningEvent) {
CF4M.MODULE.getByInstance(this).getExtend<Mod>().tag = mode.current
fun onAttack(attackEvent: AttackEvent) {
CF4M.MODULE.getByInstance(this).getExtend(Mod::class.java).tag = mode.current
critical()
}

fun critical() {
if (mc.crosshairTarget == null || mc.crosshairTarget!!.type != HitResult.Type.ENTITY || (mc.crosshairTarget as EntityHitResult).entity !is LivingEntity)
return

Expand Down Expand Up @@ -59,7 +64,7 @@ class Critical {

private fun sendPos(x: Double, y: Double, z: Double, onGround: Boolean) {
mc.player!!.networkHandler.sendPacket(
PlayerMoveC2SPacket.PositionOnly(x, y, z, onGround)
PlayerMoveC2SPacket.PositionAndOnGround(x, y, z, onGround)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ class NoFall {
@Event
fun on(motioningEvent: MotioningEvent) {
if (mc.player!!.fallDistance <= 2) return
mc.player!!.networkHandler.sendPacket(PlayerMoveC2SPacket(true))
mc.player!!.networkHandler.sendPacket(PlayerMoveC2SPacket.OnGroundOnly(true))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ import net.minecraft.client.gui.screen.DeathScreen
*/
@Module("AutoSign", type = PLAYER)
class AutoSign {
@Setting("text")
@Setting("text", description = "/n wrap")
val text = StringSetting("Vac Client/nByEnaium")
}
39 changes: 39 additions & 0 deletions src/main/kotlin/cn/enaium/vac/client/module/player/AutoTool.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package cn.enaium.vac.client.module.player

import cn.enaium.cf4m.annotation.Event
import cn.enaium.cf4m.annotation.module.Module
import cn.enaium.vac.client.event.BlockBreakingProgressEvent
import cn.enaium.vac.client.mc
import cn.enaium.vac.client.module.PLAYER
import cn.enaium.vac.client.util.BlockUtil
import net.minecraft.item.ItemStack


/**
* @author Enaium
*/
@Module("AutoTool", description = "Auto select tool", type = PLAYER)
class AutoTool {
@Event
fun onBreaking(breakingProgressEvent: BlockBreakingProgressEvent) {

if (mc.player!!.abilities.creativeMode) return

if (mc.player!!.isBlockBreakingRestricted(
mc.world,
breakingProgressEvent.pos,
mc.interactionManager!!.currentGameMode
)
) return

for (i in 0..8) {
val stack = mc.player!!.inventory.getStack(i)

val speed = stack.getMiningSpeedMultiplier(BlockUtil.getState(breakingProgressEvent.pos))

if (speed > mc.player!!.mainHandStack.getMiningSpeedMultiplier(BlockUtil.getState(breakingProgressEvent.pos))) {
mc.player!!.inventory.selectedSlot = i
}
}
}
}
Loading

0 comments on commit a409920

Please sign in to comment.