From a409920a79f6333a2f7763a7bd133de130b2a601 Mon Sep 17 00:00:00 2001 From: Enaium <32991121+Enaium@users.noreply.github.com> Date: Mon, 14 Jun 2021 19:21:56 +0800 Subject: [PATCH] Edit --- README.md | 2 + build.gradle | 10 +- gradle.properties | 16 +- .../vac/mixin/ClientPlayerEntityMixin.java | 26 +- .../enaium/vac/mixin/GameRendererMixin.java | 4 +- .../cn/enaium/vac/mixin/IKeyBindingMixin.java | 2 +- .../java/cn/enaium/vac/mixin/IWorldMixin.java | 17 ++ .../vac/mixin/MinecraftClientMixin.java | 7 + .../enaium/vac/mixin/SignEditScreenMixin.java | 4 +- .../cn/enaium/vac/mixin/TitleScreenMixin.java | 4 +- src/main/kotlin/cn/enaium/vac/client/Vac.kt | 4 + .../cn/enaium/vac/client/event/Event.kt | 2 + .../enaium/vac/client/module/combat/Aura.kt | 12 +- .../vac/client/module/combat/Critical.kt | 11 +- .../vac/client/module/movement/NoFall.kt | 2 +- .../vac/client/module/player/AutoSign.kt | 2 +- .../vac/client/module/player/AutoTool.kt | 39 +++ .../vac/client/module/player/SendChat.kt | 10 +- .../vac/client/module/render/BlockESP.kt | 4 +- .../client/module/render/BlockEntityESP.kt | 72 ++++++ .../vac/client/module/render/BlockSelect.kt | 2 +- .../enaium/vac/client/module/render/Bright.kt | 2 +- .../cn/enaium/vac/client/module/render/ESP.kt | 2 +- .../vac/client/module/render/LavaWarning.kt | 2 +- .../enaium/vac/client/module/render/Render.kt | 21 +- .../vac/client/module/render/StorageESP.kt | 84 ------- .../enaium/vac/client/module/ui/EnableList.kt | 2 +- .../cn/enaium/vac/client/screen/AltScreen.kt | 11 +- .../vac/client/screen/click/ChatList.kt | 17 +- .../vac/client/screen/click/ClickGUI.kt | 2 +- .../vac/client/screen/click/EditValue.kt | 4 +- .../vac/client/screen/click/EntityAllList.kt | 8 +- .../vac/client/screen/click/EntityList.kt | 12 +- .../vac/client/screen/click/ItemAllList.kt | 18 +- .../vac/client/screen/click/ItemList.kt | 23 +- .../client/screen/click/panel/ModulePanel.kt | 4 +- .../client/screen/click/panel/TypePanel.kt | 2 +- .../click/panel/setting/SettingPanel.kt | 2 +- .../enaium/vac/client/screen/design/Design.kt | 2 +- .../vac/client/screen/widget/ListWidget.kt | 9 +- .../vac/client/service/RenderService.kt | 18 +- .../cn/enaium/vac/client/setting/Setting.kt | 1 + .../cn/enaium/vac/client/util/ChatUtil.kt | 7 +- .../cn/enaium/vac/client/util/Render2DUtil.kt | 4 +- .../cn/enaium/vac/client/util/Render3DUtil.kt | 222 ++++++++++-------- src/main/resources/fabric.mod.json | 4 +- src/main/resources/vac.mixins.json | 3 +- 47 files changed, 427 insertions(+), 311 deletions(-) create mode 100644 src/main/java/cn/enaium/vac/mixin/IWorldMixin.java create mode 100644 src/main/kotlin/cn/enaium/vac/client/module/player/AutoTool.kt create mode 100644 src/main/kotlin/cn/enaium/vac/client/module/render/BlockEntityESP.kt delete mode 100644 src/main/kotlin/cn/enaium/vac/client/module/render/StorageESP.kt diff --git a/README.md b/README.md index 1fe3356..ec8b459 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/build.gradle b/build.gradle index 3dddda7..c73e626 100644 --- a/build.gradle +++ b/build.gradle @@ -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 @@ -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 { diff --git a/gradle.properties b/gradle.properties index 471d6fb..c4bf17e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/src/main/java/cn/enaium/vac/mixin/ClientPlayerEntityMixin.java b/src/main/java/cn/enaium/vac/mixin/ClientPlayerEntityMixin.java index 0900ee8..ea03746 100644 --- a/src/main/java/cn/enaium/vac/mixin/ClientPlayerEntityMixin.java +++ b/src/main/java/cn/enaium/vac/mixin/ClientPlayerEntityMixin.java @@ -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); } @@ -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) { @@ -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) { @@ -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", diff --git a/src/main/java/cn/enaium/vac/mixin/GameRendererMixin.java b/src/main/java/cn/enaium/vac/mixin/GameRendererMixin.java index 9d1e272..2cff20e 100644 --- a/src/main/java/cn/enaium/vac/mixin/GameRendererMixin.java +++ b/src/main/java/cn/enaium/vac/mixin/GameRendererMixin.java @@ -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); } } \ No newline at end of file diff --git a/src/main/java/cn/enaium/vac/mixin/IKeyBindingMixin.java b/src/main/java/cn/enaium/vac/mixin/IKeyBindingMixin.java index 5a67b22..0eaa1d2 100644 --- a/src/main/java/cn/enaium/vac/mixin/IKeyBindingMixin.java +++ b/src/main/java/cn/enaium/vac/mixin/IKeyBindingMixin.java @@ -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; diff --git a/src/main/java/cn/enaium/vac/mixin/IWorldMixin.java b/src/main/java/cn/enaium/vac/mixin/IWorldMixin.java new file mode 100644 index 0000000..a2dd969 --- /dev/null +++ b/src/main/java/cn/enaium/vac/mixin/IWorldMixin.java @@ -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 getBlockEntityTickers(); +} diff --git a/src/main/java/cn/enaium/vac/mixin/MinecraftClientMixin.java b/src/main/java/cn/enaium/vac/mixin/MinecraftClientMixin.java index 82c67aa..e96c746 100644 --- a/src/main/java/cn/enaium/vac/mixin/MinecraftClientMixin.java +++ b/src/main/java/cn/enaium/vac/mixin/MinecraftClientMixin.java @@ -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; @@ -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()); + } } diff --git a/src/main/java/cn/enaium/vac/mixin/SignEditScreenMixin.java b/src/main/java/cn/enaium/vac/mixin/SignEditScreenMixin.java index 0b86387..b5c3154 100644 --- a/src/main/java/cn/enaium/vac/mixin/SignEditScreenMixin.java +++ b/src/main/java/cn/enaium/vac/mixin/SignEditScreenMixin.java @@ -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; @@ -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").getSetting().getCurrent().split("/n"); List s = new ArrayList<>(); @@ -44,7 +45,6 @@ private void init(CallbackInfo ci) { } } text = s.toArray(new String[0]); - System.out.println(Arrays.toString(text)); finishEditing(); } } diff --git a/src/main/java/cn/enaium/vac/mixin/TitleScreenMixin.java b/src/main/java/cn/enaium/vac/mixin/TitleScreenMixin.java index 23cc2ab..6114de8 100644 --- a/src/main/java/cn/enaium/vac/mixin/TitleScreenMixin.java +++ b/src/main/java/cn/enaium/vac/mixin/TitleScreenMixin.java @@ -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, () -> { })); diff --git a/src/main/kotlin/cn/enaium/vac/client/Vac.kt b/src/main/kotlin/cn/enaium/vac/client/Vac.kt index 3c26812..ec3ff04 100644 --- a/src/main/kotlin/cn/enaium/vac/client/Vac.kt +++ b/src/main/kotlin/cn/enaium/vac/client/Vac.kt @@ -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 /** @@ -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 } \ No newline at end of file diff --git a/src/main/kotlin/cn/enaium/vac/client/event/Event.kt b/src/main/kotlin/cn/enaium/vac/client/event/Event.kt index 9918f31..b2067be 100644 --- a/src/main/kotlin/cn/enaium/vac/client/event/Event.kt +++ b/src/main/kotlin/cn/enaium/vac/client/event/Event.kt @@ -35,6 +35,8 @@ class RenderTooltipEvent( val y: Int ) +class AttackEvent + open class Cancel { var cancel: Boolean = false } diff --git a/src/main/kotlin/cn/enaium/vac/client/module/combat/Aura.kt b/src/main/kotlin/cn/enaium/vac/client/module/combat/Aura.kt index c31be5b..6392de3 100644 --- a/src/main/kotlin/cn/enaium/vac/client/module/combat/Aura.kt +++ b/src/main/kotlin/cn/enaium/vac/client/module/combat/Aura.kt @@ -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 @@ -73,7 +68,7 @@ class Aura { @Event fun onMotion(motioningEvent: MotioningEvent) { - CF4M.MODULE.getByInstance(this).getExtend().tag = priority.current + CF4M.MODULE.getByInstance(this).getExtend(Mod::class.java).tag = priority.current if (mc.player!!.getAttackCooldownProgress(0f) < 1) return @@ -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 diff --git a/src/main/kotlin/cn/enaium/vac/client/module/combat/Critical.kt b/src/main/kotlin/cn/enaium/vac/client/module/combat/Critical.kt index 0305ecc..e451969 100644 --- a/src/main/kotlin/cn/enaium/vac/client/module/combat/Critical.kt +++ b/src/main/kotlin/cn/enaium/vac/client/module/combat/Critical.kt @@ -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 @@ -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().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 @@ -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) ) } } \ No newline at end of file diff --git a/src/main/kotlin/cn/enaium/vac/client/module/movement/NoFall.kt b/src/main/kotlin/cn/enaium/vac/client/module/movement/NoFall.kt index 5b6536c..4851c8c 100644 --- a/src/main/kotlin/cn/enaium/vac/client/module/movement/NoFall.kt +++ b/src/main/kotlin/cn/enaium/vac/client/module/movement/NoFall.kt @@ -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)) } } \ No newline at end of file diff --git a/src/main/kotlin/cn/enaium/vac/client/module/player/AutoSign.kt b/src/main/kotlin/cn/enaium/vac/client/module/player/AutoSign.kt index d48132a..aed97f5 100644 --- a/src/main/kotlin/cn/enaium/vac/client/module/player/AutoSign.kt +++ b/src/main/kotlin/cn/enaium/vac/client/module/player/AutoSign.kt @@ -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") } \ No newline at end of file diff --git a/src/main/kotlin/cn/enaium/vac/client/module/player/AutoTool.kt b/src/main/kotlin/cn/enaium/vac/client/module/player/AutoTool.kt new file mode 100644 index 0000000..08b09a8 --- /dev/null +++ b/src/main/kotlin/cn/enaium/vac/client/module/player/AutoTool.kt @@ -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 + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/enaium/vac/client/module/player/SendChat.kt b/src/main/kotlin/cn/enaium/vac/client/module/player/SendChat.kt index ff5a453..073c02e 100644 --- a/src/main/kotlin/cn/enaium/vac/client/module/player/SendChat.kt +++ b/src/main/kotlin/cn/enaium/vac/client/module/player/SendChat.kt @@ -8,19 +8,25 @@ import cn.enaium.vac.client.event.KeyboardEvent import cn.enaium.vac.client.mc import cn.enaium.vac.client.module.PLAYER import cn.enaium.vac.client.setting.ChatListSetting +import cn.enaium.vac.client.setting.EnableSetting import org.lwjgl.glfw.GLFW /** * @author Enaium */ -@Module("SendChat", type = PLAYER) +@Module("SendChat", description = "Press the key to send", type = PLAYER) class SendChat { + @Setting("ChatList") private val chatList = ChatListSetting(arrayListOf(Pair(GLFW.GLFW_KEY_H, "/spawn"))) + @Setting("OnScreen", description = "When the screen is open") + private val onScreen = EnableSetting(false) + @Event fun onKey(keyboardEvent: KeyboardEvent) { - if (mc.currentScreen != null) return + + if (onScreen.enable && mc.currentScreen != null) return chatList.all.forEach { if (it.first == keyboardEvent.key) { diff --git a/src/main/kotlin/cn/enaium/vac/client/module/render/BlockESP.kt b/src/main/kotlin/cn/enaium/vac/client/module/render/BlockESP.kt index 90f3fd4..791f694 100644 --- a/src/main/kotlin/cn/enaium/vac/client/module/render/BlockESP.kt +++ b/src/main/kotlin/cn/enaium/vac/client/module/render/BlockESP.kt @@ -38,8 +38,6 @@ class BlockESP : Render(BoxType.BLOCK, DrawType.OUTLINE) { private val searchedChuck = Collections.synchronizedSet(HashSet()) - private var onced = false - @Event fun onMotion(motioningEvent: MotioningEvent) { val chunks = ArrayList() @@ -91,7 +89,7 @@ class BlockESP : Render(BoxType.BLOCK, DrawType.OUTLINE) { fun onRender(render3DEvent: Render3DEvent) { poss.forEach { try { - drawBox(BlockUtil.getBoundingBox(it), Color.PINK, this) + drawBox(render3DEvent.matrixStack, BlockUtil.getBoundingBox(it), Color.PINK, this) } catch (e: UnsupportedOperationException) { } diff --git a/src/main/kotlin/cn/enaium/vac/client/module/render/BlockEntityESP.kt b/src/main/kotlin/cn/enaium/vac/client/module/render/BlockEntityESP.kt new file mode 100644 index 0000000..37bfe09 --- /dev/null +++ b/src/main/kotlin/cn/enaium/vac/client/module/render/BlockEntityESP.kt @@ -0,0 +1,72 @@ +package cn.enaium.vac.client.module.render + +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.Render3DEvent +import cn.enaium.vac.client.imc +import cn.enaium.vac.client.mc +import cn.enaium.vac.client.module.RENDER +import cn.enaium.vac.client.setting.BlockEntityListSetting +import cn.enaium.vac.client.util.BlockUtil +import net.minecraft.block.entity.* +import net.minecraft.util.math.BlockPos +import java.awt.Color + +/** + * @author Enaium + */ +@Module("BlockEntityESP", type = RENDER) +class BlockEntityESP : Render(BoxType.BLOCK, DrawType.SOLID) { + + @Setting("BlockEntities") + private val blockEntities = BlockEntityListSetting( + arrayListOf( + "minecraft:furnace", + "minecraft:chest", + "minecraft:trapped_chest", + "minecraft:ender_chest", + "minecraft:jukebox", + "minecraft:dispenser", + "minecraft:dropper", + "minecraft:brewing_stand", + "minecraft:barrel", + "minecraft:smoker", + "minecraft:blast_furnace" + ) + ) + + @Event + fun onRender(render3DEvent: Render3DEvent) { + getTargets().forEach { + try { + drawBox(render3DEvent.matrixStack, BlockUtil.getBoundingBox(it), Color.GREEN, this) + } catch (e: UnsupportedOperationException) { + + } + } + } + + private fun getTargets(): ArrayList { + val blocks: ArrayList = ArrayList() + for (blockEntity in imc.world.blockEntityTickers) { + val lootTableId = BlockUtil.getBlock(blockEntity.pos).lootTableId + var path = lootTableId.path + if (path.contains("/")) { + path = path.substring( + path.indexOf( + "/" + ) + 1 + ) + } + + if (blockEntities.all.contains( + lootTableId.namespace + ":" + path + ) + ) { + blocks.add(blockEntity.pos) + } + } + return blocks + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/enaium/vac/client/module/render/BlockSelect.kt b/src/main/kotlin/cn/enaium/vac/client/module/render/BlockSelect.kt index b8b2d3a..50bccbb 100644 --- a/src/main/kotlin/cn/enaium/vac/client/module/render/BlockSelect.kt +++ b/src/main/kotlin/cn/enaium/vac/client/module/render/BlockSelect.kt @@ -18,7 +18,7 @@ class BlockSelect : Render(BoxType.BLOCK, DrawType.OUTLINE) { @Event fun render(render3DEvent: Render3DEvent) { if (mc.crosshairTarget!!.type == HitResult.Type.BLOCK) { - drawBox( + drawBox(render3DEvent.matrixStack, BlockUtil.getBoundingBox((mc.crosshairTarget as BlockHitResult).blockPos), Color.BLUE, this diff --git a/src/main/kotlin/cn/enaium/vac/client/module/render/Bright.kt b/src/main/kotlin/cn/enaium/vac/client/module/render/Bright.kt index e6b1805..07a6083 100644 --- a/src/main/kotlin/cn/enaium/vac/client/module/render/Bright.kt +++ b/src/main/kotlin/cn/enaium/vac/client/module/render/Bright.kt @@ -25,7 +25,7 @@ class Bright { @Event fun onMotion(motioningEvent: MotioningEvent) { - CF4M.MODULE.getByInstance(this).getExtend().tag = mode.current + CF4M.MODULE.getByInstance(this).getExtend(Mod::class.java).tag = mode.current when (mode.current) { "Gamma" -> mc.options.gamma = 300.0 "NightVision" -> mc.player!!.addStatusEffect( diff --git a/src/main/kotlin/cn/enaium/vac/client/module/render/ESP.kt b/src/main/kotlin/cn/enaium/vac/client/module/render/ESP.kt index 49de5a6..c4e4b5e 100644 --- a/src/main/kotlin/cn/enaium/vac/client/module/render/ESP.kt +++ b/src/main/kotlin/cn/enaium/vac/client/module/render/ESP.kt @@ -22,7 +22,7 @@ class ESP : Render(BoxType.ENTITY, DrawType.OUTLINE) { fun onRender(render3DEvent: Render3DEvent) { TargetUtil.getEntities().forEach { if (it == mc.player) return@forEach - drawBox(it, render3DEvent.tickDelta, Color.CYAN, this) + drawBox(render3DEvent.matrixStack, it.boundingBox, Color.CYAN, this) } } } \ No newline at end of file diff --git a/src/main/kotlin/cn/enaium/vac/client/module/render/LavaWarning.kt b/src/main/kotlin/cn/enaium/vac/client/module/render/LavaWarning.kt index 77b8675..e17b6ab 100644 --- a/src/main/kotlin/cn/enaium/vac/client/module/render/LavaWarning.kt +++ b/src/main/kotlin/cn/enaium/vac/client/module/render/LavaWarning.kt @@ -47,7 +47,7 @@ class LavaWarning : Render(BoxType.BLOCK, DrawType.OUTLINE) { if (block == Blocks.LAVA) { mc.inGameHud.setOverlayMessage(LiteralText("There is lava nearby"), false) if (render.enable) { - drawBox(Box(pos), Color.RED, this) + drawBox(render3DEvent.matrixStack, Box(pos), Color.RED, this) } } } diff --git a/src/main/kotlin/cn/enaium/vac/client/module/render/Render.kt b/src/main/kotlin/cn/enaium/vac/client/module/render/Render.kt index 7549c96..df21170 100644 --- a/src/main/kotlin/cn/enaium/vac/client/module/render/Render.kt +++ b/src/main/kotlin/cn/enaium/vac/client/module/render/Render.kt @@ -3,6 +3,10 @@ package cn.enaium.vac.client.module.render import cn.enaium.cf4m.CF4M import cn.enaium.vac.client.service.RenderService import cn.enaium.vac.client.util.Render3DUtil +import com.mojang.blaze3d.systems.RenderSystem +import net.minecraft.client.gl.VertexBuffer +import net.minecraft.client.render.GameRenderer +import net.minecraft.client.util.math.MatrixStack import net.minecraft.entity.Entity import net.minecraft.util.math.Box import java.awt.Color @@ -11,21 +15,14 @@ import java.awt.Color * @author Enaium */ open class Render(val boxType: BoxType, val drawType: DrawType) { - fun getList(name: String): Int? { + private fun getList(name: String): VertexBuffer? { return CF4M.CLASS.create(RenderService::class.java).list[name] } - fun drawBox(entity: Entity, tickDelta: Float, color: Color, module: Any) { - val list = getList(CF4M.MODULE.getByInstance(module).name) - if (list != null) { - Render3DUtil.drawBox(entity, tickDelta, color, list) - } - } - - fun drawBox(box: Box, color: Color, module: Any) { - val list = getList(CF4M.MODULE.getByInstance(module).name) - if (list != null) { - Render3DUtil.drawBox(box, color, list) + fun drawBox(matrixStack: MatrixStack, box: Box, color: Color, module: Any) { + val vertexBuffer = getList(CF4M.MODULE.getByInstance(module).name) + if (vertexBuffer != null) { + Render3DUtil.drawBox(matrixStack, vertexBuffer, box, color) } } diff --git a/src/main/kotlin/cn/enaium/vac/client/module/render/StorageESP.kt b/src/main/kotlin/cn/enaium/vac/client/module/render/StorageESP.kt deleted file mode 100644 index 5e669c2..0000000 --- a/src/main/kotlin/cn/enaium/vac/client/module/render/StorageESP.kt +++ /dev/null @@ -1,84 +0,0 @@ -package cn.enaium.vac.client.module.render - -import cn.enaium.cf4m.annotation.Event -import cn.enaium.cf4m.annotation.module.Enable -import cn.enaium.cf4m.annotation.module.Module -import cn.enaium.cf4m.annotation.module.Setting -import cn.enaium.vac.client.event.Render3DEvent -import cn.enaium.vac.client.mc -import cn.enaium.vac.client.module.RENDER -import cn.enaium.vac.client.setting.EnableSetting -import cn.enaium.vac.client.util.BlockUtil -import cn.enaium.vac.client.util.Render3DUtil -import net.minecraft.block.entity.* -import net.minecraft.util.math.BlockPos -import net.minecraft.util.math.Box -import org.lwjgl.opengl.GL11 -import java.awt.Color - -/** - * @author Enaium - */ -@Module("StorageESP", type = RENDER) -class StorageESP : Render(BoxType.BLOCK, DrawType.SOLID) { - - @Setting("Chest") - private val chest = EnableSetting(true) - - @Setting("TrappedChest") - private val trappedChest = EnableSetting(true) - - @Setting("EnderChest") - private val enderChest = EnableSetting(true) - - @Setting("ShulkerBoxChest") - private val shulkerBoxChest = EnableSetting(true) - - @Setting("Hopper") - private val hopper = EnableSetting(true) - - @Setting("Furnace") - private val furnace = EnableSetting(true) - - @Setting("Dispenser") - private val dispenser = EnableSetting(true) - - @Setting("Dropper") - private val dropper = EnableSetting(true) - - @Setting("Barrel") - private val barrel = EnableSetting(true) - - @Setting("BlastFurnace") - private val blastFurnace = EnableSetting(true) - - @Setting("Smoker") - private val smoker = EnableSetting(true) - - @Event - fun onRender(render3DEvent: Render3DEvent) { - getTargets().forEach { - drawBox(BlockUtil.getBoundingBox(it.pos), Color.GREEN, this) - } - } - - private fun getTargets(): ArrayList { - val blocks: ArrayList = ArrayList() - for (blockEntity in mc.world!!.blockEntities) { - when (blockEntity) { - is ChestBlockEntity -> if (chest.enable) blocks.add(blockEntity) - is TrappedChestBlockEntity -> if (trappedChest.enable) blocks.add(blockEntity) - is EnderChestBlockEntity -> if (enderChest.enable) blocks.add(blockEntity) - is ShulkerBoxBlockEntity -> if (shulkerBoxChest.enable) blocks.add(blockEntity) - is HopperBlockEntity -> if (hopper.enable) blocks.add(blockEntity) - is DispenserBlockEntity -> if (dispenser.enable) blocks.add(blockEntity) - is DropperBlockEntity -> if (dropper.enable) blocks.add(blockEntity) - is FurnaceBlockEntity -> if (furnace.enable) blocks.add(blockEntity) - is BarrelBlockEntity -> if (barrel.enable) blocks.add(blockEntity) - is BlastFurnaceBlockEntity -> if (blastFurnace.enable) blocks.add(blockEntity) - is SmokerBlockEntity -> if (smoker.enable) blocks.add(blockEntity) - } - } - return blocks - } -} \ No newline at end of file diff --git a/src/main/kotlin/cn/enaium/vac/client/module/ui/EnableList.kt b/src/main/kotlin/cn/enaium/vac/client/module/ui/EnableList.kt index b4b0d33..111dc3c 100644 --- a/src/main/kotlin/cn/enaium/vac/client/module/ui/EnableList.kt +++ b/src/main/kotlin/cn/enaium/vac/client/module/ui/EnableList.kt @@ -39,7 +39,7 @@ class EnableList : UI() { } private fun getText(module: ModuleProvider): String { - val extend = module.getExtend() + val extend = module.getExtend(Mod::class.java) if (extend.tag != null) { return "${module.name}[${extend.tag}]" } diff --git a/src/main/kotlin/cn/enaium/vac/client/screen/AltScreen.kt b/src/main/kotlin/cn/enaium/vac/client/screen/AltScreen.kt index 73a10b8..6f1886f 100644 --- a/src/main/kotlin/cn/enaium/vac/client/screen/AltScreen.kt +++ b/src/main/kotlin/cn/enaium/vac/client/screen/AltScreen.kt @@ -33,19 +33,20 @@ class AltScreen : Screen(LiteralText("")) { super.init() usernameField = TextFieldWidget(textRenderer, width / 2 - 250 / 2, 5, 250, 20, LiteralText("")) passwordField = TextFieldWidget(textRenderer, width / 2 - 250 / 2, 35, 250, 20, LiteralText("")) - addButton(ButtonWidget(width / 2 - 250 / 2, 40 * 3, 250, 20, LiteralText("Login")) { + addDrawable(ButtonWidget(width / 2 - 250 / 2, 40 * 3, 250, 20, LiteralText("Login")) { login() }) - addButton(ButtonWidget(width / 2 - 250 / 2, 40 * 3 + 25 * 2, 250, 20, LiteralText("Back")) { + addDrawable(ButtonWidget(width / 2 - 250 / 2, 40 * 3 + 25 * 2, 250, 20, LiteralText("Back")) { mc.openScreen(null) }) - children.addAll(arrayOf(usernameField, passwordField)) + addDrawable(usernameField) + addDrawable(passwordField) } override fun render(matrixStack: MatrixStack, mouseX: Int, mouseY: Int, delta: Float) { renderBackground(matrixStack) - drawCenteredString(matrixStack, textRenderer, "Username:", width / 2 - 250 / 2 - 50, 5, -1) - drawCenteredString(matrixStack, textRenderer, "Password:", width / 2 - 250 / 2 - 50, 35, -1) + drawCenteredText(matrixStack, textRenderer, "Username:", width / 2 - 250 / 2 - 50, 5, -1) + drawCenteredText(matrixStack, textRenderer, "Password:", width / 2 - 250 / 2 - 50, 35, -1) usernameField.render(matrixStack, mouseX, mouseY, delta) passwordField.render(matrixStack, mouseX, mouseY, delta) diff --git a/src/main/kotlin/cn/enaium/vac/client/screen/click/ChatList.kt b/src/main/kotlin/cn/enaium/vac/client/screen/click/ChatList.kt index 51ef945..dee9a8f 100644 --- a/src/main/kotlin/cn/enaium/vac/client/screen/click/ChatList.kt +++ b/src/main/kotlin/cn/enaium/vac/client/screen/click/ChatList.kt @@ -6,6 +6,7 @@ import cn.enaium.vac.client.screen.widget.ChatListWidget import cn.enaium.vac.client.screen.widget.ListWidget import cn.enaium.vac.client.setting.ChatListSetting import cn.enaium.vac.client.util.KeyboardUtil +import cn.enaium.vac.client.util.message import net.minecraft.client.gui.screen.Screen import net.minecraft.client.gui.widget.ButtonWidget import net.minecraft.client.gui.widget.TextFieldWidget @@ -28,30 +29,30 @@ class ChatList(private val chatListSetting: ChatListSetting) : Screen(LiteralTex keyTextField = TextFieldWidget(mc.textRenderer, 5, height - 30, 20, 20, LiteralText("")) chatTextField = TextFieldWidget(mc.textRenderer, 35, height - 30, 100, 20, LiteralText("")) - addButton(ButtonWidget(5, 5, 50, 20, LiteralText("Add")) { + addDrawable(ButtonWidget(5, 5, 50, 20, LiteralText("Add")) { if (keyTextField.text.isNotEmpty() && chatTextField.text.isNotEmpty()) { val key = KeyboardUtil.getKey(keyTextField.text) if (key != -1) { chatListSetting.all.add(Pair(key, chatTextField.text)) } else { - CF4M.CONFIGURATION.command.message("Key:${keyTextField.text} Not Found") + message("Key:${keyTextField.text} Not Found") } } }) removeButton = ButtonWidget(width - 55, 5, 50, 20, LiteralText("Remove")) { - entryListWidget.children().remove(entryListWidget.selected) - chatListSetting.all.remove(entryListWidget.selected!!.pair) + entryListWidget.children().remove(entryListWidget.selectedOrNull) + chatListSetting.all.remove(entryListWidget.selectedOrNull!!.pair) } - addButton(removeButton) - addChild(keyTextField) - addChild(chatTextField) + addDrawable(removeButton) + addDrawable(keyTextField) + addDrawable(chatTextField) super.init() } override fun render(matrices: MatrixStack, mouseX: Int, mouseY: Int, delta: Float) { renderBackground(matrices) - removeButton.active = entryListWidget.selected != null + removeButton.active = entryListWidget.selectedOrNull != null entryListWidget.render(matrices, mouseX, mouseY, delta) chatTextField.render(matrices, mouseX, mouseY, delta) keyTextField.render(matrices, mouseX, mouseY, delta) diff --git a/src/main/kotlin/cn/enaium/vac/client/screen/click/ClickGUI.kt b/src/main/kotlin/cn/enaium/vac/client/screen/click/ClickGUI.kt index 8a90531..6cd18c8 100644 --- a/src/main/kotlin/cn/enaium/vac/client/screen/click/ClickGUI.kt +++ b/src/main/kotlin/cn/enaium/vac/client/screen/click/ClickGUI.kt @@ -28,7 +28,7 @@ class ClickGUI : Screen(LiteralText("")) { } override fun init() { - addButton(ButtonWidget(0, height - 20, 50, 20, LiteralText("Design")) { + addDrawable(ButtonWidget(0, height - 20, 50, 20, LiteralText("Design")) { mc.openScreen(Design()) }) super.init() diff --git a/src/main/kotlin/cn/enaium/vac/client/screen/click/EditValue.kt b/src/main/kotlin/cn/enaium/vac/client/screen/click/EditValue.kt index 6c6d2cb..9741d4d 100644 --- a/src/main/kotlin/cn/enaium/vac/client/screen/click/EditValue.kt +++ b/src/main/kotlin/cn/enaium/vac/client/screen/click/EditValue.kt @@ -23,7 +23,7 @@ class EditValue(val setting: SettingProvider) : Screen(LiteralText("")) { override fun init() { textFieldWidget = TextFieldWidget(mc.textRenderer, width / 2 - 25, height / 2 - 10, 50, 20, LiteralText("")) - addButton(ButtonWidget(width / 2 - 25, height / 2 + 20, 50, 20, ScreenTexts.DONE) { + addDrawable(ButtonWidget(width / 2 - 25, height / 2 + 20, 50, 20, ScreenTexts.DONE) { try { when (val s = setting.getSetting()) { is FloatSetting -> { @@ -58,7 +58,7 @@ class EditValue(val setting: SettingProvider) : Screen(LiteralText("")) { } mc.openScreen(ClickGUI()) }) - addChild(textFieldWidget) + addDrawable(textFieldWidget) super.init() } diff --git a/src/main/kotlin/cn/enaium/vac/client/screen/click/EntityAllList.kt b/src/main/kotlin/cn/enaium/vac/client/screen/click/EntityAllList.kt index 8d1e671..d755489 100644 --- a/src/main/kotlin/cn/enaium/vac/client/screen/click/EntityAllList.kt +++ b/src/main/kotlin/cn/enaium/vac/client/screen/click/EntityAllList.kt @@ -24,18 +24,18 @@ class EntityAllList(private val entityList: EntityList) : Screen(LiteralText("") } buttonWidget = ButtonWidget(width / 2 - 25, height - 30, 50, 20, LiteralText("Add")) { - entityList.entityListSetting.all.add(entryListWidget.selected!!.entityType.lootTableId.path) + entityList.entityListSetting.all.add(entryListWidget.selectedOrNull!!.entityType.lootTableId.path) mc.openScreen(entityList) } - addChild(entryListWidget) - addButton(buttonWidget) + addDrawable(entryListWidget) + addDrawable(buttonWidget) super.init() } override fun render(matrices: MatrixStack, mouseX: Int, mouseY: Int, delta: Float) { entryListWidget.render(matrices, mouseX, mouseY, delta) - buttonWidget.active = entryListWidget.selected != null + buttonWidget.active = entryListWidget.selectedOrNull != null super.render(matrices, mouseX, mouseY, delta) } } \ No newline at end of file diff --git a/src/main/kotlin/cn/enaium/vac/client/screen/click/EntityList.kt b/src/main/kotlin/cn/enaium/vac/client/screen/click/EntityList.kt index 7e0e5af..e800533 100644 --- a/src/main/kotlin/cn/enaium/vac/client/screen/click/EntityList.kt +++ b/src/main/kotlin/cn/enaium/vac/client/screen/click/EntityList.kt @@ -28,14 +28,14 @@ class EntityList(val entityListSetting: EntityListSetting) : Screen(LiteralText( } removeButton = ButtonWidget(width - 55, 5, 50, 20, LiteralText("Remove")) { - entryListWidget.children().remove(entryListWidget.selected) - entityListSetting.all.remove(entryListWidget.selected!!.entityType.lootTableId.path) + entryListWidget.children().remove(entryListWidget.selectedOrNull) + entityListSetting.all.remove(entryListWidget.selectedOrNull!!.entityType.lootTableId.path) } - addButton(ButtonWidget(5, 5, 50, 20, LiteralText("All")) { + addDrawable(ButtonWidget(5, 5, 50, 20, LiteralText("All")) { mc.openScreen(EntityAllList(this)) }) - addChild(entryListWidget) - addButton(removeButton) + addDrawable(entryListWidget) + addDrawable(removeButton) super.init() } @@ -43,7 +43,7 @@ class EntityList(val entityListSetting: EntityListSetting) : Screen(LiteralText( renderBackground(matrices) entryListWidget.render(matrices, mouseX, mouseY, delta) - removeButton.active = entryListWidget.selected != null + removeButton.active = entryListWidget.selectedOrNull != null super.render(matrices, mouseX, mouseY, delta) } diff --git a/src/main/kotlin/cn/enaium/vac/client/screen/click/ItemAllList.kt b/src/main/kotlin/cn/enaium/vac/client/screen/click/ItemAllList.kt index 465e054..dc10821 100644 --- a/src/main/kotlin/cn/enaium/vac/client/screen/click/ItemAllList.kt +++ b/src/main/kotlin/cn/enaium/vac/client/screen/click/ItemAllList.kt @@ -3,6 +3,7 @@ package cn.enaium.vac.client.screen.click import cn.enaium.vac.client.mc import cn.enaium.vac.client.screen.widget.ItemListWidget import cn.enaium.vac.client.screen.widget.ListWidget +import net.minecraft.block.entity.BlockEntity import net.minecraft.client.gui.screen.Screen import net.minecraft.client.gui.widget.ButtonWidget import net.minecraft.client.util.math.MatrixStack @@ -27,33 +28,38 @@ class ItemAllList(private val itemList: ItemList, private val type: Type) : Scre entryListWidget.addEntry(ItemListWidget.Entry(it.asItem().toString())) } } - else -> { + Type.BLOCK -> { Registry.BLOCK.forEach { entryListWidget.addEntry(ItemListWidget.Entry(it.asItem().toString())) } } + + else -> Registry.BLOCK_ENTITY_TYPE.ids.forEach { + entryListWidget.addEntry(ItemListWidget.Entry(it.path)) + } } buttonWidget = ButtonWidget(width / 2 - 25, height - 30, 50, 20, LiteralText("Add")) { - itemList.itemListSetting.all.add("minecraft:" + entryListWidget.selected!!.name) + itemList.itemListSetting.all.add("minecraft:" + entryListWidget.selectedOrNull!!.name) mc.openScreen(itemList) } - addButton(buttonWidget) - addChild(entryListWidget) + addDrawable(buttonWidget) + addDrawable(entryListWidget) super.init() } override fun render(matrices: MatrixStack, mouseX: Int, mouseY: Int, delta: Float) { renderBackground(matrices) - buttonWidget.active = entryListWidget.selected != null + buttonWidget.active = entryListWidget.selectedOrNull != null entryListWidget.render(matrices, mouseX, mouseY, delta) super.render(matrices, mouseX, mouseY, delta) } enum class Type { ITEM, - BLOCK + BLOCK, + BLOCK_ENTITY } } \ No newline at end of file diff --git a/src/main/kotlin/cn/enaium/vac/client/screen/click/ItemList.kt b/src/main/kotlin/cn/enaium/vac/client/screen/click/ItemList.kt index bbfdb51..b9f8a42 100644 --- a/src/main/kotlin/cn/enaium/vac/client/screen/click/ItemList.kt +++ b/src/main/kotlin/cn/enaium/vac/client/screen/click/ItemList.kt @@ -3,6 +3,7 @@ package cn.enaium.vac.client.screen.click import cn.enaium.vac.client.mc import cn.enaium.vac.client.screen.widget.ItemListWidget import cn.enaium.vac.client.screen.widget.ListWidget +import cn.enaium.vac.client.setting.BlockEntityListSetting import cn.enaium.vac.client.setting.BlockListSetting import cn.enaium.vac.client.setting.ItemListSetting import net.minecraft.client.gui.screen.Screen @@ -28,21 +29,25 @@ class ItemList(val itemListSetting: ItemListSetting) : Screen(LiteralText("")) { removeButton = ButtonWidget(width - 55, 5, 50, 20, LiteralText("Remove")) { - entryListWidget.children().remove(entryListWidget.selected) - itemListSetting.all.remove(entryListWidget.selected!!.name) + entryListWidget.children().remove(entryListWidget.selectedOrNull) + itemListSetting.all.remove(entryListWidget.selectedOrNull!!.name) } textFieldWidget = TextFieldWidget(mc.textRenderer, 5, height - 30, 50, 20, LiteralText("")) - addButton(ButtonWidget(60, height - 30, 50, 20, LiteralText("All")) { + addDrawable(ButtonWidget(60, height - 30, 50, 20, LiteralText("All")) { mc.openScreen( ItemAllList( this, - if (itemListSetting is BlockListSetting) ItemAllList.Type.BLOCK else ItemAllList.Type.ITEM + when (itemListSetting) { + is BlockListSetting -> ItemAllList.Type.BLOCK + is BlockEntityListSetting -> ItemAllList.Type.BLOCK_ENTITY + else -> ItemAllList.Type.ITEM + } ) ) }) - addButton(ButtonWidget(5, 5, 50, 20, LiteralText("Add")) { + addDrawable(ButtonWidget(5, 5, 50, 20, LiteralText("Add")) { try { var clipboard = mc.keyboard.clipboard.lowercase() if (Registry.ITEM.containsId(Identifier(clipboard)) && textFieldWidget.text.isEmpty()) { @@ -60,9 +65,9 @@ class ItemList(val itemListSetting: ItemListSetting) : Screen(LiteralText("")) { } }) - addButton(removeButton) - addChild(entryListWidget) - addChild(textFieldWidget) + addDrawable(removeButton) + addDrawable(entryListWidget) + addDrawable(textFieldWidget) super.init() } @@ -81,7 +86,7 @@ class ItemList(val itemListSetting: ItemListSetting) : Screen(LiteralText("")) { override fun render(matrices: MatrixStack, mouseX: Int, mouseY: Int, delta: Float) { renderBackground(matrices) - removeButton.active = entryListWidget.selected != null + removeButton.active = entryListWidget.selectedOrNull != null entryListWidget.render(matrices, mouseX, mouseY, delta) textFieldWidget.render(matrices, mouseX, mouseY, delta) super.render(matrices, mouseX, mouseY, delta) diff --git a/src/main/kotlin/cn/enaium/vac/client/screen/click/panel/ModulePanel.kt b/src/main/kotlin/cn/enaium/vac/client/screen/click/panel/ModulePanel.kt index e6e5e49..6d5e6ee 100644 --- a/src/main/kotlin/cn/enaium/vac/client/screen/click/panel/ModulePanel.kt +++ b/src/main/kotlin/cn/enaium/vac/client/screen/click/panel/ModulePanel.kt @@ -40,7 +40,7 @@ class ModulePanel(private val module: ModuleProvider, var x: Int, var y: Int) : } override fun render(matrices: MatrixStack, mouseX: Int, mouseY: Int, delta: Float) { - val height = FontUtil.height + 10 + val height = FontUtil.height + 5 hovered = Render2DUtil.isHovered(mouseX, mouseY, x, y, getMaxModule(), height) Render2DUtil.drawRectWH( matrices, @@ -73,7 +73,7 @@ class ModulePanel(private val module: ModuleProvider, var x: Int, var y: Int) : it.x = x + getMaxModule() it.y = settingY it.render(matrices, mouseX, mouseY, delta) - settingY += FontUtil.height + 10 + settingY += height } } } diff --git a/src/main/kotlin/cn/enaium/vac/client/screen/click/panel/TypePanel.kt b/src/main/kotlin/cn/enaium/vac/client/screen/click/panel/TypePanel.kt index b6d64e1..2471032 100644 --- a/src/main/kotlin/cn/enaium/vac/client/screen/click/panel/TypePanel.kt +++ b/src/main/kotlin/cn/enaium/vac/client/screen/click/panel/TypePanel.kt @@ -51,7 +51,7 @@ class TypePanel(private val type: String, private var x: Int, private var y: Int it.x = x + getMaxType() / 2 - getMaxModule() / 2 it.y = moduleY it.render(matrices, mouseX, mouseY, delta) - moduleY += FontUtil.height + 10 + moduleY += FontUtil.height + 5 } } } diff --git a/src/main/kotlin/cn/enaium/vac/client/screen/click/panel/setting/SettingPanel.kt b/src/main/kotlin/cn/enaium/vac/client/screen/click/panel/setting/SettingPanel.kt index adba301..0312673 100644 --- a/src/main/kotlin/cn/enaium/vac/client/screen/click/panel/setting/SettingPanel.kt +++ b/src/main/kotlin/cn/enaium/vac/client/screen/click/panel/setting/SettingPanel.kt @@ -12,7 +12,7 @@ import net.minecraft.client.util.math.MatrixStack */ open class SettingPanel(val setting: SettingProvider, var x: Int = 0, var y: Int = 0) : Drawable, Element { - val height = FontUtil.height + 10 + val height = FontUtil.height + 5 var hovered = false override fun render(matrices: MatrixStack, mouseX: Int, mouseY: Int, delta: Float) { diff --git a/src/main/kotlin/cn/enaium/vac/client/screen/design/Design.kt b/src/main/kotlin/cn/enaium/vac/client/screen/design/Design.kt index 9801ea9..7c9b2bc 100644 --- a/src/main/kotlin/cn/enaium/vac/client/screen/design/Design.kt +++ b/src/main/kotlin/cn/enaium/vac/client/screen/design/Design.kt @@ -20,7 +20,7 @@ class Design : Screen(LiteralText("")) { panel.clear() val filter = CF4M.MODULE.all.filter { it.instance is UI } filter.forEach { panel.add(Panel(it.instance as UI)) } - addButton(ButtonWidget(width - 50, height - 20, 50, 20, LiteralText("Reset")) { + addDrawable(ButtonWidget(width - 50, height - 20, 50, 20, LiteralText("Reset")) { filter.forEach { val ui = it.instance as UI ui.x = ui.defaultX diff --git a/src/main/kotlin/cn/enaium/vac/client/screen/widget/ListWidget.kt b/src/main/kotlin/cn/enaium/vac/client/screen/widget/ListWidget.kt index 6d619b9..5909121 100644 --- a/src/main/kotlin/cn/enaium/vac/client/screen/widget/ListWidget.kt +++ b/src/main/kotlin/cn/enaium/vac/client/screen/widget/ListWidget.kt @@ -1,6 +1,7 @@ package cn.enaium.vac.client.screen.widget import net.minecraft.client.MinecraftClient +import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder import net.minecraft.client.gui.widget.EntryListWidget import net.minecraft.client.util.math.MatrixStack @@ -17,9 +18,9 @@ class ListWidget>( ) : EntryListWidget(client, width, height, top, bottom, itemHeight) { private fun setSelectedItem(index: Int) { if (index == -1) { - selected = null + setSelected(null) } else if (super.getEntryCount() != 0) { - selected = getEntry(index) + setSelected(getEntry(index)) } } @@ -32,6 +33,10 @@ class ListWidget>( return super.mouseClicked(mouseX, mouseY, button) } + override fun appendNarrations(builder: NarrationMessageBuilder) { + + } + public override fun addEntry(entry: T): Int { return super.addEntry(entry) } diff --git a/src/main/kotlin/cn/enaium/vac/client/service/RenderService.kt b/src/main/kotlin/cn/enaium/vac/client/service/RenderService.kt index f51e92d..06ce727 100644 --- a/src/main/kotlin/cn/enaium/vac/client/service/RenderService.kt +++ b/src/main/kotlin/cn/enaium/vac/client/service/RenderService.kt @@ -5,6 +5,7 @@ import cn.enaium.cf4m.provider.ModuleProvider import cn.enaium.cf4m.service.ModuleService import cn.enaium.vac.client.module.render.Render import cn.enaium.vac.client.util.Render3DUtil +import net.minecraft.client.gl.VertexBuffer import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Box import org.lwjgl.opengl.GL11 @@ -15,13 +16,12 @@ import org.lwjgl.opengl.GL11 @Service class RenderService : ModuleService { - val list = HashMap() + val list = HashMap() override fun beforeEnable(moduleProvider: ModuleProvider) { if (moduleProvider.instance !is Render) return - val gen = GL11.glGenLists(1) - GL11.glNewList(gen, GL11.GL_COMPILE) - list[moduleProvider.name] = gen + val vertexBuffer = VertexBuffer() + list[moduleProvider.name] = vertexBuffer val render = moduleProvider.instance as Render val box = when (render.boxType) { Render.BoxType.ENTITY -> { @@ -34,21 +34,19 @@ class RenderService : ModuleService { when (render.drawType) { Render.DrawType.OUTLINE -> { - Render3DUtil.drawOutline(box) + Render3DUtil.drawOutlined(box, vertexBuffer) } Render.DrawType.SOLID -> { - Render3DUtil.drawSolid(box) + Render3DUtil.drawSolid(box, vertexBuffer) } } - GL11.glEndList() } override fun beforeDisable(moduleProvider: ModuleProvider) { val i = list[moduleProvider.name] - if (i != null && i != 0) { - GL11.glDeleteLists(i, 1) - list[moduleProvider.name] = 0 + if (i != null) { + list[moduleProvider.name]!!.close() } } } \ No newline at end of file diff --git a/src/main/kotlin/cn/enaium/vac/client/setting/Setting.kt b/src/main/kotlin/cn/enaium/vac/client/setting/Setting.kt index 23889ba..b6c5530 100644 --- a/src/main/kotlin/cn/enaium/vac/client/setting/Setting.kt +++ b/src/main/kotlin/cn/enaium/vac/client/setting/Setting.kt @@ -22,5 +22,6 @@ class ModeSetting(var current: String, val modes: ArrayList) { class ChatListSetting(var all: ArrayList>) open class ItemListSetting(var all: ArrayList) class BlockListSetting(all: ArrayList) : ItemListSetting(all) +class BlockEntityListSetting(all: ArrayList) : ItemListSetting(all) class EntityListSetting(var all: ArrayList) class StringSetting(var current: String) \ No newline at end of file diff --git a/src/main/kotlin/cn/enaium/vac/client/util/ChatUtil.kt b/src/main/kotlin/cn/enaium/vac/client/util/ChatUtil.kt index 6da54b6..c0d8597 100644 --- a/src/main/kotlin/cn/enaium/vac/client/util/ChatUtil.kt +++ b/src/main/kotlin/cn/enaium/vac/client/util/ChatUtil.kt @@ -1,6 +1,7 @@ package cn.enaium.vac.client.util import cn.enaium.cf4m.CF4M +import cn.enaium.cf4m.configuration.CommandConfiguration import cn.enaium.vac.client.VAC_NAME import cn.enaium.vac.client.mc import net.minecraft.text.LiteralText @@ -20,14 +21,14 @@ object ChatUtil { private val error: String = "[" + Formatting.RED + "error" + Formatting.WHITE + "] " fun error(string: String) { - CF4M.CONFIGURATION.command.message(error + string) + CF4M.CONFIGURATION.getByClass(CommandConfiguration::class.java).message(error + string) } fun warning(string: String) { - CF4M.CONFIGURATION.command.message(warning + string) + CF4M.CONFIGURATION.getByClass(CommandConfiguration::class.java).message(warning + string) } fun success(string: String) { - CF4M.CONFIGURATION.command.message(success + string) + CF4M.CONFIGURATION.getByClass(CommandConfiguration::class.java).message(success + string) } } \ No newline at end of file diff --git a/src/main/kotlin/cn/enaium/vac/client/util/Render2DUtil.kt b/src/main/kotlin/cn/enaium/vac/client/util/Render2DUtil.kt index ad8c10e..51281bd 100644 --- a/src/main/kotlin/cn/enaium/vac/client/util/Render2DUtil.kt +++ b/src/main/kotlin/cn/enaium/vac/client/util/Render2DUtil.kt @@ -235,7 +235,7 @@ object Render2DUtil { RenderSystem.enableBlend() RenderSystem.disableTexture() RenderSystem.defaultBlendFunc() - bufferBuilder.begin(GL11.GL_QUADS, VertexFormats.POSITION_COLOR) + bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR) bufferBuilder.vertex(matrix4f, x1.toFloat(), y2.toFloat(), 0.0f).color(g, h, k, f).next() bufferBuilder.vertex(matrix4f, x2.toFloat(), y2.toFloat(), 0.0f).color(g, h, k, f).next() bufferBuilder.vertex(matrix4f, x2.toFloat(), y1.toFloat(), 0.0f).color(g, h, k, f).next() @@ -312,7 +312,7 @@ object Render2DUtil { vEnd: Float ) { val bufferBuilder = Tessellator.getInstance().buffer - bufferBuilder.begin(GL11.GL_QUADS, VertexFormats.POSITION_TEXTURE) + bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE) bufferBuilder.vertex(xStart, yEnd, z).texture(uStart, vEnd).next() bufferBuilder.vertex(xEnd, yEnd, z).texture(uEnd, vEnd).next() bufferBuilder.vertex(xEnd, yStart, z).texture(uEnd, vStart).next() diff --git a/src/main/kotlin/cn/enaium/vac/client/util/Render3DUtil.kt b/src/main/kotlin/cn/enaium/vac/client/util/Render3DUtil.kt index b14e79a..867420f 100644 --- a/src/main/kotlin/cn/enaium/vac/client/util/Render3DUtil.kt +++ b/src/main/kotlin/cn/enaium/vac/client/util/Render3DUtil.kt @@ -1,146 +1,174 @@ package cn.enaium.vac.client.util import cn.enaium.vac.client.mc -import net.minecraft.client.render.Camera -import net.minecraft.entity.Entity +import com.mojang.blaze3d.systems.RenderSystem +import net.minecraft.client.gl.VertexBuffer +import net.minecraft.client.render.* +import net.minecraft.client.util.math.MatrixStack +import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Box import net.minecraft.util.math.MathHelper import net.minecraft.util.math.Vec3d import org.lwjgl.opengl.GL11 import java.awt.Color +import java.awt.Color.* object Render3DUtil { - fun applyRenderOffset() { - applyCameraRotationOnly() - val camPos = getCameraPos() - GL11.glTranslated(-camPos.x, -camPos.y, -camPos.z) + fun getCameraPos(): Vec3d { + return mc.gameRenderer.camera.pos } - fun applyCameraRotationOnly() { - val camera: Camera = mc.gameRenderer.camera - GL11.glRotated(MathHelper.wrapDegrees(camera.pitch).toDouble(), 1.0, 0.0, 0.0) - GL11.glRotated(MathHelper.wrapDegrees(camera.yaw + 180.0), 0.0, 1.0, 0.0) - } - fun getCameraPos(): Vec3d { - return mc.gameRenderer.camera.pos + fun drawSolid(bb: Box, vertexBuffer: VertexBuffer) { + val bufferBuilder = Tessellator.getInstance().buffer + bufferBuilder.begin( + VertexFormat.DrawMode.QUADS, + VertexFormats.POSITION + ) + drawSolid(bb, bufferBuilder) + bufferBuilder.end() + vertexBuffer.upload(bufferBuilder) } - fun drawSolid(bb: Box) { - GL11.glBegin(GL11.GL_QUADS) - GL11.glVertex3d(bb.minX, bb.minY, bb.minZ) - GL11.glVertex3d(bb.maxX, bb.minY, bb.minZ) - GL11.glVertex3d(bb.maxX, bb.minY, bb.maxZ) - GL11.glVertex3d(bb.minX, bb.minY, bb.maxZ) - GL11.glVertex3d(bb.minX, bb.maxY, bb.minZ) - GL11.glVertex3d(bb.minX, bb.maxY, bb.maxZ) - GL11.glVertex3d(bb.maxX, bb.maxY, bb.maxZ) - GL11.glVertex3d(bb.maxX, bb.maxY, bb.minZ) - GL11.glVertex3d(bb.minX, bb.minY, bb.minZ) - GL11.glVertex3d(bb.minX, bb.maxY, bb.minZ) - GL11.glVertex3d(bb.maxX, bb.maxY, bb.minZ) - GL11.glVertex3d(bb.maxX, bb.minY, bb.minZ) - GL11.glVertex3d(bb.maxX, bb.minY, bb.minZ) - GL11.glVertex3d(bb.maxX, bb.maxY, bb.minZ) - GL11.glVertex3d(bb.maxX, bb.maxY, bb.maxZ) - GL11.glVertex3d(bb.maxX, bb.minY, bb.maxZ) - GL11.glVertex3d(bb.minX, bb.minY, bb.maxZ) - GL11.glVertex3d(bb.maxX, bb.minY, bb.maxZ) - GL11.glVertex3d(bb.maxX, bb.maxY, bb.maxZ) - GL11.glVertex3d(bb.minX, bb.maxY, bb.maxZ) - GL11.glVertex3d(bb.minX, bb.minY, bb.minZ) - GL11.glVertex3d(bb.minX, bb.minY, bb.maxZ) - GL11.glVertex3d(bb.minX, bb.maxY, bb.maxZ) - GL11.glVertex3d(bb.minX, bb.maxY, bb.minZ) - GL11.glEnd() + fun drawSolid(bb: Box, bufferBuilder: BufferBuilder) { + bufferBuilder.vertex(bb.minX, bb.minY, bb.minZ).next() + bufferBuilder.vertex(bb.maxX, bb.minY, bb.minZ).next() + bufferBuilder.vertex(bb.maxX, bb.minY, bb.maxZ).next() + bufferBuilder.vertex(bb.minX, bb.minY, bb.maxZ).next() + + bufferBuilder.vertex(bb.minX, bb.maxY, bb.minZ).next() + bufferBuilder.vertex(bb.minX, bb.maxY, bb.maxZ).next() + bufferBuilder.vertex(bb.maxX, bb.maxY, bb.maxZ).next() + bufferBuilder.vertex(bb.maxX, bb.maxY, bb.minZ).next() + + bufferBuilder.vertex(bb.minX, bb.minY, bb.minZ).next() + bufferBuilder.vertex(bb.minX, bb.maxY, bb.minZ).next() + bufferBuilder.vertex(bb.maxX, bb.maxY, bb.minZ).next() + bufferBuilder.vertex(bb.maxX, bb.minY, bb.minZ).next() + + bufferBuilder.vertex(bb.maxX, bb.minY, bb.minZ).next() + bufferBuilder.vertex(bb.maxX, bb.maxY, bb.minZ).next() + bufferBuilder.vertex(bb.maxX, bb.maxY, bb.maxZ).next() + bufferBuilder.vertex(bb.maxX, bb.minY, bb.maxZ).next() + + bufferBuilder.vertex(bb.minX, bb.minY, bb.maxZ).next() + bufferBuilder.vertex(bb.maxX, bb.minY, bb.maxZ).next() + bufferBuilder.vertex(bb.maxX, bb.maxY, bb.maxZ).next() + bufferBuilder.vertex(bb.minX, bb.maxY, bb.maxZ).next() + + bufferBuilder.vertex(bb.minX, bb.minY, bb.minZ).next() + bufferBuilder.vertex(bb.minX, bb.minY, bb.maxZ).next() + bufferBuilder.vertex(bb.minX, bb.maxY, bb.maxZ).next() + bufferBuilder.vertex(bb.minX, bb.maxY, bb.minZ).next() } - fun drawOutline(bb: Box) { - GL11.glBegin(GL11.GL_LINES) - GL11.glVertex3d(bb.minX, bb.minY, bb.minZ) - GL11.glVertex3d(bb.maxX, bb.minY, bb.minZ) + fun drawOutlined(bb: Box, vertexBuffer: VertexBuffer) { + val bufferBuilder = Tessellator.getInstance().buffer + bufferBuilder.begin( + VertexFormat.DrawMode.DEBUG_LINES, + VertexFormats.POSITION + ) + drawOutline(bb, bufferBuilder) + bufferBuilder.end() + vertexBuffer.upload(bufferBuilder) + } - GL11.glVertex3d(bb.maxX, bb.minY, bb.minZ) - GL11.glVertex3d(bb.maxX, bb.minY, bb.maxZ) + fun drawOutline(bb: Box, bufferBuilder: BufferBuilder) { + bufferBuilder.vertex(bb.minX, bb.minY, bb.minZ).next() + bufferBuilder.vertex(bb.maxX, bb.minY, bb.minZ).next() - GL11.glVertex3d(bb.maxX, bb.minY, bb.maxZ) - GL11.glVertex3d(bb.minX, bb.minY, bb.maxZ) + bufferBuilder.vertex(bb.maxX, bb.minY, bb.minZ).next() + bufferBuilder.vertex(bb.maxX, bb.minY, bb.maxZ).next() - GL11.glVertex3d(bb.minX, bb.minY, bb.maxZ) - GL11.glVertex3d(bb.minX, bb.minY, bb.minZ) + bufferBuilder.vertex(bb.maxX, bb.minY, bb.maxZ).next() + bufferBuilder.vertex(bb.minX, bb.minY, bb.maxZ).next() - GL11.glVertex3d(bb.minX, bb.minY, bb.minZ) - GL11.glVertex3d(bb.minX, bb.maxY, bb.minZ) + bufferBuilder.vertex(bb.minX, bb.minY, bb.maxZ).next() + bufferBuilder.vertex(bb.minX, bb.minY, bb.minZ).next() - GL11.glVertex3d(bb.maxX, bb.minY, bb.minZ) - GL11.glVertex3d(bb.maxX, bb.maxY, bb.minZ) + bufferBuilder.vertex(bb.minX, bb.minY, bb.minZ).next() + bufferBuilder.vertex(bb.minX, bb.maxY, bb.minZ).next() - GL11.glVertex3d(bb.maxX, bb.minY, bb.maxZ) - GL11.glVertex3d(bb.maxX, bb.maxY, bb.maxZ) + bufferBuilder.vertex(bb.maxX, bb.minY, bb.minZ).next() + bufferBuilder.vertex(bb.maxX, bb.maxY, bb.minZ).next() - GL11.glVertex3d(bb.minX, bb.minY, bb.maxZ) - GL11.glVertex3d(bb.minX, bb.maxY, bb.maxZ) + bufferBuilder.vertex(bb.maxX, bb.minY, bb.maxZ).next() + bufferBuilder.vertex(bb.maxX, bb.maxY, bb.maxZ).next() - GL11.glVertex3d(bb.minX, bb.maxY, bb.minZ) - GL11.glVertex3d(bb.maxX, bb.maxY, bb.minZ) + bufferBuilder.vertex(bb.minX, bb.minY, bb.maxZ).next() + bufferBuilder.vertex(bb.minX, bb.maxY, bb.maxZ).next() - GL11.glVertex3d(bb.maxX, bb.maxY, bb.minZ) - GL11.glVertex3d(bb.maxX, bb.maxY, bb.maxZ) + bufferBuilder.vertex(bb.minX, bb.maxY, bb.minZ).next() + bufferBuilder.vertex(bb.maxX, bb.maxY, bb.minZ).next() - GL11.glVertex3d(bb.maxX, bb.maxY, bb.maxZ) - GL11.glVertex3d(bb.minX, bb.maxY, bb.maxZ) + bufferBuilder.vertex(bb.maxX, bb.maxY, bb.minZ).next() + bufferBuilder.vertex(bb.maxX, bb.maxY, bb.maxZ).next() - GL11.glVertex3d(bb.minX, bb.maxY, bb.maxZ) - GL11.glVertex3d(bb.minX, bb.maxY, bb.minZ) - GL11.glEnd() + bufferBuilder.vertex(bb.maxX, bb.maxY, bb.maxZ).next() + bufferBuilder.vertex(bb.minX, bb.maxY, bb.maxZ).next() + + bufferBuilder.vertex(bb.minX, bb.maxY, bb.maxZ).next() + bufferBuilder.vertex(bb.minX, bb.maxY, bb.minZ).next() } - fun drawBox(entity: Entity, tickDelta: Float, color: Color, list: Int) { - GL11.glPushMatrix() - GL11.glTranslated( - entity.prevX + (entity.x - entity.prevX) * tickDelta, - entity.prevY + (entity.y - entity.prevY) * tickDelta, - entity.prevZ + (entity.z - entity.prevZ) * tickDelta + fun drawBox(matrixStack: MatrixStack, vertexBuffer: VertexBuffer, box: Box, color: Color) { + matrixStack.push() + val regionX: Int = (getCameraPos().getX().toInt() shr 9) * 512 + val regionZ: Int = (getCameraPos().getZ().toInt() shr 9) * 512 + RenderSystem.setShader(GameRenderer::getPositionShader) + matrixStack.translate( + box.minX - regionX, box.minY, + box.minZ - regionZ ) - GL11.glScaled( - entity.width.toDouble(), - entity.height.toDouble(), - entity.width.toDouble() + matrixStack.scale( + (box.maxX - box.minX).toFloat(), + (box.maxY - box.minY).toFloat(), (box.maxZ - box.minZ).toFloat() ) - GL11.glColor4f(color.red.toFloat(), color.green.toFloat(), color.blue.toFloat(), color.alpha.toFloat()) - GL11.glCallList(list) - GL11.glPopMatrix() + + val r = color.red.toFloat() / 255.0f + val g = color.green.toFloat() / 255.0f + val b = color.blue.toFloat() / 255.0f + val a = color.alpha.toFloat() / 255.0f + RenderSystem.setShaderColor(r, g, b, a) + + val viewMatrix = matrixStack.peek().model + val projMatrix = RenderSystem.getProjectionMatrix() + val shader = RenderSystem.getShader() + + + vertexBuffer.setShader(viewMatrix, projMatrix, shader) + matrixStack.pop() } - fun drawBox(box: Box, color: Color, list: Int) { - GL11.glPushMatrix() - GL11.glTranslated(box.minX, box.minY, box.minZ) - GL11.glScaled(box.maxX - box.minX, box.maxY - box.minY, box.maxZ - box.minZ) - GL11.glColor4f(color.red.toFloat(), color.green.toFloat(), color.blue.toFloat(), color.alpha.toFloat()) - GL11.glCallList(list) - GL11.glPopMatrix() + fun applyRegionalRenderOffset(matrixStack: MatrixStack) { + val camPos = getCameraPos() + val blockPos: BlockPos = mc.blockEntityRenderDispatcher.camera.blockPos + val regionX = (blockPos.x shr 9) * 512 + val regionZ = (blockPos.z shr 9) * 512 + + matrixStack.translate( + regionX - camPos.x, -camPos.y, + regionZ - camPos.z + ) } - fun settings() { + fun settings(matrixStack: MatrixStack) { GL11.glEnable(GL11.GL_BLEND) GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA) GL11.glEnable(GL11.GL_LINE_SMOOTH) - GL11.glLineWidth(2f) - GL11.glDisable(GL11.GL_TEXTURE_2D) + GL11.glEnable(GL11.GL_CULL_FACE) GL11.glDisable(GL11.GL_DEPTH_TEST) - GL11.glDisable(GL11.GL_LIGHTING) - GL11.glPushMatrix() - applyRenderOffset() + matrixStack.push() + applyRegionalRenderOffset(matrixStack) } - fun resets() { - GL11.glPopMatrix() - GL11.glColor4f(1f, 1f, 1f, 1f) + fun resets(matrixStack: MatrixStack) { + matrixStack.pop(); + RenderSystem.setShaderColor(1f, 1f, 1f, 1f) GL11.glEnable(GL11.GL_DEPTH_TEST) - GL11.glEnable(GL11.GL_TEXTURE_2D) GL11.glDisable(GL11.GL_BLEND) GL11.glDisable(GL11.GL_LINE_SMOOTH) } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 3e57638..051a6c1 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -29,8 +29,8 @@ "depends": { "fabricloader": ">=0.7.4", "fabric": "*", - "minecraft": "1.16.x", - "cf4m": ">=1.8.3", + "minecraft": "1.17.x", + "cf4m": ">=1.9.5", "fabric-language-kotlin": "*" }, "suggests": { diff --git a/src/main/resources/vac.mixins.json b/src/main/resources/vac.mixins.json index e3ffeec..abdfe39 100644 --- a/src/main/resources/vac.mixins.json +++ b/src/main/resources/vac.mixins.json @@ -2,7 +2,7 @@ "required": true, "minVersion": "0.8", "package": "cn.enaium.vac.mixin", - "compatibilityLevel": "JAVA_8", + "compatibilityLevel": "JAVA_16", "mixins": [ "ClientConnectionMixin", "ClientPlayerEntityMixin", @@ -12,6 +12,7 @@ "EntityRendererMixin", "GameRendererMixin", "IClientPlayerInteractionManagerMixin", + "IWorldMixin", "IKeyBindingMixin", "IMinecraftClientMixin", "InGameHudMixin",