From 1d22ec517674028ae8c6a62b29d6a4ad98ffc2a8 Mon Sep 17 00:00:00 2001 From: retuci0 Date: Mon, 27 Apr 2026 21:55:51 +0200 Subject: [PATCH] 4.1 (broken) --- README.md | 4 +- build.gradle | 19 +- cambios.md | 8 +- gradle.properties | 11 +- gradle/wrapper/gradle-wrapper.properties | 2 +- src/main/java/me/retucio/sputnik/Sputnik.java | 61 +-- .../java/me/retucio/sputnik/cape/Cape.java | 23 +- .../me/retucio/sputnik/command/Command.java | 26 +- .../sputnik/command/CommandManager.java | 10 +- .../command/args/EntityArgumentType.java | 42 +- .../command/args/EnumArgumentType.java | 8 +- .../command/args/ModuleArgumentType.java | 10 +- .../command/args/PlayerArgumentType.java | 22 +- .../sputnik/command/commands/BindCommand.java | 32 +- .../command/commands/ClickSlotCommand.java | 21 +- .../command/commands/ConfigCommand.java | 10 +- .../commands/CopyScreenshotCommand.java | 4 +- .../command/commands/EnderChestCommand.java | 4 +- .../commands/GarbageCleanerCommand.java | 8 +- .../sputnik/command/commands/PeekCommand.java | 6 +- .../command/commands/PluginsCommand.java | 22 +- .../command/commands/PrefixCommand.java | 10 +- .../command/commands/PurgeCommand.java | 14 +- .../command/commands/RepeatCommand.java | 4 +- .../command/commands/RepeatWaitCommand.java | 4 +- .../commands/SaveScreenshotCommand.java | 4 +- .../sputnik/command/commands/SendCommand.java | 44 +- .../command/commands/SpectateCommand.java | 8 +- .../command/commands/ToggleCommand.java | 4 +- .../sputnik/command/commands/WaitCommand.java | 24 +- .../retucio/sputnik/event/ShutdownEvent.java | 4 +- .../me/retucio/sputnik/event/TickEvent.java | 6 +- .../sputnik/event/input/ClientClickEvent.java | 6 +- .../retucio/sputnik/event/input/KeyEvent.java | 4 +- .../sputnik/event/input/MouseClickEvent.java | 4 +- .../sputnik/event/input/MouseScrollEvent.java | 4 +- .../event/interact/AttackBlockEvent.java | 4 +- .../event/interact/AttackEntityEvent.java | 7 +- .../event/interact/BlockShapeEvent.java | 6 +- .../sputnik/event/interact/BoatMoveEvent.java | 16 +- .../event/interact/BreakBlockEvent.java | 7 +- .../event/interact/DamageItemEvent.java | 2 +- .../event/interact/InteractEntityEvent.java | 17 +- .../event/interact/KnockbackEvent.java | 2 +- .../event/interact/OpenScreenEvent.java | 6 +- .../event/interact/PlaceBlockEvent.java | 16 +- .../sputnik/event/interact/UseItemEvent.java | 21 +- .../sputnik/event/network/AddEntityEvent.java | 6 +- .../event/network/ChunkOcclusionEvent.java | 4 +- .../event/network/DisconnectEvent.java | 22 +- .../sputnik/event/network/JoinWorldEvent.java | 13 +- .../sputnik/event/network/PacketEvent.java | 10 +- .../event/network/ReceiveMessageEvent.java | 30 +- .../event/network/RemoveEntityEvent.java | 6 +- .../event/network/SendMessageEvent.java | 4 +- .../event/render/PerspectiveChangeEvent.java | 14 +- .../sputnik/event/render/Render2DEvent.java | 24 +- .../sputnik/event/render/Render3DEvent.java | 36 +- .../sputnik/event/render/RenderArmEvent.java | 22 +- .../event/render/RenderBossbarEvent.java | 27 +- .../event/render/RenderHeldItemEvent.java | 23 +- .../AbstractContainerScreenAccessor.java | 16 + .../AbstractSignEditScreenAccessor.java | 6 +- .../mixin/accessors/AnvilScreenAccessor.java | 12 +- ...essor.java => BlockBehaviourAccessor.java} | 8 +- .../ClientPacketListenerAccessor.java | 17 + .../ClientPlayNetworkHandlerAccessor.java | 17 - ... => ClientboundExplodePacketAccessor.java} | 10 +- ...entboundSetEntityMotionPacketAccessor.java | 15 + ...nfirmServerResourcePackScreenAccessor.java | 18 - ...EntityVelocityUpdateS2CPacketAccessor.java | 14 - .../FishingBobberEntityAccessor.java | 15 - .../mixin/accessors/FishingHookAccessor.java | 16 + .../accessors/HandledScreenAccessor.java | 16 - .../mixin/accessors/KeyBindingAccessor.java | 10 +- ...or.java => MobEffectInstanceAccessor.java} | 7 +- .../accessors/OverlayTextureAccessor.java | 6 +- .../accessors/PackConfirmScreenAccessor.java | 19 + ...essor.java => PendingRequestAccessor.java} | 7 +- ...ntityMixin.java => AbstractBoatMixin.java} | 20 +- .../mixin/mixins/entity/EntityMixin.java | 153 ++++--- .../mixins/entity/EntityRendererMixin.java | 12 +- .../mixin/mixins/entity/ItemEntityMixin.java | 20 +- .../mixins/entity/LivingEntityMixin.java | 48 +- .../mixin/mixins/hud/BossBarHudMixin.java | 32 +- ...va => ChatComponentLineConsumerMixin.java} | 8 +- .../mixin/mixins/hud/ChatComponentMixin.java | 187 ++++++++ .../mixins/hud/ChatHudInteractableMixin.java | 52 --- .../mixin/mixins/hud/ChatHudMixin.java | 189 -------- .../DrawingFocusedGraphicsAccessMixin.java | 54 +++ ...bleMixin.java => GuiMessageLineMixin.java} | 12 +- ...HudLineMixin.java => GuiMessageMixin.java} | 12 +- .../mixin/mixins/hud/InGameHudMixin.java | 51 ++- ...rdMixin.java => KeyboardHandlerMixin.java} | 14 +- ...nputMixin.java => KeyboardInputMixin.java} | 22 +- ...MouseMixin.java => MouseHandlerMixin.java} | 19 +- ...ecorderMixin.java => ScreenshotMixin.java} | 26 +- .../sputnik/mixin/mixins/item/ItemMixin.java | 32 +- .../mixin/mixins/item/ItemStackMixin.java | 18 +- .../mixin/mixins/item/TridentItemMixin.java | 9 +- .../mixin/mixins/misc/FontManagerMixin.java | 22 +- ...ftClientMixin.java => MinecraftMixin.java} | 43 +- ...ameOptionsMixin.java => OptionsMixin.java} | 17 +- ...gHelperMixin.java => StringUtilMixin.java} | 9 +- .../misc/{Vec3dMixin.java => Vec3Mixin.java} | 9 +- .../network/ChatInputSuggestorMixin.java | 62 --- .../mixins/network/ChatListenerMixin.java | 38 ++ .../ClientCommonNetworkHandlerMixin.java | 67 --- .../ClientCommonPacketListenerImplMixin.java | 67 +++ ...n.java => ClientIntentionPacketMixin.java} | 30 +- ...in.java => ClientPacketListenerMixin.java} | 32 +- .../network/ClientTelemetryManagerMixin.java | 17 + .../network/CommandSuggestionsMixin.java | 72 +++ ...nectionMixin.java => ConnectionMixin.java} | 29 +- .../mixins/network/MessageHandlerMixin.java | 37 -- .../mixins/network/ServerConnectorMixin.java | 15 +- ...verInfoMixin.java => ServerDataMixin.java} | 44 +- ...yMixin.java => ServerPackStatusMixin.java} | 20 +- .../mixins/network/TelemetryManagerMixin.java | 16 - ...{PlayerInputMixin.java => InputMixin.java} | 9 +- ...EntityMixin.java => LocalPlayerMixin.java} | 31 +- ...xin.java => MultiPlayerGameModeMixin.java} | 60 ++- .../mixins/player/PlayerInventoryMixin.java | 15 +- ...layerEntityMixin.java => PlayerMixin.java} | 45 +- ...endererMixin.java => ArrowLayerMixin.java} | 9 +- .../mixins/render/BufferStorageMixin.java | 20 - .../mixin/mixins/render/CameraMixin.java | 34 +- .../render/CapeFeatureRendererMixin.java | 26 -- .../mixin/mixins/render/CapeLayerMixin.java | 23 + .../render/ChunkBorderDebugRendererMixin.java | 33 -- .../render/ChunkBorderRendererMixin.java | 33 ++ .../render/ElytraFeatureRendererMixin.java | 32 -- .../EntityHitboxDebugRendererMixin.java | 12 +- .../render/EquipmentLayerRendererMixin.java | 19 + .../mixins/render/EquipmentRendererMixin.java | 19 - .../mixin/mixins/render/FogRendererMixin.java | 49 +- ...{TextRendererMixin.java => FontMixin.java} | 9 +- .../mixins/render/GameRendererMixin.java | 97 +--- .../mixins/render/HeldItemRendererMixin.java | 90 ---- .../render/InGameOverlayRendererMixin.java | 37 -- ...xin.java => ItemFeatureRendererMixin.java} | 16 +- .../render/ItemInHandRendererMixin.java | 87 ++++ .../mixins/render/LevelRendererMixin.java | 82 ++++ .../render/LightmapTextureManagerMixin.java | 44 +- .../render/LivingEntityRendererMixin.java | 32 +- .../render/MobEffectFogEnvironmentMixin.java | 29 ++ .../mixins/render/OverlayTextureMixin.java | 6 +- .../render/PreparedTextBuilderMixin.java | 45 ++ .../mixins/render/RenderBuffersMixin.java | 22 + .../render/ScreenEffectRendererMixin.java | 37 ++ ...aderMixin.java => ShaderManagerMixin.java} | 8 +- .../mixin/mixins/render/SkyRendererMixin.java | 23 +- .../render/StatusEffectFogModifierMixin.java | 28 -- .../render/TextRendererDrawerMixin.java | 44 -- .../render/WeatherEffectRendererMixin.java | 41 ++ .../mixins/render/WeatherRenderingMixin.java | 42 -- .../mixin/mixins/render/WingsLayerMixin.java | 26 ++ .../mixins/render/WorldRendererMixin.java | 75 ---- .../mixin/mixins/screen/ChatScreenMixin.java | 8 +- .../mixins/screen/ConfirmScreenMixin.java | 24 +- ... => CreativeModeInventoryScreenMixin.java} | 14 +- .../screen/DisconnectedScreenMixin.java | 16 +- .../mixin/mixins/screen/ScreenMixin.java | 25 +- .../world/BlockCollisionSpliteratorMixin.java | 33 -- .../mixins/world/BlockCollisionsMixin.java | 33 ++ ...esMixin.java => ClientLevelDataMixin.java} | 9 +- ...tWorldMixin.java => ClientLevelMixin.java} | 12 +- .../mixin/mixins/world/CritParticleMixin.java | 48 ++ .../mixins/world/DamageParticleMixin.java | 48 -- ...Mixin.java => DeltaTrackerTimerMixin.java} | 12 +- .../mixins/world/EmitterParticleMixin.java | 56 --- .../mixins/world/ParticleEngineMixin.java | 23 + .../mixins/world/ParticleManagerMixin.java | 22 - .../mixins/world/TrackingEmitterMixin.java | 58 +++ ...taBuilderMixin.java => VisGraphMixin.java} | 10 +- .../me/retucio/sputnik/module/Module.java | 4 +- .../retucio/sputnik/module/ModuleManager.java | 1 + .../sputnik/module/modules/camera/Autism.java | 14 +- .../module/modules/camera/Freecam.java | 195 ++++---- .../module/modules/camera/Freelook.java | 32 +- .../module/modules/camera/Fullbright.java | 20 +- .../modules/camera/PerspectivePlus.java | 5 +- .../module/modules/camera/Rotations.java | 12 +- .../sputnik/module/modules/camera/Zoom.java | 31 +- .../modules/combat/ChestplateSwitch.java | 64 +++ .../module/modules/combat/CrystalAura.java | 206 +++++---- .../module/modules/combat/MaceKill.java | 107 ++--- .../combat/ProjectileTrajectories.java | 187 ++++---- .../module/modules/combat/SpearKill.java | 64 +-- .../module/modules/inventory/BundleDupe.java | 42 +- .../CreativeInventoryHotbarKeybinds.java | 4 +- .../modules/inventory/InventoryPlus.java | 15 +- .../module/modules/inventory/Offhand.java | 44 +- .../module/modules/inventory/PortalGUI.java | 4 +- .../module/modules/inventory/Replenish.java | 46 +- .../module/modules/inventory/ShulkerPeek.java | 40 +- .../module/modules/inventory/UIMove.java | 52 +-- .../module/modules/inventory/XCarry.java | 12 +- .../module/modules/misc/AnvilFont.java | 20 +- .../sputnik/module/modules/misc/BookBot.java | 75 +--- .../module/modules/misc/BossbarStack.java | 13 +- .../sputnik/module/modules/misc/ChatPlus.java | 89 ++-- .../module/modules/misc/FakePlayer.java | 28 +- .../module/modules/misc/ScreenshotPlus.java | 78 ++-- .../module/modules/movement/BoatFly.java | 25 +- .../module/modules/movement/Dolphin.java | 6 +- .../module/modules/movement/ElytraBounce.java | 42 +- .../module/modules/movement/ElytraFly.java | 30 +- .../module/modules/movement/FastStairs.java | 17 +- .../module/modules/movement/Headhitters.java | 2 +- .../module/modules/movement/HitboxDesync.java | 26 +- .../modules/movement/InfiniteElytra.java | 29 +- .../module/modules/movement/Jesus.java | 53 +-- .../module/modules/movement/Parkour.java | 20 +- .../module/modules/movement/ReverseStep.java | 39 +- .../module/modules/movement/SafeWalk.java | 37 +- .../module/modules/movement/Scaffold.java | 79 ++-- .../module/modules/movement/Slippy.java | 19 +- .../module/modules/movement/Velocity.java | 20 +- .../module/modules/network/LogoutSpots.java | 106 ++--- .../module/modules/network/PacketDelay.java | 32 +- .../module/modules/network/PacketMine.java | 40 +- .../module/modules/network/RPackBypass.java | 19 +- .../module/modules/network/Reconnect.java | 14 +- .../module/modules/player/AirPlace.java | 29 +- .../module/modules/player/AntiHunger.java | 27 +- .../module/modules/player/AutoFish.java | 39 +- .../module/modules/player/FastUse.java | 10 +- .../module/modules/player/HandView.java | 41 +- .../module/modules/player/KeyPearl.java | 15 +- .../sputnik/module/modules/player/NoFall.java | 78 ++-- .../modules/player/WarnLowDurability.java | 34 +- .../module/modules/render/BlockESP.java | 36 +- .../module/modules/render/BlockOutline.java | 4 +- .../module/modules/render/Breadcrumbs.java | 14 +- .../modules/render/BreakingProgress.java | 25 +- .../module/modules/render/Confetti.java | 1 + .../module/modules/render/CritsPlus.java | 7 +- .../module/modules/render/DamageOverlay.java | 21 +- .../module/modules/render/EntityESP.java | 15 +- .../sputnik/module/modules/render/Fonts.java | 2 +- .../module/modules/render/GlintPlus.java | 40 +- .../module/modules/render/Nametags.java | 54 +-- .../module/modules/render/NoRender.java | 26 +- .../module/modules/render/Particles.java | 33 +- .../module/modules/render/Tracers.java | 19 +- .../module/modules/world/AutoSign.java | 19 +- .../module/modules/world/AutoTool.java | 35 +- .../module/modules/world/BlockInfo.java | 43 +- .../module/modules/world/ColoredSigns.java | 7 +- .../module/modules/world/LightOverlay.java | 89 ++-- .../modules/world/NoMiningInterruptions.java | 11 +- .../sputnik/module/modules/world/Racist.java | 21 +- .../modules/world/StrongholdTriangulator.java | 79 ++-- .../module/modules/world/TimeChanger.java | 22 +- .../module/setting/settings/ColorSetting.java | 8 +- .../sputnik/ui/hud/HudEditorScreen.java | 71 +-- .../me/retucio/sputnik/ui/hud/HudElement.java | 11 +- .../retucio/sputnik/ui/hud/HudRenderer.java | 42 +- .../sputnik/ui/hud/ImageHudElement.java | 56 +-- .../sputnik/ui/hud/TextHudElement.java | 28 +- .../ui/hud/elements/CoordsElement.java | 23 +- .../ui/hud/elements/CustomTextElement.java | 14 +- .../sputnik/ui/hud/elements/DynoElement.java | 13 +- .../ui/hud/elements/EchestElement.java | 56 +-- .../sputnik/ui/hud/elements/FpsElement.java | 19 +- .../sputnik/ui/hud/elements/PingElement.java | 19 +- .../ui/hud/elements/RotationElement.java | 18 +- .../sputnik/ui/hud/elements/TimeElement.java | 11 +- .../ui/hud/elements/TotemsElement.java | 33 +- .../sputnik/ui/hud/elements/TpsElement.java | 11 +- .../ui/hud/elements/UptimeElement.java | 11 +- .../retucio/sputnik/ui/screen/ClickGUI.java | 66 +-- .../sputnik/ui/screen/PreviewScreen.java | 82 ++-- .../sputnik/ui/screen/UpdateScreen.java | 70 ++- .../me/retucio/sputnik/ui/widgets/Button.java | 4 +- .../me/retucio/sputnik/ui/widgets/Frame.java | 7 +- .../me/retucio/sputnik/ui/widgets/Widget.java | 8 +- .../ui/widgets/buttons/ModuleButton.java | 24 +- .../ui/widgets/buttons/SettingButton.java | 9 +- .../widgets/buttons/settings/BindButton.java | 32 +- .../buttons/settings/ChooseButton.java | 11 +- .../widgets/buttons/settings/ColorButton.java | 30 +- .../widgets/buttons/settings/CycleButton.java | 32 +- .../widgets/buttons/settings/ListButton.java | 14 +- .../buttons/settings/SliderButton.java | 14 +- .../widgets/buttons/settings/TextButton.java | 15 +- .../buttons/settings/ToggleButton.java | 8 +- .../ui/widgets/frames/ModuleFrame.java | 41 +- .../ui/widgets/frames/SettingsFrame.java | 54 ++- .../frames/settings/ClientSettingsFrame.java | 22 +- .../frames/settings/ColorPickerFrame.java | 66 +-- .../ui/widgets/misc/ScrollBarWidget.java | 15 +- .../ui/widgets/misc/SearchBarWidget.java | 36 +- .../me/retucio/sputnik/util/ChatUtil.java | 53 +-- .../java/me/retucio/sputnik/util/Colors.java | 14 +- .../me/retucio/sputnik/util/EntityUtil.java | 91 ++-- .../retucio/sputnik/util/InventoryUtil.java | 229 +++++----- .../java/me/retucio/sputnik/util/KeyUtil.java | 23 +- .../java/me/retucio/sputnik/util/Lists.java | 55 +-- .../me/retucio/sputnik/util/MiscUtil.java | 22 +- .../me/retucio/sputnik/util/NetworkUtil.java | 98 ++-- .../util/interfaces/IChatComponent.java | 13 + .../sputnik/util/interfaces/IChatHud.java | 13 - ...MessageHandler.java => IChatListener.java} | 2 +- .../{IChatHudLine.java => IGuiMessage.java} | 2 +- ...dLineVisible.java => IGuiMessageLine.java} | 2 +- .../interfaces/{IVec3d.java => IVec3.java} | 5 +- .../sputnik/util/interfaces/TextVisitor.java | 23 +- .../util/{ => misc}/BlockIterator.java | 24 +- .../retucio/sputnik/util/{ => misc}/Pool.java | 2 +- .../sputnik/util/misc/ProjectileInfo.java | 153 +++---- .../util/{ => misc}/VersionChecker.java | 2 +- .../retucio/sputnik/util/render/DrawUtil.java | 27 +- .../sputnik/util/render/GlintRenderLayer.java | 107 ----- .../sputnik/util/render/GlintRenderType.java | 100 +++++ .../retucio/sputnik/util/render/Layers.java | 50 --- .../sputnik/util/render/Pipelines.java | 80 ++-- .../sputnik/util/render/RenderUtil.java | 421 +++++++++--------- .../util/render/SputnikRenderTypes.java | 51 +++ .../retucio/sputnik/util/render/Textures.java | 36 +- src/main/resources/fabric.mod.json | 6 +- src/main/resources/sputnik.accesswidener | 73 ++- src/main/resources/sputnik.mixins.json | 126 +++--- 324 files changed, 5375 insertions(+), 5234 deletions(-) create mode 100644 src/main/java/me/retucio/sputnik/mixin/accessors/AbstractContainerScreenAccessor.java rename src/main/java/me/retucio/sputnik/mixin/accessors/{AbstractBlockAccessor.java => BlockBehaviourAccessor.java} (57%) create mode 100644 src/main/java/me/retucio/sputnik/mixin/accessors/ClientPacketListenerAccessor.java delete mode 100644 src/main/java/me/retucio/sputnik/mixin/accessors/ClientPlayNetworkHandlerAccessor.java rename src/main/java/me/retucio/sputnik/mixin/accessors/{ExplosionS2CPacketAccessor.java => ClientboundExplodePacketAccessor.java} (51%) create mode 100644 src/main/java/me/retucio/sputnik/mixin/accessors/ClientboundSetEntityMotionPacketAccessor.java delete mode 100644 src/main/java/me/retucio/sputnik/mixin/accessors/ConfirmServerResourcePackScreenAccessor.java delete mode 100644 src/main/java/me/retucio/sputnik/mixin/accessors/EntityVelocityUpdateS2CPacketAccessor.java delete mode 100644 src/main/java/me/retucio/sputnik/mixin/accessors/FishingBobberEntityAccessor.java create mode 100644 src/main/java/me/retucio/sputnik/mixin/accessors/FishingHookAccessor.java delete mode 100644 src/main/java/me/retucio/sputnik/mixin/accessors/HandledScreenAccessor.java rename src/main/java/me/retucio/sputnik/mixin/accessors/{StatusEffectInstanceAccessor.java => MobEffectInstanceAccessor.java} (59%) create mode 100644 src/main/java/me/retucio/sputnik/mixin/accessors/PackConfirmScreenAccessor.java rename src/main/java/me/retucio/sputnik/mixin/accessors/{PackAccessor.java => PendingRequestAccessor.java} (50%) rename src/main/java/me/retucio/sputnik/mixin/mixins/entity/{AbstractBoatEntityMixin.java => AbstractBoatMixin.java} (56%) rename src/main/java/me/retucio/sputnik/mixin/mixins/hud/{ChatHudLineConsumerMixin.java => ChatComponentLineConsumerMixin.java} (62%) create mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/hud/ChatComponentMixin.java delete mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/hud/ChatHudInteractableMixin.java delete mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/hud/ChatHudMixin.java create mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/hud/DrawingFocusedGraphicsAccessMixin.java rename src/main/java/me/retucio/sputnik/mixin/mixins/hud/{ChatHudLineVisibleMixin.java => GuiMessageLineMixin.java} (79%) rename src/main/java/me/retucio/sputnik/mixin/mixins/hud/{ChatHudLineMixin.java => GuiMessageMixin.java} (73%) rename src/main/java/me/retucio/sputnik/mixin/mixins/io/{KeyboardMixin.java => KeyboardHandlerMixin.java} (52%) rename src/main/java/me/retucio/sputnik/mixin/mixins/io/{KeyInputMixin.java => KeyboardInputMixin.java} (60%) rename src/main/java/me/retucio/sputnik/mixin/mixins/io/{MouseMixin.java => MouseHandlerMixin.java} (51%) rename src/main/java/me/retucio/sputnik/mixin/mixins/io/{ScreenshotRecorderMixin.java => ScreenshotMixin.java} (53%) rename src/main/java/me/retucio/sputnik/mixin/mixins/misc/{MinecraftClientMixin.java => MinecraftMixin.java} (61%) rename src/main/java/me/retucio/sputnik/mixin/mixins/misc/{GameOptionsMixin.java => OptionsMixin.java} (65%) rename src/main/java/me/retucio/sputnik/mixin/mixins/misc/{StringHelperMixin.java => StringUtilMixin.java} (65%) rename src/main/java/me/retucio/sputnik/mixin/mixins/misc/{Vec3dMixin.java => Vec3Mixin.java} (81%) delete mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/network/ChatInputSuggestorMixin.java create mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/network/ChatListenerMixin.java delete mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/network/ClientCommonNetworkHandlerMixin.java create mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/network/ClientCommonPacketListenerImplMixin.java rename src/main/java/me/retucio/sputnik/mixin/mixins/network/{HandshakeC2SPacketMixin.java => ClientIntentionPacketMixin.java} (65%) rename src/main/java/me/retucio/sputnik/mixin/mixins/network/{ClientPlayNetworkHandlerMixin.java => ClientPacketListenerMixin.java} (64%) create mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/network/ClientTelemetryManagerMixin.java create mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/network/CommandSuggestionsMixin.java rename src/main/java/me/retucio/sputnik/mixin/mixins/network/{ClientConnectionMixin.java => ConnectionMixin.java} (57%) delete mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/network/MessageHandlerMixin.java rename src/main/java/me/retucio/sputnik/mixin/mixins/network/{ServerInfoMixin.java => ServerDataMixin.java} (52%) rename src/main/java/me/retucio/sputnik/mixin/mixins/network/{ResourcePackPolicyMixin.java => ServerPackStatusMixin.java} (69%) delete mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/network/TelemetryManagerMixin.java rename src/main/java/me/retucio/sputnik/mixin/mixins/player/{PlayerInputMixin.java => InputMixin.java} (76%) rename src/main/java/me/retucio/sputnik/mixin/mixins/player/{ClientPlayerEntityMixin.java => LocalPlayerMixin.java} (50%) rename src/main/java/me/retucio/sputnik/mixin/mixins/player/{ClientPlayerInteractionManagerMixin.java => MultiPlayerGameModeMixin.java} (55%) rename src/main/java/me/retucio/sputnik/mixin/mixins/player/{PlayerEntityMixin.java => PlayerMixin.java} (65%) rename src/main/java/me/retucio/sputnik/mixin/mixins/render/{StuckArrowsFeatureRendererMixin.java => ArrowLayerMixin.java} (69%) delete mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/render/BufferStorageMixin.java delete mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/render/CapeFeatureRendererMixin.java create mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/render/CapeLayerMixin.java delete mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/render/ChunkBorderDebugRendererMixin.java create mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/render/ChunkBorderRendererMixin.java delete mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/render/ElytraFeatureRendererMixin.java create mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/render/EquipmentLayerRendererMixin.java delete mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/render/EquipmentRendererMixin.java rename src/main/java/me/retucio/sputnik/mixin/mixins/render/{TextRendererMixin.java => FontMixin.java} (77%) delete mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/render/HeldItemRendererMixin.java delete mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/render/InGameOverlayRendererMixin.java rename src/main/java/me/retucio/sputnik/mixin/mixins/render/{ItemRendererMixin.java => ItemFeatureRendererMixin.java} (53%) create mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/render/ItemInHandRendererMixin.java create mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/render/LevelRendererMixin.java create mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/render/MobEffectFogEnvironmentMixin.java create mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/render/PreparedTextBuilderMixin.java create mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/render/RenderBuffersMixin.java create mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/render/ScreenEffectRendererMixin.java rename src/main/java/me/retucio/sputnik/mixin/mixins/render/{ShaderLoaderMixin.java => ShaderManagerMixin.java} (54%) delete mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/render/StatusEffectFogModifierMixin.java delete mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/render/TextRendererDrawerMixin.java create mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/render/WeatherEffectRendererMixin.java delete mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/render/WeatherRenderingMixin.java create mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/render/WingsLayerMixin.java delete mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/render/WorldRendererMixin.java rename src/main/java/me/retucio/sputnik/mixin/mixins/screen/{CreativeInventoryScreenMixin.java => CreativeModeInventoryScreenMixin.java} (63%) delete mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/world/BlockCollisionSpliteratorMixin.java create mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/world/BlockCollisionsMixin.java rename src/main/java/me/retucio/sputnik/mixin/mixins/world/{ClientWorldPropertiesMixin.java => ClientLevelDataMixin.java} (74%) rename src/main/java/me/retucio/sputnik/mixin/mixins/world/{ClientWorldMixin.java => ClientLevelMixin.java} (79%) create mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/world/CritParticleMixin.java delete mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/world/DamageParticleMixin.java rename src/main/java/me/retucio/sputnik/mixin/mixins/world/{RenderTickCounterDynamicMixin.java => DeltaTrackerTimerMixin.java} (54%) delete mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/world/EmitterParticleMixin.java create mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/world/ParticleEngineMixin.java delete mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/world/ParticleManagerMixin.java create mode 100644 src/main/java/me/retucio/sputnik/mixin/mixins/world/TrackingEmitterMixin.java rename src/main/java/me/retucio/sputnik/mixin/mixins/world/{ChunkOcclusionDataBuilderMixin.java => VisGraphMixin.java} (67%) create mode 100644 src/main/java/me/retucio/sputnik/module/modules/combat/ChestplateSwitch.java create mode 100644 src/main/java/me/retucio/sputnik/util/interfaces/IChatComponent.java delete mode 100644 src/main/java/me/retucio/sputnik/util/interfaces/IChatHud.java rename src/main/java/me/retucio/sputnik/util/interfaces/{IMessageHandler.java => IChatListener.java} (78%) rename src/main/java/me/retucio/sputnik/util/interfaces/{IChatHudLine.java => IGuiMessage.java} (89%) rename src/main/java/me/retucio/sputnik/util/interfaces/{IChatHudLineVisible.java => IGuiMessageLine.java} (69%) rename src/main/java/me/retucio/sputnik/util/interfaces/{IVec3d.java => IVec3.java} (85%) rename src/main/java/me/retucio/sputnik/util/{ => misc}/BlockIterator.java (83%) rename src/main/java/me/retucio/sputnik/util/{ => misc}/Pool.java (95%) rename src/main/java/me/retucio/sputnik/util/{ => misc}/VersionChecker.java (99%) delete mode 100644 src/main/java/me/retucio/sputnik/util/render/GlintRenderLayer.java create mode 100644 src/main/java/me/retucio/sputnik/util/render/GlintRenderType.java delete mode 100644 src/main/java/me/retucio/sputnik/util/render/Layers.java create mode 100644 src/main/java/me/retucio/sputnik/util/render/SputnikRenderTypes.java diff --git a/README.md b/README.md index bf93aec..84f6d0a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # jenny's mod 2 100% real -mod para Minecraft Fabric 1.21.11 que añade algunas cosas QOL, mayormente relacionadas a la cámara. +mod para Minecraft Fabric 26.1 que añade algunas cosas QOL, mayormente relacionadas a la cámara. ## instalación @@ -10,7 +10,7 @@ mod para Minecraft Fabric 1.21.11 que añade algunas cosas QOL, mayormente relac 3. descargar el .jar 4. moverlo a tu directorio de mods (probablemente `%appdata%/.minecraft/mods`) -asegúrate de tener una version de Minecraft y Fabric compatibles con el mod (MC `1.21.11`; Fabric `0.17.3`) +asegúrate de tener una version de Minecraft y Fabric compatibles con el mod (MC `26.1`; Fabric `0.18.5`) es posible que haya problemas al usarlo junto a otros mods, especialmente junto a otros clientes, pues pueden conflictar entre ellos. ### para frikis de 200 de iq diff --git a/build.gradle b/build.gradle index dbd6be7..b22ce32 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version "${loom_version}" + id "net.fabricmc.fabric-loom" version "${loom_version}" id 'maven-publish' } @@ -23,18 +23,15 @@ dependencies { // mc minecraft "com.mojang:minecraft:${project.minecraft_version}" - // mappings - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" - // fabric & su api - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}" + implementation "net.fabricmc:fabric-loader:${project.loader_version}" + implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}" // sistema de eventos - include(modImplementation "com.github.retuci0:neutrino:${project.neutrino_version}") + include(implementation "com.github.retuci0:neutrino:${project.neutrino_version}") // rpc de discord - include(modImplementation "dev.firstdark.discordrpc:discord-rpc:1.0.3") + include(implementation "dev.firstdark.discordrpc:discord-rpc:1.0.3") } loom { @@ -50,12 +47,12 @@ processResources { } tasks.withType(JavaCompile).configureEach { - it.options.release = 21 + it.options.release = 25 } java { - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 + sourceCompatibility = JavaVersion.VERSION_25 + targetCompatibility = JavaVersion.VERSION_25 } jar { diff --git a/cambios.md b/cambios.md index 8aada33..878c632 100644 --- a/cambios.md +++ b/cambios.md @@ -1,16 +1,18 @@ -# v4.0 +# v4.1 ## novedades +- actualizado a 26.1 + ### adiciones #### módulos nuevos: -- aura de cristales: hace cpvp por ti (muy mejorable, estoy en ello) +- autopechera: equipa una pechera antes de atacar con el mazo ### arreglos / mejoras -- `$echest` ya funciona y tal +- arreglado el cálculo de anchura de los marcos de ajustes para tener en cuenta los botones de los ajustes de colores ## problemas reconocidos diff --git a/gradle.properties b/gradle.properties index a9564b0..63eae7c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,15 +1,14 @@ org.gradle.jvmargs=-Xmx2G org.gradle.parallel=true -minecraft_version=1.21.11 -yarn_mappings=1.21.11+build.3 -loader_version=0.18.4 -loom_version=1.13-SNAPSHOT +minecraft_version=26.1.2 +loader_version=0.19.2 +loom_version=1.16-SNAPSHOT -fabric_api_version=0.140.2+1.21.11 +fabric_api_version=0.146.0+26.1.2 neutrino_version=1.1.0 -mod_version=4.0 +mod_version=4.1 maven_group=me.retucio archives_base_name=sputnik \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ff23a68..dbc3ce4 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/src/main/java/me/retucio/sputnik/Sputnik.java b/src/main/java/me/retucio/sputnik/Sputnik.java index 7511101..4a6585e 100644 --- a/src/main/java/me/retucio/sputnik/Sputnik.java +++ b/src/main/java/me/retucio/sputnik/Sputnik.java @@ -32,6 +32,8 @@ import me.retucio.sputnik.ui.widgets.Button; import me.retucio.sputnik.util.*; import me.retucio.sputnik.util.KeyUtil; +import me.retucio.sputnik.util.misc.BlockIterator; +import me.retucio.sputnik.util.misc.VersionChecker; import me.retucio.sputnik.util.render.DrawUtil; import me.retucio.sputnik.util.render.RenderUtil; @@ -40,13 +42,13 @@ import net.fabricmc.api.ClientModInitializer; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.SharedConstants; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.ChatScreen; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.screen.TitleScreen; -import net.minecraft.client.gui.screen.ingame.AbstractCommandBlockScreen; -import net.minecraft.client.gui.screen.ingame.AbstractSignEditScreen; -import net.minecraft.client.gui.screen.ingame.AnvilScreen; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.ChatScreen; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.gui.screens.TitleScreen; +import net.minecraft.client.gui.screens.inventory.AbstractCommandBlockEditScreen; +import net.minecraft.client.gui.screens.inventory.AbstractSignEditScreen; +import net.minecraft.client.gui.screens.inventory.AnvilScreen; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -60,7 +62,7 @@ public class Sputnik implements ClientModInitializer { public static final EventBus EVENT_BUS = new EventBus(); public static final Logger LOGGER = LogManager.getLogger(Sputnik.class); public static final long LAUNCH_TIME = System.currentTimeMillis(); - public static MinecraftClient mc; + public static Minecraft mc; // id y versión public static final String MOD_ID = "sputnik"; @@ -81,7 +83,7 @@ public class Sputnik implements ClientModInitializer { @Override public void onInitializeClient() { - mc = MinecraftClient.getInstance(); + mc = Minecraft.getInstance(); ConfigManager.load(); VersionChecker.check(); @@ -99,7 +101,6 @@ public class Sputnik implements ClientModInitializer { EVENT_BUS.subscribe(BlockIterator.class); Lists.init(); - Textures.init(); CapeManager.INSTANCE = new CapeManager(); EVENT_BUS.post(new LoadCapeManagerEvent()); @@ -110,11 +111,13 @@ public class Sputnik implements ClientModInitializer { CommandManager.INSTANCE = new CommandManager(); EVENT_BUS.post(new LoadCommandManagerEvent()); - ClickGUI.INSTANCE = new ClickGUI(); - HudEditorScreen.INSTANCE = new HudEditorScreen(); - EVENT_BUS.post(new LoadClickGUIEvent()); - - mc.execute(HudRenderer::init); + mc.execute(() -> { + Textures.init(); + ClickGUI.INSTANCE = new ClickGUI(); + HudEditorScreen.INSTANCE = new HudEditorScreen(); + EVENT_BUS.post(new LoadClickGUIEvent()); + HudRenderer.init(); + }); Runtime.getRuntime().addShutdownHook(new Thread(() -> { EVENT_BUS.post(new ShutdownEvent()); @@ -169,7 +172,7 @@ public class Sputnik implements ClientModInitializer { // se ocupa de la lógica de encendido y apagado de los módulos private void handleModuleToggle(int key, boolean anyFocused) { - if (mc.currentScreen != null && mc.currentScreen != ClickGUI.INSTANCE) return; + if (mc.screen != null && mc.screen != ClickGUI.INSTANCE) return; for (Module module : ModuleManager.INSTANCE.getModules()) { if (key != module.getKey() || anyFocused || KeyUtil.isKeyDown(GLFW.GLFW_KEY_F3)) continue; // evitar interrumpir combinaciones de teclas del F3 @@ -196,11 +199,11 @@ public class Sputnik implements ClientModInitializer { if (key != ClientSettingsFrame.guiSettings.getKey() || anyFocused || isOnTypingScreen()) return; - if (mc.currentScreen != ClickGUI.INSTANCE) { - prevScreen = mc.currentScreen; + if (mc.screen != ClickGUI.INSTANCE) { + prevScreen = mc.screen; mc.setScreen(ClickGUI.INSTANCE); } else { - ClickGUI.INSTANCE.close(); + ClickGUI.INSTANCE.onClose(); mc.setScreen(prevScreen); } } @@ -210,22 +213,22 @@ public class Sputnik implements ClientModInitializer { HUD hud = ModuleManager.INSTANCE.getModuleByClass(HUD.class); if (key != hud.editorKey.getValue() || anyFocused || isOnTypingScreen()) return; - if (mc.currentScreen != HudEditorScreen.INSTANCE) { + if (mc.screen != HudEditorScreen.INSTANCE) { if (!hud.isEnabled()) { ChatUtil.warn("HUD está desactivado, lumbreras"); return; } - prevScreen = mc.currentScreen; + prevScreen = mc.screen; mc.setScreen(HudEditorScreen.INSTANCE); } else { - HudEditorScreen.INSTANCE.close(); + HudEditorScreen.INSTANCE.onClose(); mc.setScreen(prevScreen); } } // se ocupa de apagar los módulos que tengan configurado hacerlo tras soltar su tecla private void handleModuleRelease(int key) { - if (mc.currentScreen != null && mc.currentScreen != ClickGUI.INSTANCE) return; + if (mc.screen != null && mc.screen != ClickGUI.INSTANCE) return; for (Module module : ModuleManager.INSTANCE.getEnabledModules()) if (module.shouldToggleOnBindRelease() && key == module.getKey()) @@ -233,10 +236,10 @@ public class Sputnik implements ClientModInitializer { } private boolean isOnTypingScreen() { - return mc.currentScreen instanceof ChatScreen - || mc.currentScreen instanceof AnvilScreen - || mc.currentScreen instanceof AbstractSignEditScreen - || mc.currentScreen instanceof AbstractCommandBlockScreen; + return mc.screen instanceof ChatScreen + || mc.screen instanceof AnvilScreen + || mc.screen instanceof AbstractSignEditScreen + || mc.screen instanceof AbstractCommandBlockEditScreen; } @EventListener @@ -245,7 +248,7 @@ public class Sputnik implements ClientModInitializer { if (VersionChecker.shouldShowScreen && event.getScreen() instanceof TitleScreen) { event.cancel(); VersionChecker.shouldShowScreen = false; - mc.execute(() -> mc.currentScreen = new UpdateScreen()); + mc.execute(() -> mc.screen = new UpdateScreen()); } } @@ -255,6 +258,6 @@ public class Sputnik implements ClientModInitializer { } public static String getVersionName() { - return MOD_ID + "_v" + MOD_VERSION + "_" + SharedConstants.getGameVersion().name(); + return MOD_ID + "_v" + MOD_VERSION + "_" + SharedConstants.getCurrentVersion().name(); } } \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/cape/Cape.java b/src/main/java/me/retucio/sputnik/cape/Cape.java index 7377cad..78e325e 100644 --- a/src/main/java/me/retucio/sputnik/cape/Cape.java +++ b/src/main/java/me/retucio/sputnik/cape/Cape.java @@ -1,26 +1,27 @@ package me.retucio.sputnik.cape; import me.retucio.sputnik.Sputnik; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.texture.NativeImage; -import net.minecraft.client.texture.NativeImageBackedTexture; -import net.minecraft.util.Identifier; +import net.minecraft.client.Minecraft; +import com.mojang.blaze3d.platform.NativeImage; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.client.renderer.texture.ReloadableTexture; +import net.minecraft.resources.Identifier; import java.io.IOException; import java.io.InputStream; public class Cape { - private final MinecraftClient mc = MinecraftClient.getInstance(); + private final Minecraft mc = Minecraft.getInstance(); private final String name; private final Identifier id; private NativeImage img; - private NativeImageBackedTexture texture; + private DynamicTexture texture; public Cape(String name) { this.name = name; - this.id = Identifier.of(Sputnik.MOD_ID, "textures/capes/" + name + ".png"); + this.id = Identifier.fromNamespaceAndPath(Sputnik.MOD_ID, "textures/capes/" + name + ".png"); } public void load() { @@ -28,7 +29,7 @@ public class Cape { } public NativeImage loadTexture(Identifier id) { - try (InputStream inputStream = mc.getResourceManager().getResource(id).get().getInputStream()) { + try (InputStream inputStream = mc.getResourceManager().getResource(id).get().open()) { return NativeImage.read(inputStream); } catch (IOException e) { Sputnik.LOGGER.error("ups: {}", e.getMessage()); @@ -37,8 +38,8 @@ public class Cape { } public void register() { - texture = new NativeImageBackedTexture(null, img); - mc.getTextureManager().registerTexture(id, texture); + texture = new DynamicTexture(null, img); + mc.getTextureManager().register(id, texture); img = null; } @@ -50,7 +51,7 @@ public class Cape { return id; } - public NativeImageBackedTexture getTexture() { + public DynamicTexture getTexture() { return texture; } diff --git a/src/main/java/me/retucio/sputnik/command/Command.java b/src/main/java/me/retucio/sputnik/command/Command.java index 4cb4248..4b2a488 100644 --- a/src/main/java/me/retucio/sputnik/command/Command.java +++ b/src/main/java/me/retucio/sputnik/command/Command.java @@ -4,21 +4,21 @@ import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.ArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.builder.RequiredArgumentBuilder; -import net.minecraft.client.MinecraftClient; -import net.minecraft.command.CommandRegistryAccess; -import net.minecraft.command.CommandSource; -import net.minecraft.registry.BuiltinRegistries; -import net.minecraft.server.command.CommandManager; +import net.minecraft.client.Minecraft; +import net.minecraft.commands.CommandBuildContext; +import net.minecraft.commands.Commands; +import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.data.registries.VanillaRegistries; import java.util.List; public abstract class Command { // utilizar los "registries" ya existentes de Brigadier para el autocompletado - protected static final CommandRegistryAccess REGISTRY_ACCESS = CommandManager.createRegistryAccess(BuiltinRegistries.createWrapperLookup()); + protected static final CommandBuildContext REGISTRY_ACCESS = Commands.createValidationContext(VanillaRegistries.createLookup()); protected static final int SUCCESS = com.mojang.brigadier.Command.SINGLE_SUCCESS; - protected static final MinecraftClient mc = MinecraftClient.getInstance(); + protected static final Minecraft mc = Minecraft.getInstance(); private final String name, description; private final List aliases; @@ -30,27 +30,27 @@ public abstract class Command { } // métodos "helper" para reducir el "boilerplate" - protected static RequiredArgumentBuilder argument(final String name, final ArgumentType type) { + protected static RequiredArgumentBuilder argument(final String name, final ArgumentType type) { return RequiredArgumentBuilder.argument(name, type); } - protected static LiteralArgumentBuilder literal(final String name) { + protected static LiteralArgumentBuilder literal(final String name) { return LiteralArgumentBuilder.literal(name); } // para registrar comandos - public final void registerTo(CommandDispatcher dispatcher) { + public final void registerTo(CommandDispatcher dispatcher) { register(dispatcher, name); for (String alias : aliases) register(dispatcher, alias); } - public void register(CommandDispatcher dispatcher, String name) { - LiteralArgumentBuilder builder = LiteralArgumentBuilder.literal(name); + public void register(CommandDispatcher dispatcher, String name) { + LiteralArgumentBuilder builder = LiteralArgumentBuilder.literal(name); build(builder); dispatcher.register(builder); } - public abstract void build(LiteralArgumentBuilder builder); + public abstract void build(LiteralArgumentBuilder builder); public String getName() { return name; diff --git a/src/main/java/me/retucio/sputnik/command/CommandManager.java b/src/main/java/me/retucio/sputnik/command/CommandManager.java index a4cfb65..8f4efeb 100644 --- a/src/main/java/me/retucio/sputnik/command/CommandManager.java +++ b/src/main/java/me/retucio/sputnik/command/CommandManager.java @@ -5,8 +5,8 @@ import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.exceptions.CommandSyntaxException; import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.command.commands.*; -import net.minecraft.client.MinecraftClient; -import net.minecraft.command.CommandSource; +import net.minecraft.client.Minecraft; +import net.minecraft.commands.SharedSuggestionProvider; import java.lang.reflect.Method; import java.util.ArrayList; @@ -22,9 +22,9 @@ public class CommandManager { private String prefix = "$"; public static final List commands = new ArrayList<>(); - public static final CommandDispatcher dispatcher = new CommandDispatcher<>(); + public static final CommandDispatcher dispatcher = new CommandDispatcher<>(); - private static final MinecraftClient mc = MinecraftClient.getInstance(); + private static final Minecraft mc = Minecraft.getInstance(); public CommandManager() { registerCommands(); @@ -68,7 +68,7 @@ public class CommandManager { } public static void dispatch(String message) throws CommandSyntaxException { - dispatcher.execute(message, Objects.requireNonNull(mc.getNetworkHandler()).getCommandSource()); + dispatcher.execute(message, Objects.requireNonNull(mc.getConnection()).getSuggestionsProvider()); } public static Command getCommandByName(String name) { diff --git a/src/main/java/me/retucio/sputnik/command/args/EntityArgumentType.java b/src/main/java/me/retucio/sputnik/command/args/EntityArgumentType.java index 5c17ce7..ac762a3 100644 --- a/src/main/java/me/retucio/sputnik/command/args/EntityArgumentType.java +++ b/src/main/java/me/retucio/sputnik/command/args/EntityArgumentType.java @@ -9,9 +9,9 @@ import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; import me.retucio.sputnik.util.EntityUtil; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.text.Text; +import net.minecraft.network.chat.Component; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; import java.util.*; import java.util.concurrent.CompletableFuture; @@ -25,7 +25,7 @@ public class EntityArgumentType implements ArgumentType { public static final EntityArgumentType INSTANCE = new EntityArgumentType(); private static final DynamicCommandExceptionType NO_SUCH_ENTITY = new DynamicCommandExceptionType( - name -> Text.literal("Entidad \"" + name + "\" no encontrada")); + name -> Component.literal("Entidad \"" + name + "\" no encontrada")); private static final Collection EXAMPLES = List.of( "AdlerHitdolf", @@ -42,7 +42,7 @@ public class EntityArgumentType implements ArgumentType { public Entity parse(StringReader reader) throws CommandSyntaxException { String argument = reader.readString(); - if (mc.world == null) + if (mc.level == null) throw NO_SUCH_ENTITY.create(argument); if (argument.startsWith("@")) @@ -83,13 +83,13 @@ public class EntityArgumentType implements ArgumentType { } private Entity findNearestPlayer() throws CommandSyntaxException { - PlayerEntity nearest = null; + Player nearest = null; double nearestDistance = Double.MAX_VALUE; - for (PlayerEntity player : mc.world.getPlayers()) { + for (Player player : mc.level.players()) { if (player == mc.player) continue; - double distance = mc.player.squaredDistanceTo(player); + double distance = mc.player.distanceToSqr(player); if (distance < nearestDistance) { nearestDistance = distance; nearest = player; @@ -103,7 +103,7 @@ public class EntityArgumentType implements ArgumentType { } private Entity findRandomPlayer() throws CommandSyntaxException { - List players = new ArrayList<>(mc.world.getPlayers()); + List players = new ArrayList<>(mc.level.players()); if (players.isEmpty()) throw NO_SUCH_ENTITY.create("@r"); players.remove(mc.player); @@ -116,8 +116,8 @@ public class EntityArgumentType implements ArgumentType { private Entity parseEntitySelector(String selector) throws CommandSyntaxException { if (selector.equals("@e")) { List entities = new ArrayList<>(); - for (Entity entity : mc.world.getEntities()) - if (!(entity instanceof PlayerEntity)) + for (Entity entity : mc.level.getEntities().getAll()) + if (!(entity instanceof Player)) entities.add(entity); if (entities.isEmpty()) throw NO_SUCH_ENTITY.create(selector); @@ -141,8 +141,8 @@ public class EntityArgumentType implements ArgumentType { private Entity findEntityByType(String type) throws CommandSyntaxException { List matchingEntities = new ArrayList<>(); - for (Entity entity : mc.world.getEntities()) { - String entityType = entity.getType().getTranslationKey(); + for (Entity entity : mc.level.getEntities().getAll()) { + String entityType = entity.getType().getDescriptionId(); if (entityType.contains(type.toLowerCase().replace("minecraft:", ""))) matchingEntities.add(entity); } @@ -153,7 +153,7 @@ public class EntityArgumentType implements ArgumentType { double nearestDistance = Double.MAX_VALUE; for (Entity entity : matchingEntities) { - double distance = mc.player.squaredDistanceTo(entity); + double distance = mc.player.distanceToSqr(entity); if (distance < nearestDistance) { nearestDistance = distance; nearest = entity; @@ -164,15 +164,15 @@ public class EntityArgumentType implements ArgumentType { } private Entity findEntityByUUID(UUID uuid) throws CommandSyntaxException { - for (Entity entity : mc.world.getEntities()) - if (entity.getUuid().equals(uuid)) + for (Entity entity : mc.level.getEntities().getAll()) + if (entity.getUUID().equals(uuid)) return entity; throw NO_SUCH_ENTITY.create(uuid.toString()); } - private PlayerEntity findPlayerByName(String name) throws CommandSyntaxException { - for (PlayerEntity player : mc.world.getPlayers()) + private Player findPlayerByName(String name) throws CommandSyntaxException { + for (Player player : mc.level.players()) if (player.getName().getString().equalsIgnoreCase(name)) return player; @@ -181,8 +181,8 @@ public class EntityArgumentType implements ArgumentType { @Override public CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder builder) { - if (mc.world != null) - for (PlayerEntity player : mc.world.getPlayers()) + if (mc.level != null) + for (Player player : mc.level.players()) builder.suggest(player.getName().getString()); @@ -192,7 +192,7 @@ public class EntityArgumentType implements ArgumentType { Entity lookingAt = EntityUtil.getEntityPlayerIsLookingAt(); if (lookingAt != null) - builder.suggest(lookingAt.getUuid().toString()); + builder.suggest(lookingAt.getUUID().toString()); return builder.buildFuture(); } diff --git a/src/main/java/me/retucio/sputnik/command/args/EnumArgumentType.java b/src/main/java/me/retucio/sputnik/command/args/EnumArgumentType.java index a44ae0e..a822d67 100644 --- a/src/main/java/me/retucio/sputnik/command/args/EnumArgumentType.java +++ b/src/main/java/me/retucio/sputnik/command/args/EnumArgumentType.java @@ -7,15 +7,15 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; -import net.minecraft.command.CommandSource; -import net.minecraft.text.Text; +import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.network.chat.Component; import java.util.Arrays; import java.util.concurrent.CompletableFuture; public class EnumArgumentType> implements ArgumentType { - private static final DynamicCommandExceptionType NO_SUCH_TYPE = new DynamicCommandExceptionType((value) -> Text.of(" argumento inválido: " + value)); + private static final DynamicCommandExceptionType NO_SUCH_TYPE = new DynamicCommandExceptionType((value) -> Component.nullToEmpty(" argumento inválido: " + value)); private final T[] values; @@ -41,6 +41,6 @@ public class EnumArgumentType> implements ArgumentType { } public CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder builder) { - return CommandSource.suggestMatching(Arrays.stream(this.values).map(e -> e.toString().toLowerCase()), builder); + return SharedSuggestionProvider.suggest(Arrays.stream(this.values).map(e -> e.toString().toLowerCase()), builder); } } \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/command/args/ModuleArgumentType.java b/src/main/java/me/retucio/sputnik/command/args/ModuleArgumentType.java index a22213b..b8c7e75 100644 --- a/src/main/java/me/retucio/sputnik/command/args/ModuleArgumentType.java +++ b/src/main/java/me/retucio/sputnik/command/args/ModuleArgumentType.java @@ -10,8 +10,8 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.util.MiscUtil; -import net.minecraft.command.CommandSource; -import net.minecraft.text.Text; +import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.network.chat.Component; import java.util.Collection; import java.util.concurrent.CompletableFuture; @@ -22,7 +22,7 @@ public class ModuleArgumentType implements ArgumentType { public static final ModuleArgumentType INSTANCE = new ModuleArgumentType(); private static final DynamicCommandExceptionType UNKNOWN_MODULE = new DynamicCommandExceptionType( - name -> Text.literal("módulo \"" + name + "\" no encontrado")); + name -> Component.literal("módulo \"" + name + "\" no encontrado")); private static final Collection examples = ModuleManager.INSTANCE.getModules() .stream().limit(3).map(module -> module.getName().replace(" ", "_")).toList(); @@ -37,7 +37,7 @@ public class ModuleArgumentType implements ArgumentType { @Override public CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder builder) { - return CommandSource.suggestMatching(ModuleManager.INSTANCE.getModules() + return SharedSuggestionProvider.suggest(ModuleManager.INSTANCE.getModules() .stream().map(module -> MiscUtil.removeAccentMarks(module.getName().replace(" ", "_"))), builder); } @@ -46,7 +46,7 @@ public class ModuleArgumentType implements ArgumentType { return examples; } - public static Module get(CommandContext ctx) { + public static Module get(CommandContext ctx) { return ctx.getArgument("módulo", Module.class); } } diff --git a/src/main/java/me/retucio/sputnik/command/args/PlayerArgumentType.java b/src/main/java/me/retucio/sputnik/command/args/PlayerArgumentType.java index be26538..216be95 100644 --- a/src/main/java/me/retucio/sputnik/command/args/PlayerArgumentType.java +++ b/src/main/java/me/retucio/sputnik/command/args/PlayerArgumentType.java @@ -7,9 +7,9 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; -import net.minecraft.command.CommandSource; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.text.Text; +import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.network.chat.Component; +import net.minecraft.world.entity.player.Player; import java.util.Collection; import java.util.List; @@ -18,21 +18,21 @@ import java.util.concurrent.CompletableFuture; import static me.retucio.sputnik.Sputnik.mc; // para autocompletar nombres de jugadores -public class PlayerArgumentType implements ArgumentType { +public class PlayerArgumentType implements ArgumentType { public static final PlayerArgumentType INSTANCE = new PlayerArgumentType(); - private static final DynamicCommandExceptionType NO_SUCH_PLAYER = new DynamicCommandExceptionType(name -> Text.literal("Player with name " + name + " doesn't exist.")); + private static final DynamicCommandExceptionType NO_SUCH_PLAYER = new DynamicCommandExceptionType(name -> Component.literal("Player with name " + name + " doesn't exist.")); private static final Collection EXAMPLES = List.of("retucio", "prepucio", "postpucio", "pucio", "adler hitdolf"); private PlayerArgumentType() {} @Override - public PlayerEntity parse(StringReader reader) throws CommandSyntaxException { + public Player parse(StringReader reader) throws CommandSyntaxException { String argument = reader.readString(); - PlayerEntity playerEntity = null; + Player playerEntity = null; - for (PlayerEntity p : mc.world.getPlayers()) + for (Player p : mc.level.players()) if (p.getName().getString().equalsIgnoreCase(argument)) { playerEntity = p; break; @@ -45,7 +45,7 @@ public class PlayerArgumentType implements ArgumentType { @Override public CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder builder) { - return CommandSource.suggestMatching(mc.world.getPlayers().stream().map( + return SharedSuggestionProvider.suggest(mc.level.players().stream().map( abstractClientPlayerEntity -> abstractClientPlayerEntity.getName().getString()), builder); } @@ -54,8 +54,8 @@ public class PlayerArgumentType implements ArgumentType { return EXAMPLES; } - public static PlayerEntity get(CommandContext context) { - return context.getArgument("jugador", PlayerEntity.class); + public static Player get(CommandContext context) { + return context.getArgument("jugador", Player.class); } } \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/command/commands/BindCommand.java b/src/main/java/me/retucio/sputnik/command/commands/BindCommand.java index 3b1be55..71705b6 100644 --- a/src/main/java/me/retucio/sputnik/command/commands/BindCommand.java +++ b/src/main/java/me/retucio/sputnik/command/commands/BindCommand.java @@ -8,14 +8,13 @@ import me.retucio.sputnik.module.setting.settings.KeySetting; import me.retucio.sputnik.ui.widgets.frames.settings.ClientSettingsFrame; import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.KeyUtil; -import net.minecraft.client.input.KeyInput; -import net.minecraft.client.option.KeyBinding; -import net.minecraft.client.resource.language.I18n; -import net.minecraft.command.CommandSource; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; +import net.minecraft.client.KeyMapping; +import net.minecraft.client.input.KeyEvent; +import net.minecraft.client.resources.language.I18n; +import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.network.chat.Component; -import javax.swing.text.JTextComponent; import java.util.ArrayList; import java.util.List; @@ -29,19 +28,20 @@ public class BindCommand extends Command { } @Override - public void build(LiteralArgumentBuilder builder) { + public void build(LiteralArgumentBuilder builder) { builder .then(argument("módulo", ModuleArgumentType.INSTANCE) .executes(ctx -> { Module module = ctx.getArgument("módulo", Module.class); listeningModule = module; - ChatUtil.info("presiona una tecla para asignarla al módulo " + Formatting.GREEN + module.getName()); + ChatUtil.info("presiona una tecla para asignarla al módulo " + ChatFormatting.GREEN + module.getName()); return SUCCESS; }) .then(literal("reset").executes(ctx -> { Module module = ctx.getArgument("módulo", Module.class); module.getBind().reset(); - ChatUtil.info("tecla para el módulo " + Formatting.GREEN + module.getName() + " restablecida a " + Formatting.AQUA + KeyUtil.getKeyName(module.getKey())); + ChatUtil.info("tecla para el módulo " + ChatFormatting.GREEN + module.getName() + + " restablecida a " + ChatFormatting.AQUA + KeyUtil.getKeyName(module.getKey())); return SUCCESS; })) ); @@ -52,16 +52,16 @@ public class BindCommand extends Command { KeySetting bind = listeningModule.getBind(); if (ClientSettingsFrame.guiSettings.multipleKeybinds.getValue()) { - List keys = new ArrayList<>(List.of(mc.options.allKeys)); + List keys = new ArrayList<>(List.of(mc.options.keyMappings)); keys.removeAll(List.of(mc.options.debugKeys)); - for (KeyBinding kb : keys) { - boolean keyAlreadyBound = kb.matchesKey(new KeyInput(key, 0, 0)); + for (KeyMapping kb : keys) { + boolean keyAlreadyBound = kb.matches(new KeyEvent(key, 0, 0)); boolean allowMultiple = ClientSettingsFrame.guiSettings.multipleKeybinds.getValue(); if (keyAlreadyBound && !allowMultiple) { ChatUtil.warn("esa tecla ya está cogida por " - + Formatting.GREEN + "\"" + I18n.translate(kb.getId()) + "\""); + + ChatFormatting.GREEN + "\"" + I18n.get(kb.getName() + "\"")); listeningModule = null; return true; } @@ -71,8 +71,8 @@ public class BindCommand extends Command { if (bind != null) bind.setValue(key); ChatUtil.info( - Text.of("la tecla " + Formatting.AQUA + KeyUtil.getKeyName(key) + Formatting.RESET + - " ha sido asignada al módulo " + Formatting.GREEN + listeningModule.getName()) + Component.nullToEmpty("la tecla " + ChatFormatting.AQUA + KeyUtil.getKeyName(key) + ChatFormatting.RESET + + " ha sido asignada al módulo " + ChatFormatting.GREEN + listeningModule.getName()) ); listeningModule = null; diff --git a/src/main/java/me/retucio/sputnik/command/commands/ClickSlotCommand.java b/src/main/java/me/retucio/sputnik/command/commands/ClickSlotCommand.java index 8f4c704..a6aef02 100644 --- a/src/main/java/me/retucio/sputnik/command/commands/ClickSlotCommand.java +++ b/src/main/java/me/retucio/sputnik/command/commands/ClickSlotCommand.java @@ -4,10 +4,10 @@ import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import me.retucio.sputnik.command.Command; import me.retucio.sputnik.command.args.EnumArgumentType; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.screen.ingame.GenericContainerScreen; -import net.minecraft.command.CommandSource; -import net.minecraft.screen.slot.SlotActionType; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.gui.screens.inventory.ContainerScreen; +import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.world.inventory.ContainerInput; // https://cdn.discordapp.com/attachments/1456079799045980400/1457154232737206375/dupersunited-public-addon-1.21.11-3.1.3.jar?ex=69735be1&is=69720a61&hm=77fb6faee49762e0a812661f0d98931e89cb725db711c45722249d0efe3b91e4& public class ClickSlotCommand extends Command { @@ -16,16 +16,17 @@ public class ClickSlotCommand extends Command { super("clickslot", "simula un clic a un slot"); } - public void build(LiteralArgumentBuilder builder) { + public void build(LiteralArgumentBuilder builder) { builder.then(argument("slot", IntegerArgumentType.integer()) .then(argument("botón", IntegerArgumentType.integer()) - .then(argument("acción", EnumArgumentType.enumArgument(SlotActionType.SWAP)) + .then(argument("acción", EnumArgumentType.enumArgument(ContainerInput.SWAP)) .executes(context -> { int slot = context.getArgument("slot", Integer.class), button = context.getArgument("botón", Integer.class); - SlotActionType action = context.getArgument("acción", SlotActionType.class); - Screen screen = mc.currentScreen; - int syncId = (screen instanceof GenericContainerScreen gcScreen) ? gcScreen.getScreenHandler().syncId : 0; - mc.interactionManager.clickSlot(syncId, slot, button, action, mc.player); + ContainerInput action = context.getArgument("acción", ContainerInput.class); + Screen screen = mc.screen; + int syncId = (screen instanceof ContainerScreen cScreen) ? cScreen.getMenu().containerId : 0; + if (mc.gameMode == null) return 0; + mc.gameMode.handleContainerInput(syncId, slot, button, action, mc.player); return SUCCESS; }) ) diff --git a/src/main/java/me/retucio/sputnik/command/commands/ConfigCommand.java b/src/main/java/me/retucio/sputnik/command/commands/ConfigCommand.java index 9b80d5a..a4673bc 100644 --- a/src/main/java/me/retucio/sputnik/command/commands/ConfigCommand.java +++ b/src/main/java/me/retucio/sputnik/command/commands/ConfigCommand.java @@ -7,7 +7,7 @@ import me.retucio.sputnik.command.Command; import me.retucio.sputnik.command.args.ModuleArgumentType; import me.retucio.sputnik.ui.screen.ClickGUI; import me.retucio.sputnik.ui.widgets.frames.SettingsFrame; -import net.minecraft.command.CommandSource; +import net.minecraft.commands.SharedSuggestionProvider; import me.retucio.sputnik.module.Module; public class ConfigCommand extends Command { @@ -17,7 +17,7 @@ public class ConfigCommand extends Command { } @Override - public void build(LiteralArgumentBuilder builder) { + public void build(LiteralArgumentBuilder builder) { builder .then(argument("módulo", ModuleArgumentType.INSTANCE) .executes(ctx -> { @@ -38,20 +38,20 @@ public class ConfigCommand extends Command { } - private void openSf(CommandContext ctx) { + private void openSf(CommandContext ctx) { Module module = ctx.getArgument("módulo", Module.class); mc.setScreen(ClickGUI.INSTANCE); if (ClickGUI.INSTANCE.isSettingsFrameOpen(module)) return; SettingsFrame sf = ClickGUI.INSTANCE.getSfOfModule(module); - int x = mc.getWindow().getScaledWidth() / 2 - sf.getW() / 2; + int x = mc.getWindow().getGuiScaledWidth() / 2 - sf.getW() / 2; int y = 67; ClickGUI.INSTANCE.openSettingsFrame(module, x, y); } - private void openSfWithPos(CommandContext ctx, int x, int y) { + private void openSfWithPos(CommandContext ctx, int x, int y) { Module module = ctx.getArgument("módulo", Module.class); mc.setScreen(ClickGUI.INSTANCE); diff --git a/src/main/java/me/retucio/sputnik/command/commands/CopyScreenshotCommand.java b/src/main/java/me/retucio/sputnik/command/commands/CopyScreenshotCommand.java index cb91fdc..53c2fc1 100644 --- a/src/main/java/me/retucio/sputnik/command/commands/CopyScreenshotCommand.java +++ b/src/main/java/me/retucio/sputnik/command/commands/CopyScreenshotCommand.java @@ -4,7 +4,7 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder; import me.retucio.sputnik.command.Command; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.misc.ScreenshotPlus; -import net.minecraft.command.CommandSource; +import net.minecraft.commands.SharedSuggestionProvider; // se usa principalmente para el módulo ScreenshotPlus, pero también se puede usar sin él supongo public class CopyScreenshotCommand extends Command { @@ -14,7 +14,7 @@ public class CopyScreenshotCommand extends Command { } @Override - public void build(LiteralArgumentBuilder builder) { + public void build(LiteralArgumentBuilder builder) { builder.executes(ctx -> { ScreenshotPlus screenshotPlus = ModuleManager.INSTANCE.getModuleByClass(ScreenshotPlus.class); diff --git a/src/main/java/me/retucio/sputnik/command/commands/EnderChestCommand.java b/src/main/java/me/retucio/sputnik/command/commands/EnderChestCommand.java index 6b23fbc..2a74122 100644 --- a/src/main/java/me/retucio/sputnik/command/commands/EnderChestCommand.java +++ b/src/main/java/me/retucio/sputnik/command/commands/EnderChestCommand.java @@ -7,7 +7,7 @@ import me.retucio.sputnik.event.TickEvent; import me.retucio.sputnik.ui.screen.PreviewScreen; import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.InventoryUtil; -import net.minecraft.command.CommandSource; +import net.minecraft.commands.SharedSuggestionProvider; // accede a los contenidos de tu enderchest public class EnderChestCommand extends Command { @@ -19,7 +19,7 @@ public class EnderChestCommand extends Command { } @Override - public void build(LiteralArgumentBuilder builder) { + public void build(LiteralArgumentBuilder builder) { builder.executes(ctx -> { mc.execute(() -> { if (mc.player == null) return; diff --git a/src/main/java/me/retucio/sputnik/command/commands/GarbageCleanerCommand.java b/src/main/java/me/retucio/sputnik/command/commands/GarbageCleanerCommand.java index 9e73081..d168ddd 100644 --- a/src/main/java/me/retucio/sputnik/command/commands/GarbageCleanerCommand.java +++ b/src/main/java/me/retucio/sputnik/command/commands/GarbageCleanerCommand.java @@ -3,8 +3,8 @@ package me.retucio.sputnik.command.commands; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import me.retucio.sputnik.command.Command; import me.retucio.sputnik.util.ChatUtil; -import net.minecraft.command.CommandSource; -import net.minecraft.text.Text; +import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.network.chat.Component; public class GarbageCleanerCommand extends Command { @@ -13,10 +13,10 @@ public class GarbageCleanerCommand extends Command { } @Override - public void build(LiteralArgumentBuilder builder) { + public void build(LiteralArgumentBuilder builder) { builder.executes(context -> { System.gc(); - ChatUtil.info(Text.of("basura recolectada")); + ChatUtil.info(Component.nullToEmpty("basura recolectada")); return SUCCESS; }); } diff --git a/src/main/java/me/retucio/sputnik/command/commands/PeekCommand.java b/src/main/java/me/retucio/sputnik/command/commands/PeekCommand.java index e717daf..fb2827b 100644 --- a/src/main/java/me/retucio/sputnik/command/commands/PeekCommand.java +++ b/src/main/java/me/retucio/sputnik/command/commands/PeekCommand.java @@ -4,8 +4,8 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder; import me.retucio.sputnik.command.Command; import me.retucio.sputnik.command.args.PlayerArgumentType; import me.retucio.sputnik.util.MiscUtil; -import net.minecraft.client.gui.screen.ingame.InventoryScreen; -import net.minecraft.command.CommandSource; +import net.minecraft.client.gui.screens.inventory.InventoryScreen; +import net.minecraft.commands.SharedSuggestionProvider; // comando que debería de mostrar el inventario de un jugador, pero por cómo funcionan los servers, solo te deja ver el ítem que tenga en la mano public class PeekCommand extends Command { @@ -15,7 +15,7 @@ public class PeekCommand extends Command { } @Override - public void build(LiteralArgumentBuilder builder) { + public void build(LiteralArgumentBuilder builder) { builder .then(argument("jugador", PlayerArgumentType.INSTANCE) .executes(ctx -> { diff --git a/src/main/java/me/retucio/sputnik/command/commands/PluginsCommand.java b/src/main/java/me/retucio/sputnik/command/commands/PluginsCommand.java index 044fc32..cbaf3f5 100644 --- a/src/main/java/me/retucio/sputnik/command/commands/PluginsCommand.java +++ b/src/main/java/me/retucio/sputnik/command/commands/PluginsCommand.java @@ -9,10 +9,10 @@ import me.retucio.sputnik.command.Command; import me.retucio.sputnik.event.network.PacketEvent; import me.retucio.sputnik.util.ChatUtil; -import net.minecraft.client.network.ClientCommandSource; -import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.command.CommandSource; -import net.minecraft.network.packet.s2c.play.CommandTreeS2CPacket; +import net.minecraft.client.multiplayer.ClientPacketListener; +import net.minecraft.client.multiplayer.ClientSuggestionProvider; +import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.network.protocol.game.ClientboundCommandsPacket; import java.util.HashSet; import java.util.Set; @@ -28,9 +28,9 @@ public class PluginsCommand extends Command { } @Override - public void build(LiteralArgumentBuilder builder) { + public void build(LiteralArgumentBuilder builder) { builder.executes(context -> { - if (mc.isIntegratedServerRunning()) { + if (mc.hasSingleplayerServer()) { ChatUtil.error("estás en un solo jugador"); return SUCCESS; } @@ -51,12 +51,12 @@ public class PluginsCommand extends Command { private void findNamespaces() { try { - ClientPlayNetworkHandler networkHandler = mc.getNetworkHandler(); - if (networkHandler == null || networkHandler.getCommandDispatcher() == null) { + ClientPacketListener networkHandler = mc.getConnection(); + if (networkHandler == null) { return; } - RootCommandNode root = networkHandler.getCommandDispatcher().getRoot(); + RootCommandNode root = networkHandler.getCommands().getRoot(); root.getChildren().forEach(this::checkNodeForPlugins); if (!plugins.isEmpty()) { @@ -73,7 +73,7 @@ public class PluginsCommand extends Command { } } - private void checkNodeForPlugins(CommandNode node) { + private void checkNodeForPlugins(CommandNode node) { String name = node.getName(); if (name.contains(":")) { @@ -92,7 +92,7 @@ public class PluginsCommand extends Command { private void onPacketReceive(PacketEvent.Receive event) { if (!scanning) return; - if (event.getPacket() instanceof CommandTreeS2CPacket) { + if (event.getPacket() instanceof ClientboundCommandsPacket) { findNamespaces(); } } diff --git a/src/main/java/me/retucio/sputnik/command/commands/PrefixCommand.java b/src/main/java/me/retucio/sputnik/command/commands/PrefixCommand.java index b010828..2472515 100644 --- a/src/main/java/me/retucio/sputnik/command/commands/PrefixCommand.java +++ b/src/main/java/me/retucio/sputnik/command/commands/PrefixCommand.java @@ -5,9 +5,9 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder; import me.retucio.sputnik.command.Command; import me.retucio.sputnik.ui.widgets.frames.settings.ClientSettingsFrame; import me.retucio.sputnik.util.ChatUtil; -import net.minecraft.command.CommandSource; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; +import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.network.chat.Component; // también se puede hacer desde los ajustes de la interfaz public class PrefixCommand extends Command { @@ -17,12 +17,12 @@ public class PrefixCommand extends Command { } @Override - public void build(LiteralArgumentBuilder builder) { + public void build(LiteralArgumentBuilder builder) { builder .then(argument("prefijo", StringArgumentType.word()).executes(ctx -> { String prefix = ctx.getArgument("prefijo", String.class); ClientSettingsFrame.guiSettings.commandPrefix.setValue(prefix); - ChatUtil.info(Text.literal("prefijo cambiado a " + Formatting.AQUA + prefix)); + ChatUtil.info(Component.literal("prefijo cambiado a " + ChatFormatting.AQUA + prefix)); return SUCCESS; })); } diff --git a/src/main/java/me/retucio/sputnik/command/commands/PurgeCommand.java b/src/main/java/me/retucio/sputnik/command/commands/PurgeCommand.java index 10d8696..17e171f 100644 --- a/src/main/java/me/retucio/sputnik/command/commands/PurgeCommand.java +++ b/src/main/java/me/retucio/sputnik/command/commands/PurgeCommand.java @@ -3,10 +3,10 @@ package me.retucio.sputnik.command.commands; import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import me.retucio.sputnik.command.Command; -import me.retucio.sputnik.util.interfaces.IChatHud; -import net.minecraft.client.gui.hud.ChatHud; -import net.minecraft.client.gui.hud.ChatHudLine; -import net.minecraft.command.CommandSource; +import me.retucio.sputnik.util.interfaces.IChatComponent; +import net.minecraft.client.gui.components.ChatComponent; +import net.minecraft.client.multiplayer.chat.GuiMessage; +import net.minecraft.commands.SharedSuggestionProvider; import java.util.List; @@ -17,7 +17,7 @@ public class PurgeCommand extends Command { } @Override - public void build(LiteralArgumentBuilder builder) { + public void build(LiteralArgumentBuilder builder) { builder.then(argument("cantidad", IntegerArgumentType.integer(1)) .executes(context -> { int amount = IntegerArgumentType.getInteger(context, "cantidad"); @@ -28,10 +28,10 @@ public class PurgeCommand extends Command { } private void purgeMessages(int amount) { - ChatHud chatHud = mc.inGameHud.getChatHud(); + ChatComponent chatHud = mc.gui.getChat(); synchronized (chatHud) { - List visibleMessages = ((IChatHud) chatHud).sputnik$getVisibleMessages(); + List visibleMessages = ((IChatComponent) chatHud).sputnik$getVisibleMessages(); int toRemove = Math.min(amount, visibleMessages.size()); for (int i = 0; i < toRemove; i++) visibleMessages.removeFirst(); diff --git a/src/main/java/me/retucio/sputnik/command/commands/RepeatCommand.java b/src/main/java/me/retucio/sputnik/command/commands/RepeatCommand.java index 0c85fc3..f23e041 100644 --- a/src/main/java/me/retucio/sputnik/command/commands/RepeatCommand.java +++ b/src/main/java/me/retucio/sputnik/command/commands/RepeatCommand.java @@ -5,7 +5,7 @@ import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import me.retucio.sputnik.command.Command; import me.retucio.sputnik.util.ChatUtil; -import net.minecraft.command.CommandSource; +import net.minecraft.commands.SharedSuggestionProvider; public class RepeatCommand extends Command { @@ -14,7 +14,7 @@ public class RepeatCommand extends Command { } @Override - public void build(LiteralArgumentBuilder builder) { + public void build(LiteralArgumentBuilder builder) { builder .then(argument("veces", IntegerArgumentType.integer(1)) .then(argument("comando", StringArgumentType.greedyString()) diff --git a/src/main/java/me/retucio/sputnik/command/commands/RepeatWaitCommand.java b/src/main/java/me/retucio/sputnik/command/commands/RepeatWaitCommand.java index 6ee6c94..9ca63b3 100644 --- a/src/main/java/me/retucio/sputnik/command/commands/RepeatWaitCommand.java +++ b/src/main/java/me/retucio/sputnik/command/commands/RepeatWaitCommand.java @@ -5,7 +5,7 @@ import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import me.retucio.sputnik.command.Command; import me.retucio.sputnik.util.ChatUtil; -import net.minecraft.command.CommandSource; +import net.minecraft.commands.SharedSuggestionProvider; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; @@ -17,7 +17,7 @@ public class RepeatWaitCommand extends Command { } @Override - public void build(LiteralArgumentBuilder builder) { + public void build(LiteralArgumentBuilder builder) { builder.then(argument("ms", IntegerArgumentType.integer(1)) .then(argument("veces", IntegerArgumentType.integer(1)) .then(argument("comando", StringArgumentType.greedyString()) diff --git a/src/main/java/me/retucio/sputnik/command/commands/SaveScreenshotCommand.java b/src/main/java/me/retucio/sputnik/command/commands/SaveScreenshotCommand.java index 61956c4..c46651f 100644 --- a/src/main/java/me/retucio/sputnik/command/commands/SaveScreenshotCommand.java +++ b/src/main/java/me/retucio/sputnik/command/commands/SaveScreenshotCommand.java @@ -5,7 +5,7 @@ import me.retucio.sputnik.command.Command; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.misc.ScreenshotPlus; import me.retucio.sputnik.util.ChatUtil; -import net.minecraft.command.CommandSource; +import net.minecraft.commands.SharedSuggestionProvider; import java.io.IOException; @@ -17,7 +17,7 @@ public class SaveScreenshotCommand extends Command { } @Override - public void build(LiteralArgumentBuilder builder) { + public void build(LiteralArgumentBuilder builder) { builder.executes(ctx -> { ScreenshotPlus screenshotPlus = ModuleManager.INSTANCE.getModuleByClass(ScreenshotPlus.class); diff --git a/src/main/java/me/retucio/sputnik/command/commands/SendCommand.java b/src/main/java/me/retucio/sputnik/command/commands/SendCommand.java index 929e931..2cd8ff8 100644 --- a/src/main/java/me/retucio/sputnik/command/commands/SendCommand.java +++ b/src/main/java/me/retucio/sputnik/command/commands/SendCommand.java @@ -3,18 +3,18 @@ package me.retucio.sputnik.command.commands; import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import me.retucio.sputnik.command.Command; -import me.retucio.sputnik.mixin.accessors.ClientPlayNetworkHandlerAccessor; -import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.command.CommandSource; -import net.minecraft.network.encryption.NetworkEncryptionUtils; -import net.minecraft.network.message.LastSeenMessagesCollector; -import net.minecraft.network.message.MessageBody; -import net.minecraft.network.message.MessageSignatureData; -import net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket; +import me.retucio.sputnik.mixin.accessors.ClientPacketListenerAccessor; +import net.minecraft.client.multiplayer.ClientPacketListener; +import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.network.chat.LastSeenMessagesTracker; +import net.minecraft.network.chat.MessageSignature; +import net.minecraft.network.chat.SignedMessageBody; +import net.minecraft.network.protocol.game.ServerboundChatPacket; +import net.minecraft.util.Crypt; import java.time.Instant; -// uso principal: protección de coordenadas de ChatPlus, que ni siquiera funciona +// uso principal: protección de coordenadas de ChatPlus public class SendCommand extends Command { public SendCommand() { @@ -22,31 +22,35 @@ public class SendCommand extends Command { } @Override - public void build(LiteralArgumentBuilder builder) { + public void build(LiteralArgumentBuilder builder) { builder.then(argument("message", StringArgumentType.greedyString()).executes(context -> { String message = context.getArgument("message", String.class); if (message != null && !message.isEmpty()) { Instant instant = Instant.now(); - long salt = NetworkEncryptionUtils.SecureRandomUtil.nextLong(); - ClientPlayNetworkHandler handler = mc.getNetworkHandler(); + long salt = Crypt.SaltSupplier.getLong(); + ClientPacketListener handler = mc.getConnection(); // obtener últimos mensajes vistos para la firma - LastSeenMessagesCollector.LastSeenMessages lastSeenMessages = - ((ClientPlayNetworkHandlerAccessor) handler).getLastSeenMessagesCollector().collect(); + ClientPacketListenerAccessor listener = ((ClientPacketListenerAccessor) handler); + if (listener == null) return 0; + LastSeenMessagesTracker tracker = ((ClientPacketListenerAccessor) handler).getLastSeenMessagesTracker(); + LastSeenMessagesTracker.Update lastSeenMessages = tracker.generateAndApplyUpdate(); // empacar firma para un chat seguro - MessageSignatureData messageSignatureData = - ((ClientPlayNetworkHandlerAccessor) handler).getMessagePacker().pack( - new MessageBody(message, instant, salt, lastSeenMessages.lastSeen()) - ); + MessageSignature messageSignature = ((ClientPacketListenerAccessor) handler) + .getSignedMessageEncoder() + .pack(new SignedMessageBody( + message, instant, salt, lastSeenMessages.lastSeen() + ) + ); // enviar paquete para enviar mensaje - handler.sendPacket(new ChatMessageC2SPacket( + handler.send(new ServerboundChatPacket( message, instant, salt, - messageSignatureData, + messageSignature, lastSeenMessages.update() )); } diff --git a/src/main/java/me/retucio/sputnik/command/commands/SpectateCommand.java b/src/main/java/me/retucio/sputnik/command/commands/SpectateCommand.java index 95e0884..ca76e31 100644 --- a/src/main/java/me/retucio/sputnik/command/commands/SpectateCommand.java +++ b/src/main/java/me/retucio/sputnik/command/commands/SpectateCommand.java @@ -6,8 +6,8 @@ import me.retucio.sputnik.command.Command; import me.retucio.sputnik.command.args.EntityArgumentType; import me.retucio.sputnik.event.input.KeyEvent; import me.retucio.sputnik.util.EntityUtil; -import net.minecraft.command.CommandSource; -import net.minecraft.entity.Entity; +import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.world.entity.Entity; import org.lwjgl.glfw.GLFW; public class SpectateCommand extends Command { @@ -17,7 +17,7 @@ public class SpectateCommand extends Command { } @Override - public void build(LiteralArgumentBuilder builder) { + public void build(LiteralArgumentBuilder builder) { builder .executes(ctx -> { // If no argument, use the entity player is looking at mc.execute(() -> { @@ -40,7 +40,7 @@ public class SpectateCommand extends Command { @EventListener public void onKey(KeyEvent event) { - if (mc.getCameraEntity() != mc.player && mc.currentScreen == null + if (mc.getCameraEntity() != mc.player && mc.screen == null && event.getKey() == GLFW.GLFW_KEY_ESCAPE && event.getAction() != GLFW.GLFW_RELEASE ) { event.cancel(); mc.setCameraEntity(mc.player); diff --git a/src/main/java/me/retucio/sputnik/command/commands/ToggleCommand.java b/src/main/java/me/retucio/sputnik/command/commands/ToggleCommand.java index 124b089..4758a6f 100644 --- a/src/main/java/me/retucio/sputnik/command/commands/ToggleCommand.java +++ b/src/main/java/me/retucio/sputnik/command/commands/ToggleCommand.java @@ -5,7 +5,7 @@ import me.retucio.sputnik.command.Command; import me.retucio.sputnik.command.args.ModuleArgumentType; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.ModuleManager; -import net.minecraft.command.CommandSource; +import net.minecraft.commands.SharedSuggestionProvider; // porque usar el ratón es más lento que escribir, a menos que tengas toque con el teclado como yo public class ToggleCommand extends Command { @@ -15,7 +15,7 @@ public class ToggleCommand extends Command { } @Override - public void build(LiteralArgumentBuilder builder) { + public void build(LiteralArgumentBuilder builder) { builder .then(literal("todos") .then(literal("on") diff --git a/src/main/java/me/retucio/sputnik/command/commands/WaitCommand.java b/src/main/java/me/retucio/sputnik/command/commands/WaitCommand.java index e622768..567ec83 100644 --- a/src/main/java/me/retucio/sputnik/command/commands/WaitCommand.java +++ b/src/main/java/me/retucio/sputnik/command/commands/WaitCommand.java @@ -8,7 +8,7 @@ import me.retucio.sputnik.command.Command; import me.retucio.sputnik.command.CommandManager; import me.retucio.sputnik.ui.widgets.frames.settings.ClientSettingsFrame; import me.retucio.sputnik.util.ChatUtil; -import net.minecraft.command.CommandSource; +import net.minecraft.commands.SharedSuggestionProvider; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledThreadPoolExecutor; @@ -23,18 +23,18 @@ public class WaitCommand extends Command { } @Override - public void build(LiteralArgumentBuilder builder) { + public void build(LiteralArgumentBuilder builder) { builder - .then(argument("delay", IntegerArgumentType.integer(0)) - .then(argument("comando", StringArgumentType.greedyString()) - .executes(ctx -> { - int delay = ctx.getArgument("delay", Integer.class); - String command = ctx.getArgument("comando", String.class); + .then(argument("delay", IntegerArgumentType.integer(0)) + .then(argument("comando", StringArgumentType.greedyString()) + .executes(ctx -> { + int delay = ctx.getArgument("delay", Integer.class); + String command = ctx.getArgument("comando", String.class); - DELAYED_EXECUTOR.schedule(() -> ChatUtil.simulateChatMessage(command), delay, TimeUnit.MILLISECONDS); - return SUCCESS; - }) - ) - ); + DELAYED_EXECUTOR.schedule(() -> ChatUtil.simulateChatMessage(command), delay, TimeUnit.MILLISECONDS); + return SUCCESS; + }) + ) + ); } } diff --git a/src/main/java/me/retucio/sputnik/event/ShutdownEvent.java b/src/main/java/me/retucio/sputnik/event/ShutdownEvent.java index e112000..7c1b066 100644 --- a/src/main/java/me/retucio/sputnik/event/ShutdownEvent.java +++ b/src/main/java/me/retucio/sputnik/event/ShutdownEvent.java @@ -1,11 +1,11 @@ package me.retucio.sputnik.event; import com.github.retucio.neutrino.Event; -import me.retucio.sputnik.mixin.mixins.misc.MinecraftClientMixin; +import me.retucio.sputnik.mixin.mixins.misc.MinecraftMixin; /** - * @see MinecraftClientMixin#onStop + * @see MinecraftMixin#onStop */ public class ShutdownEvent extends Event { diff --git a/src/main/java/me/retucio/sputnik/event/TickEvent.java b/src/main/java/me/retucio/sputnik/event/TickEvent.java index 3e05452..588ee3e 100644 --- a/src/main/java/me/retucio/sputnik/event/TickEvent.java +++ b/src/main/java/me/retucio/sputnik/event/TickEvent.java @@ -1,12 +1,12 @@ package me.retucio.sputnik.event; import com.github.retucio.neutrino.Event; -import me.retucio.sputnik.mixin.mixins.misc.MinecraftClientMixin; +import me.retucio.sputnik.mixin.mixins.misc.MinecraftMixin; /** - * @see MinecraftClientMixin#onTickPre - * @see MinecraftClientMixin#onTickPost + * @see MinecraftMixin#onTickPre + * @see MinecraftMixin#onTickPost */ public class TickEvent { diff --git a/src/main/java/me/retucio/sputnik/event/input/ClientClickEvent.java b/src/main/java/me/retucio/sputnik/event/input/ClientClickEvent.java index 8796cd2..28e74a0 100644 --- a/src/main/java/me/retucio/sputnik/event/input/ClientClickEvent.java +++ b/src/main/java/me/retucio/sputnik/event/input/ClientClickEvent.java @@ -1,12 +1,14 @@ package me.retucio.sputnik.event.input; import me.retucio.sputnik.module.modules.misc.ChatPlus; -import net.minecraft.text.ClickEvent; +import net.minecraft.network.chat.ClickEvent; +import org.jspecify.annotations.NonNull; /** este evento es solo para asegurarse de que comandos del mod se puedan ejecutar solo desde el lado del cliente * @see ChatPlus#getSendButton */ + public class ClientClickEvent implements ClickEvent { private final String value; @@ -20,7 +22,7 @@ public class ClientClickEvent implements ClickEvent { } @Override - public Action getAction() { + public @NonNull Action action() { return Action.RUN_COMMAND; } diff --git a/src/main/java/me/retucio/sputnik/event/input/KeyEvent.java b/src/main/java/me/retucio/sputnik/event/input/KeyEvent.java index 8b0143e..d3fe5a4 100644 --- a/src/main/java/me/retucio/sputnik/event/input/KeyEvent.java +++ b/src/main/java/me/retucio/sputnik/event/input/KeyEvent.java @@ -1,11 +1,11 @@ package me.retucio.sputnik.event.input; import com.github.retucio.neutrino.Event; -import me.retucio.sputnik.mixin.mixins.io.KeyboardMixin; +import me.retucio.sputnik.mixin.mixins.io.KeyboardHandlerMixin; /** - * @see KeyboardMixin#onKeyPress + * @see KeyboardHandlerMixin#onKeyPress */ public class KeyEvent extends Event { diff --git a/src/main/java/me/retucio/sputnik/event/input/MouseClickEvent.java b/src/main/java/me/retucio/sputnik/event/input/MouseClickEvent.java index 26978ab..2be11f9 100644 --- a/src/main/java/me/retucio/sputnik/event/input/MouseClickEvent.java +++ b/src/main/java/me/retucio/sputnik/event/input/MouseClickEvent.java @@ -1,11 +1,11 @@ package me.retucio.sputnik.event.input; import com.github.retucio.neutrino.Event; -import me.retucio.sputnik.mixin.mixins.io.MouseMixin; +import me.retucio.sputnik.mixin.mixins.io.MouseHandlerMixin; /** - * @see MouseMixin#onMouseButton + * @see MouseHandlerMixin#onMouseButton */ public class MouseClickEvent extends Event { diff --git a/src/main/java/me/retucio/sputnik/event/input/MouseScrollEvent.java b/src/main/java/me/retucio/sputnik/event/input/MouseScrollEvent.java index e0bec26..1388f61 100644 --- a/src/main/java/me/retucio/sputnik/event/input/MouseScrollEvent.java +++ b/src/main/java/me/retucio/sputnik/event/input/MouseScrollEvent.java @@ -1,11 +1,11 @@ package me.retucio.sputnik.event.input; import com.github.retucio.neutrino.Event; -import me.retucio.sputnik.mixin.mixins.io.MouseMixin; +import me.retucio.sputnik.mixin.mixins.io.MouseHandlerMixin; /** - * @see MouseMixin#onMouseScroll + * @see MouseHandlerMixin#onMouseScroll */ public class MouseScrollEvent extends Event { diff --git a/src/main/java/me/retucio/sputnik/event/interact/AttackBlockEvent.java b/src/main/java/me/retucio/sputnik/event/interact/AttackBlockEvent.java index 683b260..a393be2 100644 --- a/src/main/java/me/retucio/sputnik/event/interact/AttackBlockEvent.java +++ b/src/main/java/me/retucio/sputnik/event/interact/AttackBlockEvent.java @@ -1,8 +1,8 @@ package me.retucio.sputnik.event.interact; import com.github.retucio.neutrino.Event; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; public class AttackBlockEvent extends Event { diff --git a/src/main/java/me/retucio/sputnik/event/interact/AttackEntityEvent.java b/src/main/java/me/retucio/sputnik/event/interact/AttackEntityEvent.java index e678a84..57090de 100644 --- a/src/main/java/me/retucio/sputnik/event/interact/AttackEntityEvent.java +++ b/src/main/java/me/retucio/sputnik/event/interact/AttackEntityEvent.java @@ -1,13 +1,14 @@ package me.retucio.sputnik.event.interact; import com.github.retucio.neutrino.Event; -import me.retucio.sputnik.mixin.mixins.player.ClientPlayerInteractionManagerMixin; -import net.minecraft.entity.Entity; +import me.retucio.sputnik.mixin.mixins.player.MultiPlayerGameModeMixin; +import net.minecraft.world.entity.Entity; /** - * @see ClientPlayerInteractionManagerMixin#onAttackEntity + * @see MultiPlayerGameModeMixin#onAttackEntity */ + public class AttackEntityEvent extends Event { private final Entity entity; diff --git a/src/main/java/me/retucio/sputnik/event/interact/BlockShapeEvent.java b/src/main/java/me/retucio/sputnik/event/interact/BlockShapeEvent.java index a279bbe..7e592ad 100644 --- a/src/main/java/me/retucio/sputnik/event/interact/BlockShapeEvent.java +++ b/src/main/java/me/retucio/sputnik/event/interact/BlockShapeEvent.java @@ -1,9 +1,9 @@ package me.retucio.sputnik.event.interact; import com.github.retucio.neutrino.Event; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.shape.VoxelShape; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.shapes.VoxelShape; public class BlockShapeEvent extends Event { diff --git a/src/main/java/me/retucio/sputnik/event/interact/BoatMoveEvent.java b/src/main/java/me/retucio/sputnik/event/interact/BoatMoveEvent.java index 2218b58..0eac875 100644 --- a/src/main/java/me/retucio/sputnik/event/interact/BoatMoveEvent.java +++ b/src/main/java/me/retucio/sputnik/event/interact/BoatMoveEvent.java @@ -1,28 +1,28 @@ package me.retucio.sputnik.event.interact; import com.github.retucio.neutrino.Event; -import net.minecraft.entity.vehicle.AbstractBoatEntity; -import net.minecraft.util.math.Vec3d; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; +import net.minecraft.world.phys.Vec3; public class BoatMoveEvent extends Event { - private final AbstractBoatEntity boat; - private Vec3d pos; + private final AbstractBoat boat; + private Vec3 pos; - public BoatMoveEvent(AbstractBoatEntity boat, Vec3d pos) { + public BoatMoveEvent(AbstractBoat boat, Vec3 pos) { this.boat = boat; this.pos = pos; } - public AbstractBoatEntity getBoat() { + public AbstractBoat getBoat() { return boat; } - public Vec3d getPos() { + public Vec3 getPos() { return pos; } - public void setPos(Vec3d pos) { + public void setPos(Vec3 pos) { this.pos = pos; } } diff --git a/src/main/java/me/retucio/sputnik/event/interact/BreakBlockEvent.java b/src/main/java/me/retucio/sputnik/event/interact/BreakBlockEvent.java index 92dba2f..e186a2f 100644 --- a/src/main/java/me/retucio/sputnik/event/interact/BreakBlockEvent.java +++ b/src/main/java/me/retucio/sputnik/event/interact/BreakBlockEvent.java @@ -1,13 +1,14 @@ package me.retucio.sputnik.event.interact; import com.github.retucio.neutrino.Event; -import me.retucio.sputnik.mixin.mixins.player.ClientPlayerInteractionManagerMixin; -import net.minecraft.util.math.BlockPos; +import me.retucio.sputnik.mixin.mixins.player.MultiPlayerGameModeMixin; +import net.minecraft.core.BlockPos; /** - * @see ClientPlayerInteractionManagerMixin#onBlockBreak + * @see MultiPlayerGameModeMixin#onBlockBreak */ + public class BreakBlockEvent extends Event { private BlockPos pos; diff --git a/src/main/java/me/retucio/sputnik/event/interact/DamageItemEvent.java b/src/main/java/me/retucio/sputnik/event/interact/DamageItemEvent.java index 60cb485..c275a65 100644 --- a/src/main/java/me/retucio/sputnik/event/interact/DamageItemEvent.java +++ b/src/main/java/me/retucio/sputnik/event/interact/DamageItemEvent.java @@ -2,7 +2,7 @@ package me.retucio.sputnik.event.interact; import com.github.retucio.neutrino.Event; import me.retucio.sputnik.mixin.mixins.item.ItemStackMixin; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; /** diff --git a/src/main/java/me/retucio/sputnik/event/interact/InteractEntityEvent.java b/src/main/java/me/retucio/sputnik/event/interact/InteractEntityEvent.java index 8104fbd..8510886 100644 --- a/src/main/java/me/retucio/sputnik/event/interact/InteractEntityEvent.java +++ b/src/main/java/me/retucio/sputnik/event/interact/InteractEntityEvent.java @@ -1,20 +1,21 @@ package me.retucio.sputnik.event.interact; import com.github.retucio.neutrino.Event; -import me.retucio.sputnik.mixin.mixins.player.ClientPlayerInteractionManagerMixin; -import net.minecraft.entity.Entity; -import net.minecraft.util.Hand; +import me.retucio.sputnik.mixin.mixins.player.MultiPlayerGameModeMixin; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.Entity; /** - * @see ClientPlayerInteractionManagerMixin#onEntityInteract + * @see MultiPlayerGameModeMixin#onEntityInteract */ + public class InteractEntityEvent extends Event { private final Entity entity; - private Hand hand; + private InteractionHand hand; - public InteractEntityEvent(Entity entity, Hand hand) { + public InteractEntityEvent(Entity entity, InteractionHand hand) { this.entity = entity; this.hand = hand; } @@ -23,11 +24,11 @@ public class InteractEntityEvent extends Event { return entity; } - public Hand getHand() { + public InteractionHand getHand() { return hand; } - public void setHand(Hand hand) { + public void setHand(InteractionHand hand) { this.hand = hand; } } \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/event/interact/KnockbackEvent.java b/src/main/java/me/retucio/sputnik/event/interact/KnockbackEvent.java index 189831b..8e0776a 100644 --- a/src/main/java/me/retucio/sputnik/event/interact/KnockbackEvent.java +++ b/src/main/java/me/retucio/sputnik/event/interact/KnockbackEvent.java @@ -1,7 +1,7 @@ package me.retucio.sputnik.event.interact; import com.github.retucio.neutrino.Event; -import net.minecraft.entity.LivingEntity; +import net.minecraft.world.entity.LivingEntity; public class KnockbackEvent extends Event { diff --git a/src/main/java/me/retucio/sputnik/event/interact/OpenScreenEvent.java b/src/main/java/me/retucio/sputnik/event/interact/OpenScreenEvent.java index 9c4b9d9..384f66c 100644 --- a/src/main/java/me/retucio/sputnik/event/interact/OpenScreenEvent.java +++ b/src/main/java/me/retucio/sputnik/event/interact/OpenScreenEvent.java @@ -1,12 +1,12 @@ package me.retucio.sputnik.event.interact; import com.github.retucio.neutrino.Event; -import me.retucio.sputnik.mixin.mixins.misc.MinecraftClientMixin; -import net.minecraft.client.gui.screen.Screen; +import me.retucio.sputnik.mixin.mixins.misc.MinecraftMixin; +import net.minecraft.client.gui.screens.Screen; /** - * @see MinecraftClientMixin#onOpenScreen + * @see MinecraftMixin#onOpenScreen */ public class OpenScreenEvent extends Event { diff --git a/src/main/java/me/retucio/sputnik/event/interact/PlaceBlockEvent.java b/src/main/java/me/retucio/sputnik/event/interact/PlaceBlockEvent.java index eaa84d3..261d00e 100644 --- a/src/main/java/me/retucio/sputnik/event/interact/PlaceBlockEvent.java +++ b/src/main/java/me/retucio/sputnik/event/interact/PlaceBlockEvent.java @@ -1,29 +1,29 @@ package me.retucio.sputnik.event.interact; import com.github.retucio.neutrino.Event; -import me.retucio.sputnik.mixin.mixins.player.ClientPlayerInteractionManagerMixin; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; +import me.retucio.sputnik.mixin.mixins.player.MultiPlayerGameModeMixin; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.phys.BlockHitResult; /** - * @see ClientPlayerInteractionManagerMixin#onBlockPlace + * @see MultiPlayerGameModeMixin#onBlockPlace */ public class PlaceBlockEvent extends Event { - private Hand hand; + private InteractionHand hand; private BlockHitResult result; - public PlaceBlockEvent(Hand hand, BlockHitResult result) { + public PlaceBlockEvent(InteractionHand hand, BlockHitResult result) { this.hand = hand; this.result = result; } - public Hand getHand() { + public InteractionHand getHand() { return hand; } - public void setHand(Hand hand) { + public void setHand(InteractionHand hand) { this.hand = hand; } diff --git a/src/main/java/me/retucio/sputnik/event/interact/UseItemEvent.java b/src/main/java/me/retucio/sputnik/event/interact/UseItemEvent.java index edcfe88..3ebb5c4 100644 --- a/src/main/java/me/retucio/sputnik/event/interact/UseItemEvent.java +++ b/src/main/java/me/retucio/sputnik/event/interact/UseItemEvent.java @@ -1,20 +1,21 @@ package me.retucio.sputnik.event.interact; import com.github.retucio.neutrino.Event; -import me.retucio.sputnik.mixin.mixins.misc.MinecraftClientMixin; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Hand; +import me.retucio.sputnik.mixin.mixins.misc.MinecraftMixin; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; /** - * @see MinecraftClientMixin#onUseItem + * @see MinecraftMixin#onUseItem */ public class UseItemEvent extends Event { private ItemStack stack; - private Hand hand; + private InteractionHand hand; - public UseItemEvent(ItemStack stack, Hand hand) { + public UseItemEvent(ItemStack stack, InteractionHand hand) { this.stack = stack; this.hand = hand; } @@ -27,11 +28,15 @@ public class UseItemEvent extends Event { this.stack = stack; } - public Hand getHand() { + public Item getItem() { + return stack.getItem(); + } + + public InteractionHand getHand() { return hand; } - public void setHand(Hand hand) { + public void setHand(InteractionHand hand) { this.hand = hand; } } diff --git a/src/main/java/me/retucio/sputnik/event/network/AddEntityEvent.java b/src/main/java/me/retucio/sputnik/event/network/AddEntityEvent.java index 1cd0c75..af068a7 100644 --- a/src/main/java/me/retucio/sputnik/event/network/AddEntityEvent.java +++ b/src/main/java/me/retucio/sputnik/event/network/AddEntityEvent.java @@ -1,12 +1,12 @@ package me.retucio.sputnik.event.network; import com.github.retucio.neutrino.Event; -import me.retucio.sputnik.mixin.mixins.world.ClientWorldMixin; -import net.minecraft.entity.Entity; +import me.retucio.sputnik.mixin.mixins.world.ClientLevelMixin; +import net.minecraft.world.entity.Entity; /** - * @see ClientWorldMixin#onAddEntity + * @see ClientLevelMixin#onAddEntity */ public class AddEntityEvent extends Event { diff --git a/src/main/java/me/retucio/sputnik/event/network/ChunkOcclusionEvent.java b/src/main/java/me/retucio/sputnik/event/network/ChunkOcclusionEvent.java index e03368f..1644178 100644 --- a/src/main/java/me/retucio/sputnik/event/network/ChunkOcclusionEvent.java +++ b/src/main/java/me/retucio/sputnik/event/network/ChunkOcclusionEvent.java @@ -1,10 +1,10 @@ package me.retucio.sputnik.event.network; import com.github.retucio.neutrino.Event; -import me.retucio.sputnik.mixin.mixins.world.ChunkOcclusionDataBuilderMixin; +import me.retucio.sputnik.mixin.mixins.world.VisGraphMixin; /** - * @see ChunkOcclusionDataBuilderMixin#onChunkOcclusion + * @see VisGraphMixin#onChunkOcclusion */ public class ChunkOcclusionEvent extends Event {} diff --git a/src/main/java/me/retucio/sputnik/event/network/DisconnectEvent.java b/src/main/java/me/retucio/sputnik/event/network/DisconnectEvent.java index c5cf5c5..f613249 100644 --- a/src/main/java/me/retucio/sputnik/event/network/DisconnectEvent.java +++ b/src/main/java/me/retucio/sputnik/event/network/DisconnectEvent.java @@ -1,29 +1,29 @@ package me.retucio.sputnik.event.network; import com.github.retucio.neutrino.Event; -import me.retucio.sputnik.mixin.mixins.network.ClientConnectionMixin; -import net.minecraft.client.network.ServerInfo; -import net.minecraft.network.DisconnectionInfo; +import me.retucio.sputnik.mixin.mixins.network.ConnectionMixin; +import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.network.DisconnectionDetails; /** - * @see ClientConnectionMixin#onDisconnect + * @see ConnectionMixin#onDisconnect */ public class DisconnectEvent extends Event { - private final DisconnectionInfo info; - private final ServerInfo server; + private final DisconnectionDetails details; + private final ServerData server; - public DisconnectEvent(DisconnectionInfo info, ServerInfo server) { - this.info = info; + public DisconnectEvent(DisconnectionDetails details, ServerData server) { + this.details = details; this.server = server; } - public DisconnectionInfo getInfo() { - return info; + public DisconnectionDetails getDetails() { + return details; } - public ServerInfo getServer() { + public ServerData getServer() { return server; } } \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/event/network/JoinWorldEvent.java b/src/main/java/me/retucio/sputnik/event/network/JoinWorldEvent.java index f837f74..be0844a 100644 --- a/src/main/java/me/retucio/sputnik/event/network/JoinWorldEvent.java +++ b/src/main/java/me/retucio/sputnik/event/network/JoinWorldEvent.java @@ -1,22 +1,23 @@ package me.retucio.sputnik.event.network; import com.github.retucio.neutrino.Event; -import me.retucio.sputnik.mixin.mixins.misc.MinecraftClientMixin; -import net.minecraft.client.world.ClientWorld; +import me.retucio.sputnik.mixin.mixins.misc.MinecraftMixin; +import net.minecraft.client.multiplayer.ClientLevel; /** - * @see MinecraftClientMixin#onJoinWorld + * @see MinecraftMixin#onJoinWorld */ + public class JoinWorldEvent extends Event { - private final ClientWorld world; + private final ClientLevel world; - public JoinWorldEvent(ClientWorld world) { + public JoinWorldEvent(ClientLevel world) { this.world = world; } - public ClientWorld getWorld() { + public ClientLevel getWorld() { return world; } } diff --git a/src/main/java/me/retucio/sputnik/event/network/PacketEvent.java b/src/main/java/me/retucio/sputnik/event/network/PacketEvent.java index 7ffac2d..38e6729 100644 --- a/src/main/java/me/retucio/sputnik/event/network/PacketEvent.java +++ b/src/main/java/me/retucio/sputnik/event/network/PacketEvent.java @@ -1,14 +1,14 @@ package me.retucio.sputnik.event.network; import com.github.retucio.neutrino.Event; -import me.retucio.sputnik.mixin.mixins.network.ClientConnectionMixin; -import net.minecraft.network.packet.Packet; +import me.retucio.sputnik.mixin.mixins.network.ConnectionMixin; +import net.minecraft.network.protocol.Packet; /** - * @see ClientConnectionMixin#onSendPacketPre - * @see ClientConnectionMixin#onSendPacketPost - * @see ClientConnectionMixin#onReceivePacket + * @see ConnectionMixin#onSendPacketPre + * @see ConnectionMixin#onSendPacketPost + * @see ConnectionMixin#onReceivePacket */ public class PacketEvent { diff --git a/src/main/java/me/retucio/sputnik/event/network/ReceiveMessageEvent.java b/src/main/java/me/retucio/sputnik/event/network/ReceiveMessageEvent.java index f78c7da..77768e9 100644 --- a/src/main/java/me/retucio/sputnik/event/network/ReceiveMessageEvent.java +++ b/src/main/java/me/retucio/sputnik/event/network/ReceiveMessageEvent.java @@ -1,41 +1,43 @@ package me.retucio.sputnik.event.network; import com.github.retucio.neutrino.Event; -import me.retucio.sputnik.mixin.mixins.hud.ChatHudMixin; -import net.minecraft.client.gui.hud.MessageIndicator; -import net.minecraft.text.Text; +import me.retucio.sputnik.mixin.mixins.hud.ChatComponentMixin; +import net.minecraft.client.multiplayer.chat.GuiMessageTag; +import net.minecraft.network.chat.Component; + /** - * @see ChatHudMixin#onAddMessage + * @see ChatComponentMixin#onAddMessage */ + public class ReceiveMessageEvent extends Event { - private Text text; - private MessageIndicator indicator; + private Component text; + private GuiMessageTag tag; private final int id; private boolean modified = false; - public ReceiveMessageEvent(Text text, MessageIndicator indicator, int id) { + public ReceiveMessageEvent(Component text, GuiMessageTag tag, int id) { this.text = text; - this.indicator = indicator; + this.tag = tag; this.id = id; } - public Text getMessage() { + public Component getMessage() { return text; } - public MessageIndicator getIndicator() { - return indicator; + public GuiMessageTag getTag() { + return tag; } - public void setMessage(Text message) { + public void setMessage(Component message) { this.text = message; this.modified = true; } - public void setIndicator(MessageIndicator indicator) { - this.indicator = indicator; + public void setTag(GuiMessageTag tag) { + this.tag = tag; this.modified = true; } diff --git a/src/main/java/me/retucio/sputnik/event/network/RemoveEntityEvent.java b/src/main/java/me/retucio/sputnik/event/network/RemoveEntityEvent.java index b01ed20..f5a3624 100644 --- a/src/main/java/me/retucio/sputnik/event/network/RemoveEntityEvent.java +++ b/src/main/java/me/retucio/sputnik/event/network/RemoveEntityEvent.java @@ -1,12 +1,12 @@ package me.retucio.sputnik.event.network; import com.github.retucio.neutrino.Event; -import me.retucio.sputnik.mixin.mixins.world.ClientWorldMixin; -import net.minecraft.entity.Entity; +import me.retucio.sputnik.mixin.mixins.world.ClientLevelMixin; +import net.minecraft.world.entity.Entity; /** - * @see ClientWorldMixin#onRemoveEntity + * @see ClientLevelMixin#onRemoveEntity */ public class RemoveEntityEvent extends Event { diff --git a/src/main/java/me/retucio/sputnik/event/network/SendMessageEvent.java b/src/main/java/me/retucio/sputnik/event/network/SendMessageEvent.java index 16b6dd2..739f9a7 100644 --- a/src/main/java/me/retucio/sputnik/event/network/SendMessageEvent.java +++ b/src/main/java/me/retucio/sputnik/event/network/SendMessageEvent.java @@ -1,11 +1,11 @@ package me.retucio.sputnik.event.network; import com.github.retucio.neutrino.Event; -import me.retucio.sputnik.mixin.mixins.network.ClientPlayNetworkHandlerMixin; +import me.retucio.sputnik.mixin.mixins.network.ClientPacketListenerMixin; /** - * @see ClientPlayNetworkHandlerMixin#onSendMessage + * @see ClientPacketListenerMixin#onSendMessage */ public class SendMessageEvent extends Event { diff --git a/src/main/java/me/retucio/sputnik/event/render/PerspectiveChangeEvent.java b/src/main/java/me/retucio/sputnik/event/render/PerspectiveChangeEvent.java index 0eebed4..2a61f8d 100644 --- a/src/main/java/me/retucio/sputnik/event/render/PerspectiveChangeEvent.java +++ b/src/main/java/me/retucio/sputnik/event/render/PerspectiveChangeEvent.java @@ -1,26 +1,26 @@ package me.retucio.sputnik.event.render; import com.github.retucio.neutrino.Event; -import me.retucio.sputnik.mixin.mixins.misc.GameOptionsMixin; -import net.minecraft.client.option.Perspective; +import me.retucio.sputnik.mixin.mixins.misc.OptionsMixin; +import net.minecraft.client.CameraType; /** - * @see GameOptionsMixin#changePerspective + * @see OptionsMixin#changePerspective */ public class PerspectiveChangeEvent extends Event { - private Perspective perspective; + private CameraType perspective; - public PerspectiveChangeEvent(Perspective perspective) { + public PerspectiveChangeEvent(CameraType perspective) { this.perspective = perspective; } - public Perspective getPerspective() { + public CameraType getPerspective() { return perspective; } - public void setPerspective(Perspective perspective) { + public void setPerspective(CameraType perspective) { this.perspective = perspective; } } diff --git a/src/main/java/me/retucio/sputnik/event/render/Render2DEvent.java b/src/main/java/me/retucio/sputnik/event/render/Render2DEvent.java index 13c4234..7d8d395 100644 --- a/src/main/java/me/retucio/sputnik/event/render/Render2DEvent.java +++ b/src/main/java/me/retucio/sputnik/event/render/Render2DEvent.java @@ -1,24 +1,26 @@ package me.retucio.sputnik.event.render; import com.github.retucio.neutrino.Event; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.render.RenderTickCounter; + +import net.minecraft.client.DeltaTracker; +import net.minecraft.client.gui.GuiGraphicsExtractor; + public class Render2DEvent extends Event { - private final DrawContext ctx; - private final RenderTickCounter tc; + private final GuiGraphicsExtractor gui; + private final DeltaTracker dt; - public Render2DEvent(DrawContext ctx, RenderTickCounter tc) { - this.ctx = ctx; - this.tc = tc; + public Render2DEvent(GuiGraphicsExtractor gui, DeltaTracker dt) { + this.gui = gui; + this.dt = dt; } - public DrawContext getCtx() { - return ctx; + public GuiGraphicsExtractor getGui() { + return gui; } - public RenderTickCounter getTc() { - return tc; + public DeltaTracker getDt() { + return dt; } } diff --git a/src/main/java/me/retucio/sputnik/event/render/Render3DEvent.java b/src/main/java/me/retucio/sputnik/event/render/Render3DEvent.java index 04d77b7..39f0638 100644 --- a/src/main/java/me/retucio/sputnik/event/render/Render3DEvent.java +++ b/src/main/java/me/retucio/sputnik/event/render/Render3DEvent.java @@ -1,40 +1,42 @@ package me.retucio.sputnik.event.render; import com.github.retucio.neutrino.Event; -import me.retucio.sputnik.mixin.mixins.render.WorldRendererMixin; -import net.minecraft.client.render.Camera; -import net.minecraft.client.render.RenderTickCounter; -import net.minecraft.client.util.math.MatrixStack; +import com.mojang.blaze3d.vertex.PoseStack; +import me.retucio.sputnik.mixin.mixins.render.LevelRendererMixin; +import net.minecraft.client.Camera; +import net.minecraft.client.DeltaTracker; +import net.minecraft.client.renderer.state.level.CameraRenderState; /** - * @see WorldRendererMixin#render + * @see LevelRendererMixin#renderLevel */ + public class Render3DEvent extends Event { - private final MatrixStack matrices; - private final RenderTickCounter tc; - private final Camera camera; + private final PoseStack matrices; + private final DeltaTracker dt; + private final CameraRenderState cameraState; - public Render3DEvent(MatrixStack matrices, RenderTickCounter tc, Camera camera) { + public Render3DEvent(PoseStack matrices, DeltaTracker dt, CameraRenderState cameraState) { this.matrices = matrices; - this.tc = tc; - this.camera = camera; + this.dt = dt; + this.cameraState = cameraState; } - public MatrixStack getMatrices() { + public PoseStack getMatrices() { return matrices; } - public RenderTickCounter getTickCounter() { - return tc; + public DeltaTracker getDeltaTracker() { + return dt; } - public Camera getCamera() { - return camera; + public CameraRenderState getCamera() { + return cameraState; } public float getTickDelta() { - return tc.getDynamicDeltaTicks(); + return dt.getGameTimeDeltaTicks(); } } diff --git a/src/main/java/me/retucio/sputnik/event/render/RenderArmEvent.java b/src/main/java/me/retucio/sputnik/event/render/RenderArmEvent.java index 805fde3..7eefb99 100644 --- a/src/main/java/me/retucio/sputnik/event/render/RenderArmEvent.java +++ b/src/main/java/me/retucio/sputnik/event/render/RenderArmEvent.java @@ -1,37 +1,37 @@ package me.retucio.sputnik.event.render; import com.github.retucio.neutrino.Event; -import me.retucio.sputnik.mixin.mixins.render.HeldItemRendererMixin; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.Hand; +import com.mojang.blaze3d.vertex.PoseStack; +import me.retucio.sputnik.mixin.mixins.render.ItemInHandRendererMixin; +import net.minecraft.world.InteractionHand; /** - * @see HeldItemRendererMixin#onRenderArm + * @see ItemInHandRendererMixin#onRenderArm */ public class RenderArmEvent extends Event { - private MatrixStack matrices; - private Hand hand; + private PoseStack matrices; + private InteractionHand hand; - public RenderArmEvent(MatrixStack matrices, Hand hand) { + public RenderArmEvent(PoseStack matrices, InteractionHand hand) { this.matrices = matrices; this.hand = hand; } - public MatrixStack getMatrices() { + public PoseStack getMatrices() { return matrices; } - public void setMatrices(MatrixStack matrices) { + public void setMatrices(PoseStack matrices) { this.matrices = matrices; } - public Hand getHand() { + public InteractionHand getHand() { return hand; } - public void setHand(Hand hand) { + public void setHand(InteractionHand hand) { this.hand = hand; } } diff --git a/src/main/java/me/retucio/sputnik/event/render/RenderBossbarEvent.java b/src/main/java/me/retucio/sputnik/event/render/RenderBossbarEvent.java index 4c867f0..219dffc 100644 --- a/src/main/java/me/retucio/sputnik/event/render/RenderBossbarEvent.java +++ b/src/main/java/me/retucio/sputnik/event/render/RenderBossbarEvent.java @@ -2,9 +2,10 @@ package me.retucio.sputnik.event.render; import com.github.retucio.neutrino.Event; import me.retucio.sputnik.mixin.mixins.hud.BossBarHudMixin; -import net.minecraft.client.gui.hud.ClientBossBar; -import net.minecraft.text.Text; +import net.minecraft.client.gui.components.LerpingBossEvent; +import net.minecraft.network.chat.MutableComponent; +import java.awt.*; import java.util.Iterator; @@ -17,27 +18,27 @@ public class RenderBossbarEvent { public static class BossText extends Event { - private ClientBossBar bossBar; - private Text name; + private LerpingBossEvent bossBar; + private MutableComponent name; - public BossText(ClientBossBar bossBar, Text name) { + public BossText(LerpingBossEvent bossBar, MutableComponent name) { this.bossBar = bossBar; this.name = name; } - public ClientBossBar getBossBar() { + public LerpingBossEvent getBossBar() { return bossBar; } - public void setBossBar(ClientBossBar bossBar) { + public void setBossBar(LerpingBossEvent bossBar) { this.bossBar = bossBar; } - public Text getName() { + public MutableComponent getName() { return name; } - public void setName(Text name) { + public void setName(MutableComponent name) { this.name = name; } } @@ -61,17 +62,17 @@ public class RenderBossbarEvent { public static class BossIterator extends Event { - private Iterator iterator; + private Iterator iterator; - public BossIterator(Iterator iterator) { + public BossIterator(Iterator iterator) { this.iterator = iterator; } - public Iterator getIterator() { + public Iterator getIterator() { return iterator; } - public void setIterator(Iterator iterator) { + public void setIterator(Iterator iterator) { this.iterator = iterator; } } diff --git a/src/main/java/me/retucio/sputnik/event/render/RenderHeldItemEvent.java b/src/main/java/me/retucio/sputnik/event/render/RenderHeldItemEvent.java index c6aa11d..0cea364 100644 --- a/src/main/java/me/retucio/sputnik/event/render/RenderHeldItemEvent.java +++ b/src/main/java/me/retucio/sputnik/event/render/RenderHeldItemEvent.java @@ -1,37 +1,38 @@ package me.retucio.sputnik.event.render; import com.github.retucio.neutrino.Event; -import me.retucio.sputnik.mixin.mixins.render.HeldItemRendererMixin; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.Hand; +import com.mojang.blaze3d.vertex.PoseStack; +import me.retucio.sputnik.mixin.mixins.render.ItemInHandRendererMixin; +import net.minecraft.world.InteractionHand; /** - * @see HeldItemRendererMixin#onRenderItem + * @see ItemInHandRendererMixin#onRenderItem */ + public class RenderHeldItemEvent extends Event { - private MatrixStack matrices; - private Hand hand; + private PoseStack matrices; + private InteractionHand hand; - public RenderHeldItemEvent(MatrixStack matrices, Hand hand) { + public RenderHeldItemEvent(PoseStack matrices, InteractionHand hand) { this.matrices = matrices; this.hand = hand; } - public MatrixStack getMatrices() { + public PoseStack getMatrices() { return matrices; } - public void setMatrices(MatrixStack matrices) { + public void setMatrices(PoseStack matrices) { this.matrices = matrices; } - public Hand getHand() { + public InteractionHand getHand() { return hand; } - public void setHand(Hand hand) { + public void setHand(InteractionHand hand) { this.hand = hand; } } diff --git a/src/main/java/me/retucio/sputnik/mixin/accessors/AbstractContainerScreenAccessor.java b/src/main/java/me/retucio/sputnik/mixin/accessors/AbstractContainerScreenAccessor.java new file mode 100644 index 0000000..419f55e --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/accessors/AbstractContainerScreenAccessor.java @@ -0,0 +1,16 @@ +package me.retucio.sputnik.mixin.accessors; + +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.world.inventory.Slot; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(AbstractContainerScreen.class) +public interface AbstractContainerScreenAccessor { + + @Accessor("hoveredSlot") + Slot getHoveredSlot(); + + @Accessor("doubleclick") + void setDoubleClicking(boolean doubleClicking); +} diff --git a/src/main/java/me/retucio/sputnik/mixin/accessors/AbstractSignEditScreenAccessor.java b/src/main/java/me/retucio/sputnik/mixin/accessors/AbstractSignEditScreenAccessor.java index 9ee44bc..73fd1b3 100644 --- a/src/main/java/me/retucio/sputnik/mixin/accessors/AbstractSignEditScreenAccessor.java +++ b/src/main/java/me/retucio/sputnik/mixin/accessors/AbstractSignEditScreenAccessor.java @@ -1,13 +1,13 @@ package me.retucio.sputnik.mixin.accessors; -import net.minecraft.block.entity.SignBlockEntity; -import net.minecraft.client.gui.screen.ingame.AbstractSignEditScreen; +import net.minecraft.client.gui.screens.inventory.AbstractSignEditScreen; +import net.minecraft.world.level.block.entity.SignBlockEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; @Mixin(AbstractSignEditScreen.class) public interface AbstractSignEditScreenAccessor { - @Accessor("blockEntity") + @Accessor("sign") SignBlockEntity getBlockEntity(); } diff --git a/src/main/java/me/retucio/sputnik/mixin/accessors/AnvilScreenAccessor.java b/src/main/java/me/retucio/sputnik/mixin/accessors/AnvilScreenAccessor.java index 94ba08f..8c99969 100644 --- a/src/main/java/me/retucio/sputnik/mixin/accessors/AnvilScreenAccessor.java +++ b/src/main/java/me/retucio/sputnik/mixin/accessors/AnvilScreenAccessor.java @@ -1,16 +1,16 @@ package me.retucio.sputnik.mixin.accessors; -import net.minecraft.client.gui.screen.ingame.AnvilScreen; -import net.minecraft.client.gui.widget.TextFieldWidget; +import net.minecraft.client.gui.components.EditBox; +import net.minecraft.client.gui.screens.inventory.AnvilScreen; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; @Mixin(AnvilScreen.class) public interface AnvilScreenAccessor { - @Accessor("nameField") - TextFieldWidget getNameField(); + @Accessor("name") + EditBox getNameField(); - @Accessor("nameField") - void setNameField(TextFieldWidget nameField); + @Accessor("name") + void setNameField(EditBox nameField); } diff --git a/src/main/java/me/retucio/sputnik/mixin/accessors/AbstractBlockAccessor.java b/src/main/java/me/retucio/sputnik/mixin/accessors/BlockBehaviourAccessor.java similarity index 57% rename from src/main/java/me/retucio/sputnik/mixin/accessors/AbstractBlockAccessor.java rename to src/main/java/me/retucio/sputnik/mixin/accessors/BlockBehaviourAccessor.java index b3d45fa..4136b8f 100644 --- a/src/main/java/me/retucio/sputnik/mixin/accessors/AbstractBlockAccessor.java +++ b/src/main/java/me/retucio/sputnik/mixin/accessors/BlockBehaviourAccessor.java @@ -1,13 +1,13 @@ package me.retucio.sputnik.mixin.accessors; -import net.minecraft.block.AbstractBlock; +import net.minecraft.world.level.block.state.BlockBehaviour; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.gen.Accessor; -@Mixin(AbstractBlock.class) -public interface AbstractBlockAccessor { +@Mixin(BlockBehaviour.class) +public interface BlockBehaviourAccessor { - @Mutable @Accessor("slipperiness") + @Mutable @Accessor("friction") void setSlipperiness(float slipperiness); } diff --git a/src/main/java/me/retucio/sputnik/mixin/accessors/ClientPacketListenerAccessor.java b/src/main/java/me/retucio/sputnik/mixin/accessors/ClientPacketListenerAccessor.java new file mode 100644 index 0000000..2e21f5a --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/accessors/ClientPacketListenerAccessor.java @@ -0,0 +1,17 @@ +package me.retucio.sputnik.mixin.accessors; + +import net.minecraft.client.multiplayer.ClientPacketListener; +import net.minecraft.network.chat.LastSeenMessagesTracker; +import net.minecraft.network.chat.SignedMessageChain; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(ClientPacketListener.class) +public interface ClientPacketListenerAccessor { + + @Accessor("lastSeenMessages") + LastSeenMessagesTracker getLastSeenMessagesTracker(); + + @Accessor("signedMessageEncoder") + SignedMessageChain.Encoder getSignedMessageEncoder(); +} diff --git a/src/main/java/me/retucio/sputnik/mixin/accessors/ClientPlayNetworkHandlerAccessor.java b/src/main/java/me/retucio/sputnik/mixin/accessors/ClientPlayNetworkHandlerAccessor.java deleted file mode 100644 index 2aa354c..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/accessors/ClientPlayNetworkHandlerAccessor.java +++ /dev/null @@ -1,17 +0,0 @@ -package me.retucio.sputnik.mixin.accessors; - -import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.network.message.LastSeenMessagesCollector; -import net.minecraft.network.message.MessageChain; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(ClientPlayNetworkHandler.class) -public interface ClientPlayNetworkHandlerAccessor { - - @Accessor("lastSeenMessagesCollector") - LastSeenMessagesCollector getLastSeenMessagesCollector(); - - @Accessor("messagePacker") - MessageChain.Packer getMessagePacker(); -} diff --git a/src/main/java/me/retucio/sputnik/mixin/accessors/ExplosionS2CPacketAccessor.java b/src/main/java/me/retucio/sputnik/mixin/accessors/ClientboundExplodePacketAccessor.java similarity index 51% rename from src/main/java/me/retucio/sputnik/mixin/accessors/ExplosionS2CPacketAccessor.java rename to src/main/java/me/retucio/sputnik/mixin/accessors/ClientboundExplodePacketAccessor.java index 0d70091..8ed6a2f 100644 --- a/src/main/java/me/retucio/sputnik/mixin/accessors/ExplosionS2CPacketAccessor.java +++ b/src/main/java/me/retucio/sputnik/mixin/accessors/ClientboundExplodePacketAccessor.java @@ -1,16 +1,16 @@ package me.retucio.sputnik.mixin.accessors; -import net.minecraft.network.packet.s2c.play.ExplosionS2CPacket; -import net.minecraft.util.math.Vec3d; +import net.minecraft.network.protocol.game.ClientboundExplodePacket; +import net.minecraft.world.phys.Vec3; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.gen.Accessor; import java.util.Optional; -@Mixin(ExplosionS2CPacket.class) -public interface ExplosionS2CPacketAccessor { +@Mixin(ClientboundExplodePacket.class) +public interface ClientboundExplodePacketAccessor { @Mutable @Accessor("playerKnockback") - void setKnockback(Optional kb); + void setKnockback(Optional kb); } diff --git a/src/main/java/me/retucio/sputnik/mixin/accessors/ClientboundSetEntityMotionPacketAccessor.java b/src/main/java/me/retucio/sputnik/mixin/accessors/ClientboundSetEntityMotionPacketAccessor.java new file mode 100644 index 0000000..ad19d2b --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/accessors/ClientboundSetEntityMotionPacketAccessor.java @@ -0,0 +1,15 @@ +package me.retucio.sputnik.mixin.accessors; + +import net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket; +import net.minecraft.world.phys.Vec3; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.gen.Accessor; + + +@Mixin(ClientboundSetEntityMotionPacket.class) +public interface ClientboundSetEntityMotionPacketAccessor { + + @Mutable @Accessor("movement") + void setVelocity(Vec3 velocity); +} diff --git a/src/main/java/me/retucio/sputnik/mixin/accessors/ConfirmServerResourcePackScreenAccessor.java b/src/main/java/me/retucio/sputnik/mixin/accessors/ConfirmServerResourcePackScreenAccessor.java deleted file mode 100644 index a7edf7c..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/accessors/ConfirmServerResourcePackScreenAccessor.java +++ /dev/null @@ -1,18 +0,0 @@ -package me.retucio.sputnik.mixin.accessors; - -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.network.ClientCommonNetworkHandler; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import java.util.List; - -@Mixin(ClientCommonNetworkHandler.ConfirmServerResourcePackScreen.class) -public interface ConfirmServerResourcePackScreenAccessor { - - @Accessor("parent") - Screen getParentScreen(); - - @Accessor("packs") - List getRequests(); -} diff --git a/src/main/java/me/retucio/sputnik/mixin/accessors/EntityVelocityUpdateS2CPacketAccessor.java b/src/main/java/me/retucio/sputnik/mixin/accessors/EntityVelocityUpdateS2CPacketAccessor.java deleted file mode 100644 index e241a1b..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/accessors/EntityVelocityUpdateS2CPacketAccessor.java +++ /dev/null @@ -1,14 +0,0 @@ -package me.retucio.sputnik.mixin.accessors; - -import net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket; -import net.minecraft.util.math.Vec3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(EntityVelocityUpdateS2CPacket.class) -public interface EntityVelocityUpdateS2CPacketAccessor { - - @Mutable @Accessor("velocity") - void setVelocity(Vec3d velocity); -} diff --git a/src/main/java/me/retucio/sputnik/mixin/accessors/FishingBobberEntityAccessor.java b/src/main/java/me/retucio/sputnik/mixin/accessors/FishingBobberEntityAccessor.java deleted file mode 100644 index 7a87dd4..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/accessors/FishingBobberEntityAccessor.java +++ /dev/null @@ -1,15 +0,0 @@ -package me.retucio.sputnik.mixin.accessors; - -import net.minecraft.entity.projectile.FishingBobberEntity; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(FishingBobberEntity.class) -public interface FishingBobberEntityAccessor { - - @Accessor("caughtFish") - boolean caughtFish(); - - @Accessor("state") - FishingBobberEntity.State getState(); -} diff --git a/src/main/java/me/retucio/sputnik/mixin/accessors/FishingHookAccessor.java b/src/main/java/me/retucio/sputnik/mixin/accessors/FishingHookAccessor.java new file mode 100644 index 0000000..c644844 --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/accessors/FishingHookAccessor.java @@ -0,0 +1,16 @@ +package me.retucio.sputnik.mixin.accessors; + +import net.minecraft.world.entity.projectile.FishingHook; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + + +@Mixin(FishingHook.class) +public interface FishingHookAccessor { + + @Accessor("biting") + boolean caughtFish(); + + @Accessor("currentState") + FishingHook.FishHookState getState(); +} diff --git a/src/main/java/me/retucio/sputnik/mixin/accessors/HandledScreenAccessor.java b/src/main/java/me/retucio/sputnik/mixin/accessors/HandledScreenAccessor.java deleted file mode 100644 index 7fa245f..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/accessors/HandledScreenAccessor.java +++ /dev/null @@ -1,16 +0,0 @@ -package me.retucio.sputnik.mixin.accessors; - -import net.minecraft.client.gui.screen.ingame.HandledScreen; -import net.minecraft.screen.slot.Slot; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(HandledScreen.class) -public interface HandledScreenAccessor { - - @Accessor("focusedSlot") - Slot getFocusedSlot(); - - @Accessor("doubleClicking") - void setDoubleClicking(boolean doubleClicking); -} diff --git a/src/main/java/me/retucio/sputnik/mixin/accessors/KeyBindingAccessor.java b/src/main/java/me/retucio/sputnik/mixin/accessors/KeyBindingAccessor.java index 7c2b99b..bbf95e8 100644 --- a/src/main/java/me/retucio/sputnik/mixin/accessors/KeyBindingAccessor.java +++ b/src/main/java/me/retucio/sputnik/mixin/accessors/KeyBindingAccessor.java @@ -1,13 +1,13 @@ package me.retucio.sputnik.mixin.accessors; -import net.minecraft.client.option.KeyBinding; -import net.minecraft.client.util.InputUtil; +import com.mojang.blaze3d.platform.InputConstants; +import net.minecraft.client.KeyMapping; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -@Mixin(KeyBinding.class) +@Mixin(KeyMapping.class) public interface KeyBindingAccessor { - @Accessor("boundKey") - InputUtil.Key getBoundKey(); + @Accessor("key") + InputConstants.Key getKey(); } diff --git a/src/main/java/me/retucio/sputnik/mixin/accessors/StatusEffectInstanceAccessor.java b/src/main/java/me/retucio/sputnik/mixin/accessors/MobEffectInstanceAccessor.java similarity index 59% rename from src/main/java/me/retucio/sputnik/mixin/accessors/StatusEffectInstanceAccessor.java rename to src/main/java/me/retucio/sputnik/mixin/accessors/MobEffectInstanceAccessor.java index 91da007..3f4f535 100644 --- a/src/main/java/me/retucio/sputnik/mixin/accessors/StatusEffectInstanceAccessor.java +++ b/src/main/java/me/retucio/sputnik/mixin/accessors/MobEffectInstanceAccessor.java @@ -1,11 +1,12 @@ package me.retucio.sputnik.mixin.accessors; -import net.minecraft.entity.effect.StatusEffectInstance; +import net.minecraft.world.effect.MobEffectInstance; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -@Mixin(StatusEffectInstance.class) -public interface StatusEffectInstanceAccessor { + +@Mixin(MobEffectInstance.class) +public interface MobEffectInstanceAccessor { @Accessor("duration") void setDuration(int duration); diff --git a/src/main/java/me/retucio/sputnik/mixin/accessors/OverlayTextureAccessor.java b/src/main/java/me/retucio/sputnik/mixin/accessors/OverlayTextureAccessor.java index 49e9632..87e964f 100644 --- a/src/main/java/me/retucio/sputnik/mixin/accessors/OverlayTextureAccessor.java +++ b/src/main/java/me/retucio/sputnik/mixin/accessors/OverlayTextureAccessor.java @@ -1,7 +1,7 @@ package me.retucio.sputnik.mixin.accessors; -import net.minecraft.client.render.OverlayTexture; -import net.minecraft.client.texture.NativeImageBackedTexture; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.client.renderer.texture.OverlayTexture; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.gen.Accessor; @@ -10,5 +10,5 @@ import org.spongepowered.asm.mixin.gen.Accessor; public interface OverlayTextureAccessor { @Mutable @Accessor("texture") - void setTexture(NativeImageBackedTexture texture); + void setTexture(DynamicTexture texture); } diff --git a/src/main/java/me/retucio/sputnik/mixin/accessors/PackConfirmScreenAccessor.java b/src/main/java/me/retucio/sputnik/mixin/accessors/PackConfirmScreenAccessor.java new file mode 100644 index 0000000..4012180 --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/accessors/PackConfirmScreenAccessor.java @@ -0,0 +1,19 @@ +package me.retucio.sputnik.mixin.accessors; + +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import java.util.List; + + +@Mixin(ClientCommonPacketListenerImpl.PackConfirmScreen.class) +public interface PackConfirmScreenAccessor { + + @Accessor("parentScreen") + Screen getParentScreen(); + + @Accessor("requests") + List getRequests(); +} diff --git a/src/main/java/me/retucio/sputnik/mixin/accessors/PackAccessor.java b/src/main/java/me/retucio/sputnik/mixin/accessors/PendingRequestAccessor.java similarity index 50% rename from src/main/java/me/retucio/sputnik/mixin/accessors/PackAccessor.java rename to src/main/java/me/retucio/sputnik/mixin/accessors/PendingRequestAccessor.java index 35a6372..103c265 100644 --- a/src/main/java/me/retucio/sputnik/mixin/accessors/PackAccessor.java +++ b/src/main/java/me/retucio/sputnik/mixin/accessors/PendingRequestAccessor.java @@ -1,13 +1,14 @@ package me.retucio.sputnik.mixin.accessors; -import net.minecraft.client.network.ClientCommonNetworkHandler; +import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; import java.util.UUID; -@Mixin(ClientCommonNetworkHandler.ConfirmServerResourcePackScreen.Pack.class) -public interface PackAccessor { + +@Mixin(ClientCommonPacketListenerImpl.PackConfirmScreen.PendingRequest.class) +public interface PendingRequestAccessor { @Invoker UUID callId(); diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/entity/AbstractBoatEntityMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/entity/AbstractBoatMixin.java similarity index 56% rename from src/main/java/me/retucio/sputnik/mixin/mixins/entity/AbstractBoatEntityMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/entity/AbstractBoatMixin.java index 77e797d..8d10c11 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/entity/AbstractBoatEntityMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/entity/AbstractBoatMixin.java @@ -4,25 +4,25 @@ import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.event.interact.BoatMoveEvent; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.movement.BoatFly; -import net.minecraft.entity.MovementType; -import net.minecraft.entity.vehicle.AbstractBoatEntity; -import net.minecraft.util.math.Vec3d; +import net.minecraft.world.entity.MoverType; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; +import net.minecraft.world.phys.Vec3; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(AbstractBoatEntity.class) -public abstract class AbstractBoatEntityMixin { +@Mixin(AbstractBoat.class) +public abstract class AbstractBoatMixin { - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/vehicle/AbstractBoatEntity;move(Lnet/minecraft/entity/MovementType;Lnet/minecraft/util/math/Vec3d;)V")) - private void onMove(AbstractBoatEntity instance, MovementType movementType, Vec3d vec3d) { - BoatMoveEvent event = Sputnik.EVENT_BUS.post(new BoatMoveEvent(instance, vec3d)); - if(!event.isCancelled()) instance.move(movementType, event.getPos()); + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/vehicle/boat/AbstractBoat;move(Lnet/minecraft/world/entity/MoverType;Lnet/minecraft/world/phys/Vec3;)V")) + private void onMove(AbstractBoat instance, MoverType moverType, Vec3 vec3) { + BoatMoveEvent event = Sputnik.EVENT_BUS.post(new BoatMoveEvent(instance, vec3)); + if (!event.isCancelled()) instance.move(moverType, event.getPos()); } - @Inject(method = "updatePaddles", at = @At("HEAD"), cancellable = true) + @Inject(method = "controlBoat", at = @At("HEAD"), cancellable = true) private void onPaddle(CallbackInfo ci) { if (ModuleManager.INSTANCE.getModuleByClass(BoatFly.class).isEnabled()) { ci.cancel(); diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/entity/EntityMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/entity/EntityMixin.java index 39c6bf7..d7cb804 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/entity/EntityMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/entity/EntityMixin.java @@ -1,8 +1,8 @@ package me.retucio.sputnik.mixin.mixins.entity; import com.llamalad7.mixinextras.injector.ModifyReturnValue; +import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.event.render.ChangeRotationEvent; -import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.camera.Freecam; import me.retucio.sputnik.module.modules.camera.Freelook; @@ -11,35 +11,43 @@ import me.retucio.sputnik.module.modules.misc.AntiInvis; import me.retucio.sputnik.module.modules.movement.BoatFly; import me.retucio.sputnik.module.modules.movement.Velocity; import me.retucio.sputnik.module.modules.render.Nametags; -import net.minecraft.entity.*; -import net.minecraft.entity.passive.TameableEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.projectile.PersistentProjectileEntity; -import net.minecraft.entity.vehicle.AbstractBoatEntity; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; -import net.minecraft.world.World; +import me.retucio.sputnik.util.interfaces.IVec3; +import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.network.chat.Component; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.TamableAnimal; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.item.PrimedTnt; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.projectile.arrow.AbstractArrow; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; +import net.minecraft.world.phys.HitResult; +import org.joml.Vector3d; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.gen.Accessor; -import org.spongepowered.asm.mixin.gen.Invoker; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import static me.retucio.sputnik.Sputnik.EVENT_BUS; -import static me.retucio.sputnik.Sputnik.mc; @Mixin(Entity.class) public abstract class EntityMixin { - @Shadow public abstract Text getName(); + @Unique boolean freecamDone; + + @Shadow public abstract Component getName(); @Shadow public abstract EntityType getType(); - @Shadow private float yaw; - @Shadow private float pitch; + @Shadow private float yRot; + @Shadow private float xRot; + + @Shadow + public abstract HitResult pick(double range, float a, boolean withLiquids); @Unique Freecam freecam; @@ -50,30 +58,74 @@ public abstract class EntityMixin { @Unique Rotations rotations; - @SuppressWarnings("rawtypes") @Inject(method = "", at = @At("TAIL")) - private void getModules(EntityType type, World world, CallbackInfo ci) { + private void getModules(CallbackInfo ci) { freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class); freelook = ModuleManager.INSTANCE.getModuleByClass(Freelook.class); nametags = ModuleManager.INSTANCE.getModuleByClass(Nametags.class); rotations = ModuleManager.INSTANCE.getModuleByClass(Rotations.class); } + @Inject(method = "pick", at = @At("HEAD"), cancellable = true) + private void updateTargetedEntityInvoke(double range, float a, boolean withLiquids, CallbackInfoReturnable cir) { + Minecraft mc = Minecraft.getInstance(); + if ((freecam.isEnabled()) && mc.getCameraEntity() != null && !freecamDone) { + cir.cancel(); + + Entity cameraEntity = mc.getCameraEntity(); + Vector3d pos = freecam.getPos(); + Vector3d prevPos = freecam.getPrevPos(); + + double x = cameraEntity.getX(); + double y = cameraEntity.getY(); + double z = cameraEntity.getZ(); + double lastX = cameraEntity.xo; + double lastY = cameraEntity.yo; + double lastZ = cameraEntity.zo; + float yaw = cameraEntity.getYRot(); + float pitch = cameraEntity.getXRot(); + float lastYaw = cameraEntity.yRotO; + float lastPitch = cameraEntity.xRotO; + + ((IVec3) cameraEntity.position()).sputnik$set(pos.x, pos.y - cameraEntity.getEyeHeight(cameraEntity.getPose()), pos.z); + cameraEntity.xo = prevPos.x; + cameraEntity.yo = prevPos.y - cameraEntity.getEyeHeight(cameraEntity.getPose()); + cameraEntity.zo = prevPos.z; + cameraEntity.setYRot(freecam.getYaw()); + cameraEntity.setXRot(freecam.getPitch()); + cameraEntity.yRotO = freecam.getPrevYaw(); + cameraEntity.xRotO = freecam.getPrevPitch(); + + freecamDone = true; + pick(range, a, withLiquids); + freecamDone = false; + + ((IVec3) cameraEntity.position()).sputnik$set(x, y, z); + cameraEntity.xo = lastX; + cameraEntity.yo = lastY; + cameraEntity.zo = lastZ; + cameraEntity.setYRot(yaw); + cameraEntity.setXRot(pitch); + cameraEntity.yRotO = lastYaw; + cameraEntity.xRotO = lastPitch; + } + } + // cámara libre & perspectiva libre @SuppressWarnings("ConstantConditions") - @Inject(method = "changeLookDirection", at = @At("HEAD"), cancellable = true) - private void onChangeLookDirection(double cursorDeltaX, double cursorDeltaY, CallbackInfo ci) { - if ((Object) this != mc.player) return; + @Inject(method = "turn", at = @At("HEAD"), cancellable = true) + private void onChangeLookDirection(double xo, double yo, CallbackInfo ci) { + if ((Object) this != Sputnik.mc.player) return; if (freecam.isEnabled()) { - freecam.changeLookDirection(cursorDeltaX * 0.15, cursorDeltaY * 0.15); + freecam.changeLookDirection(xo * 0.15, yo * 0.15); ci.cancel(); } else if (freelook.isEnabled() && freelook.mode.is(Freelook.CameraMode.CAMERA)) { - freelook.setYaw(freelook.getYaw() + (float) (cursorDeltaX * freelook.mouseSens.getFloatValue())); - freelook.setPitch(freelook.getPitch() + (float) (cursorDeltaY * freelook.mouseSens.getFloatValue())); + freelook.setYaw(freelook.getYaw() + (float) (xo * freelook.mouseSens.getFloatValue())); + freelook.setPitch(freelook.getPitch() + (float) (yo * freelook.mouseSens.getFloatValue())); if (Math.abs(freelook.getPitch()) > 90) freelook.setPitch(freelook.getPitch() > 0 ? 90 : -90); ci.cancel(); @@ -87,39 +139,39 @@ public abstract class EntityMixin { @ModifyReturnValue(method = "isCustomNameVisible", at = @At("RETURN")) private boolean renderEntityNametags(boolean original) { if (!nametags.isEnabled()) return original; - if ((Object) this instanceof PersistentProjectileEntity p && p.isOnGround()) return false; - if ((Object) this instanceof ItemEntity i && !nametags.items.isEnabled(i.getStack().getItem())) return false; + if ((Object) this instanceof AbstractArrow p && p.onGround()) return false; + if ((Object) this instanceof ItemEntity i && !nametags.items.isEnabled(i.getItem().getItem())) return false; return nametags.entities.isEnabled((this.getType())); } @ModifyReturnValue(method = "getName", at = @At("RETURN")) - private Text showProjectileDamage(Text original) { + private Component showProjectileDamage(Component original) { if (!nametags.isEnabled() || !nametags.showProjectileDamage.getValue()) return original; - if ((Object) this instanceof PersistentProjectileEntity arrow) { // aunque lo llame "arrow", también cubre flechas espectrales y tridentes + if ((Object) this instanceof AbstractArrow arrow) { // aunque se llame "arrow", también cubre flechas espectrales y tridentes String damage = nametags.getArrowDamage(arrow); - if (!damage.equals("0")) return original.copy().append(Text.literal(" (" + damage + ")").formatted(Formatting.RED)); + if (!damage.equals("0")) return original.copy().append(Component.literal(" (" + damage + ")").withStyle(ChatFormatting.RED)); } return original; } @ModifyReturnValue(method = "getName", at = @At("RETURN")) - private Text showTntPrimeTime(Text original) { + private Component showTntPrimeTime(Component original) { if (!nametags.isEnabled() || !nametags.tntPrime.getValue()) return original; - if ((Object) this instanceof TntEntity tnt) { - return Text.of(nametags.getTntPrimeTime(tnt)); + if ((Object) this instanceof PrimedTnt tnt) { + return Component.nullToEmpty(nametags.getTntPrimeTime(tnt)); } return original; } @SuppressWarnings("ConstantConditions") @ModifyReturnValue(method = "getCustomName", at = @At("RETURN")) - private Text displayEntityOwner(Text original) { + private Component displayEntityOwner(Component original) { if (!nametags.isEnabled() || !nametags.petOwner.getValue()) return original; - if ((Object) this instanceof TameableEntity entity && entity.getOwnerReference() != null) { + if ((Object) this instanceof TamableAnimal entity && entity.getOwnerReference() != null) { if (original != null) return original.copy().append(" (de " + nametags.getOwnerName(entity.getOwnerReference()) + ")"); - else return Text.of(nametags.getOwnerName(entity.getOwnerReference())); + else return Component.nullToEmpty(nametags.getOwnerName(entity.getOwnerReference())); } return original; } @@ -127,7 +179,7 @@ public abstract class EntityMixin { @SuppressWarnings("ConstantConditions") @ModifyReturnValue(method = "getName", at = @At("RETURN")) - private Text showBabies(Text original) { + private Component showBabies(Component original) { if (!nametags.isEnabled() || !nametags.distinguishBabies.getValue()) return original; if ((Object) this instanceof LivingEntity entity && entity.isBaby()) return original.copy().append(" (baby)"); return original; @@ -136,24 +188,24 @@ public abstract class EntityMixin { // rotaciones - @Inject(method = "setRotation", at = @At("HEAD"), cancellable = true) + @Inject(method = "setRot", at = @At("HEAD"), cancellable = true) private void onRotation(float yaw, float pitch, CallbackInfo ci) { - if ((Object) this != mc.player) return; - ChangeRotationEvent event = EVENT_BUS.post(new ChangeRotationEvent(yaw, pitch)); + if ((Object) this != Sputnik.mc.player) return; + ChangeRotationEvent event = Sputnik.EVENT_BUS.post(new ChangeRotationEvent(yaw, pitch)); if (event.isCancelled()) ci.cancel(); } - @Inject(method = "setYaw", at = @At("HEAD"), cancellable = true) + @Inject(method = "setYRot", at = @At("HEAD"), cancellable = true) private void onChangeYaw(float yaw, CallbackInfo ci) { - if ((Object) this != mc.player) return; - ChangeRotationEvent event = EVENT_BUS.post(new ChangeRotationEvent(yaw, this.pitch)); + if ((Object) this != Sputnik.mc.player) return; + ChangeRotationEvent event = Sputnik.EVENT_BUS.post(new ChangeRotationEvent(yaw, this.xRot)); if (event.isCancelled()) ci.cancel(); } - @Inject(method = "setPitch", at = @At("HEAD"), cancellable = true) + @Inject(method = "setXRot", at = @At("HEAD"), cancellable = true) private void onChangePitch(float pitch, CallbackInfo ci) { - if ((Object) this != mc.player) return; - ChangeRotationEvent event = EVENT_BUS.post(new ChangeRotationEvent(this.yaw, pitch)); + if ((Object) this != Sputnik.mc.player) return; + ChangeRotationEvent event = Sputnik.EVENT_BUS.post(new ChangeRotationEvent(this.yRot, pitch)); if (event.isCancelled()) ci.cancel(); } @@ -161,22 +213,23 @@ public abstract class EntityMixin { // otros @Inject(method = "isInvisibleTo", at = @At("RETURN"), cancellable = true) - private void renderInvisPlayers(PlayerEntity player, CallbackInfoReturnable cir) { + private void renderInvisPlayers(Player player, CallbackInfoReturnable cir) { if (ModuleManager.INSTANCE.getModuleByClass(AntiInvis.class).isEnabled()) cir.setReturnValue(false); } @SuppressWarnings("ConstantConditions") - @Inject(method = "getStepHeight", at = @At("RETURN"), cancellable = true) + @Inject(method = "maxUpStep", at = @At("RETURN"), cancellable = true) private void modifyBoatStepHeight(CallbackInfoReturnable cir) { BoatFly boatFly = ModuleManager.INSTANCE.getModuleByClass(BoatFly.class); - if (((Object) this) instanceof AbstractBoatEntity && boatFly.isEnabled()) { + if (((Object) this) instanceof AbstractBoat && boatFly.isEnabled()) { cir.setReturnValue(boatFly.stepHeight.getFloatValue()); } } - @Inject(method = "pushAwayFrom", at = @At("HEAD"), cancellable = true) + @SuppressWarnings("ConstantConditions") + @Inject(method = "push(Lnet/minecraft/world/entity/Entity;)V", at = @At("HEAD"), cancellable = true) private void onPushed(Entity entity, CallbackInfo ci) { Velocity velocity = ModuleManager.INSTANCE.getModuleByClass(Velocity.class); - if (velocity.isEnabled() && !velocity.push.getValue() && (Object) this == mc.player) ci.cancel(); + if (velocity.isEnabled() && !velocity.push.getValue() && (Object) this == Sputnik.mc.player) ci.cancel(); } } \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/entity/EntityRendererMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/entity/EntityRendererMixin.java index c378e60..cf7a50f 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/entity/EntityRendererMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/entity/EntityRendererMixin.java @@ -4,15 +4,15 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.sugar.Local; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.render.EntityESP; -import net.minecraft.client.render.entity.EntityRenderer; -import net.minecraft.client.render.entity.EntityRendererFactory; -import net.minecraft.entity.Entity; +import net.minecraft.client.renderer.entity.EntityRenderer; +import net.minecraft.world.entity.Entity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + @Mixin(EntityRenderer.class) public abstract class EntityRendererMixin { @@ -20,16 +20,16 @@ public abstract class EntityRendererMixin { private EntityESP esp; @Inject(method = "", at = @At("TAIL")) - private void getModules(EntityRendererFactory.Context context, CallbackInfo ci) { + private void getModules(CallbackInfo ci) { esp = ModuleManager.INSTANCE.getModuleByClass(EntityESP.class); } - @ModifyExpressionValue(method = "updateRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;hasOutline(Lnet/minecraft/entity/Entity;)Z")) + @ModifyExpressionValue(method = "extractRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;shouldEntityAppearGlowing(Lnet/minecraft/world/entity/Entity;)Z")) private boolean renderGlowESP(boolean original, @Local(argsOnly = true) Entity entity) { return (esp.isEnabled() && esp.mode.is(EntityESP.ESPMode.GLOW) && esp.entities.isEnabled(entity.getType())) || original; } - @ModifyExpressionValue(method = "updateRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getTeamColorValue()I")) + @ModifyExpressionValue(method = "extractRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getTeamColor()I")) private int setGlowESPColor(int original, @Local(argsOnly = true) Entity entity) { if (esp.isEnabled() && esp.mode.is(EntityESP.ESPMode.GLOW) && esp.entities.isEnabled(entity.getType())) return esp.glowColor.getRGB(); return original; diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/entity/ItemEntityMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/entity/ItemEntityMixin.java index bf9c791..60cc8d5 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/entity/ItemEntityMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/entity/ItemEntityMixin.java @@ -3,11 +3,11 @@ package me.retucio.sputnik.mixin.mixins.entity; import com.llamalad7.mixinextras.injector.ModifyReturnValue; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.render.Nametags; -import net.minecraft.entity.ItemEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.text.MutableText; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.ItemStack; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -16,17 +16,17 @@ import org.spongepowered.asm.mixin.injection.At; public abstract class ItemEntityMixin { @Shadow - public abstract ItemStack getStack(); + public abstract ItemStack getItem(); @ModifyReturnValue(method = "getName", at = @At("RETURN")) - private Text showItemCount(Text original) { + private Component showItemCount(Component original) { Nametags nametags = ModuleManager.INSTANCE.getModuleByClass(Nametags.class); if (!nametags.isEnabled()) return original; - int count = this.getStack().getCount(); - MutableText name = this.getStack().getCustomName() != null ? this.getStack().getCustomName().copyContentOnly() : original.copyContentOnly(); + int count = this.getItem().getCount(); + MutableComponent name = this.getItem().getCustomName() != null ? this.getItem().getCustomName().plainCopy() : original.plainCopy(); - if (!name.equals(original)) name = name.formatted(Formatting.ITALIC); + if (!name.equals(original)) name = name.withStyle(ChatFormatting.ITALIC); if (nametags.countItems.getValue()) { if (count > 1) return name.copy().append(" x" + count); diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/entity/LivingEntityMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/entity/LivingEntityMixin.java index bb94368..cf2e958 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/entity/LivingEntityMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/entity/LivingEntityMixin.java @@ -5,12 +5,12 @@ import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.movement.ElytraBounce; import me.retucio.sputnik.module.modules.movement.Step; import me.retucio.sputnik.module.modules.movement.Velocity; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvents; -import net.minecraft.util.math.Vec3d; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.phys.Vec3; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -21,6 +21,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import static me.retucio.sputnik.Sputnik.mc; + @Mixin(LivingEntity.class) public abstract class LivingEntityMixin { @@ -28,50 +29,49 @@ public abstract class LivingEntityMixin { @Unique private boolean awaitingElytra = false; @Shadow - public abstract boolean isGliding(); + public abstract boolean isFallFlying(); @SuppressWarnings("ConstantConditions") - @Inject(method = "tickMovement", at = @At("TAIL")) + @Inject(method = "aiStep", at = @At("TAIL")) private void recastIfLanded(CallbackInfo ci) { - ElytraBounce bounce = ModuleManager.INSTANCE.getModuleByClass(ElytraBounce.class); + ElytraBounce ebounce = ModuleManager.INSTANCE.getModuleByClass(ElytraBounce.class); - if (!((Object) this instanceof ClientPlayerEntity) + if (!((Object) this instanceof LocalPlayer) || mc.player == null - || bounce == null) + || ebounce == null) return; - boolean elytra = isGliding(); + boolean elytra = isFallFlying(); if (awaitingElytra) { if (elytra) awaitingElytra = false; - } else if (!elytra && prevElytra) { - mc.getSoundManager().stopSounds(SoundEvents.ITEM_ELYTRA_FLYING.id(), SoundCategory.PLAYERS); - bounce.bounce(); - awaitingElytra = bounce.canUseElytra(); + mc.getSoundManager().stop(SoundEvents.ELYTRA_FLYING.location(), SoundSource.PLAYERS); // armor equip elytra?? + ebounce.bounce(); + awaitingElytra = ebounce.canUseElytra(); } prevElytra = elytra; } - @Inject(method = "getStepHeight", at = @At("RETURN"), cancellable = true) + @Inject(method = "maxUpStep", at = @At("RETURN"), cancellable = true) private void step(CallbackInfoReturnable cir) { Step step = ModuleManager.INSTANCE.getModuleByClass(Step.class); if (step.isEnabled()) cir.setReturnValue(step.height.getFloatValue()); } - @Inject(method = "takeKnockback", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;setVelocity(DDD)V"), cancellable = true) - private void onTakeKb(double strength, double x, double z, CallbackInfo ci, @Local(ordinal = 0) Vec3d vec3d, @Local(ordinal = 1) Vec3d vec3d2) { + @Inject(method = "knockback", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;setDeltaMovement(DDD)V"), cancellable = true) + private void onTakeKb(double strength, double x, double z, CallbackInfo ci, @Local(name = "deltaMovement") Vec3 dm, @Local(name = "deltaVector") Vec3 dv) { Velocity velocity = ModuleManager.INSTANCE.getModuleByClass(Velocity.class); if (!velocity.isEnabled() || velocity.hits.getValue()) return; - boolean onGround = ((LivingEntity) (Object) this).isOnGround(); + boolean onGround = ((LivingEntity) (Object) this).onGround(); - double kbX = (velocity.xPercentage.getValue() / 100) * (vec3d.x / 2 - vec3d2.x); - double kbY = (velocity.yPercentage.getValue() / 100) * ((onGround ? Math.min(0.4, vec3d.y / 2 + strength) : vec3d.y)); - double kbZ = (velocity.zPercentage.getValue() / 100) * (vec3d.z / 2 - vec3d2.z); + double kbX = (velocity.xPercentage.getValue() / 100) * (dm.x / 2 - dv.x); + double kbY = (velocity.yPercentage.getValue() / 100) * ((onGround ? Math.min(0.4, dm.y / 2 + strength) : dm.y)); + double kbZ = (velocity.zPercentage.getValue() / 100) * (dm.z / 2 - dv.z); ci.cancel(); - ((Entity) (Object) this).addVelocity(kbX, kbY, kbZ); + ((Entity) (Object) this).addDeltaMovement(new Vec3(kbX, kbY, kbZ)); } } \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/hud/BossBarHudMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/hud/BossBarHudMixin.java index 854ff75..e88acfc 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/hud/BossBarHudMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/hud/BossBarHudMixin.java @@ -2,10 +2,12 @@ package me.retucio.sputnik.mixin.mixins.hud; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.sugar.Local; +import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.event.render.RenderBossbarEvent; -import net.minecraft.client.gui.hud.BossBarHud; -import net.minecraft.client.gui.hud.ClientBossBar; -import net.minecraft.text.Text; +import net.minecraft.client.gui.components.BossHealthOverlay; +import net.minecraft.client.gui.components.LerpingBossEvent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Constant; @@ -13,28 +15,26 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant; import java.util.Iterator; -import static me.retucio.sputnik.Sputnik.EVENT_BUS; - -@Mixin(value = BossBarHud.class) +@Mixin(value = BossHealthOverlay.class) public abstract class BossBarHudMixin { - @ModifyExpressionValue(method = "render", at = @At(value = "INVOKE", target = "Ljava/util/Collection;iterator()Ljava/util/Iterator;")) - public Iterator modifyBossBarIterator(Iterator original) { - RenderBossbarEvent.BossIterator event = EVENT_BUS.post(new RenderBossbarEvent.BossIterator(original)); + @ModifyExpressionValue(method = "extractRenderState", at = @At(value = "INVOKE", target = "Ljava/util/Collection;iterator()Ljava/util/Iterator;")) + private Iterator modifyBossBarIterator(Iterator original) { + RenderBossbarEvent.BossIterator event = Sputnik.EVENT_BUS.post(new RenderBossbarEvent.BossIterator(original)); return event.getIterator(); } - @ModifyExpressionValue(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ClientBossBar;getName()Lnet/minecraft/text/Text;")) - public Text modifyBossBarName(Text original, @Local ClientBossBar clientBossBar) { - RenderBossbarEvent.BossText event = EVENT_BUS.post(new RenderBossbarEvent.BossText(clientBossBar, original)); + @ModifyExpressionValue(method = "extractRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/LerpingBossEvent;getName()Lnet/minecraft/network/chat/Component;")) + private Component modifyBossBarName(Component original, @Local(name = "event") LerpingBossEvent clientBossBar) { + RenderBossbarEvent.BossText event = Sputnik.EVENT_BUS.post(new RenderBossbarEvent.BossText(clientBossBar, (MutableComponent) original)); return event.getName(); } - // require = 0 para meteor - @ModifyConstant(method = "render", constant = @Constant(intValue = 9, ordinal = 1), require = 0) - public int modifySpacingConstant(int constant) { - RenderBossbarEvent.BossSpacing event = EVENT_BUS.post(new RenderBossbarEvent.BossSpacing(constant)); + // require = 0 para compat. con meteor + @ModifyConstant(method = "extractRenderState", constant = @Constant(intValue = 9, ordinal = 1), require = 0) + private int modifySpacingConstant(int constant) { + RenderBossbarEvent.BossSpacing event = Sputnik.EVENT_BUS.post(new RenderBossbarEvent.BossSpacing(constant)); return event.getSpacing(); } } diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/hud/ChatHudLineConsumerMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/hud/ChatComponentLineConsumerMixin.java similarity index 62% rename from src/main/java/me/retucio/sputnik/mixin/mixins/hud/ChatHudLineConsumerMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/hud/ChatComponentLineConsumerMixin.java index bc56da7..f675b4b 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/hud/ChatHudLineConsumerMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/hud/ChatComponentLineConsumerMixin.java @@ -2,17 +2,17 @@ package me.retucio.sputnik.mixin.mixins.hud; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.misc.ChatPlus; -import net.minecraft.client.gui.hud.ChatHudLine; +import net.minecraft.client.multiplayer.chat.GuiMessage; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(targets = "net.minecraft.client.gui.hud.ChatHud$1", remap = false) -public abstract class ChatHudLineConsumerMixin { +@Mixin(targets = "net.minecraft.client.gui.components.ChatComponent$1", remap = false) +public abstract class ChatComponentLineConsumerMixin { @Inject(method = "accept", at = @At("HEAD")) - private void setLine(ChatHudLine.Visible line, int y, float opacity, CallbackInfo ci) { + private void setLine(GuiMessage.Line line, int lineIndex, float alpha, CallbackInfo ci) { ModuleManager.INSTANCE.getModuleByClass(ChatPlus.class).line = line; } } diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/hud/ChatComponentMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/hud/ChatComponentMixin.java new file mode 100644 index 0000000..5157a2e --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/hud/ChatComponentMixin.java @@ -0,0 +1,187 @@ +package me.retucio.sputnik.mixin.mixins.hud; + +import me.retucio.sputnik.Sputnik; +import me.retucio.sputnik.event.network.ReceiveMessageEvent; +import me.retucio.sputnik.module.ModuleManager; +import me.retucio.sputnik.module.modules.misc.ChatPlus; + +import me.retucio.sputnik.util.interfaces.IChatComponent; +import me.retucio.sputnik.util.interfaces.IGuiMessage; +import me.retucio.sputnik.util.interfaces.IGuiMessageLine; +import me.retucio.sputnik.util.interfaces.IChatListener; + +import net.minecraft.client.gui.components.ChatComponent; +import net.minecraft.client.multiplayer.chat.GuiMessage; +import net.minecraft.client.multiplayer.chat.GuiMessageSource; +import net.minecraft.client.multiplayer.chat.GuiMessageTag; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MessageSignature; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.sugar.Local; +import net.minecraft.util.FormattedCharSequence; +import org.jspecify.annotations.Nullable; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.List; + + +@Mixin(ChatComponent.class) +public abstract class ChatComponentMixin implements IChatComponent { + + @Unique + private boolean skipOnAddMessage; + + @Unique + private int nextId; + + @Unique + ChatPlus chatPlus; + + @Shadow @Final + private List allMessages; + + @Shadow @Final + private List trimmedMessages; + + @Shadow + public abstract void addClientSystemMessage(Component message); + + @Shadow + protected abstract void addMessage(final Component contents, final @Nullable MessageSignature signature, final GuiMessageSource source, final @Nullable GuiMessageTag tag); + + @Inject(method = "", at = @At("TAIL")) + private void getModules(CallbackInfo ci) { + chatPlus = ModuleManager.INSTANCE.getModuleByClass(ChatPlus.class); + } + + + // métodos relacionados con las interfaces IChatHud, IChatHudLine, IChadHudLineVisible y IMessageHandler + + @Override + public void sputnik$add(Component message, int id) { + nextId = id; + addClientSystemMessage(message); + nextId = 0; + } + + @Inject(method = "addMessageToDisplayQueue", at = @At(value = "INVOKE", target = "Ljava/util/List;addFirst(Ljava/lang/Object;)V", shift = At.Shift.AFTER)) + private void onAddMessageAfterNewChatHudLineVisible(GuiMessage message, CallbackInfo ci) { + ((IGuiMessage) (Object) trimmedMessages.getFirst()).sputnik$setId(nextId); + } + + @Inject(method = "addMessageToQueue", at = @At(value = "INVOKE", target = "Ljava/util/List;addFirst(Ljava/lang/Object;)V", shift = At.Shift.AFTER)) + private void onAddMessageAfterNewChatHudLine(GuiMessage message, CallbackInfo ci) { + ((IGuiMessage) (Object) allMessages.getFirst()).sputnik$setId(nextId); + } + + @ModifyExpressionValue(method = "addMessageToDisplayQueue", at = @At(value = "NEW", target = "(Lnet/minecraft/client/multiplayer/chat/GuiMessage;Lnet/minecraft/util/FormattedCharSequence;Z)Lnet/minecraft/client/multiplayer/chat/GuiMessage$Line;")) + private GuiMessage.Line onAddMessage_modifyChatHudLineVisible(GuiMessage.Line line, @Local(name = "i") int i) { + IChatListener iListener = (IChatListener) Sputnik.mc.getChatListener(); + IGuiMessageLine iLine = (IGuiMessageLine) (Object) line; + + iLine.sputnik$setSender(iListener.sputnik$getSender()); + iLine.sputnik$setStartOfEntry(i == 0); + + return line; + } + + @ModifyExpressionValue(method = "addMessage", at = @At(value = "NEW", target = "(ILnet/minecraft/network/chat/Component;Lnet/minecraft/network/chat/MessageSignature;Lnet/minecraft/client/multiplayer/chat/GuiMessageSource;Lnet/minecraft/client/multiplayer/chat/GuiMessageTag;)Lnet/minecraft/client/multiplayer/chat/GuiMessage;")) + private GuiMessage onAddMessage_modifyChatHudLine(GuiMessage line) { + IChatListener iListener = (IChatListener) Sputnik.mc.getChatListener(); + ((IGuiMessage) (Object) line).sputnik$setSender(iListener.sputnik$getSender()); + return line; + } + + @Override + public List sputnik$getVisibleMessages() { + return trimmedMessages; + } + + + // modificar contenido del mensaje + + @Inject(at = @At("HEAD"), method = "addMessage", cancellable = true) + private void onAddMessage(Component contents, MessageSignature signature, GuiMessageSource source, GuiMessageTag tag, CallbackInfo ci) { + if (skipOnAddMessage) return; + + ReceiveMessageEvent event = Sputnik.EVENT_BUS.post(new ReceiveMessageEvent(contents, tag, nextId)); + + if (event.isCancelled()) { + ci.cancel(); + } else { + trimmedMessages.removeIf(msg -> ((IGuiMessage) (Object) msg).sputnik$getId() == nextId && nextId != 0); + + for (int i = allMessages.size() - 1; i > -1; i--) { + if (((IGuiMessage) (Object) allMessages.get(i)).sputnik$getId() == nextId && nextId != 0) { + allMessages.remove(i); + chatPlus.removeLine(i); + } + } + + if (event.wasModified()) { + ci.cancel(); + + skipOnAddMessage = true; + addMessage(event.getMessage(), signature, source, event.getTag()); + skipOnAddMessage = false; + } + } + } + + + + // cabezas + + @ModifyExpressionValue(method = "extractRenderState(Lnet/minecraft/client/gui/components/ChatComponent$ChatGraphicsAccess;IILnet/minecraft/client/gui/components/ChatComponent$DisplayMode;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Mth;ceil(F)I")) + private int onRender_modifyWidth(int width) { + return (chatPlus.isEnabled() && chatPlus.showHeads.getValue()) ? width + 10 : width; + } + + + // historial (registro) del chat + + @ModifyExpressionValue(method = "addMessageToQueue", at = @At(value = "CONSTANT", args = "intValue=100")) + private int maxLength(int size) { + if (!chatPlus.isEnabled()) return size; + return size + chatPlus.chatHistoryExtraLength.getIntValue(); + } + + @ModifyExpressionValue(method = "addMessageToDisplayQueue", at = @At(value = "CONSTANT", args = "intValue=100")) + private int maxLengthVisible(int size) { + if (!chatPlus.isEnabled()) return size; + return size + chatPlus.chatHistoryExtraLength.getIntValue(); + } + + @Inject(method = "addMessageToDisplayQueue", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/ChatComponent;isChatFocused()Z")) + private void onBreakChatMessageLines(GuiMessage message, CallbackInfo ci, @Local(name = "lines") List lines) { + chatPlus.lines.addFirst(lines.size()); + } + + @Inject(method = "addMessageToDisplayQueue", at = @At(value = "INVOKE", target = "Ljava/util/List;removeLast()Ljava/lang/Object;")) + private void onRemoveMessage(GuiMessage message, CallbackInfo ci) { + int extra = chatPlus.chatHistoryExtraLength.getIntValue(); + int size = chatPlus.lines.size(); + + while (size > 100 + extra) { + chatPlus.lines.removeLast(); + size--; + } + } + + @Inject(method = "clearMessages", at = @At("HEAD")) + private void onClear(boolean history, CallbackInfo ci) { + chatPlus.lines.clear(); + } + + @Inject(method = "refreshTrimmedMessages", at = @At("HEAD")) + private void onRefresh(CallbackInfo ci) { + chatPlus.lines.clear(); + } +} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/hud/ChatHudInteractableMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/hud/ChatHudInteractableMixin.java deleted file mode 100644 index 93eb38a..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/hud/ChatHudInteractableMixin.java +++ /dev/null @@ -1,52 +0,0 @@ -package me.retucio.sputnik.mixin.mixins.hud; - -import com.llamalad7.mixinextras.injector.ModifyReceiver; -import me.retucio.sputnik.module.ModuleManager; -import me.retucio.sputnik.module.modules.misc.ChatPlus; -import net.minecraft.client.font.Alignment; -import net.minecraft.client.font.DrawnTextConsumer; -import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.hud.ChatHud; -import net.minecraft.text.OrderedText; -import net.minecraft.util.math.ColorHelper; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(ChatHud.Interactable.class) -public abstract class ChatHudInteractableMixin { - - @Unique - private static ChatPlus chatPlus; - - @Shadow @Final - private DrawContext context; - - @Inject(method = "", at = @At("TAIL")) - private void getModules(DrawContext context, TextRenderer textRenderer, int mouseX, int mouseY, boolean bl, CallbackInfo ci) { - chatPlus = ModuleManager.INSTANCE.getModuleByClass(ChatPlus.class); - } - - @ModifyReceiver(method = "text", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/DrawnTextConsumer;text(Lnet/minecraft/client/font/Alignment;IILnet/minecraft/client/font/DrawnTextConsumer$Transformation;Lnet/minecraft/text/OrderedText;)V")) - private DrawnTextConsumer onRender_beforeDrawTextWithShadow(DrawnTextConsumer instance, Alignment alignment, int x, int y, DrawnTextConsumer.Transformation transformation, OrderedText orderedText) { - chatPlus.beforeDrawMessage(context, y, ColorHelper.getWhite(transformation.opacity())); - return instance; - } - - @ModifyArg(method = "text", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/DrawnTextConsumer;text(Lnet/minecraft/client/font/Alignment;IILnet/minecraft/client/font/DrawnTextConsumer$Transformation;Lnet/minecraft/text/OrderedText;)V"), index = 1) - private int modifyX(int x) { - return (chatPlus.isEnabled() && chatPlus.showHeads.getValue()) ? x + 10 : x; - } - - @Inject(method = "text", at = @At("TAIL")) - private void onRender_afterDrawTextWithShadow(int y, float f, OrderedText text, CallbackInfoReturnable cir) { - chatPlus.afterDrawMessage(); - } -} diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/hud/ChatHudMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/hud/ChatHudMixin.java deleted file mode 100644 index 6b58130..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/hud/ChatHudMixin.java +++ /dev/null @@ -1,189 +0,0 @@ -package me.retucio.sputnik.mixin.mixins.hud; - -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import com.llamalad7.mixinextras.sugar.Local; -import me.retucio.sputnik.event.network.ReceiveMessageEvent; -import me.retucio.sputnik.module.ModuleManager; -import me.retucio.sputnik.module.modules.misc.ChatPlus; -import me.retucio.sputnik.util.interfaces.IChatHud; -import me.retucio.sputnik.util.interfaces.IChatHudLine; -import me.retucio.sputnik.util.interfaces.IChatHudLineVisible; -import me.retucio.sputnik.util.interfaces.IMessageHandler; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.hud.ChatHud; -import net.minecraft.client.gui.hud.ChatHudLine; -import net.minecraft.client.gui.hud.MessageIndicator; -import net.minecraft.network.message.MessageSignatureData; -import net.minecraft.text.OrderedText; -import net.minecraft.text.Text; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.List; - -import static me.retucio.sputnik.Sputnik.*; - -@Mixin(ChatHud.class) -public abstract class ChatHudMixin implements IChatHud { - - @Unique - private boolean skipOnAddMessage; - - @Unique - private int nextId; - - @Unique - ChatPlus chatPlus; - - @Shadow @Final - private List messages; - - @Shadow @Final - private List visibleMessages; - - @Shadow - public abstract void addMessage(Text message); - - @Shadow - public abstract void addMessage(Text message, @Nullable MessageSignatureData signatureData, @Nullable MessageIndicator indicator); - - @Inject(method = "", at = @At("TAIL")) - private void getModules(MinecraftClient client, CallbackInfo ci) { - chatPlus = ModuleManager.INSTANCE.getModuleByClass(ChatPlus.class); - } - - - // métodos relacionados a las interfaces IChatHud, IChatHudLine, IChadHudLineVisible y IMessageHandler - - @Override - public void sputnik$add(Text message, int id) { - nextId = id; - addMessage(message); - nextId = 0; - } - - @Inject(method = "addVisibleMessage", at = @At(value = "INVOKE", target = "Ljava/util/List;addFirst(Ljava/lang/Object;)V", shift = At.Shift.AFTER)) - private void onAddMessageAfterNewChatHudLineVisible(ChatHudLine message, CallbackInfo ci) { - ((IChatHudLine) (Object) visibleMessages.getFirst()).sputnik$setId(nextId); - } - - @Inject(method = "addMessage(Lnet/minecraft/client/gui/hud/ChatHudLine;)V", at = @At(value = "INVOKE", target = "Ljava/util/List;addFirst(Ljava/lang/Object;)V", shift = At.Shift.AFTER)) - private void onAddMessageAfterNewChatHudLine(ChatHudLine message, CallbackInfo ci) { - ((IChatHudLine) (Object) messages.getFirst()).sputnik$setId(nextId); - } - - @SuppressWarnings("DataFlowIssue") - @ModifyExpressionValue(method = "addVisibleMessage", at = @At(value = "NEW", target = "(ILnet/minecraft/text/OrderedText;Lnet/minecraft/client/gui/hud/MessageIndicator;Z)Lnet/minecraft/client/gui/hud/ChatHudLine$Visible;")) - private ChatHudLine.Visible onAddMessage_modifyChatHudLineVisible(ChatHudLine.Visible line, @Local(ordinal = 1) int j) { - IMessageHandler handler = (IMessageHandler) mc.getMessageHandler(); - if (handler == null) return line; - - IChatHudLineVisible iLine = (IChatHudLineVisible) (Object) line; - - iLine.sputnik$setSender(handler.sputnik$getSender()); - iLine.sputnik$setStartOfEntry(j == 0); - - return line; - } - - @ModifyExpressionValue(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V", at = @At(value = "NEW", target = "(ILnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)Lnet/minecraft/client/gui/hud/ChatHudLine;")) - private ChatHudLine onAddMessage_modifyChatHudLine(ChatHudLine line) { - IMessageHandler handler = (IMessageHandler) mc.getMessageHandler(); - if (handler == null) return line; - - ((IChatHudLine) (Object) line).sputnik$setSender(handler.sputnik$getSender()); - return line; - } - - @Override - public List sputnik$getVisibleMessages() { - return visibleMessages; - } - - - // modificar contenido del mensaje - - @Inject(at = @At("HEAD"), method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V", cancellable = true) - private void onAddMessage(Text message, MessageSignatureData signatureData, MessageIndicator indicator, CallbackInfo ci) { - if (skipOnAddMessage) return; - - ReceiveMessageEvent event = EVENT_BUS.post(new ReceiveMessageEvent(message, indicator, nextId)); - - if (event.isCancelled()) { - ci.cancel(); - } else { - visibleMessages.removeIf(msg -> ((IChatHudLine) (Object) msg).sputnik$getId() == nextId && nextId != 0); - - for (int i = messages.size() - 1; i > -1; i--) { - if (((IChatHudLine) (Object) messages.get(i)).sputnik$getId() == nextId && nextId != 0) { - messages.remove(i); - chatPlus.removeLine(i); - } - } - - if (event.wasModified()) { - ci.cancel(); - - skipOnAddMessage = true; - addMessage(event.getMessage(), signatureData, event.getIndicator()); - skipOnAddMessage = false; - } - } - } - - - - // cabezas - - @ModifyExpressionValue(method = "render(Lnet/minecraft/client/gui/hud/ChatHud$Backend;IIZ)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;ceil(F)I")) - private int onRender_modifyWidth(int width) { - return (chatPlus.isEnabled() && chatPlus.showHeads.getValue()) ? width + 10 : width; - } - - - // historial (registro) del chat - - @ModifyExpressionValue(method = "addMessage(Lnet/minecraft/client/gui/hud/ChatHudLine;)V", at = @At(value = "CONSTANT", args = "intValue=100")) - private int maxLength(int size) { - if (!chatPlus.isEnabled()) return size; - return size + chatPlus.chatHistoryExtraLength.getIntValue(); - } - - @ModifyExpressionValue(method = "addVisibleMessage", at = @At(value = "CONSTANT", args = "intValue=100")) - private int maxLengthVisible(int size) { - if (!chatPlus.isEnabled()) return size; - return size + chatPlus.chatHistoryExtraLength.getIntValue(); - } - - @Inject(method = "addVisibleMessage", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;isChatFocused()Z")) - private void onBreakChatMessageLines(ChatHudLine message, CallbackInfo ci, @Local List list) { - chatPlus.lines.addFirst(list.size()); - } - - @Inject(method = "addMessage(Lnet/minecraft/client/gui/hud/ChatHudLine;)V", at = @At(value = "INVOKE", target = "Ljava/util/List;removeLast()Ljava/lang/Object;")) - private void onRemoveMessage(ChatHudLine message, CallbackInfo ci) { - int extra = chatPlus.chatHistoryExtraLength.getIntValue(); - int size = chatPlus.lines.size(); - - while (size > 100 + extra) { - chatPlus.lines.removeLast(); - size--; - } - } - - @Inject(method = "clear", at = @At("HEAD")) - private void onClear(boolean clearHistory, CallbackInfo ci) { - chatPlus.lines.clear(); - } - - @Inject(method = "refresh", at = @At("HEAD")) - private void onRefresh(CallbackInfo ci) { - chatPlus.lines.clear(); - } -} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/hud/DrawingFocusedGraphicsAccessMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/hud/DrawingFocusedGraphicsAccessMixin.java new file mode 100644 index 0000000..5a904e8 --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/hud/DrawingFocusedGraphicsAccessMixin.java @@ -0,0 +1,54 @@ +package me.retucio.sputnik.mixin.mixins.hud; + +import me.retucio.sputnik.module.ModuleManager; +import me.retucio.sputnik.module.modules.misc.ChatPlus; + +import net.minecraft.client.gui.ActiveTextCollector; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.client.gui.TextAlignment; +import net.minecraft.client.gui.components.ChatComponent; +import net.minecraft.util.ARGB; +import net.minecraft.util.FormattedCharSequence; + +import com.llamalad7.mixinextras.injector.ModifyReceiver; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + + +@Mixin(ChatComponent.DrawingFocusedGraphicsAccess.class) +public abstract class DrawingFocusedGraphicsAccessMixin { + + @Unique + private static ChatPlus chatPlus; + + @Shadow @Final + private GuiGraphicsExtractor graphics; + + @Inject(method = "", at = @At("TAIL")) + private void getModules(CallbackInfo ci) { + chatPlus = ModuleManager.INSTANCE.getModuleByClass(ChatPlus.class); + } + + @ModifyReceiver(method = "handleMessage", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/ActiveTextCollector;accept(Lnet/minecraft/client/gui/TextAlignment;IILnet/minecraft/client/gui/ActiveTextCollector$Parameters;Lnet/minecraft/util/FormattedCharSequence;)V")) + private ActiveTextCollector onRender_beforeDrawTextWithShadow(ActiveTextCollector instance, TextAlignment textAlignment, int x, int y, ActiveTextCollector.Parameters parameters, FormattedCharSequence formattedCharSequence) { + chatPlus.beforeDrawMessage(graphics, y, ARGB.white(parameters.opacity())); + return instance; + } + + @ModifyArg(method = "handleMessage", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/ActiveTextCollector;accept(Lnet/minecraft/client/gui/TextAlignment;IILnet/minecraft/client/gui/ActiveTextCollector$Parameters;Lnet/minecraft/util/FormattedCharSequence;)V"), index = 1) + private int modifyX(int x) { + return (chatPlus.isEnabled() && chatPlus.showHeads.getValue()) ? x + 10 : x; + } + + @Inject(method = "handleMessage", at = @At("TAIL")) + private void onRender_afterDrawTextWithShadow(int textTop, float opacity, FormattedCharSequence message, CallbackInfoReturnable cir) { + chatPlus.afterDrawMessage(); + } +} diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/hud/ChatHudLineVisibleMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/hud/GuiMessageLineMixin.java similarity index 79% rename from src/main/java/me/retucio/sputnik/mixin/mixins/hud/ChatHudLineVisibleMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/hud/GuiMessageLineMixin.java index 32bfac3..0db7345 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/hud/ChatHudLineVisibleMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/hud/GuiMessageLineMixin.java @@ -1,19 +1,19 @@ package me.retucio.sputnik.mixin.mixins.hud; import com.mojang.authlib.GameProfile; -import me.retucio.sputnik.util.interfaces.IChatHudLineVisible; -import net.minecraft.client.gui.hud.ChatHudLine; -import net.minecraft.text.OrderedText; +import me.retucio.sputnik.util.interfaces.IGuiMessageLine; +import net.minecraft.client.multiplayer.chat.GuiMessage; +import net.minecraft.util.FormattedCharSequence; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; -@Mixin(ChatHudLine.Visible.class) -public class ChatHudLineVisibleMixin implements IChatHudLineVisible { +@Mixin(GuiMessage.Line.class) +public class GuiMessageLineMixin implements IGuiMessageLine { @Shadow @Final - private OrderedText content; + private FormattedCharSequence content; @Unique private int id; diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/hud/ChatHudLineMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/hud/GuiMessageMixin.java similarity index 73% rename from src/main/java/me/retucio/sputnik/mixin/mixins/hud/ChatHudLineMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/hud/GuiMessageMixin.java index dda03a0..090e7a7 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/hud/ChatHudLineMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/hud/GuiMessageMixin.java @@ -1,19 +1,19 @@ package me.retucio.sputnik.mixin.mixins.hud; import com.mojang.authlib.GameProfile; -import me.retucio.sputnik.util.interfaces.IChatHudLine; -import net.minecraft.client.gui.hud.ChatHudLine; -import net.minecraft.text.Text; +import me.retucio.sputnik.util.interfaces.IGuiMessage; +import net.minecraft.client.multiplayer.chat.GuiMessage; +import net.minecraft.network.chat.Component; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; -@Mixin(ChatHudLine.class) -public class ChatHudLineMixin implements IChatHudLine { +@Mixin(GuiMessage.class) +public class GuiMessageMixin implements IGuiMessage { @Shadow @Final - private Text content; + private Component content; @Unique private int id; diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/hud/InGameHudMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/hud/InGameHudMixin.java index 2bcfb22..9148ce4 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/hud/InGameHudMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/hud/InGameHudMixin.java @@ -8,80 +8,79 @@ import me.retucio.sputnik.module.modules.misc.ChatPlus; import me.retucio.sputnik.module.modules.camera.Freecam; import me.retucio.sputnik.module.modules.render.NoRender; import me.retucio.sputnik.ui.hud.HudRenderer; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.hud.InGameHud; -import net.minecraft.client.render.RenderTickCounter; -import net.minecraft.util.Identifier; +import net.minecraft.client.DeltaTracker; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.resources.Identifier; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(InGameHud.class) +@Mixin(Gui.class) public abstract class InGameHudMixin { @Unique NoRender noRender; @Inject(method = "", at = @At("TAIL")) - private void getModules(MinecraftClient client, CallbackInfo ci) { + private void getModules(CallbackInfo ci) { noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class); } - @Inject(method = "render", at = @At("TAIL")) - private void onRenderHud(DrawContext ctx, RenderTickCounter tc, CallbackInfo ci) { - Sputnik.EVENT_BUS.post(new Render2DEvent(ctx, tc)); + @Inject(method = "extractRenderState", at = @At("TAIL")) + private void onRenderHud(GuiGraphicsExtractor gui, DeltaTracker dt, CallbackInfo ci) { + Sputnik.EVENT_BUS.post(new Render2DEvent(gui, dt)); } // norender - @Inject(method = "renderScoreboardSidebar*", at = @At("HEAD"), cancellable = true) + @Inject(method = "extractScoreboardSidebar", at = @At("HEAD"), cancellable = true) private void noRenderScoreboard(CallbackInfo ci) { if (noRender.isEnabled() && !noRender.scoreboard.getValue()) ci.cancel(); } - @Inject(method = "renderTitleAndSubtitle", at = @At("HEAD"), cancellable = true) - private void noRenderTitles(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) { + @Inject(method = "extractTitle", at = @At("HEAD"), cancellable = true) + private void noRenderTitles(GuiGraphicsExtractor graphics, DeltaTracker deltaTracker, CallbackInfo ci) { if (noRender.isEnabled() && !noRender.titles.getValue()) ci.cancel(); } - @Inject(method = "renderNauseaOverlay", at = @At("HEAD"), cancellable = true) - private void noRenderNausea(DrawContext context, float nauseaStrength, CallbackInfo ci) { + @Inject(method = "extractConfusionOverlay", at = @At("HEAD"), cancellable = true) + private void noRenderNausea(GuiGraphicsExtractor graphics, float strength, CallbackInfo ci) { if (noRender.isEnabled() && !noRender.nauseaEffect.getValue()) ci.cancel(); } - @Inject(method = "renderSpyglassOverlay", at = @At("HEAD"), cancellable = true) - private void noRenderSpyglass(DrawContext context, float scale, CallbackInfo ci) { + @Inject(method = "extractSpyglassOverlay", at = @At("HEAD"), cancellable = true) + private void noRenderSpyglass(GuiGraphicsExtractor graphics, float scale, CallbackInfo ci) { if (noRender.isEnabled() && !noRender.spyglassOverlay.getValue()) ci.cancel(); } - @Inject(method = "renderPortalOverlay", at = @At("HEAD"), cancellable = true) - private void noRenderPortal(DrawContext context, float nauseaStrength, CallbackInfo ci) { + @Inject(method = "extractPortalOverlay", at = @At("HEAD"), cancellable = true) + private void noRenderPortal(GuiGraphicsExtractor graphics, float alpha, CallbackInfo ci) { if (noRender.isEnabled() && !noRender.portalOverlay.getValue()) ci.cancel(); } - @Inject(method = "renderOverlay", at = @At("HEAD"), cancellable = true) - private void noRenderPumpkinBlur(DrawContext context, Identifier texture, float opacity, CallbackInfo ci) { + @Inject(method = "extractTextureOverlay", at = @At("HEAD"), cancellable = true) + private void noRenderPumpkinBlur(GuiGraphicsExtractor graphics, Identifier texture, float alpha, CallbackInfo ci) { if (noRender.isEnabled() && !noRender.pumpkinOverlay.getValue() && texture.getPath().equals("textures/misc/pumpkinblur.png")) ci.cancel(); } // otros - @Inject(method = "render", at = @At("RETURN")) - private void renderHUD(DrawContext ctx, RenderTickCounter tc, CallbackInfo ci) { - HudRenderer.render(ctx, tc); + @Inject(method = "extractRenderState", at = @At("RETURN")) + private void renderHUD(GuiGraphicsExtractor gui, DeltaTracker dt, CallbackInfo ci) { + HudRenderer.render(gui, dt); } - @ModifyExpressionValue(method = "renderCrosshair", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/Perspective;isFirstPerson()Z")) + @ModifyExpressionValue(method = "extractCrosshair", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/CameraType;isFirstPerson()Z")) private boolean alwaysRenderCrosshairInFreecam(boolean firstPerson) { return ModuleManager.INSTANCE.getModuleByClass(Freecam.class).isEnabled() || firstPerson; } - @Inject(method = "clear", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;clear(Z)V"), cancellable = true) + @Inject(method = "onDisconnected", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/ChatComponent;clearMessages(Z)V"), cancellable = true) private void onClear(CallbackInfo ci) { ChatPlus chatPlus = ModuleManager.INSTANCE.getModuleByClass(ChatPlus.class); if (chatPlus.isEnabled() && chatPlus.keepHistory.getValue()) ci.cancel(); diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/io/KeyboardMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/io/KeyboardHandlerMixin.java similarity index 52% rename from src/main/java/me/retucio/sputnik/mixin/mixins/io/KeyboardMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/io/KeyboardHandlerMixin.java index eb887f8..0df5af1 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/io/KeyboardMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/io/KeyboardHandlerMixin.java @@ -2,23 +2,21 @@ package me.retucio.sputnik.mixin.mixins.io; import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.event.input.KeyEvent; -import net.minecraft.client.Keyboard; -import net.minecraft.client.input.KeyInput; +import net.minecraft.client.KeyboardHandler; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import static me.retucio.sputnik.Sputnik.EVENT_BUS; -@Mixin(Keyboard.class) -public abstract class KeyboardMixin { +@Mixin(KeyboardHandler.class) +public abstract class KeyboardHandlerMixin { - @Inject(method = "onKey", at = @At("HEAD"), cancellable = true) - private void onKeyPress(long window, int action, KeyInput input, CallbackInfo ci) { + @Inject(method = "keyPress", at = @At("HEAD"), cancellable = true) + private void onKeyPress(long handle, int action, net.minecraft.client.input.KeyEvent input, CallbackInfo ci) { if (input.key() == -1) return; Sputnik.INSTANCE.onInput(input.key(), action); - KeyEvent event = EVENT_BUS.post(new KeyEvent(input.key(), input.scancode(), action)); + KeyEvent event = Sputnik.EVENT_BUS.post(new KeyEvent(input.key(), input.scancode(), action)); if (event.isCancelled()) ci.cancel(); } } diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/io/KeyInputMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/io/KeyboardInputMixin.java similarity index 60% rename from src/main/java/me/retucio/sputnik/mixin/mixins/io/KeyInputMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/io/KeyboardInputMixin.java index a932a9f..dfa26bc 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/io/KeyInputMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/io/KeyboardInputMixin.java @@ -2,27 +2,27 @@ package me.retucio.sputnik.mixin.mixins.io; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.camera.Freecam; -import net.minecraft.client.input.Input; -import net.minecraft.client.input.KeyboardInput; -import net.minecraft.util.PlayerInput; +import net.minecraft.client.player.ClientInput; +import net.minecraft.client.player.KeyboardInput; +import net.minecraft.world.entity.player.Input; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(KeyboardInput.class) -public abstract class KeyInputMixin extends Input { +public abstract class KeyboardInputMixin extends ClientInput { @Inject(method = "tick", at = @At("TAIL")) private void isPressed(CallbackInfo ci) { Freecam freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class); if (freecam.isEnabled() && freecam.stayCrouching.getValue() && freecam.isCrouching()) - playerInput = new PlayerInput( - false, false, - false, false, - false, - true, // siempre agachado - false - ); + keyPresses = new Input( + false, false, + false, false, + false, + true, // siempre agachado + false + ); } } \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/io/MouseMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/io/MouseHandlerMixin.java similarity index 51% rename from src/main/java/me/retucio/sputnik/mixin/mixins/io/MouseMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/io/MouseHandlerMixin.java index e60d428..694c59f 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/io/MouseMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/io/MouseHandlerMixin.java @@ -3,28 +3,27 @@ package me.retucio.sputnik.mixin.mixins.io; import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.event.input.MouseClickEvent; import me.retucio.sputnik.event.input.MouseScrollEvent; -import net.minecraft.client.Mouse; -import net.minecraft.client.input.MouseInput; +import net.minecraft.client.MouseHandler; +import net.minecraft.client.input.MouseButtonInfo; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import static me.retucio.sputnik.Sputnik.EVENT_BUS; -@Mixin(Mouse.class) -public abstract class MouseMixin { +@Mixin(MouseHandler.class) +public abstract class MouseHandlerMixin { - @Inject(method = "onMouseButton", at = @At("HEAD"), cancellable = true) - private void onMouseButton(long window, MouseInput input, int action, CallbackInfo ci) { + @Inject(method = "onButton", at = @At("HEAD"), cancellable = true) + private void onMouseButton(long handle, MouseButtonInfo input, int action, CallbackInfo ci) { Sputnik.INSTANCE.onInput(input.button(), action); - MouseClickEvent event = EVENT_BUS.post(new MouseClickEvent(action, input.button())); + MouseClickEvent event = Sputnik.EVENT_BUS.post(new MouseClickEvent(action, input.button())); if (event.isCancelled()) ci.cancel(); } - @Inject(method = "onMouseScroll", at = @At("HEAD"), cancellable = true) + @Inject(method = "onScroll", at = @At("HEAD"), cancellable = true) private void onMouseScroll(long window, double horizontal, double vertical, CallbackInfo ci) { - MouseScrollEvent event = EVENT_BUS.post(new MouseScrollEvent(horizontal, vertical)); + MouseScrollEvent event = Sputnik.EVENT_BUS.post(new MouseScrollEvent(horizontal, vertical)); if (event.isCancelled()) ci.cancel(); } } diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/io/ScreenshotRecorderMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/io/ScreenshotMixin.java similarity index 53% rename from src/main/java/me/retucio/sputnik/mixin/mixins/io/ScreenshotRecorderMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/io/ScreenshotMixin.java index 2e9fe2d..8ed8d5a 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/io/ScreenshotRecorderMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/io/ScreenshotMixin.java @@ -1,10 +1,10 @@ package me.retucio.sputnik.mixin.mixins.io; +import com.mojang.blaze3d.platform.NativeImage; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.misc.ScreenshotPlus; -import net.minecraft.client.texture.NativeImage; -import net.minecraft.client.util.ScreenshotRecorder; -import net.minecraft.text.Text; +import net.minecraft.client.Minecraft; +import net.minecraft.client.Screenshot; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; @@ -15,33 +15,31 @@ import java.io.File; import java.io.IOException; import java.util.function.Consumer; -import static me.retucio.sputnik.Sputnik.mc; -@Mixin(ScreenshotRecorder.class) -public abstract class ScreenshotRecorderMixin { +@Mixin(Screenshot.class) +public abstract class ScreenshotMixin { - // "method_22691" es la lambda de la función "saveScreenshot()" (por lo menos en 1.21.6) - @Inject(method = "method_22691", at = @At(value = "INVOKE", target = "Ljava/util/function/Consumer;accept(Ljava/lang/Object;)V"), cancellable = true) - private static void sendActionsMessage(NativeImage nativeImage, File file, Consumer consumer, CallbackInfo ci) { + @Inject(method = "lambda$grab$1", at = @At(value = "INVOKE", target = "Ljava/util/function/Consumer;accept(Ljava/lang/Object;)V"), cancellable = true) + private static void sendActionsMessage(NativeImage image, File file, Consumer callback, CallbackInfo ci) { ScreenshotPlus screenshotPlus = getScreenshotPlus(); if (screenshotPlus.isEnabled()) ci.cancel(); } - @Inject(method = "method_22691", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/NativeImage;writeTo(Ljava/io/File;)V"), cancellable = true) - private static void interceptScreenshotFile(NativeImage nativeImage, File file, Consumer consumer, CallbackInfo ci) throws IOException { + @Inject(method = "lambda$grab$1", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/NativeImage;writeToFile(Ljava/io/File;)V"), cancellable = true) + private static void interceptScreenshotFile(NativeImage image, File file, Consumer callback, CallbackInfo ci) throws IOException { ScreenshotPlus screenshotPlus = getScreenshotPlus(); // aunque el módulo esté apagado, pasar las referencias para poder usar los comandos para las capturas - screenshotPlus.setScreenshot(nativeImage); + screenshotPlus.setScreenshot(image); screenshotPlus.setScreenshotFile(file); if (!screenshotPlus.isEnabled()) return; // por los threads o lo que sea - mc.execute(screenshotPlus::sendScreenshotMessage); + Minecraft.getInstance().execute(screenshotPlus::sendScreenshotMessage); switch (screenshotPlus.defaultAction.getValue()) { - case COPY -> screenshotPlus.copyScreenshot(nativeImage); + case COPY -> screenshotPlus.copyScreenshot(image); case SAVE -> screenshotPlus.saveScreenshot(); case NONE -> ci.cancel(); } diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/item/ItemMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/item/ItemMixin.java index cf22beb..841a6fb 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/item/ItemMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/item/ItemMixin.java @@ -2,14 +2,14 @@ package me.retucio.sputnik.mixin.mixins.item; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.inventory.ShulkerPeek; -import net.minecraft.block.ShulkerBoxBlock; -import net.minecraft.component.type.TooltipDisplayComponent; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.tooltip.TooltipType; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.item.component.TooltipDisplay; +import net.minecraft.world.level.block.ShulkerBoxBlock; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -20,21 +20,21 @@ import java.util.function.Consumer; @Mixin(Item.class) public abstract class ItemMixin { - @Inject(method = "appendTooltip", at = @At("HEAD")) - private void onAppendTooltip(ItemStack stack, Item.TooltipContext context, TooltipDisplayComponent displayComponent, Consumer textConsumer, TooltipType type, CallbackInfo ci) { + @Inject(method = "appendHoverText", at = @At("HEAD")) + private void onAppendTooltip(ItemStack stack, Item.TooltipContext context, TooltipDisplay display, Consumer builder, TooltipFlag tooltipFlag, CallbackInfo ci) { ShulkerPeek shulkerPeek = ModuleManager.INSTANCE.getModuleByClass(ShulkerPeek.class); if (!shulkerPeek.isEnabled() || !shulkerPeek.showTooltips.getValue()) return; if (stack.getItem() instanceof BlockItem blockItem && blockItem.getBlock() instanceof ShulkerBoxBlock) { if (ShulkerPeek.isShulkerEmpty(stack)) { - textConsumer.accept(Text.literal("vacío").formatted(Formatting.GRAY, Formatting.ITALIC)); + builder.accept(Component.literal("vacío").withStyle(ChatFormatting.GRAY, ChatFormatting.ITALIC)); } else { - textConsumer.accept( - Text.literal("mantén ") - .append(Text.literal(shulkerPeek.previewKey.getKeyName()) - .formatted(Formatting.GOLD, Formatting.BOLD)) + builder.accept( + Component.literal("mantén ") + .append(Component.literal(shulkerPeek.previewKey.getKeyName()) + .withStyle(ChatFormatting.GOLD, ChatFormatting.BOLD)) .append(" para previsualizar") - .formatted(Formatting.GRAY) + .withStyle(ChatFormatting.GRAY) ); } } diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/item/ItemStackMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/item/ItemStackMixin.java index a3114d7..dd5c109 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/item/ItemStackMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/item/ItemStackMixin.java @@ -1,28 +1,28 @@ package me.retucio.sputnik.mixin.mixins.item; +import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.event.interact.DamageItemEvent; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import org.jspecify.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - import java.util.function.Consumer; -import static me.retucio.sputnik.Sputnik.EVENT_BUS; @Mixin(ItemStack.class) public abstract class ItemStackMixin { @Shadow - public abstract int getDamage(); + public abstract int getDamageValue(); - @Inject(method = "onDurabilityChange", at = @At("TAIL")) - private void onDamage(int damage, ServerPlayerEntity player, Consumer breakCallback, CallbackInfo ci) { + @Inject(method = "applyDamage", at = @At("TAIL")) + private void onDamage(int newDamage, @Nullable ServerPlayer player, Consumer onBreak, CallbackInfo ci) { ItemStack stack = (ItemStack) (Object) this; - EVENT_BUS.post(new DamageItemEvent(getDamage(), stack)); + Sputnik.EVENT_BUS.post(new DamageItemEvent(getDamageValue(), stack)); } } diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/item/TridentItemMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/item/TridentItemMixin.java index 0b2c896..b3e781c 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/item/TridentItemMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/item/TridentItemMixin.java @@ -3,16 +3,17 @@ package me.retucio.sputnik.mixin.mixins.item; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.movement.TridentBoost; -import net.minecraft.item.TridentItem; +import net.minecraft.world.item.TridentItem; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyArgs; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; + @Mixin(TridentItem.class) public abstract class TridentItemMixin { - @ModifyArgs(method = "onStoppedUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;addVelocity(DDD)V")) + @ModifyArgs(method = "releaseUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;push(DDD)V")) private void modifyVelocity(Args args) { TridentBoost tridentBoost = ModuleManager.INSTANCE.getModuleByClass(TridentBoost.class); if (!tridentBoost.isEnabled()) return; @@ -21,13 +22,13 @@ public abstract class TridentItemMixin { args.set(2, (double) args.get(2) * tridentBoost.multiplier.getValue()); } - @ModifyExpressionValue(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isTouchingWaterOrRain()Z")) + @ModifyExpressionValue(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;isInWaterOrRain()Z")) private boolean allowUseOutOfWaterPre(boolean original) { TridentBoost tridentBoost = ModuleManager.INSTANCE.getModuleByClass(TridentBoost.class); return (tridentBoost.outOfWater.getValue() && tridentBoost.isEnabled()) || original; } - @ModifyExpressionValue(method = "onStoppedUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isTouchingWaterOrRain()Z")) + @ModifyExpressionValue(method = "releaseUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;isInWaterOrRain()Z")) private boolean allowUseOutOfWaterPost(boolean original) { TridentBoost tridentBoost = ModuleManager.INSTANCE.getModuleByClass(TridentBoost.class); return (tridentBoost.outOfWater.getValue() && tridentBoost.isEnabled()) || original; diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/misc/FontManagerMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/misc/FontManagerMixin.java index 53cabcb..eb3aa07 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/misc/FontManagerMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/misc/FontManagerMixin.java @@ -4,11 +4,11 @@ import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.render.Fonts; -import net.minecraft.client.font.FontManager; -import net.minecraft.client.font.FontStorage; -import net.minecraft.text.StyleSpriteSource; -import net.minecraft.util.Identifier; +import net.minecraft.client.gui.font.FontManager; +import net.minecraft.client.gui.font.FontSet; +import net.minecraft.network.chat.FontDescription; +import net.minecraft.resources.Identifier; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -20,20 +20,20 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; public abstract class FontManagerMixin { @Shadow - public abstract FontStorage getStorageInternal(Identifier id); + protected abstract FontSet getFontSetRaw(Identifier id); - @Inject(method = "getStorageInternal", at = @At("HEAD"), cancellable = true) - private void onGetStorageInternal(Identifier id, CallbackInfoReturnable cir) { + @Inject(method = "getFontSetRaw", at = @At("HEAD"), cancellable = true) + private void onGetStorageInternal(Identifier id, CallbackInfoReturnable cir) { Fonts fonts = ModuleManager.INSTANCE.getModuleByClass(Fonts.class); if (!fonts.isEnabled()) return; - if (id.equals(StyleSpriteSource.Font.DEFAULT.id())) { - cir.setReturnValue(getStorageInternal( - Identifier.of( + if (id.equals(FontDescription.Resource.DEFAULT.id())) { + cir.setReturnValue(getFontSetRaw( + Identifier.fromNamespaceAndPath( Sputnik.MOD_ID, fonts.getFont() ) )); } } -} +} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/misc/MinecraftClientMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/misc/MinecraftMixin.java similarity index 61% rename from src/main/java/me/retucio/sputnik/mixin/mixins/misc/MinecraftClientMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/misc/MinecraftMixin.java index 9b88663..597efc8 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/misc/MinecraftClientMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/misc/MinecraftMixin.java @@ -9,11 +9,11 @@ import me.retucio.sputnik.event.TickEvent; import me.retucio.sputnik.event.interact.UseItemEvent; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.player.FastUse; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Hand; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.item.ItemStack; import org.jspecify.annotations.Nullable; import org.spongepowered.asm.mixin.*; import org.spongepowered.asm.mixin.injection.*; @@ -21,21 +21,20 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(MinecraftClient.class) -public abstract class MinecraftClientMixin { +@Mixin(Minecraft.class) +public abstract class MinecraftMixin { @Shadow - private int itemUseCooldown; + private int rightClickDelay; @Shadow - public int attackCooldown; + private static Minecraft instance; // eventos - @Shadow - @Nullable - public Screen currentScreen; + @Shadow @Nullable + public Screen screen; @Inject(method = "tick", at = @At("HEAD")) private void onTickPre(CallbackInfo ci) { @@ -59,22 +58,22 @@ public abstract class MinecraftClientMixin { if (event.isCancelled()) ci.cancel(); } - @Inject(method = "joinWorld", at = @At("HEAD"), cancellable = true) - private void onJoinWorld(ClientWorld world, CallbackInfo ci) { - JoinWorldEvent event = Sputnik.EVENT_BUS.post(new JoinWorldEvent(world)); + @Inject(method = "setLevel", at = @At("HEAD"), cancellable = true) + private void onJoinWorld(ClientLevel level, CallbackInfo ci) { + JoinWorldEvent event = Sputnik.EVENT_BUS.post(new JoinWorldEvent(level)); if (event.isCancelled()) ci.cancel(); } - @Inject(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getStackInHand(Lnet/minecraft/util/Hand;)Lnet/minecraft/item/ItemStack;"), cancellable = true) - private void onUseItem(CallbackInfo ci, @Local Hand hand) { + @Inject(method = "startUseItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;getItemInHand(Lnet/minecraft/world/InteractionHand;)Lnet/minecraft/world/item/ItemStack;"), cancellable = true) + private void onUseItem(CallbackInfo ci, @Local(name = "hand") InteractionHand hand) { if (Sputnik.mc.player == null) return; - UseItemEvent event = Sputnik.EVENT_BUS.post(new UseItemEvent(Sputnik.mc.player.getStackInHand(hand), hand)); + UseItemEvent event = Sputnik.EVENT_BUS.post(new UseItemEvent(instance.player.getItemInHand(hand), hand)); if (event.isCancelled()) ci.cancel(); } // telemetría - @Inject(method = "isTelemetryEnabledByApi", at = @At("RETURN"), cancellable = true) + @Inject(method = "allowsTelemetry", at = @At("RETURN"), cancellable = true) private void disableMicropenisTelemetryShi(CallbackInfoReturnable cir) { cir.setReturnValue(false); } @@ -82,10 +81,10 @@ public abstract class MinecraftClientMixin { // precoz - @Inject(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;isItemEnabled(Lnet/minecraft/resource/featuretoggle/FeatureSet;)Z")) - private void modifyItemUseCooldown(CallbackInfo ci, @Local ItemStack stack) { + @Inject(method = "startUseItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;isItemEnabled(Lnet/minecraft/world/flag/FeatureFlagSet;)Z")) + private void modifyItemUseCooldown(CallbackInfo ci, @Local(name = "heldItem") ItemStack stack) { FastUse fastUse = ModuleManager.INSTANCE.getModuleByClass(FastUse.class); if (!fastUse.isEnabled()) return; - itemUseCooldown = fastUse.getCooldown(stack); + rightClickDelay = fastUse.getCooldown(stack); } } \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/misc/GameOptionsMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/misc/OptionsMixin.java similarity index 65% rename from src/main/java/me/retucio/sputnik/mixin/mixins/misc/GameOptionsMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/misc/OptionsMixin.java index 8421a2c..660158a 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/misc/GameOptionsMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/misc/OptionsMixin.java @@ -3,8 +3,8 @@ package me.retucio.sputnik.mixin.mixins.misc; import me.retucio.sputnik.event.render.PerspectiveChangeEvent; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.camera.Freecam; -import net.minecraft.client.option.GameOptions; -import net.minecraft.client.option.Perspective; +import net.minecraft.client.CameraType; +import net.minecraft.client.Options; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -13,15 +13,16 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import static me.retucio.sputnik.Sputnik.EVENT_BUS; -@Mixin(GameOptions.class) -public abstract class GameOptionsMixin { + +@Mixin(Options.class) +public abstract class OptionsMixin { @Shadow - public abstract Perspective getPerspective(); + public abstract CameraType getCameraType(); - @Inject(method = "setPerspective", at = @At("HEAD"), cancellable = true) - private void changePerspective(Perspective perspective, CallbackInfo ci) { - if (getPerspective() == null) return; + @Inject(method = "setCameraType", at = @At("HEAD"), cancellable = true) + private void changePerspective(CameraType perspective, CallbackInfo ci) { + if (getCameraType() == null) return; if (ModuleManager.INSTANCE.getModuleByClass(Freecam.class).isEnabled()) ci.cancel(); PerspectiveChangeEvent event = EVENT_BUS.post(new PerspectiveChangeEvent(perspective)); if (event.isCancelled()) ci.cancel(); diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/misc/StringHelperMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/misc/StringUtilMixin.java similarity index 65% rename from src/main/java/me/retucio/sputnik/mixin/mixins/misc/StringHelperMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/misc/StringUtilMixin.java index f2038d9..a7edc81 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/misc/StringHelperMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/misc/StringUtilMixin.java @@ -2,15 +2,16 @@ package me.retucio.sputnik.mixin.mixins.misc; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.misc.ChatPlus; -import net.minecraft.util.StringHelper; +import net.minecraft.util.StringUtil; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyArg; -@Mixin(StringHelper.class) -public abstract class StringHelperMixin { - @ModifyArg(method = "truncateChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/StringHelper;truncate(Ljava/lang/String;IZ)Ljava/lang/String;"), index = 1) +@Mixin(StringUtil.class) +public abstract class StringUtilMixin { + + @ModifyArg(method = "trimChatMessage", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/StringUtil;truncateStringIfNecessary(Ljava/lang/String;IZ)Ljava/lang/String;"), index = 1) private static int onTruncate(int maxLength) { ChatPlus chatPlus = ModuleManager.INSTANCE.getModuleByClass(ChatPlus.class); return ((chatPlus.isEnabled() && chatPlus.noCharLimit.getValue()) ? Integer.MAX_VALUE : maxLength); diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/misc/Vec3dMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/misc/Vec3Mixin.java similarity index 81% rename from src/main/java/me/retucio/sputnik/mixin/mixins/misc/Vec3dMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/misc/Vec3Mixin.java index 7ca0121..eb32648 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/misc/Vec3dMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/misc/Vec3Mixin.java @@ -1,14 +1,15 @@ package me.retucio.sputnik.mixin.mixins.misc; -import me.retucio.sputnik.util.interfaces.IVec3d; -import net.minecraft.util.math.Vec3d; +import me.retucio.sputnik.util.interfaces.IVec3; +import net.minecraft.world.phys.Vec3; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.Shadow; -@Mixin(Vec3d.class) -public abstract class Vec3dMixin implements IVec3d { + +@Mixin(Vec3.class) +public abstract class Vec3Mixin implements IVec3 { @Shadow @Final @Mutable public double x; diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/network/ChatInputSuggestorMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/network/ChatInputSuggestorMixin.java deleted file mode 100644 index 646bbc3..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/network/ChatInputSuggestorMixin.java +++ /dev/null @@ -1,62 +0,0 @@ -package me.retucio.sputnik.mixin.mixins.network; - -import com.llamalad7.mixinextras.sugar.Local; -import com.mojang.brigadier.ParseResults; -import com.mojang.brigadier.StringReader; -import com.mojang.brigadier.suggestion.Suggestions; -import me.retucio.sputnik.command.CommandManager; -import net.minecraft.client.gui.screen.ChatInputSuggestor; -import net.minecraft.client.gui.widget.TextFieldWidget; -import net.minecraft.command.CommandSource; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.concurrent.CompletableFuture; - -import static me.retucio.sputnik.Sputnik.mc; - -@Mixin(ChatInputSuggestor.class) -public abstract class ChatInputSuggestorMixin { - - @Shadow - private ParseResults parse; - - @Shadow @Final - TextFieldWidget textField; - - @Shadow - private ChatInputSuggestor.SuggestionWindow window; - - @Shadow - boolean completingSuggestions; - - @Shadow - private CompletableFuture pendingSuggestions; - - @Shadow protected abstract void showCommandSuggestions(); - - @Inject(method = "refresh", at = @At(value = "INVOKE", target = "Lcom/mojang/brigadier/StringReader;canRead()Z", remap = false), cancellable = true) - private void onRefresh(CallbackInfo ci, @Local StringReader reader) { - String prefix = CommandManager.INSTANCE.getPrefix(); - int length = prefix.length(); - - if (reader.canRead(length) && reader.getString().startsWith(prefix, reader.getCursor())) { - reader.setCursor(reader.getCursor() + length); - - if (parse == null) this.parse = CommandManager.dispatcher.parse(reader, mc.getNetworkHandler().getCommandSource()); - - int cursor = textField.getCursor(); - if (cursor >= length && (window == null || !completingSuggestions)) { - pendingSuggestions = CommandManager.dispatcher.getCompletionSuggestions(parse, cursor); - pendingSuggestions.thenRun(() -> { - if (pendingSuggestions.isDone()) showCommandSuggestions(); - }); - } - ci.cancel(); - } - } -} diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/network/ChatListenerMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/network/ChatListenerMixin.java new file mode 100644 index 0000000..422e8fa --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/network/ChatListenerMixin.java @@ -0,0 +1,38 @@ +package me.retucio.sputnik.mixin.mixins.network; + +import com.mojang.authlib.GameProfile; +import me.retucio.sputnik.util.interfaces.IChatListener; +import net.minecraft.client.multiplayer.chat.ChatListener; +import net.minecraft.network.chat.ChatType; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.PlayerChatMessage; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.time.Instant; + + +@Mixin(ChatListener.class) +public abstract class ChatListenerMixin implements IChatListener { + + @Unique + private GameProfile sender; + + @Inject(method = "showMessageToPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/ChatComponent;addPlayerMessage(Lnet/minecraft/network/chat/Component;Lnet/minecraft/network/chat/MessageSignature;Lnet/minecraft/client/multiplayer/chat/GuiMessageTag;)V", shift = At.Shift.BEFORE)) + private void onShowMessageToPlayer_beforeAddMessage(ChatType.Bound boundChatType, PlayerChatMessage message, Component decoratedMessage, GameProfile sender, boolean onlyShowSecure, Instant received, CallbackInfoReturnable cir) { + this.sender = sender; + } + + @Inject(method = "showMessageToPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/ChatComponent;addPlayerMessage(Lnet/minecraft/network/chat/Component;Lnet/minecraft/network/chat/MessageSignature;Lnet/minecraft/client/multiplayer/chat/GuiMessageTag;)V", shift = At.Shift.AFTER)) + private void onShowMessageToPlayer_afterAddMessage(ChatType.Bound boundChatType, PlayerChatMessage message, Component decoratedMessage, GameProfile sender, boolean onlyShowSecure, Instant received, CallbackInfoReturnable cir) { + this.sender = null; + } + + @Override + public GameProfile sputnik$getSender() { + return sender; + } +} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/network/ClientCommonNetworkHandlerMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/network/ClientCommonNetworkHandlerMixin.java deleted file mode 100644 index aa5bbea..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/network/ClientCommonNetworkHandlerMixin.java +++ /dev/null @@ -1,67 +0,0 @@ -package me.retucio.sputnik.mixin.mixins.network; - -import me.retucio.sputnik.mixin.accessors.ConfirmServerResourcePackScreenAccessor; -import me.retucio.sputnik.mixin.accessors.PackAccessor; -import me.retucio.sputnik.module.ModuleManager; -import me.retucio.sputnik.module.modules.network.RPackBypass; -import me.retucio.sputnik.util.interfaces.IConfirmScreen; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.network.ClientCommonNetworkHandler; -import net.minecraft.client.network.ServerInfo; -import net.minecraft.client.option.ServerList; -import net.minecraft.network.ClientConnection; -import net.minecraft.network.packet.c2s.common.ResourcePackStatusC2SPacket; -import net.minecraft.text.Text; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import java.net.URL; -import java.util.List; -import java.util.UUID; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; -import java.util.concurrent.TimeUnit; - - -@Mixin(ClientCommonNetworkHandler.class) -public abstract class ClientCommonNetworkHandlerMixin { - - @Shadow @Final protected MinecraftClient client; - @Shadow @Final protected ServerInfo serverInfo; - @Shadow @Final protected ClientConnection connection; - - @Unique // tardar 3 segundos porque algunos servers detectar el tiempo entre que se acepta y se carga el pack - private final Executor DELAYED_EXECUTOR = CompletableFuture.delayedExecutor(3L, TimeUnit.SECONDS); - - @Inject(method = "createConfirmServerResourcePackScreen", at = @At("TAIL")) - private void setScreenBypassAction(UUID id, URL url, String hash, boolean required, Text prompt, CallbackInfoReturnable cir) { - RPackBypass bypassPack = ModuleManager.INSTANCE.getModuleByClass(RPackBypass.class); - if (!bypassPack.isEnabled()) return; - - final Screen screen = cir.getReturnValue(); - ((IConfirmScreen) screen).sputnik$setBypassAction(() -> { - client.setScreen(((ConfirmServerResourcePackScreenAccessor) screen).getParentScreen()); - if (this.serverInfo != null) { - this.serverInfo.setResourcePackPolicy(bypassPack.getPolicy()); - this.client.getServerResourcePackProvider().acceptAll(); - ServerList.updateServerListEntry(this.serverInfo); - } - bypass(((ConfirmServerResourcePackScreenAccessor) screen).getRequests().stream().map(PackAccessor::callId).toList()); - }); - } - - @Unique - public void bypass(List ids) { - ids.forEach(id -> connection.send(new ResourcePackStatusC2SPacket(id, ResourcePackStatusC2SPacket.Status.ACCEPTED))); - ids.forEach(id -> connection.send(new ResourcePackStatusC2SPacket(id, ResourcePackStatusC2SPacket.Status.DOWNLOADED))); - DELAYED_EXECUTOR.execute(() -> - ids.forEach(id -> connection.send(new ResourcePackStatusC2SPacket(id, ResourcePackStatusC2SPacket.Status.SUCCESSFULLY_LOADED))) - ); - } -} diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/network/ClientCommonPacketListenerImplMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/network/ClientCommonPacketListenerImplMixin.java new file mode 100644 index 0000000..f4718f1 --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/network/ClientCommonPacketListenerImplMixin.java @@ -0,0 +1,67 @@ +package me.retucio.sputnik.mixin.mixins.network; + +import me.retucio.sputnik.mixin.accessors.PackConfirmScreenAccessor; +import me.retucio.sputnik.mixin.accessors.PendingRequestAccessor; +import me.retucio.sputnik.module.ModuleManager; +import me.retucio.sputnik.module.modules.network.RPackBypass; +import me.retucio.sputnik.util.interfaces.IConfirmScreen; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl; +import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.client.multiplayer.ServerList; +import net.minecraft.network.Connection; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.common.ServerboundResourcePackPacket; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.net.URL; +import java.util.List; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; +import java.util.concurrent.TimeUnit; + + +@Mixin(ClientCommonPacketListenerImpl.class) +public abstract class ClientCommonPacketListenerImplMixin { + + @Shadow @Final protected Minecraft minecraft; + @Shadow @Final protected ServerData serverData; + @Shadow @Final protected Connection connection; + + @Unique // tardar 3 segundos porque algunos servers detectar el tiempo entre que se acepta y se carga el pack + private final Executor DELAYED_EXECUTOR = CompletableFuture.delayedExecutor(3L, TimeUnit.SECONDS); + + @Inject(method = "addOrUpdatePackPrompt", at = @At("TAIL")) + private void setScreenBypassAction(UUID packId, URL url, String hash, boolean required, Component prompt, CallbackInfoReturnable cir) { + RPackBypass bypassPack = ModuleManager.INSTANCE.getModuleByClass(RPackBypass.class); + if (!bypassPack.isEnabled()) return; + + final Screen screen = cir.getReturnValue(); + ((IConfirmScreen) screen).sputnik$setBypassAction(() -> { + minecraft.setScreen(((PackConfirmScreenAccessor) screen).getParentScreen()); + if (serverData != null) { + serverData.setResourcePackStatus(bypassPack.getStatus()); + minecraft.getDownloadedPackSource().allowServerPacks(); + ServerList.saveSingleServer(this.serverData); + } + bypass(((PackConfirmScreenAccessor) screen).getRequests().stream().map(PendingRequestAccessor::callId).toList()); + }); + } + + @Unique + public void bypass(List ids) { + ids.forEach(id -> connection.send(new ServerboundResourcePackPacket(id, ServerboundResourcePackPacket.Action.ACCEPTED))); + ids.forEach(id -> connection.send(new ServerboundResourcePackPacket(id, ServerboundResourcePackPacket.Action.DOWNLOADED))); + DELAYED_EXECUTOR.execute(() -> + ids.forEach(id -> connection.send(new ServerboundResourcePackPacket(id, ServerboundResourcePackPacket.Action.SUCCESSFULLY_LOADED))) + ); + } +} diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/network/HandshakeC2SPacketMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/network/ClientIntentionPacketMixin.java similarity index 65% rename from src/main/java/me/retucio/sputnik/mixin/mixins/network/HandshakeC2SPacketMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/network/ClientIntentionPacketMixin.java index 7b07304..425ea71 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/network/HandshakeC2SPacketMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/network/ClientIntentionPacketMixin.java @@ -3,10 +3,11 @@ package me.retucio.sputnik.mixin.mixins.network; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.google.gson.JsonParser; +import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.network.BungeecordSpoofer; -import net.minecraft.network.packet.c2s.handshake.ConnectionIntent; -import net.minecraft.network.packet.c2s.handshake.HandshakeC2SPacket; +import net.minecraft.network.protocol.handshake.ClientIntent; +import net.minecraft.network.protocol.handshake.ClientIntentionPacket; import org.spongepowered.asm.mixin.*; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -20,11 +21,12 @@ import java.util.concurrent.Executors; import static me.retucio.sputnik.Sputnik.mc; -@Mixin(HandshakeC2SPacket.class) -public abstract class HandshakeC2SPacketMixin { + +@Mixin(ClientIntentionPacket.class) +public abstract class ClientIntentionPacketMixin { @Shadow @Mutable @Final - private String address; + private String hostName; @Unique private final Gson gson = new Gson(); @@ -33,18 +35,18 @@ public abstract class HandshakeC2SPacketMixin { private static final ExecutorService executor = Executors.newCachedThreadPool(); @Shadow - public abstract ConnectionIntent intendedState(); + public abstract ClientIntent intention(); @SuppressWarnings("deprecation") - @Inject(method = "(ILjava/lang/String;ILnet/minecraft/network/packet/c2s/handshake/ConnectionIntent;)V", at = @At("RETURN")) - private void onHandshakeC2SPacket(int i, String string, int j, ConnectionIntent connectionIntent, CallbackInfo ci) { + @Inject(method = "(ILjava/lang/String;ILnet/minecraft/network/protocol/handshake/ClientIntent;)V", at = @At("RETURN")) + private void onHandshakeC2SPacket(int protocolVersion, String hostName, int port, ClientIntent intention, CallbackInfo ci) { BungeecordSpoofer spoofer = ModuleManager.INSTANCE.getModuleByClass(BungeecordSpoofer.class); if (!spoofer.isEnabled()) return; - if (this.intendedState() != ConnectionIntent.LOGIN) return; + if (this.intention() != ClientIntent.LOGIN) return; - final String[] spoofedUUID = {me.retucio.sputnik.Sputnik.mc.getSession().getUuidOrNull().toString()}; - String URL = "https://api.mojang.com/users/profiles/minecraft/" + mc.getSession().getUsername(); + final String[] spoofedUUID = {Sputnik.mc.getUser().getProfileId().toString()}; + String URL = "https://api.mojang.com/users/profiles/minecraft/" + mc.getUser().getName(); executor.execute(() -> { try { @@ -54,7 +56,7 @@ public abstract class HandshakeC2SPacketMixin { req.setReadTimeout(5000); if (req.getResponseCode() != 200) { - this.address += "\u0000" + spoofer.address.getValue() + "\u0000" + spoofedUUID[0]; + this.hostName += "\u0000" + spoofer.address.getValue() + "\u0000" + spoofedUUID[0]; return; } @@ -63,11 +65,11 @@ public abstract class HandshakeC2SPacketMixin { if (obj.has("id")) spoofedUUID[0] = obj.get("id").getAsString(); - this.address += "\u0000" + spoofer.address.getValue() + "\u0000" + spoofedUUID[0]; + this.hostName += "\u0000" + spoofer.address.getValue() + "\u0000" + spoofedUUID[0]; } catch (Exception e) { e.printStackTrace(); - this.address += "\u0000" + spoofer.address.getValue() + "\u0000" + spoofedUUID[0]; + this.hostName += "\u0000" + spoofer.address.getValue() + "\u0000" + spoofedUUID[0]; } }); } diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/network/ClientPlayNetworkHandlerMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/network/ClientPacketListenerMixin.java similarity index 64% rename from src/main/java/me/retucio/sputnik/mixin/mixins/network/ClientPlayNetworkHandlerMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/network/ClientPacketListenerMixin.java index dc34fb6..b8cd050 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/network/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/network/ClientPacketListenerMixin.java @@ -6,9 +6,9 @@ import me.retucio.sputnik.event.network.SendMessageEvent; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.render.NoRender; import me.retucio.sputnik.util.ChatUtil; -import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.client.render.GameRenderer; -import net.minecraft.item.ItemStack; +import net.minecraft.client.multiplayer.ClientPacketListener; +import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.world.item.ItemStack; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -19,23 +19,23 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import static me.retucio.sputnik.Sputnik.*; -@Mixin(ClientPlayNetworkHandler.class) -public abstract class ClientPlayNetworkHandlerMixin { +@Mixin(ClientPacketListener.class) +public abstract class ClientPacketListenerMixin { @Unique private boolean ignoreChatMessage; @Shadow - public abstract void sendChatMessage(String content); + public abstract void sendChat(String content); - @Inject(method = "sendChatMessage", at = @At("HEAD"), cancellable = true) - private void onSendMessage(String message, CallbackInfo ci) { + @Inject(method = "sendChat", at = @At("HEAD"), cancellable = true) + private void onSendMessage(String content, CallbackInfo ci) { if (ignoreChatMessage) return; - if (!message.startsWith(CommandManager.INSTANCE.getPrefix())) { - SendMessageEvent event = EVENT_BUS.post(new SendMessageEvent(message)); + if (!content.startsWith(CommandManager.INSTANCE.getPrefix())) { + SendMessageEvent event = EVENT_BUS.post(new SendMessageEvent(content)); if (!event.isCancelled()) { ignoreChatMessage = true; - sendChatMessage(event.getMessage()); + sendChat(event.getMessage()); ignoreChatMessage = false; } ci.cancel(); @@ -43,19 +43,19 @@ public abstract class ClientPlayNetworkHandlerMixin { }; try { - CommandManager.dispatch(message.substring(CommandManager.INSTANCE.getPrefix().length())); + CommandManager.dispatch(content.substring(CommandManager.INSTANCE.getPrefix().length())); } catch (CommandSyntaxException e) { ChatUtil.error(e.getMessage()); } - mc.inGameHud.getChatHud().addToMessageHistory(message); + mc.gui.getChat().addRecentChat(content); ci.cancel(); } - @Redirect(method = "onEntityStatus", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/GameRenderer;showFloatingItem(Lnet/minecraft/item/ItemStack;)V")) - private void noRenderTotemPop(GameRenderer instance, ItemStack floatingItem) { + @Redirect(method = "handleEntityEvent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GameRenderer;displayItemActivation(Lnet/minecraft/world/item/ItemStack;)V")) + private void noRenderTotemPop(GameRenderer instance, ItemStack itemStack) { NoRender noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class); if (!noRender.isEnabled() || noRender.totemPop.getValue()) - mc.gameRenderer.showFloatingItem(floatingItem); + mc.gameRenderer.displayItemActivation(itemStack); } } diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/network/ClientTelemetryManagerMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/network/ClientTelemetryManagerMixin.java new file mode 100644 index 0000000..e6feb1d --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/network/ClientTelemetryManagerMixin.java @@ -0,0 +1,17 @@ +package me.retucio.sputnik.mixin.mixins.network; + +import com.mojang.authlib.minecraft.TelemetrySession; +import net.minecraft.client.telemetry.ClientTelemetryManager; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + + +@Mixin(ClientTelemetryManager.class) +public class ClientTelemetryManagerMixin { + + @Redirect(method = "createEventSender", at = @At(value = "INVOKE", target = "Lcom/mojang/authlib/minecraft/TelemetrySession;isEnabled()Z")) + private boolean disableTelemetry(TelemetrySession instance) { + return false; + } +} diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/network/CommandSuggestionsMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/network/CommandSuggestionsMixin.java new file mode 100644 index 0000000..9d5167e --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/network/CommandSuggestionsMixin.java @@ -0,0 +1,72 @@ +package me.retucio.sputnik.mixin.mixins.network; + +import com.llamalad7.mixinextras.sugar.Local; +import com.mojang.brigadier.ParseResults; +import com.mojang.brigadier.StringReader; +import com.mojang.brigadier.suggestion.Suggestions; +import me.retucio.sputnik.command.CommandManager; +import net.minecraft.client.gui.components.CommandSuggestions; +import net.minecraft.client.gui.components.EditBox; +import net.minecraft.client.multiplayer.ClientSuggestionProvider; +import net.minecraft.commands.SharedSuggestionProvider; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.concurrent.CompletableFuture; + +import static me.retucio.sputnik.Sputnik.mc; + +@Mixin(CommandSuggestions.class) +public abstract class CommandSuggestionsMixin { + + @Shadow + private ParseResults currentParse; + + @Shadow @Final + private EditBox input; + + @Shadow + private CommandSuggestions.SuggestionsList suggestions; + + @Shadow + private boolean keepSuggestions; + + @Shadow + private CompletableFuture pendingSuggestions; + + @Shadow + protected abstract void updateUsageInfo(ParseResults currentParse, Suggestions suggestions); + + @Inject( + method = "updateCommandInfo", + at = @At(value = "INVOKE", target = "Lcom/mojang/brigadier/StringReader;canRead()Z", remap = false), + cancellable = true + ) + private void onRefresh(CallbackInfo ci, @Local(name = "reader") StringReader reader) { + String prefix = CommandManager.INSTANCE.getPrefix(); + int length = prefix.length(); + + if (reader.canRead(length) && reader.getString().startsWith(prefix, reader.getCursor())) { + reader.setCursor(reader.getCursor() + length); + + if (currentParse == null) { + currentParse = CommandManager.dispatcher.parse(reader, mc.getConnection().getSuggestionsProvider()); + } + + int cursor = input.getCursorPosition(); + if (cursor >= length && (suggestions == null || !keepSuggestions)) { + pendingSuggestions = CommandManager.dispatcher.getCompletionSuggestions(currentParse, cursor); + pendingSuggestions.thenAccept(suggestionResult -> { + if (pendingSuggestions.isDone()) { + updateUsageInfo(currentParse, suggestionResult); + } + }); + } + ci.cancel(); + } + } +} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/network/ClientConnectionMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/network/ConnectionMixin.java similarity index 57% rename from src/main/java/me/retucio/sputnik/mixin/mixins/network/ClientConnectionMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/network/ConnectionMixin.java index 7206637..ba05d6f 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/network/ClientConnectionMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/network/ConnectionMixin.java @@ -5,9 +5,10 @@ import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; import me.retucio.sputnik.event.network.DisconnectEvent; import me.retucio.sputnik.event.network.PacketEvent; -import net.minecraft.network.ClientConnection; -import net.minecraft.network.DisconnectionInfo; -import net.minecraft.network.packet.Packet; +import net.minecraft.network.Connection; +import net.minecraft.network.DisconnectionDetails; +import net.minecraft.network.protocol.Packet; +import org.jspecify.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -16,19 +17,19 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import static me.retucio.sputnik.Sputnik.EVENT_BUS; import static me.retucio.sputnik.Sputnik.mc; -@Mixin(ClientConnection.class) -public abstract class ClientConnectionMixin { +@Mixin(Connection.class) +public abstract class ConnectionMixin { // mandar paquetes - @Inject(method = "send(Lnet/minecraft/network/packet/Packet;Lio/netty/channel/ChannelFutureListener;)V", at = @At("HEAD"), cancellable = true) - private void onSendPacketPre(Packet packet, ChannelFutureListener channelFutureListener, CallbackInfo ci) { + @Inject(method = "send(Lnet/minecraft/network/protocol/Packet;Lio/netty/channel/ChannelFutureListener;)V", at = @At("HEAD"), cancellable = true) + private void onSendPacketPre(Packet packet, @Nullable ChannelFutureListener listener, CallbackInfo ci) { PacketEvent.Send event = EVENT_BUS.post(new PacketEvent.Send(packet, Event.Stage.PRE)); if (event.isCancelled()) ci.cancel(); } - @Inject(method = "send(Lnet/minecraft/network/packet/Packet;Lio/netty/channel/ChannelFutureListener;)V", at = @At("TAIL"), cancellable = true) - private void onSendPacketPost(Packet packet, ChannelFutureListener channelFutureListener, CallbackInfo ci) { + @Inject(method = "send(Lnet/minecraft/network/protocol/Packet;Lio/netty/channel/ChannelFutureListener;)V", at = @At("TAIL"), cancellable = true) + private void onSendPacketPost(Packet packet, ChannelFutureListener listener, CallbackInfo ci) { PacketEvent.Send event = EVENT_BUS.post(new PacketEvent.Send(packet, Event.Stage.POST)); if (event.isCancelled()) ci.cancel(); } @@ -36,8 +37,8 @@ public abstract class ClientConnectionMixin { // recibir paquetes - @Inject(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/packet/Packet;)V", at = @At("HEAD"), cancellable = true) - private void onReceivePacket(ChannelHandlerContext context, Packet packet, CallbackInfo ci) { + @Inject(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/protocol/Packet;)V", at = @At("HEAD"), cancellable = true) + private void onReceivePacket(ChannelHandlerContext ctx, Packet packet, CallbackInfo ci) { PacketEvent.Receive event = EVENT_BUS.post(new PacketEvent.Receive(packet)); if (event.isCancelled()) ci.cancel(); } @@ -45,9 +46,9 @@ public abstract class ClientConnectionMixin { // otros - @Inject(method = "disconnect(Lnet/minecraft/network/DisconnectionInfo;)V", at = @At("HEAD"), cancellable = true) - private void onDisconnect(DisconnectionInfo disconnectionInfo, CallbackInfo ci) { - DisconnectEvent event = EVENT_BUS.post(new DisconnectEvent(disconnectionInfo, mc.getCurrentServerEntry())); + @Inject(method = "disconnect(Lnet/minecraft/network/DisconnectionDetails;)V", at = @At("HEAD"), cancellable = true) + private void onDisconnect(DisconnectionDetails details, CallbackInfo ci) { + DisconnectEvent event = EVENT_BUS.post(new DisconnectEvent(details, mc.getCurrentServer())); if (event.isCancelled()) ci.cancel(); } } \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/network/MessageHandlerMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/network/MessageHandlerMixin.java deleted file mode 100644 index 7ad3b61..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/network/MessageHandlerMixin.java +++ /dev/null @@ -1,37 +0,0 @@ -package me.retucio.sputnik.mixin.mixins.network; - -import com.mojang.authlib.GameProfile; -import me.retucio.sputnik.util.interfaces.IMessageHandler; -import net.minecraft.client.network.message.MessageHandler; -import net.minecraft.network.message.MessageType; -import net.minecraft.network.message.SignedMessage; -import net.minecraft.text.Text; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import java.time.Instant; - -@Mixin(MessageHandler.class) -public abstract class MessageHandlerMixin implements IMessageHandler { - - @Unique - private GameProfile sender; - - @Inject(method = "processChatMessageInternal", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V", shift = At.Shift.BEFORE)) - private void onProcessChatMessageInternal_beforeAddMessage(MessageType.Parameters params, SignedMessage message, Text decorated, GameProfile sender, boolean onlyShowSecureChat, Instant receptionTimestamp, CallbackInfoReturnable info) { - this.sender = sender; - } - - @Inject(method = "processChatMessageInternal", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V", shift = At.Shift.AFTER)) - private void onProcessChatMessageInternal_afterAddMessage(MessageType.Parameters params, SignedMessage message, Text decorated, GameProfile sender, boolean onlyShowSecureChat, Instant receptionTimestamp, CallbackInfoReturnable info) { - this.sender = null; - } - - @Override - public GameProfile sputnik$getSender() { - return sender; - } -} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/network/ServerConnectorMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/network/ServerConnectorMixin.java index 1366113..ee20e8d 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/network/ServerConnectorMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/network/ServerConnectorMixin.java @@ -2,21 +2,22 @@ package me.retucio.sputnik.mixin.mixins.network; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.network.RPackBypass; -import net.minecraft.client.network.ServerInfo; -import net.minecraft.client.resource.server.ServerResourcePackManager; +import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.client.resources.server.ServerPackManager; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(targets = "net.minecraft.client.gui.screen.multiplayer.ConnectScreen$1") + +@Mixin(targets = "net.minecraft.client.gui.screens.ConnectScreen$1") public abstract class ServerConnectorMixin { - @Inject(method = "toAcceptanceStatus", at = @At("HEAD"), cancellable = true) - private static void guardSwitchCase(ServerInfo.ResourcePackPolicy policy, CallbackInfoReturnable cir) { + @Inject(method = "convertPackStatus", at = @At("HEAD"), cancellable = true) + private static void guardSwitchCase(ServerData.ServerPackStatus resourcePackStatus, CallbackInfoReturnable cir) { RPackBypass bypassPack = ModuleManager.INSTANCE.getModuleByClass(RPackBypass.class); if (!bypassPack.isEnabled()) return; - if (policy == bypassPack.getPolicy()) - cir.setReturnValue(ServerResourcePackManager.AcceptanceStatus.ALLOWED); + if (resourcePackStatus == bypassPack.getStatus()) + cir.setReturnValue(ServerPackManager.PackPromptStatus.ALLOWED); } } diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/network/ServerInfoMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/network/ServerDataMixin.java similarity index 52% rename from src/main/java/me/retucio/sputnik/mixin/mixins/network/ServerInfoMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/network/ServerDataMixin.java index bd78839..19d2882 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/network/ServerInfoMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/network/ServerDataMixin.java @@ -2,8 +2,8 @@ package me.retucio.sputnik.mixin.mixins.network; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.network.RPackBypass; -import net.minecraft.client.network.ServerInfo; -import net.minecraft.nbt.NbtCompound; +import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.nbt.CompoundTag; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -12,42 +12,44 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(ServerInfo.class) -public abstract class ServerInfoMixin { - @Shadow private ServerInfo.ResourcePackPolicy resourcePackPolicy; +@Mixin(ServerData.class) +public abstract class ServerDataMixin { + + @Shadow private ServerData.ServerPackStatus packStatus; @Unique private boolean isBypassStatus; @Unique private static RPackBypass bypassPack; @Inject(method = "", at = @At("TAIL")) - private void getModules(String name, String address, ServerInfo.ServerType serverType, CallbackInfo ci) { + private void getModules(String name, String ip, ServerData.Type type, CallbackInfo ci) { bypassPack = ModuleManager.INSTANCE.getModuleByClass(RPackBypass.class); } - @Inject(method = "fromNbt", at = @At("TAIL")) - private static void addToRead(NbtCompound root, CallbackInfoReturnable cir) { + @Inject(method = "read", at = @At("TAIL")) + private static void addToRead(CompoundTag tag, CallbackInfoReturnable cir) { if (!bypassPack.isEnabled()) return; - if (root.getBoolean(bypassPack.TAG_NAME, false)) - cir.getReturnValue().setResourcePackPolicy(bypassPack.getPolicy()); - } - - @Inject(method = "toNbt", at = @At("HEAD")) - private void preWrite(CallbackInfoReturnable cir) { - if (!bypassPack.isEnabled()) return; - if (this.resourcePackPolicy == bypassPack.getPolicy()) { - this.isBypassStatus = true; - this.resourcePackPolicy = ServerInfo.ResourcePackPolicy.PROMPT; + if (tag.getBooleanOr(bypassPack.TAG_NAME, false)) { + cir.getReturnValue().setResourcePackStatus(bypassPack.getStatus()); } } - @Inject(method = "toNbt", at = @At("TAIL")) - private void addToWrite(CallbackInfoReturnable cir) { + @Inject(method = "write", at = @At("HEAD")) + private void preWrite(CallbackInfoReturnable cir) { + if (!bypassPack.isEnabled()) return; + if (this.packStatus == bypassPack.getStatus()) { + this.isBypassStatus = true; + this.packStatus = ServerData.ServerPackStatus.PROMPT; + } + } + + @Inject(method = "write", at = @At("TAIL")) + private void addToWrite(CallbackInfoReturnable cir) { if (!bypassPack.isEnabled()) return; if (this.isBypassStatus) { cir.getReturnValue().putBoolean(bypassPack.TAG_NAME, true); - this.resourcePackPolicy = bypassPack.getPolicy(); + this.packStatus = bypassPack.getStatus(); this.isBypassStatus = false; } } diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/network/ResourcePackPolicyMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/network/ServerPackStatusMixin.java similarity index 69% rename from src/main/java/me/retucio/sputnik/mixin/mixins/network/ResourcePackPolicyMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/network/ServerPackStatusMixin.java index e0106ad..c916e0a 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/network/ResourcePackPolicyMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/network/ServerPackStatusMixin.java @@ -2,8 +2,8 @@ package me.retucio.sputnik.mixin.mixins.network; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.network.RPackBypass; -import net.minecraft.client.network.ServerInfo; -import net.minecraft.text.Text; +import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.network.chat.Component; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.gen.Invoker; @@ -13,30 +13,32 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import java.util.Arrays; -@Mixin(ServerInfo.ResourcePackPolicy.class) -public abstract class ResourcePackPolicyMixin { + +@Mixin(ServerData.ServerPackStatus.class) +public abstract class ServerPackStatusMixin { @Unique - private static ServerInfo.ResourcePackPolicy BYPASS; + private static ServerData.ServerPackStatus BYPASS; @Invoker("") - public static ServerInfo.ResourcePackPolicy init(final String enumName, final int enumOrdinal, final String name) { + public static ServerData.ServerPackStatus init(final String enumName, final int enumOrdinal, final String name) { throw new AssertionError(); } @Inject(method = "values", at = @At("TAIL"), cancellable = true) - private static void addVariant(CallbackInfoReturnable cir) { + private static void addVariant(CallbackInfoReturnable cir) { RPackBypass bypassPack = ModuleManager.INSTANCE.getModuleByClass(RPackBypass.class); if (!bypassPack.isEnabled()) return; - ServerInfo.ResourcePackPolicy[] values = cir.getReturnValue(); + ServerData.ServerPackStatus[] values = cir.getReturnValue(); final int ordinal = values.length; cir.setReturnValue(values = Arrays.copyOfRange(values, 0, ordinal + 1)); values[ordinal] = BYPASS = init(bypassPack.ENUM_NAME, ordinal, "bypass"); } + @SuppressWarnings("ConstantConditions") @Inject(method = "getName", at = @At("HEAD"), cancellable = true) - private void addToGetName(final CallbackInfoReturnable cir) { + private void addToGetName(final CallbackInfoReturnable cir) { RPackBypass bypassPack = ModuleManager.INSTANCE.getModuleByClass(RPackBypass.class); if (BYPASS == (Object) this && bypassPack.isEnabled()) cir.setReturnValue(bypassPack.BYPASS_TEXT); diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/network/TelemetryManagerMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/network/TelemetryManagerMixin.java deleted file mode 100644 index fcde6fb..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/network/TelemetryManagerMixin.java +++ /dev/null @@ -1,16 +0,0 @@ -package me.retucio.sputnik.mixin.mixins.network; - -import net.minecraft.client.session.telemetry.TelemetryManager; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Coerce; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(TelemetryManager.class) -public class TelemetryManagerMixin { - - @Redirect(method = "computeSender", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;isTelemetryEnabledByApi()Z")) - private boolean disableTelemetry(@Coerce Object minecraftClient) { - return false; - } -} diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/player/PlayerInputMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/player/InputMixin.java similarity index 76% rename from src/main/java/me/retucio/sputnik/mixin/mixins/player/PlayerInputMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/player/InputMixin.java index fe33583..b14a178 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/player/PlayerInputMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/player/InputMixin.java @@ -2,16 +2,17 @@ package me.retucio.sputnik.mixin.mixins.player; import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.event.input.SneakEvent; -import net.minecraft.util.PlayerInput; +import net.minecraft.world.entity.player.Input; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(PlayerInput.class) -public abstract class PlayerInputMixin { - @Inject(method = "sneak", at = @At("HEAD"), cancellable = true) +@Mixin(Input.class) +public abstract class InputMixin { + + @Inject(method = "shift", at = @At("HEAD"), cancellable = true) private void onSneak(CallbackInfoReturnable cir) { SneakEvent event = Sputnik.EVENT_BUS.post(new SneakEvent()); if (event.isCancelled()) cir.cancel(); diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/player/ClientPlayerEntityMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/player/LocalPlayerMixin.java similarity index 50% rename from src/main/java/me/retucio/sputnik/mixin/mixins/player/ClientPlayerEntityMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/player/LocalPlayerMixin.java index 44fa1d9..6274d52 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/player/ClientPlayerEntityMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/player/LocalPlayerMixin.java @@ -6,43 +6,42 @@ import com.llamalad7.mixinextras.sugar.Local; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.world.NoMiningInterruptions; import me.retucio.sputnik.module.modules.inventory.PortalGUI; -import me.retucio.sputnik.util.ChatUtil; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.util.hit.EntityHitResult; -import net.minecraft.util.hit.HitResult; -import net.minecraft.util.math.Vec3d; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + import static me.retucio.sputnik.Sputnik.mc; -@Mixin(ClientPlayerEntity.class) -public abstract class ClientPlayerEntityMixin { +@Mixin(LocalPlayer.class) +public abstract class LocalPlayerMixin { @Shadow - private static HitResult checkCrosshairTargetRange(HitResult hitResult, Vec3d cameraPos, double range) { - return null; + private static HitResult filterHitResult(HitResult hitResult, Vec3 from, double maxRange) { + throw new UnsupportedOperationException("Implemented via mixin"); } - @ModifyExpressionValue(method = "tickNausea", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;", opcode = Opcodes.GETFIELD)) + @ModifyExpressionValue(method = "handlePortalTransitionEffect", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Minecraft;screen:Lnet/minecraft/client/gui/screens/Screen;", opcode = Opcodes.GETFIELD)) private Screen allowScreensInPortals(Screen original) { if (ModuleManager.INSTANCE.getModuleByClass(PortalGUI.class).isEnabled()) return null; return original; } // no va?? - @ModifyReturnValue(method = "getCrosshairTarget(Lnet/minecraft/entity/Entity;DDF)Lnet/minecraft/util/hit/HitResult;", at = @At("RETURN")) - private static HitResult onUpdateTargetedEntity(HitResult original, @Local HitResult hitResult, @Local(ordinal = 0) Vec3d vec3d) { + @ModifyReturnValue(method = "pick", at = @At("RETURN")) + private static HitResult onUpdateTargetedEntity(HitResult original, @Local(name = "blockHitResult") HitResult blockHitResult, @Local(name = "from") Vec3 from) { NoMiningInterruptions nmi = ModuleManager.INSTANCE.getModuleByClass(NoMiningInterruptions.class); if (!(original instanceof EntityHitResult ehr)) return original; if (!nmi.shouldIgnoreEntity((ehr.getEntity()))) return original; - return checkCrosshairTargetRange(hitResult, vec3d, mc.player.getEntityInteractionRange()); + return filterHitResult(blockHitResult, from, mc.player.entityInteractionRange()); } } \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/player/ClientPlayerInteractionManagerMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/player/MultiPlayerGameModeMixin.java similarity index 55% rename from src/main/java/me/retucio/sputnik/mixin/mixins/player/ClientPlayerInteractionManagerMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/player/MultiPlayerGameModeMixin.java index 05bf5fd..df71c2d 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/player/ClientPlayerInteractionManagerMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/player/MultiPlayerGameModeMixin.java @@ -5,18 +5,17 @@ import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.camera.Freecam; import me.retucio.sputnik.module.modules.player.FastUse; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.client.network.ClientPlayerInteractionManager; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.ActionResult; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.client.multiplayer.MultiPlayerGameMode; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.EntityHitResult; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -29,61 +28,58 @@ import static me.retucio.sputnik.Sputnik.EVENT_BUS; import static me.retucio.sputnik.Sputnik.mc; -@Mixin(ClientPlayerInteractionManager.class) -public abstract class ClientPlayerInteractionManagerMixin { +@Mixin(MultiPlayerGameMode.class) +public abstract class MultiPlayerGameModeMixin { @Shadow - private int blockBreakingCooldown; + private int destroyDelay; - @Unique - Freecam freecam; - - @Unique - FastUse fastUse; + @Unique Freecam freecam; + @Unique FastUse fastUse; @Inject(method = "", at = @At("TAIL")) - private void getModules(MinecraftClient client, ClientPlayNetworkHandler networkHandler, CallbackInfo ci) { + private void getModules(CallbackInfo ci) { freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class); fastUse = ModuleManager.INSTANCE.getModuleByClass(FastUse.class); } - @Inject(method = "breakBlock", at = @At("HEAD"), cancellable = true) + @Inject(method = "destroyBlock", at = @At("HEAD"), cancellable = true) private void onBlockBreak(BlockPos pos, CallbackInfoReturnable cir) { BreakBlockEvent event = EVENT_BUS.post(new BreakBlockEvent(pos)); if (event.isCancelled()) cir.cancel(); } - @Inject(method = "interactBlock", at = @At("HEAD"), cancellable = true) - private void onBlockPlace(ClientPlayerEntity player, Hand hand, BlockHitResult result, CallbackInfoReturnable cir) { + @Inject(method = "useItemOn", at = @At("HEAD"), cancellable = true) + private void onBlockPlace(LocalPlayer player, InteractionHand hand, BlockHitResult blockHit, CallbackInfoReturnable cir) { if (mc.player != player) return; - PlaceBlockEvent event = EVENT_BUS.post(new PlaceBlockEvent(hand, result)); + PlaceBlockEvent event = EVENT_BUS.post(new PlaceBlockEvent(hand, blockHit)); if (event.isCancelled()) cir.cancel(); } - @Inject(method = "attackBlock", at = @At("HEAD"), cancellable = true) + @Inject(method = "startDestroyBlock", at = @At("HEAD"), cancellable = true) private void onAttackBlock(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { AttackBlockEvent event = EVENT_BUS.post(new AttackBlockEvent(pos, direction)); if (event.isCancelled()) cir.cancel(); } - @Inject(method = "interactEntity", at = @At("HEAD"), cancellable = true) - private void onEntityInteract(PlayerEntity player, Entity entity, Hand hand, CallbackInfoReturnable cir) { + @Inject(method = "interact", at = @At("HEAD"), cancellable = true) + private void onEntityInteract(Player player, Entity entity, EntityHitResult hitResult, InteractionHand hand, CallbackInfoReturnable cir) { if (mc.player != player) return; InteractEntityEvent event = EVENT_BUS.post(new InteractEntityEvent(entity, hand)); if (event.isCancelled()) cir.cancel(); } - @Inject(method = "attackEntity", at = @At("HEAD"), cancellable = true) - private void onAttackEntity(PlayerEntity player, Entity target, CallbackInfo ci) { + @Inject(method = "attack", at = @At("HEAD"), cancellable = true) + private void onAttackEntity(Player player, Entity entity, CallbackInfo ci) { if (mc.player != player) return; - AttackEntityEvent event = EVENT_BUS.post(new AttackEntityEvent(target)); + AttackEntityEvent event = EVENT_BUS.post(new AttackEntityEvent(entity)); if (event.isCancelled()) ci.cancel(); } - @Inject(method = "updateBlockBreakingProgress", at = @At("HEAD")) + @Inject(method = "continueDestroyBlock", at = @At("HEAD")) private void modifyBlockBreakingCooldown(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { if (!fastUse.isEnabled() || !fastUse.mining.getValue()) return; - blockBreakingCooldown = fastUse.miningCooldown.getIntValue(); + destroyDelay = fastUse.miningCooldown.getIntValue(); } } diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/player/PlayerInventoryMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/player/PlayerInventoryMixin.java index ed93d7a..00fbbc6 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/player/PlayerInventoryMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/player/PlayerInventoryMixin.java @@ -2,24 +2,25 @@ package me.retucio.sputnik.mixin.mixins.player; import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.event.interact.SwitchSlotEvent; -import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.world.entity.player.Inventory; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(PlayerInventory.class) + +@Mixin(Inventory.class) public abstract class PlayerInventoryMixin { @Shadow - private int selectedSlot; + private int selected; @Inject(method = "setSelectedSlot", at = @At("HEAD"), cancellable = true) - private void onSwitchSlot(int slot, CallbackInfo ci) { - if (selectedSlot == slot) return; - SwitchSlotEvent event = Sputnik.EVENT_BUS.post(new SwitchSlotEvent(selectedSlot, slot)); + private void onSwitchSlot(int selected, CallbackInfo ci) { + if (this.selected == selected) return; + SwitchSlotEvent event = Sputnik.EVENT_BUS.post(new SwitchSlotEvent(this.selected, selected)); if (event.isCancelled()) ci.cancel(); - if (event.getSlot() != slot) this.selectedSlot = event.getSlot(); + if (event.getSlot() != selected) this.selected = event.getSlot(); } } diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/player/PlayerEntityMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/player/PlayerMixin.java similarity index 65% rename from src/main/java/me/retucio/sputnik/mixin/mixins/player/PlayerEntityMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/player/PlayerMixin.java index ee921b1..0746fb3 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/player/PlayerEntityMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/player/PlayerMixin.java @@ -1,41 +1,44 @@ package me.retucio.sputnik.mixin.mixins.player; -import com.llamalad7.mixinextras.injector.ModifyReturnValue; import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.event.interact.ClipAtLedgeEvent; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.render.Nametags; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; -import net.minecraft.world.World; + +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; + +import com.llamalad7.mixinextras.injector.ModifyReturnValue; +import net.minecraft.world.level.Level; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(PlayerEntity.class) -public abstract class PlayerEntityMixin extends LivingEntity { - protected PlayerEntityMixin(EntityType entityType, World world) { +@Mixin(Player.class) +public abstract class PlayerMixin extends LivingEntity { + + protected PlayerMixin(EntityType entityType, Level world) { super(entityType, world); } @ModifyReturnValue(method = "getDisplayName", at = @At("RETURN")) - private Text addHealthIndicator(Text original) { + private Component addHealthIndicator(Component original) { Nametags nametags = ModuleManager.INSTANCE.getModuleByClass(Nametags.class); if (!nametags.isEnabled() || !nametags.health.getValue()) return original; float health = getHealth(); float absorption = getAbsorptionAmount(); - Formatting color; + ChatFormatting color; - if (health < 5) color = Formatting.RED; - else if (health < 10) color = Formatting.YELLOW; - else if (health < 15) color = Formatting.GREEN; - else color = Formatting.DARK_GREEN; + if (health < 5) color = ChatFormatting.RED; + else if (health < 10) color = ChatFormatting.YELLOW; + else if (health < 15) color = ChatFormatting.GREEN; + else color = ChatFormatting.DARK_GREEN; // me gustaría también añadir un modo en el que se renderizan los corazones directamente en la nametag, pero no sé cómo hacer para las imágenes :'( // ahora que lo pienso en la snapshot más reciente han metido iconos que se pueden usar en texto, y uno de ellos es un corazón :D @@ -44,20 +47,20 @@ public abstract class PlayerEntityMixin extends LivingEntity { ? String.format("%.2f", health / 2) // redondear a dos decimales : (int) health) + (absorption > 0 // tener absorción en cuenta - ? Formatting.RESET + " + " + Formatting.GOLD + + ? ChatFormatting.RESET + " + " + ChatFormatting.GOLD + (nametags.healthMode.is(Nametags.HealthMode.HEARTS) ? String.format("%.2f", absorption / 2) : Integer.toString((int) absorption)) : "") + - Formatting.RESET + "]"; + ChatFormatting.RESET + "]"; return original.copy().append(text); } - @Inject(method = "clipAtLedge", at = @At("HEAD"), cancellable = true) + @Inject(method = "isStayingOnGroundSurface", at = @At("HEAD"), cancellable = true) private void clipAtLedge(CallbackInfoReturnable cir) { - if (!getEntityWorld().isClient()) return; - ClipAtLedgeEvent event = Sputnik.EVENT_BUS.post(new ClipAtLedgeEvent(isSneaking())); + if (!level().isClientSide()) return; + ClipAtLedgeEvent event = Sputnik.EVENT_BUS.post(new ClipAtLedgeEvent(isCrouching())); cir.setReturnValue(event.isClipping()); } } \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/StuckArrowsFeatureRendererMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/ArrowLayerMixin.java similarity index 69% rename from src/main/java/me/retucio/sputnik/mixin/mixins/render/StuckArrowsFeatureRendererMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/render/ArrowLayerMixin.java index 66ce98b..a48da3b 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/render/StuckArrowsFeatureRendererMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/render/ArrowLayerMixin.java @@ -3,14 +3,15 @@ package me.retucio.sputnik.mixin.mixins.render; import com.llamalad7.mixinextras.injector.ModifyReturnValue; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.render.NoRender; -import net.minecraft.client.render.entity.feature.StuckArrowsFeatureRenderer; +import net.minecraft.client.renderer.entity.layers.ArrowLayer; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -@Mixin(StuckArrowsFeatureRenderer.class) -public abstract class StuckArrowsFeatureRendererMixin { - @ModifyReturnValue(method = "getObjectCount", at = @At("RETURN")) +@Mixin(ArrowLayer.class) +public abstract class ArrowLayerMixin { + + @ModifyReturnValue(method = "numStuck", at = @At("RETURN")) private int noRenderStuckArrows(int original) { NoRender noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class); if (noRender.isEnabled() && !noRender.stuckArrows.getValue()) return 0; diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/BufferStorageMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/BufferStorageMixin.java deleted file mode 100644 index 6e1c05b..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/render/BufferStorageMixin.java +++ /dev/null @@ -1,20 +0,0 @@ -package me.retucio.sputnik.mixin.mixins.render; - -import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; -import me.retucio.sputnik.util.render.GlintRenderLayer; -import net.minecraft.client.render.BufferBuilderStorage; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.util.BufferAllocator; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(BufferBuilderStorage.class) -public abstract class BufferStorageMixin { - - @Inject(method = "assignBufferBuilder", at = @At("HEAD")) - private static void addGlintTypes(Object2ObjectLinkedOpenHashMap builderStorage, RenderLayer layer, CallbackInfo ci) { - GlintRenderLayer.addGlintTypes(builderStorage); - } -} diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/CameraMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/CameraMixin.java index fe1db68..f67d0f5 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/render/CameraMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/render/CameraMixin.java @@ -1,12 +1,14 @@ package me.retucio.sputnik.mixin.mixins.render; +import com.llamalad7.mixinextras.injector.ModifyReturnValue; +import me.retucio.sputnik.event.render.GetFOVEvent; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.camera.Freelook; import me.retucio.sputnik.module.modules.camera.Freecam; import me.retucio.sputnik.module.modules.camera.PerspectivePlus; -import net.minecraft.client.render.Camera; -import net.minecraft.entity.Entity; -import net.minecraft.world.World; +import net.minecraft.client.Camera; +import net.minecraft.client.DeltaTracker; +import net.minecraft.world.entity.Entity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -18,6 +20,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; +import static me.retucio.sputnik.Sputnik.EVENT_BUS; + + @Mixin(Camera.class) public abstract class CameraMixin { @@ -34,7 +39,7 @@ public abstract class CameraMixin { Freelook freelook; @Shadow - private boolean thirdPerson; + private boolean detached; @Inject(method = "", at = @At("TAIL")) private void getModules(CallbackInfo ci) { @@ -44,20 +49,24 @@ public abstract class CameraMixin { } @Inject(method = "update", at = @At("HEAD")) - private void onUpdateHead(World area, Entity focusedEntity, boolean thirdPerson, boolean inverseView, float tickDelta, CallbackInfo ci) { - this.tickDelta = tickDelta; + private void onUpdateHead(DeltaTracker deltaTracker, CallbackInfo ci) { + this.tickDelta = deltaTracker.getGameTimeDeltaTicks(); } + @ModifyReturnValue(method = "getFov", at = @At("RETURN")) + private float modifyFov(float original) { + return EVENT_BUS.post(new GetFOVEvent(original)).getFov(); + } // perspectiva - @ModifyVariable(method = "clipToSpace", at = @At("HEAD"), ordinal = 0, argsOnly = true) + @ModifyVariable(method = "getMaxZoom", at = @At("HEAD"), argsOnly = true, name = "cameraDist") private float modifyClipToSpace(float distance) { if (freecam.isEnabled()) return 0; return perspectivePlus.isEnabled() ? (float) perspectivePlus.getDistance() : distance; } - @Inject(method = "clipToSpace", at = @At("HEAD"), cancellable = true) + @Inject(method = "getMaxZoom", at = @At("HEAD"), cancellable = true) private void onClipToSpace(float distance, CallbackInfoReturnable cir) { if (perspectivePlus.isEnabled() && perspectivePlus.clip.getValue()) cir.setReturnValue(distance); @@ -67,12 +76,11 @@ public abstract class CameraMixin { // cámara libre @Inject(method = "update", at = @At("TAIL")) - private void onUpdateTail(World area, Entity focusedEntity, boolean thirdPerson, boolean inverseView, float tickProgress, CallbackInfo ci) { - if (freecam.isEnabled()) - this.thirdPerson = true; + private void onUpdateTail(final DeltaTracker dt, CallbackInfo ci) { + if (freecam.isEnabled()) this.detached = true; } - @ModifyArgs(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;setPos(DDD)V")) + @ModifyArgs(method = "alignWithEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;setPosition(DDD)V")) private void onUpdateSetPosArgs(Args args) { if (freecam.isEnabled()) { args.set(0, freecam.getX(tickDelta)); @@ -81,7 +89,7 @@ public abstract class CameraMixin { } } - @ModifyArgs(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;setRotation(FF)V")) + @ModifyArgs(method = "alignWithEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;setRotation(FF)V")) private void onUpdateSetRotationArgs(Args args) { if (freecam.isEnabled()) { args.set(0, freecam.getYaw(tickDelta)); diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/CapeFeatureRendererMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/CapeFeatureRendererMixin.java deleted file mode 100644 index 93163e2..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/render/CapeFeatureRendererMixin.java +++ /dev/null @@ -1,26 +0,0 @@ -package me.retucio.sputnik.mixin.mixins.render; - -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import me.retucio.sputnik.module.ModuleManager; -import me.retucio.sputnik.module.modules.player.Capes; -import net.minecraft.client.render.command.OrderedRenderCommandQueue; -import net.minecraft.client.render.entity.feature.CapeFeatureRenderer; -import net.minecraft.client.render.entity.state.PlayerEntityRenderState; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.AssetInfo; -import net.minecraft.util.Identifier; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(CapeFeatureRenderer.class) -public abstract class CapeFeatureRendererMixin { - - @ModifyExpressionValue(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;ILnet/minecraft/client/render/entity/state/PlayerEntityRenderState;FF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/SkinTextures;cape()Lnet/minecraft/util/AssetInfo$TextureAsset;")) - private AssetInfo.TextureAsset modifyCapeTexture(AssetInfo.TextureAsset original, MatrixStack matrices, OrderedRenderCommandQueue entityRenderCommandQueue, int i, PlayerEntityRenderState state, float f, float g) { - Capes capes = ModuleManager.INSTANCE.getModuleByClass(Capes.class); - if (!capes.isEnabled()) return original; - - Identifier id = capes.cape.getValue().getId(); - return id == null ? original : new AssetInfo.TextureAssetInfo(id, id); - } -} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/CapeLayerMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/CapeLayerMixin.java new file mode 100644 index 0000000..43e3aa4 --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/render/CapeLayerMixin.java @@ -0,0 +1,23 @@ +package me.retucio.sputnik.mixin.mixins.render; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import me.retucio.sputnik.module.ModuleManager; +import me.retucio.sputnik.module.modules.player.Capes; +import net.minecraft.client.renderer.entity.layers.CapeLayer; +import net.minecraft.core.ClientAsset; +import net.minecraft.resources.Identifier; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(CapeLayer.class) +public abstract class CapeLayerMixin { + + @ModifyExpressionValue(method = "submit(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;ILnet/minecraft/client/renderer/entity/state/AvatarRenderState;FF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/PlayerSkin;cape()Lnet/minecraft/core/ClientAsset$Texture;")) + private ClientAsset.Texture modifyCapeTexture(ClientAsset.Texture original) { + Capes capes = ModuleManager.INSTANCE.getModuleByClass(Capes.class); + if (!capes.isEnabled()) return original; + + Identifier id = capes.cape.getValue().getId(); + return id == null ? original : new ClientAsset.ResourceTexture(id, id); + } +} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/ChunkBorderDebugRendererMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/ChunkBorderDebugRendererMixin.java deleted file mode 100644 index 292d162..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/render/ChunkBorderDebugRendererMixin.java +++ /dev/null @@ -1,33 +0,0 @@ -package me.retucio.sputnik.mixin.mixins.render; - -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import me.retucio.sputnik.module.ModuleManager; -import me.retucio.sputnik.module.modules.camera.Freecam; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.render.debug.ChunkBorderDebugRenderer; -import net.minecraft.util.math.ChunkSectionPos; -import net.minecraft.util.math.MathHelper; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(ChunkBorderDebugRenderer.class) -public abstract class ChunkBorderDebugRendererMixin { - - @Shadow @Final - private MinecraftClient client; - - @ModifyExpressionValue(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/ChunkSectionPos;from(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/util/math/ChunkSectionPos;")) - private ChunkSectionPos getChunkPos(ChunkSectionPos chunkPos) { - Freecam freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class); - if (!freecam.isEnabled()) return chunkPos; - - float delta = client.getRenderTickCounter().getTickProgress(true); - return ChunkSectionPos.from( - ChunkSectionPos.getSectionCoord(MathHelper.floor(freecam.getX(delta))), - ChunkSectionPos.getSectionCoord(MathHelper.floor(freecam.getY(delta))), - ChunkSectionPos.getSectionCoord(MathHelper.floor(freecam.getZ(delta))) - ); - } -} diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/ChunkBorderRendererMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/ChunkBorderRendererMixin.java new file mode 100644 index 0000000..d8b08f2 --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/render/ChunkBorderRendererMixin.java @@ -0,0 +1,33 @@ +package me.retucio.sputnik.mixin.mixins.render; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import me.retucio.sputnik.module.ModuleManager; +import me.retucio.sputnik.module.modules.camera.Freecam; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.debug.ChunkBorderRenderer; +import net.minecraft.core.SectionPos; +import net.minecraft.util.Mth; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(ChunkBorderRenderer.class) +public abstract class ChunkBorderRendererMixin { + + @Shadow @Final + private Minecraft minecraft; + + @ModifyExpressionValue(method = "emitGizmos", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/SectionPos;of(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/core/SectionPos;")) + private SectionPos getChunkPos(SectionPos chunkPos) { + Freecam freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class); + if (!freecam.isEnabled()) return chunkPos; + + float delta = minecraft.getDeltaTracker().getGameTimeDeltaPartialTick(true); + return SectionPos.of( + SectionPos.posToSectionCoord(Mth.floor(freecam.getX(delta))), + SectionPos.posToSectionCoord(Mth.floor(freecam.getY(delta))), + SectionPos.posToSectionCoord(Mth.floor(freecam.getZ(delta))) + ); + } +} diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/ElytraFeatureRendererMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/ElytraFeatureRendererMixin.java deleted file mode 100644 index 3594c1a..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/render/ElytraFeatureRendererMixin.java +++ /dev/null @@ -1,32 +0,0 @@ -package me.retucio.sputnik.mixin.mixins.render; - -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import me.retucio.sputnik.module.ModuleManager; -import me.retucio.sputnik.module.modules.player.Capes; -import net.minecraft.client.render.command.OrderedRenderCommandQueue; -import net.minecraft.client.render.entity.feature.ElytraFeatureRenderer; -import net.minecraft.client.render.entity.feature.FeatureRenderer; -import net.minecraft.client.render.entity.feature.FeatureRendererContext; -import net.minecraft.client.render.entity.model.EntityModel; -import net.minecraft.client.render.entity.state.BipedEntityRenderState; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.Identifier; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(ElytraFeatureRenderer.class) -public abstract class ElytraFeatureRendererMixin> extends FeatureRenderer { - - public ElytraFeatureRendererMixin(FeatureRendererContext context) { - super(context); - } - - @ModifyExpressionValue(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;ILnet/minecraft/client/render/entity/state/BipedEntityRenderState;FF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/feature/ElytraFeatureRenderer;getTexture(Lnet/minecraft/client/render/entity/state/BipedEntityRenderState;)Lnet/minecraft/util/Identifier;")) - private Identifier modifyCapeTexture(Identifier original, MatrixStack matrices, OrderedRenderCommandQueue entityRenderCommandQueue, int i, S state, float f, float g) { - Capes capes = ModuleManager.INSTANCE.getModuleByClass(Capes.class); - if (!capes.isEnabled()) return original; - - Identifier id = capes.cape.getValue().getId(); - return id == null ? original : id; - } -} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/EntityHitboxDebugRendererMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/EntityHitboxDebugRendererMixin.java index dda56ec..8db8b3f 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/render/EntityHitboxDebugRendererMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/render/EntityHitboxDebugRendererMixin.java @@ -2,8 +2,8 @@ package me.retucio.sputnik.mixin.mixins.render; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.render.Hitboxes; -import net.minecraft.client.render.DrawStyle; -import net.minecraft.client.render.debug.EntityHitboxDebugRenderer; +import net.minecraft.client.renderer.debug.EntityHitboxDebugRenderer; +import net.minecraft.gizmos.GizmoStyle; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyArg; @@ -12,17 +12,17 @@ import org.spongepowered.asm.mixin.injection.ModifyVariable; @Mixin(EntityHitboxDebugRenderer.class) public abstract class EntityHitboxDebugRendererMixin { - @ModifyVariable(method = "drawHitbox", at = @At("STORE")) + @ModifyVariable(method = "showHitboxes", at = @At("STORE"), name = "mainColor") private int modifyHitboxColor(int original) { Hitboxes hitboxes = ModuleManager.INSTANCE.getModuleByClass(Hitboxes.class); if (hitboxes.isEnabled()) return hitboxes.color.getRGB(); return original; } - @ModifyArg(method = "drawHitbox", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/debug/gizmo/GizmoDrawing;box(Lnet/minecraft/util/math/Box;Lnet/minecraft/client/render/DrawStyle;)Lnet/minecraft/world/debug/gizmo/VisibilityConfigurable;")) - private DrawStyle modifyHitboxLineWidth(DrawStyle original) { + @ModifyArg(method = "showHitboxes", at = @At(value = "INVOKE", target = "Lnet/minecraft/gizmos/Gizmos;cuboid(Lnet/minecraft/world/phys/AABB;Lnet/minecraft/gizmos/GizmoStyle;)Lnet/minecraft/gizmos/GizmoProperties;")) + private GizmoStyle modifyHitboxLineWidth(GizmoStyle original) { Hitboxes hitboxes = ModuleManager.INSTANCE.getModuleByClass(Hitboxes.class); - if (hitboxes.isEnabled()) return DrawStyle.stroked(original.stroke(), hitboxes.lineWidth.getFloatValue()); + if (hitboxes.isEnabled()) return GizmoStyle.stroke(original.stroke(), hitboxes.lineWidth.getFloatValue()); return original; } } diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/EquipmentLayerRendererMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/EquipmentLayerRendererMixin.java new file mode 100644 index 0000000..87b2096 --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/render/EquipmentLayerRendererMixin.java @@ -0,0 +1,19 @@ +package me.retucio.sputnik.mixin.mixins.render; + +import me.retucio.sputnik.module.ModuleManager; +import me.retucio.sputnik.module.modules.render.GlintPlus; +import net.minecraft.client.renderer.entity.layers.EquipmentLayerRenderer; +import net.minecraft.client.renderer.rendertype.RenderType; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(EquipmentLayerRenderer.class) +public abstract class EquipmentLayerRendererMixin { + + @Redirect(method = "renderLayers(Lnet/minecraft/client/resources/model/EquipmentClientInfo$LayerType;Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lnet/minecraft/world/item/ItemStack;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;ILnet/minecraft/resources/Identifier;II)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/rendertype/RenderTypes;armorEntityGlint()Lnet/minecraft/client/renderer/rendertype/RenderType;")) + private RenderType redirectArmorEntityGlint() { + GlintPlus glintPlus = ModuleManager.INSTANCE.getModuleByClass(GlintPlus.class); + return glintPlus.getArmorEntityGlint(); + } +} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/EquipmentRendererMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/EquipmentRendererMixin.java deleted file mode 100644 index f67674b..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/render/EquipmentRendererMixin.java +++ /dev/null @@ -1,19 +0,0 @@ -package me.retucio.sputnik.mixin.mixins.render; - -import me.retucio.sputnik.module.ModuleManager; -import me.retucio.sputnik.module.modules.render.GlintPlus; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.entity.equipment.EquipmentRenderer; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(EquipmentRenderer.class) -public abstract class EquipmentRendererMixin { - - @Redirect(method = "render(Lnet/minecraft/client/render/entity/equipment/EquipmentModel$LayerType;Lnet/minecraft/registry/RegistryKey;Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;ILnet/minecraft/util/Identifier;II)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/RenderLayers;armorEntityGlint()Lnet/minecraft/client/render/RenderLayer;")) - private RenderLayer redirectArmorEntityGlint() { - GlintPlus glintPlus = ModuleManager.INSTANCE.getModuleByClass(GlintPlus.class); - return glintPlus.getArmorEntityGlint(); - } -} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/FogRendererMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/FogRendererMixin.java index c01e514..35f3365 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/render/FogRendererMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/render/FogRendererMixin.java @@ -1,21 +1,27 @@ package me.retucio.sputnik.mixin.mixins.render; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import com.llamalad7.mixinextras.injector.ModifyReturnValue; + +import com.llamalad7.mixinextras.sugar.Local; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.render.NoRender; -import net.minecraft.block.enums.CameraSubmersionType; -import net.minecraft.client.render.Camera; -import net.minecraft.client.render.fog.FogModifier; -import net.minecraft.client.render.fog.FogRenderer; -import net.minecraft.entity.Entity; + +import net.minecraft.client.Camera; +import net.minecraft.client.renderer.fog.FogRenderer; +import net.minecraft.client.renderer.fog.environment.FogEnvironment; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.material.FogType; + import org.joml.Vector4f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyArgs; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.invoke.arg.Args; + @Mixin(FogRenderer.class) public abstract class FogRendererMixin { @@ -28,31 +34,36 @@ public abstract class FogRendererMixin { noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class); } - @Redirect(method = "applyFog(Lnet/minecraft/client/render/Camera;ILnet/minecraft/client/render/RenderTickCounter;FLnet/minecraft/client/world/ClientWorld;)Lorg/joml/Vector4f;", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/fog/FogModifier;shouldApply(Lnet/minecraft/block/enums/CameraSubmersionType;Lnet/minecraft/entity/Entity;)Z")) - private boolean noRenderFogs(FogModifier instance, CameraSubmersionType cameraSubmersionType, Entity entity) { - if (!noRender.isEnabled()) return instance.shouldApply(cameraSubmersionType, entity); + @Redirect(method = "setupFog", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/fog/environment/FogEnvironment;isApplicable(Lnet/minecraft/world/level/material/FogType;Lnet/minecraft/world/entity/Entity;)Z")) + private boolean noRenderFogs(FogEnvironment instance, FogType fogType, Entity entity) { + if (!noRender.isEnabled()) return instance.isApplicable(fogType, entity); String className = instance.getClass().getSimpleName(); if ((className.equals("BlindnessEffectFogModifier") && !noRender.blindnessEffect.getValue()) || (className.equals("DarknessEffectFogModifier") && !noRender.darknessEffect.getValue()) || ((className.equals("LavaFogModifier") || className.equals("WaterFogModifier") - || className.equals("PowederSnowFogModifier")) && !noRender.fluidOverlay.getValue())) + || className.equals("PowederSnowFogModifier")) && !noRender.fluidOverlay.getValue())) + { return false; + } - return instance.shouldApply(cameraSubmersionType, entity); + return instance.isApplicable(fogType, entity); } - @ModifyReturnValue(method = "getFogColor", at = @At("RETURN")) - private Vector4f modifyLavaFog(Vector4f original, Camera camera) { + @ModifyArgs(method = "computeFogColor", at = @At(value = "INVOKE", target = "Lorg/joml/Vector4f;set(FFFF)Lorg/joml/Vector4f;")) + private void modifyLavaFog(Args args, @Local(argsOnly = true, name = "dest") Vector4f original, @Local(argsOnly = true, name = "camera") Camera camera) { if (noRender.isEnabled() && !noRender.fluidOverlay.getValue() && - (camera.getSubmersionType() == CameraSubmersionType.LAVA - || camera.getSubmersionType() == CameraSubmersionType.WATER)) - return new Vector4f(original.x, original.y, original.z, 0f); - - return original; + (camera.getFluidInCamera() == FogType.LAVA + || camera.getFluidInCamera() == FogType.WATER)) + { + args.set(0, original.x); + args.set(1, original.y); + args.set(2, original.z); + args.set(3, 0); + } } - @ModifyExpressionValue(method = "getFogColor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getUnderwaterVisibility()F")) + @ModifyExpressionValue(method = "computeFogColor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;getWaterVision()F")) private float noRenderUnderwaterFog(float original) { return (noRender.isEnabled() && !noRender.fluidOverlay.getValue()) ? 0 : original; } diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/TextRendererMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/FontMixin.java similarity index 77% rename from src/main/java/me/retucio/sputnik/mixin/mixins/render/TextRendererMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/render/FontMixin.java index 47ea03c..db17931 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/render/TextRendererMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/render/FontMixin.java @@ -3,14 +3,15 @@ package me.retucio.sputnik.mixin.mixins.render; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.render.NoRender; -import net.minecraft.client.font.TextRenderer; +import net.minecraft.client.gui.Font; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -@Mixin(TextRenderer.class) -public abstract class TextRendererMixin { - @ModifyExpressionValue(method = "getGlyph", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/Style;isObfuscated()Z")) +@Mixin(Font.class) +public abstract class FontMixin { + + @ModifyExpressionValue(method = "getGlyph", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/chat/Style;isObfuscated()Z")) private boolean noRenderMTS(boolean original) { NoRender noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class); return (!noRender.isEnabled() || noRender.scrambledText.getValue()) && original; diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/GameRendererMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/GameRendererMixin.java index 42bc5c5..7f7f009 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/render/GameRendererMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/render/GameRendererMixin.java @@ -7,18 +7,16 @@ import me.retucio.sputnik.module.modules.camera.Freecam; import me.retucio.sputnik.module.modules.misc.UnfocusedCpu; import me.retucio.sputnik.module.modules.render.NoRender; import me.retucio.sputnik.module.modules.camera.Zoom; -import me.retucio.sputnik.util.interfaces.IVec3d; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.render.BufferBuilderStorage; -import net.minecraft.client.render.GameRenderer; -import net.minecraft.client.render.RenderTickCounter; -import net.minecraft.client.render.block.BlockRenderManager; -import net.minecraft.client.render.item.HeldItemRenderer; -import net.minecraft.entity.Entity; -import org.joml.Matrix4f; -import org.joml.Vector3d; +import net.minecraft.client.DeltaTracker; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.client.renderer.ItemInHandRenderer; +import net.minecraft.client.renderer.RenderBuffers; +import net.minecraft.client.renderer.state.level.CameraRenderState; +import net.minecraft.client.resources.model.ModelManager; +import org.joml.Matrix4fc; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -37,94 +35,35 @@ import static me.retucio.sputnik.Sputnik.mc; @Mixin(GameRenderer.class) public abstract class GameRendererMixin { - @Unique - boolean freecamDone; - - @Unique - Zoom zoom; - - @Unique - Freecam freecam; - - @Unique - NoRender noRender; + @Unique Zoom zoom; + @Unique Freecam freecam; + @Unique NoRender noRender; @Shadow @Final - private MinecraftClient client; - - @Shadow - public abstract void updateCrosshairTarget(float tickDelta); + private Minecraft minecraft; @Inject(method = "", at = @At("TAIL")) - private void getModules(MinecraftClient client, HeldItemRenderer firstPersonHeldItemRenderer, BufferBuilderStorage buffers, BlockRenderManager blockRenderManager, CallbackInfo ci) { + private void getModules(Minecraft minecraft, ItemInHandRenderer itemInHandRenderer, RenderBuffers renderBuffers, ModelManager modelManager, CallbackInfo ci) { zoom = ModuleManager.INSTANCE.getModuleByClass(Zoom.class);; freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class); noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class); } - @ModifyReturnValue(method = "getFov", at = @At("RETURN")) - private float modifyFov(float original) { - return EVENT_BUS.post(new GetFOVEvent(original)).getFov(); - } - @Inject(method = "render", at = @At("HEAD"), cancellable = true) - private void avoidRenderingUnfocusedCpu(RenderTickCounter tickCounter, boolean tick, CallbackInfo ci) { - if (ModuleManager.INSTANCE.getModuleByClass(UnfocusedCpu.class).isEnabled() && !mc.isWindowFocused()) + private void avoidRenderingUnfocusedCpu(DeltaTracker dt, boolean tick, CallbackInfo ci) { + if (ModuleManager.INSTANCE.getModuleByClass(UnfocusedCpu.class).isEnabled() && !mc.isWindowActive()) { ci.cancel(); - } - - @Inject(method = "updateCrosshairTarget", at = @At("HEAD"), cancellable = true) - private void updateTargetedEntityInvoke(float tickDelta, CallbackInfo ci) { - if ((freecam.isEnabled()) && client.getCameraEntity() != null && !freecamDone) { - ci.cancel(); - - Entity cameraEntity = client.getCameraEntity(); - Vector3d pos = freecam.getPos(); - Vector3d prevPos = freecam.getPrevPos(); - - double x = cameraEntity.getX(); - double y = cameraEntity.getY(); - double z = cameraEntity.getZ(); - double lastX = cameraEntity.lastX; - double lastY = cameraEntity.lastY; - double lastZ = cameraEntity.lastZ; - float yaw = cameraEntity.getYaw(); - float pitch = cameraEntity.getPitch(); - float lastYaw = cameraEntity.lastYaw; - float lastPitch = cameraEntity.lastPitch; - - ((IVec3d) cameraEntity.getEntityPos()).sputnik$set(pos.x, pos.y - cameraEntity.getEyeHeight(cameraEntity.getPose()), pos.z); - cameraEntity.lastX = prevPos.x; - cameraEntity.lastY = prevPos.y - cameraEntity.getEyeHeight(cameraEntity.getPose()); - cameraEntity.lastZ = prevPos.z; - cameraEntity.setYaw(freecam.getYaw()); - cameraEntity.setPitch(freecam.getPitch()); - cameraEntity.lastYaw = freecam.getPrevYaw(); - cameraEntity.lastPitch = freecam.getPrevPitch(); - - freecamDone = true; - updateCrosshairTarget(tickDelta); - freecamDone = false; - - ((IVec3d) cameraEntity.getEntityPos()).sputnik$set(x, y, z); - cameraEntity.lastX = lastX; - cameraEntity.lastY = lastY; - cameraEntity.lastZ = lastZ; - cameraEntity.setYaw(yaw); - cameraEntity.setPitch(pitch); - cameraEntity.lastYaw = lastYaw; - cameraEntity.lastPitch = lastPitch; } } - @Inject(method = "renderHand", at = @At("HEAD"), cancellable = true) - private void renderHand(float tickProgress, boolean sleeping, Matrix4f positionMatrix, CallbackInfo ci) { + @Inject(method = "renderItemInHand", at = @At("HEAD"), cancellable = true) + private void renderHand(CameraRenderState cameraState, float deltaPartialTick, Matrix4fc modelViewMatrix, CallbackInfo ci) { if ((zoom.isEnabled() && !zoom.showHands.getValue()) || (freecam.isEnabled() && !freecam.renderHands.getValue())) ci.cancel(); } - @ModifyVariable(method = "renderWorld", ordinal = 6, at = @At(value = "STORE")) + @ModifyVariable(method = "renderLevel", at = @At(value = "STORE"), name = "skew") private float noRenderNauseaDistortion(float scaledNauseaEffectFactor) { return (noRender.isEnabled() && !noRender.nauseaEffect.getValue()) ? 0 : scaledNauseaEffectFactor; } diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/HeldItemRendererMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/HeldItemRendererMixin.java deleted file mode 100644 index 44176c3..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/render/HeldItemRendererMixin.java +++ /dev/null @@ -1,90 +0,0 @@ -package me.retucio.sputnik.mixin.mixins.render; - -import com.llamalad7.mixinextras.injector.ModifyReturnValue; -import me.retucio.sputnik.event.render.RenderHeldItemEvent; -import me.retucio.sputnik.event.render.RenderArmEvent; -import me.retucio.sputnik.module.ModuleManager; -import me.retucio.sputnik.module.modules.player.HandView; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.item.ItemModelManager; -import net.minecraft.client.network.AbstractClientPlayerEntity; -import net.minecraft.client.render.command.OrderedRenderCommandQueue; -import net.minecraft.client.render.entity.EntityRenderManager; -import net.minecraft.client.render.item.HeldItemRenderer; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Arm; -import net.minecraft.util.Hand; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import static me.retucio.sputnik.Sputnik.*; - -@Mixin(HeldItemRenderer.class) -public abstract class HeldItemRendererMixin { - - @Unique - HandView handView; - - @Shadow - private float equipProgressMainHand; - - @Shadow - private float equipProgressOffHand; - - @Shadow - private ItemStack mainHand; - - @Shadow - private ItemStack offHand; - - @Shadow - protected abstract boolean shouldSkipHandAnimationOnSwap(ItemStack from, ItemStack to); - - @Inject(method = "", at = @At("TAIL")) - private void getModules(MinecraftClient client, EntityRenderManager entityRenderDispatcher, ItemModelManager itemModelManager, CallbackInfo ci) { - handView = ModuleManager.INSTANCE.getModuleByClass(HandView.class); - } - - @Inject(method = "renderFirstPersonItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemDisplayContext;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;I)V", shift = At.Shift.BEFORE)) - private void onRenderItem(AbstractClientPlayerEntity player, float tickProgress, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, OrderedRenderCommandQueue orderedRenderCommandQueue, int light, CallbackInfo ci) { - EVENT_BUS.post(new RenderHeldItemEvent(matrices, hand)); - } - - @Inject(method = "renderFirstPersonItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderArmHoldingItem(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;IFFLnet/minecraft/util/Arm;)V")) - private void onRenderArm(AbstractClientPlayerEntity player, float tickProgress, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, OrderedRenderCommandQueue orderedRenderCommandQueue, int light, CallbackInfo ci) { - EVENT_BUS.post(new RenderArmEvent(matrices, hand)); - } - - - @ModifyReturnValue(method = "shouldSkipHandAnimationOnSwap", at = @At("RETURN")) - private boolean modifySkipSwapAnimation(boolean original) { - return original || (handView.isEnabled() && handView.skipSwapping.getValue()); - } - - @Inject(method = "applyEatOrDrinkTransformation", at = @At(value = "INVOKE", target = "Ljava/lang/Math;pow(DD)D", shift = At.Shift.BEFORE), cancellable = true) - private void cancelTransformations(MatrixStack matrices, float tickDelta, Arm arm, ItemStack stack, PlayerEntity player, CallbackInfo ci) { - if (handView.isEnabled() && handView.noFood.getValue()) ci.cancel(); - } - - @ModifyArg(method = "updateHeldItems", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;clamp(FFF)F", ordinal = 2), index = 0) - private float modifyEquipProgressMainhand(float value) { - if (mc.player == null) return value; - float progress = mc.player.getAttackCooldownProgress(1); - float modified = handView.isEnabled() && handView.oldAnimations.getValue() ? 1 : (float) Math.pow(progress, 3); - - return (shouldSkipHandAnimationOnSwap(mainHand, mc.player.getMainHandStack()) ? modified : 0) - equipProgressMainHand; - } - - @ModifyArg(method = "updateHeldItems", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;clamp(FFF)F", ordinal = 3), index = 0) - private float modifyEquipProgressOffhand(float value) { - if (mc.player == null) return value; - return (shouldSkipHandAnimationOnSwap(offHand, mc.player.getOffHandStack()) ? 1 : 0) - equipProgressOffHand; - } -} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/InGameOverlayRendererMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/InGameOverlayRendererMixin.java deleted file mode 100644 index a3dbb65..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/render/InGameOverlayRendererMixin.java +++ /dev/null @@ -1,37 +0,0 @@ -package me.retucio.sputnik.mixin.mixins.render; - -import me.retucio.sputnik.module.ModuleManager; -import me.retucio.sputnik.module.modules.render.NoRender; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.hud.InGameOverlayRenderer; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.texture.Sprite; -import net.minecraft.client.texture.SpriteHolder; -import net.minecraft.client.util.math.MatrixStack; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(InGameOverlayRenderer.class) -public abstract class InGameOverlayRendererMixin { - - @Unique - private static NoRender noRender; - - @Inject(method = "", at = @At("TAIL")) - private void getModules(MinecraftClient client, SpriteHolder spriteHolder, VertexConsumerProvider vertexConsumers, CallbackInfo ci) { - noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class); - } - - @Inject(method = "renderFireOverlay", at = @At("HEAD"), cancellable = true) - private static void noRenderFireOverlay(MatrixStack matrices, VertexConsumerProvider vertexConsumers, Sprite sprite, CallbackInfo ci) { - if (noRender.isEnabled() && !noRender.fireOverlay.getValue()) ci.cancel(); - } - - @Inject(method = "renderUnderwaterOverlay", at = @At("HEAD"), cancellable = true) - private static void noRenderUnderwaterOverlay(MinecraftClient client, MatrixStack matrices, VertexConsumerProvider vertexConsumers, CallbackInfo ci) { - if (noRender.isEnabled() && !noRender.fluidOverlay.getValue()) ci.cancel(); - } -} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/ItemRendererMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/ItemFeatureRendererMixin.java similarity index 53% rename from src/main/java/me/retucio/sputnik/mixin/mixins/render/ItemRendererMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/render/ItemFeatureRendererMixin.java index 7e47012..509d56b 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/render/ItemRendererMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/render/ItemFeatureRendererMixin.java @@ -2,8 +2,8 @@ package me.retucio.sputnik.mixin.mixins.render; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.render.GlintPlus; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.item.ItemRenderer; +import net.minecraft.client.renderer.feature.ItemFeatureRenderer; +import net.minecraft.client.renderer.rendertype.RenderType; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; @@ -11,8 +11,8 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(ItemRenderer.class) -public abstract class ItemRendererMixin { +@Mixin(ItemFeatureRenderer.class) +public abstract class ItemFeatureRendererMixin { @Unique private static GlintPlus glintPlus; @@ -22,13 +22,13 @@ public abstract class ItemRendererMixin { glintPlus = ModuleManager.INSTANCE.getModuleByClass(GlintPlus.class); } - @Redirect(method = "getItemGlintConsumer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/RenderLayers;glint()Lnet/minecraft/client/render/RenderLayer;")) - private static RenderLayer getGlint() { + @Redirect(method = "getFoilRenderType", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/rendertype/RenderTypes;glint()Lnet/minecraft/client/renderer/rendertype/RenderType;")) + private static RenderType getGlint() { return glintPlus.getGlint(); } - @Redirect(method = "getItemGlintConsumer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/RenderLayers;entityGlint()Lnet/minecraft/client/render/RenderLayer;")) - private static RenderLayer getEntityGlint() { + @Redirect(method = "getFoilRenderType", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/rendertype/RenderTypes;entityGlint()Lnet/minecraft/client/renderer/rendertype/RenderType;")) + private static RenderType getEntityGlint() { return glintPlus.getEntityGlint(); } } diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/ItemInHandRendererMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/ItemInHandRendererMixin.java new file mode 100644 index 0000000..1d2aa67 --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/render/ItemInHandRendererMixin.java @@ -0,0 +1,87 @@ +package me.retucio.sputnik.mixin.mixins.render; + +import com.llamalad7.mixinextras.injector.ModifyReturnValue; +import com.mojang.blaze3d.vertex.PoseStack; +import me.retucio.sputnik.event.render.RenderHeldItemEvent; +import me.retucio.sputnik.event.render.RenderArmEvent; +import me.retucio.sputnik.module.ModuleManager; +import me.retucio.sputnik.module.modules.player.HandView; +import net.minecraft.client.player.AbstractClientPlayer; +import net.minecraft.client.renderer.ItemInHandRenderer; +import net.minecraft.client.renderer.SubmitNodeCollector; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.HumanoidArm; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import static me.retucio.sputnik.Sputnik.*; + +@Mixin(ItemInHandRenderer.class) +public abstract class ItemInHandRendererMixin { + + @Unique + HandView handView; + + @Shadow + private float mainHandHeight; + + @Shadow + private float offHandHeight; + + @Shadow + private ItemStack mainHandItem; + + @Shadow + private ItemStack offHandItem; + + @Shadow + protected abstract boolean shouldInstantlyReplaceVisibleItem(ItemStack from, ItemStack to); + + @Inject(method = "", at = @At("TAIL")) + private void getModules(CallbackInfo ci) { + handView = ModuleManager.INSTANCE.getModuleByClass(HandView.class); + } + + @Inject(method = "renderArmWithItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ItemInHandRenderer;renderItem(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/item/ItemDisplayContext;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;I)V", shift = At.Shift.BEFORE)) + private void onRenderItem(AbstractClientPlayer player, float frameInterp, float xRot, InteractionHand hand, float attack, ItemStack itemStack, float inverseArmHeight, PoseStack matrices, SubmitNodeCollector submitNodeCollector, int lightCoords, CallbackInfo ci) { + EVENT_BUS.post(new RenderHeldItemEvent(matrices, hand)); + } + + @Inject(method = "renderArmWithItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ItemInHandRenderer;renderPlayerArm(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;IFFLnet/minecraft/world/entity/HumanoidArm;)V")) + private void onRenderArm(AbstractClientPlayer player, float frameInterp, float xRot, InteractionHand hand, float attack, ItemStack itemStack, float inverseArmHeight, PoseStack matrices, SubmitNodeCollector submitNodeCollector, int lightCoords, CallbackInfo ci) { + EVENT_BUS.post(new RenderArmEvent(matrices, hand)); + } + + + @ModifyReturnValue(method = "shouldInstantlyReplaceVisibleItem", at = @At("RETURN")) + private boolean modifySkipSwapAnimation(boolean original) { + return original || (handView.isEnabled() && handView.skipSwapping.getValue()); + } + + @Inject(method = "applyEatTransform", at = @At(value = "INVOKE", target = "Ljava/lang/Math;pow(DD)D", shift = At.Shift.BEFORE), cancellable = true) + private void cancelTransformations(PoseStack matrices, float frameInterp, HumanoidArm arm, ItemStack itemStack, Player player, CallbackInfo ci) { + if (handView.isEnabled() && handView.noFood.getValue()) ci.cancel(); + } + + @ModifyArg(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Mth;clamp(FFF)F", ordinal = 2), index = 0) + private float modifyEquipProgressMainhand(float value) { + if (mc.player == null) return value; + float progress = mc.player.getAttackStrengthScale(1); + float modified = handView.isEnabled() && handView.oldAnimations.getValue() ? 1 : (float) Math.pow(progress, 3); + + return (shouldInstantlyReplaceVisibleItem(mainHandItem, mc.player.getMainHandItem()) ? modified : 0) - mainHandHeight; + } + + @ModifyArg(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Mth;clamp(FFF)F", ordinal = 3), index = 0) + private float modifyEquipProgressOffhand(float value) { + if (mc.player == null) return value; + return (shouldInstantlyReplaceVisibleItem(offHandItem, mc.player.getOffhandItem()) ? 1 : 0) - offHandHeight; + } +} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/LevelRendererMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/LevelRendererMixin.java new file mode 100644 index 0000000..cfd798b --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/render/LevelRendererMixin.java @@ -0,0 +1,82 @@ +package me.retucio.sputnik.mixin.mixins.render; + +import com.llamalad7.mixinextras.sugar.Local; +import com.mojang.blaze3d.buffers.GpuBufferSlice; +import com.mojang.blaze3d.resource.GraphicsResourceAllocator; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.math.Axis; +import me.retucio.sputnik.Sputnik; +import me.retucio.sputnik.event.render.Render3DEvent; +import me.retucio.sputnik.event.render.RenderBlockOutlineEvent; +import me.retucio.sputnik.module.ModuleManager; +import me.retucio.sputnik.module.modules.camera.Freecam; +import me.retucio.sputnik.module.modules.render.NoRender; +import net.minecraft.client.DeltaTracker; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.chunk.ChunkSectionsToRender; +import net.minecraft.client.renderer.state.level.CameraRenderState; +import net.minecraft.client.renderer.state.level.LevelRenderState; +import net.minecraft.util.profiling.ProfilerFiller; +import org.joml.Matrix4fc; +import org.joml.Vector4f; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.*; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.invoke.arg.Args; + +import static me.retucio.sputnik.Sputnik.EVENT_BUS; +import static me.retucio.sputnik.Sputnik.mc; + + +@Mixin(LevelRenderer.class) +public abstract class LevelRendererMixin { + + // renderLevel()?? + @ModifyArg(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LevelRenderer;cullTerrain(Lnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/culling/Frustum;Z)V"), index = 2) + private boolean renderSetupTerrainModifyArg(boolean spectator) { + return ModuleManager.INSTANCE.getModuleByClass(Freecam.class).isEnabled() || spectator; + } + + @Inject(method = "renderLevel", at = @At("RETURN")) + private void render(GraphicsResourceAllocator resourceAllocator, DeltaTracker dt, boolean renderOutline, CameraRenderState cameraState, Matrix4fc modelViewMatrix, GpuBufferSlice terrainFog, Vector4f fogColor, boolean shouldRenderSky, ChunkSectionsToRender chunkSectionsToRender, CallbackInfo ci, @Local(name = "profiler") ProfilerFiller profiler) { + if (mc == null || mc.level == null) return; + + PoseStack matrices = new PoseStack(); + matrices.pushPose(); + + matrices.mulPose(Axis.XP.rotationDegrees(cameraState.xRot)); + matrices.mulPose(Axis.YP.rotationDegrees(cameraState.yRot + 180f)); + + profiler.push(Sputnik.MOD_ID + "-3d"); + EVENT_BUS.post(new Render3DEvent(matrices, dt, cameraState)); + + profiler.pop(); + matrices.popPose(); + } + + @Inject(method = "renderBlockOutline", at = @At("HEAD"), cancellable = true) + private void noRenderBlockOutlinesFreecam(MultiBufferSource.BufferSource bufferSource, PoseStack poseStack, boolean onlyTranslucentBlocks, LevelRenderState levelRenderState, CallbackInfo ci) { + Freecam freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class); + if (freecam.isEnabled() && !freecam.blockOutlines.getValue()) ci.cancel(); + } + +// @Inject(method = "hasBlindnessOrDarkness(Lnet/minecraft/client/extractRenderState/Camera;)Z", at = @At("HEAD"), cancellable = true) +// private void hasBlindnessOrDarkness(Camera camera, CallbackInfoReturnable cir) { +// NoRender noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class); +// if (!noRender.isEnabled()) return; +// if (!noRender.blindnessEffect.getValue() || !noRender.darknessEffect.getValue()) cir.setReturnValue(null); +// } + + // puto mojang con sus nombres confusos + @ModifyArgs(method = "renderBlockOutline", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LevelRenderer;renderHitOutline(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;DDDLnet/minecraft/client/renderer/state/level/BlockOutlineRenderState;IF)V")) + private void modifyBlockOutline(Args args) { + // SIX SEVEN!!! (me pegan en casa) + RenderBlockOutlineEvent event = EVENT_BUS.post(new RenderBlockOutlineEvent(args.get(6), args.get(7))); + if (event.getColor() != (int) args.get(6)) + args.set(6, event.getColor()); + if (event.getLineWidth() != (float) args.get(7)) + args.set(7, event.getLineWidth()); + } +} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/LightmapTextureManagerMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/LightmapTextureManagerMixin.java index 71bf389..61a3312 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/render/LightmapTextureManagerMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/render/LightmapTextureManagerMixin.java @@ -2,59 +2,53 @@ package me.retucio.sputnik.mixin.mixins.render; import com.llamalad7.mixinextras.sugar.Local; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.textures.GpuTexture; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.camera.Fullbright; import me.retucio.sputnik.module.modules.render.NoRender; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.render.GameRenderer; -import net.minecraft.client.render.LightmapTextureManager; -import net.minecraft.entity.LivingEntity; -import net.minecraft.util.math.ColorHelper; -import net.minecraft.util.profiler.Profiler; -import org.spongepowered.asm.mixin.Final; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.LightmapRenderStateExtractor; +import net.minecraft.client.renderer.state.LightmapRenderState; +import net.minecraft.util.ARGB; +import net.minecraft.util.profiling.ProfilerFiller; +import net.minecraft.world.entity.LivingEntity; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(LightmapTextureManager.class) + +@Mixin(LightmapRenderStateExtractor.class) public abstract class LightmapTextureManagerMixin { - @Unique - Fullbright fullbright; - - @Unique - NoRender noRender; - - @Shadow @Final - private GpuTexture glTexture; + @Unique Fullbright fullbright; + @Unique NoRender noRender; @Inject(method = "", at = @At("TAIL")) - private void getModules(GameRenderer renderer, MinecraftClient client, CallbackInfo ci) { + private void getModules(CallbackInfo ci) { fullbright = ModuleManager.INSTANCE.getModuleByClass(Fullbright.class); noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class); } - @Inject(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;push(Ljava/lang/String;)V", shift = At.Shift.AFTER), cancellable = true) - private void update(float tickProgress, CallbackInfo ci, @Local Profiler profiler) { + @Inject(method = "extract", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiling/ProfilerFiller;push(Ljava/lang/String;)V", shift = At.Shift.AFTER), cancellable = true) + private void update(LightmapRenderState renderState, float partialTicks, CallbackInfo ci, @Local(name = "profiler") ProfilerFiller profiler) { if (fullbright.isEnabled() && fullbright.mode.is(Fullbright.Modes.GAMMA)) { - RenderSystem.getDevice().createCommandEncoder().clearColorTexture(glTexture, ColorHelper.getArgb( + RenderSystem.getDevice().createCommandEncoder().clearColorTexture(Minecraft.getInstance().gameRenderer.lightmap().texture(), + ARGB.color( fullbright.color.getA(), fullbright.color.getR(), fullbright.color.getG(), fullbright.color.getB() - )); + ) + ); profiler.pop(); ci.cancel(); } } - @Inject(method = "getDarkness", at = @At("HEAD"), cancellable = true) - private void noRenderDarkness(LivingEntity entity, float factor, float tickProgress, CallbackInfoReturnable cir) { + @Inject(method = "calculateDarknessScale", at = @At("HEAD"), cancellable = true) + private void noRenderDarkness(LivingEntity camera, float darknessGamma, float partialTickTime, CallbackInfoReturnable cir) { if (noRender.isEnabled() && !noRender.darknessEffect.getValue()) cir.setReturnValue(0f); } } \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/LivingEntityRendererMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/LivingEntityRendererMixin.java index 36af53f..7cd4653 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/render/LivingEntityRendererMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/render/LivingEntityRendererMixin.java @@ -6,13 +6,11 @@ import com.llamalad7.mixinextras.sugar.Local; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.camera.Freecam; import me.retucio.sputnik.module.modules.render.Nametags; -import net.minecraft.client.render.entity.EntityRendererFactory; -import net.minecraft.client.render.entity.LivingEntityRenderer; -import net.minecraft.client.render.entity.model.EntityModel; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.client.renderer.entity.LivingEntityRenderer; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; @@ -29,36 +27,36 @@ public abstract class LivingEntityRendererMixin { Nametags nametags; @Inject(method = "", at = @At("TAIL")) - private void getModules(EntityRendererFactory.Context ctx, EntityModel model, float shadowRadius, CallbackInfo ci) { + private void getModules(CallbackInfo ci) { nametags = ModuleManager.INSTANCE.getModuleByClass(Nametags.class); } - @ModifyExpressionValue(method = "hasLabel(Lnet/minecraft/entity/LivingEntity;D)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;getCameraEntity()Lnet/minecraft/entity/Entity;")) - private Entity hasLabelGetCameraEntityProxy(Entity cameraEntity) { - return ModuleManager.INSTANCE.getModuleByClass(Freecam.class).isEnabled() ? null : cameraEntity; + @ModifyExpressionValue(method = "shouldShowName(Lnet/minecraft/world/entity/LivingEntity;D)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getCameraEntity()Lnet/minecraft/world/entity/Entity;")) + private Entity hasLabelGetCameraEntityProxy(Entity original) { + return ModuleManager.INSTANCE.getModuleByClass(Freecam.class).isEnabled() ? null : original; } - @ModifyExpressionValue(method = "hasLabel(Lnet/minecraft/entity/LivingEntity;D)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;isSneaky()Z")) + @ModifyExpressionValue(method = "shouldShowName(Lnet/minecraft/world/entity/LivingEntity;D)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;isDiscrete()Z")) private boolean renderSneakingPlayerNametags(boolean original) { return (nametags.isEnabled() && nametags.alwaysVisible.getValue()) || original; } - @ModifyExpressionValue(method = "hasLabel(Lnet/minecraft/entity/LivingEntity;D)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;isInvisibleTo(Lnet/minecraft/entity/player/PlayerEntity;)Z")) + @ModifyExpressionValue(method = "shouldShowName(Lnet/minecraft/world/entity/LivingEntity;D)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;isInvisibleTo(Lnet/minecraft/world/entity/player/Player;)Z")) private boolean renderInvisPlayerNametags(boolean original) { if (nametags.isEnabled() && nametags.alwaysVisible.getValue()) return false; else return original; } - @ModifyReturnValue(method = "hasLabel(Lnet/minecraft/entity/LivingEntity;D)Z", at = @At("RETURN")) + @ModifyReturnValue(method = "shouldShowName(Lnet/minecraft/world/entity/LivingEntity;D)Z", at = @At("RETURN")) private boolean shouldRenderPlayerNametag(boolean original, @Local(argsOnly = true) T livingEntity) { - if (nametags.isEnabled() && livingEntity instanceof PlayerEntity) + if (nametags.isEnabled() && livingEntity instanceof Player) return nametags.entities.isEnabled(EntityType.PLAYER) && original; return original; } - @Inject(method = "hasLabel(Lnet/minecraft/entity/LivingEntity;D)Z", at = @At("RETURN"), cancellable = true) + @Inject(method = "shouldShowName(Lnet/minecraft/world/entity/LivingEntity;D)Z", at = @At("RETURN"), cancellable = true) private void renderSelfNametag(T livingEntity, double d, CallbackInfoReturnable cir) { - if (livingEntity instanceof PlayerEntity player) { + if (livingEntity instanceof Player player) { if (player == mc.player && nametags.showSelf.getValue()) { cir.setReturnValue(true); cir.cancel(); diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/MobEffectFogEnvironmentMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/MobEffectFogEnvironmentMixin.java new file mode 100644 index 0000000..a91a0df --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/render/MobEffectFogEnvironmentMixin.java @@ -0,0 +1,29 @@ +package me.retucio.sputnik.mixin.mixins.render; + +import com.llamalad7.mixinextras.injector.ModifyReturnValue; +import me.retucio.sputnik.module.ModuleManager; +import me.retucio.sputnik.module.modules.render.NoRender; +import net.minecraft.client.renderer.fog.environment.MobEffectFogEnvironment; +import net.minecraft.core.Holder; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.effect.MobEffects; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; + + +@Mixin(MobEffectFogEnvironment.class) +public abstract class MobEffectFogEnvironmentMixin { + + @Shadow + public abstract Holder getMobEffect(); + + @ModifyReturnValue(method = "isApplicable", at = @At("RETURN")) + public boolean noRenderBadEffects(boolean original) { + NoRender noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class); + if (!noRender.isEnabled()) return original; + if (getMobEffect() == MobEffects.BLINDNESS && !noRender.blindnessEffect.getValue()) return false; + if (getMobEffect() == MobEffects.DARKNESS && !noRender.darknessEffect.getValue()) return false; + return original; + } +} diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/OverlayTextureMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/OverlayTextureMixin.java index 64b69ce..1234fa8 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/render/OverlayTextureMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/render/OverlayTextureMixin.java @@ -2,8 +2,8 @@ package me.retucio.sputnik.mixin.mixins.render; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.render.DamageOverlay; -import net.minecraft.client.render.OverlayTexture; -import net.minecraft.client.texture.NativeImageBackedTexture; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.client.renderer.texture.OverlayTexture; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; public abstract class OverlayTextureMixin implements AutoCloseable { @Shadow @Final - private NativeImageBackedTexture texture; + private DynamicTexture texture; @Inject(method = "", at = @At("TAIL")) private void modifyDamageOverlayColor(CallbackInfo ci) { diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/PreparedTextBuilderMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/PreparedTextBuilderMixin.java new file mode 100644 index 0000000..746dc3b --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/render/PreparedTextBuilderMixin.java @@ -0,0 +1,45 @@ +package me.retucio.sputnik.mixin.mixins.render; + +import me.retucio.sputnik.module.ModuleManager; +import me.retucio.sputnik.module.modules.render.NoRender; +import net.minecraft.client.gui.Font; +import net.minecraft.network.chat.Style; +import net.minecraft.network.chat.TextColor; +import org.jspecify.annotations.Nullable; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.*; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +// falta italics pero no sé dónde se comprueba eso, no es aquí :P +@Mixin(Font.PreparedTextBuilder.class) +public abstract class PreparedTextBuilderMixin { + + @Unique + NoRender noRender; + + @Inject(method = "(Lnet/minecraft/client/gui/Font;FFIIZZ)V", at = @At("TAIL")) + private void getModules(CallbackInfo ci) { + noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class); + } + + @Redirect(method = "accept(ILnet/minecraft/network/chat/Style;Lnet/minecraft/client/gui/font/glyphs/BakedGlyph;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/chat/Style;isBold()Z")) + private boolean noRenderBold(Style style) { + return !(noRender.isEnabled() && !noRender.bold.getValue()) && style.isBold(); + } + + @Redirect(method = "accept(ILnet/minecraft/network/chat/Style;Lnet/minecraft/client/gui/font/glyphs/BakedGlyph;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/chat/Style;isUnderlined()Z")) + private boolean noRenderUnderlined(Style style) { + return !(noRender.isEnabled() && !noRender.underlined.getValue()) && style.isUnderlined(); + } + + @Redirect(method = "accept(ILnet/minecraft/network/chat/Style;Lnet/minecraft/client/gui/font/glyphs/BakedGlyph;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/chat/Style;isStrikethrough()Z")) + private boolean noRenderStrikethrough(Style style) { + return !(noRender.isEnabled() && !noRender.strikethrough.getValue()) && style.isStrikethrough(); + } + + @ModifyArg(method = "accept(ILnet/minecraft/network/chat/Style;Lnet/minecraft/client/gui/font/glyphs/BakedGlyph;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Font$PreparedTextBuilder;getTextColor(Lnet/minecraft/network/chat/TextColor;)I")) + private @Nullable TextColor noRenderColor(@Nullable TextColor original) { + return !noRender.color.is(NoRender.Colors.DEFAULT) ? TextColor.fromLegacyFormat(noRender.color.getValue().toFormatting()) : original; + } +} diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/RenderBuffersMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/RenderBuffersMixin.java new file mode 100644 index 0000000..f9e8d69 --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/render/RenderBuffersMixin.java @@ -0,0 +1,22 @@ +package me.retucio.sputnik.mixin.mixins.render; + +import com.mojang.blaze3d.vertex.ByteBufferBuilder; +import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; +import me.retucio.sputnik.util.render.GlintRenderType; +import net.minecraft.client.renderer.RenderBuffers; +import net.minecraft.client.renderer.rendertype.RenderType; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + + +@Mixin(RenderBuffers.class) +public abstract class RenderBuffersMixin { + + @Inject(method = "put", at = @At("HEAD")) + private static void addGlintTypes(Object2ObjectLinkedOpenHashMap map, RenderType type, CallbackInfo ci) { + GlintRenderType.addGlintTypes(map); + } +} diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/ScreenEffectRendererMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/ScreenEffectRendererMixin.java new file mode 100644 index 0000000..35953c3 --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/render/ScreenEffectRendererMixin.java @@ -0,0 +1,37 @@ +package me.retucio.sputnik.mixin.mixins.render; + +import com.mojang.blaze3d.vertex.PoseStack; +import me.retucio.sputnik.module.ModuleManager; +import me.retucio.sputnik.module.modules.render.NoRender; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.ScreenEffectRenderer; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + + +@Mixin(ScreenEffectRenderer.class) +public abstract class ScreenEffectRendererMixin { + + @Unique + private static NoRender noRender; + + @Inject(method = "", at = @At("TAIL")) + private void getModules(CallbackInfo ci) { + noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class); + } + + @Inject(method = "renderFire", at = @At("HEAD"), cancellable = true) + private static void noRenderFireOverlay(PoseStack matrices, MultiBufferSource bufferSource, TextureAtlasSprite sprite, CallbackInfo ci) { + if (noRender.isEnabled() && !noRender.fireOverlay.getValue()) ci.cancel(); + } + + @Inject(method = "renderWater", at = @At("HEAD"), cancellable = true) + private static void noRenderUnderwaterOverlay(Minecraft minecraft, PoseStack matrices, MultiBufferSource bufferSource, CallbackInfo ci) { + if (noRender.isEnabled() && !noRender.fluidOverlay.getValue()) ci.cancel(); + } +} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/ShaderLoaderMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/ShaderManagerMixin.java similarity index 54% rename from src/main/java/me/retucio/sputnik/mixin/mixins/render/ShaderLoaderMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/render/ShaderManagerMixin.java index e6a33f0..d2f2e92 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/render/ShaderLoaderMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/render/ShaderManagerMixin.java @@ -1,16 +1,16 @@ package me.retucio.sputnik.mixin.mixins.render; import me.retucio.sputnik.util.render.Pipelines; -import net.minecraft.client.gl.ShaderLoader; +import net.minecraft.client.renderer.ShaderManager; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(ShaderLoader.class) -public abstract class ShaderLoaderMixin { +@Mixin(ShaderManager.class) +public abstract class ShaderManagerMixin { - @Inject(method = "apply(Lnet/minecraft/client/gl/ShaderLoader$Definitions;Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/profiler/Profiler;)V", at = @At("TAIL")) + @Inject(method = "apply(Lnet/minecraft/client/renderer/ShaderManager$Configs;Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/util/profiling/ProfilerFiller;)V", at = @At("TAIL")) private void onReload(CallbackInfo ci) { Pipelines.init(); } diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/SkyRendererMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/SkyRendererMixin.java index 4efe578..0aea7f6 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/render/SkyRendererMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/render/SkyRendererMixin.java @@ -1,11 +1,11 @@ package me.retucio.sputnik.mixin.mixins.render; +import com.mojang.blaze3d.vertex.PoseStack; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.render.NoRender; import me.retucio.sputnik.module.modules.world.TimeChanger; -import net.minecraft.client.render.SkyRendering; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.world.MoonPhase; +import net.minecraft.client.renderer.SkyRenderer; +import net.minecraft.world.level.MoonPhase; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; @@ -13,7 +13,8 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(SkyRendering.class) + +@Mixin(SkyRenderer.class) public abstract class SkyRendererMixin { @Unique @@ -25,31 +26,31 @@ public abstract class SkyRendererMixin { } @Inject(method = "renderSun", at = @At("HEAD"), cancellable = true) - private void onRenderSun(float alpha, MatrixStack matrices, CallbackInfo ci) { + private void onRenderSun(float rainBrightness, PoseStack poseStack, CallbackInfo ci) { if (timeChanger.isEnabled() && !timeChanger.renderSun.getValue()) ci.cancel(); } @Inject(method = "renderMoon", at = @At("HEAD"), cancellable = true) - private void onRenderMoon(MoonPhase moonPhase, float alpha, MatrixStack matrices, CallbackInfo ci) { + private void onRenderMoon(MoonPhase moonPhase, float rainBrightness, PoseStack poseStack, CallbackInfo ci) { if (!timeChanger.isEnabled()) return; if (!timeChanger.renderMoon.getValue()) ci.cancel(); } - @ModifyArg(method = "renderCelestialBodies", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/SkyRendering;renderMoon(Lnet/minecraft/world/MoonPhase;FLnet/minecraft/client/util/math/MatrixStack;)V")) + @ModifyArg(method = "renderSunMoonAndStars", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/SkyRenderer;renderMoon(Lnet/minecraft/world/level/MoonPhase;FLcom/mojang/blaze3d/vertex/PoseStack;)V")) private MoonPhase timeChangerMoonPhase(MoonPhase original) { if (!timeChanger.isEnabled() || timeChanger.moonPhase.is(TimeChanger.MoonPhases.DEFAULT)) return original; int phase = timeChanger.moonPhase.getIndex(); - if (timeChanger.moonPhase.is(TimeChanger.MoonPhases.DEFAULT)) phase = original.getIndex(); + if (timeChanger.moonPhase.is(TimeChanger.MoonPhases.DEFAULT)) phase = original.index(); return MoonPhase.values()[phase]; } @Inject(method = "renderStars", at = @At("HEAD"), cancellable = true) - private void onRenderStars(float brightness, MatrixStack matrices, CallbackInfo ci) { + private void onRenderStars(float starBrightness, PoseStack poseStack, CallbackInfo ci) { if (timeChanger.isEnabled() && !timeChanger.renderStars.getValue()) ci.cancel(); } - @Inject(method = "drawEndLightFlash", at = @At("HEAD"), cancellable = true) - private void onEndFlash(MatrixStack matrixStack, float f, float skyFactor, float pitch, CallbackInfo ci) { + @Inject(method = "renderEndFlash", at = @At("HEAD"), cancellable = true) + private void onEndFlash(PoseStack matrices, float intensity, float xAngle, float yAngle, CallbackInfo ci) { NoRender noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class); if (noRender.isEnabled() && !noRender.endFlashes.getValue()) ci.cancel(); } diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/StatusEffectFogModifierMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/StatusEffectFogModifierMixin.java deleted file mode 100644 index d058938..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/render/StatusEffectFogModifierMixin.java +++ /dev/null @@ -1,28 +0,0 @@ -package me.retucio.sputnik.mixin.mixins.render; - -import com.llamalad7.mixinextras.injector.ModifyReturnValue; -import me.retucio.sputnik.module.ModuleManager; -import me.retucio.sputnik.module.modules.render.NoRender; -import net.minecraft.client.render.fog.StatusEffectFogModifier; -import net.minecraft.entity.effect.StatusEffect; -import net.minecraft.entity.effect.StatusEffects; -import net.minecraft.registry.entry.RegistryEntry; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(StatusEffectFogModifier.class) -public abstract class StatusEffectFogModifierMixin { - - @Shadow - public abstract RegistryEntry getStatusEffect(); - - @ModifyReturnValue(method = "shouldApply", at = @At("RETURN")) - public boolean noRenderBadEffects(boolean original) { - NoRender noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class); - if (!noRender.isEnabled()) return original; - if (getStatusEffect() == StatusEffects.BLINDNESS && !noRender.blindnessEffect.getValue()) return false; - if (getStatusEffect() == StatusEffects.DARKNESS && !noRender.darknessEffect.getValue()) return false; - return original; - } -} diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/TextRendererDrawerMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/TextRendererDrawerMixin.java deleted file mode 100644 index b47731d..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/render/TextRendererDrawerMixin.java +++ /dev/null @@ -1,44 +0,0 @@ -package me.retucio.sputnik.mixin.mixins.render; - -import me.retucio.sputnik.module.ModuleManager; -import me.retucio.sputnik.module.modules.render.NoRender; -import net.minecraft.client.font.TextRenderer; -import net.minecraft.text.Style; -import net.minecraft.text.TextColor; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.*; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -// falta italics pero no sé dónde se comprueba eso, no es aquí :P -@Mixin(TextRenderer.Drawer.class) -public abstract class TextRendererDrawerMixin { - - @Unique - NoRender noRender; - - @Inject(method = "(Lnet/minecraft/client/font/TextRenderer;FFIIZZ)V", at = @At("TAIL")) - private void getModules(TextRenderer textRenderer, float x, float y, int color, int backgroundColor, boolean shadow, boolean trackEmpty, CallbackInfo ci) { - noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class); - } - - @Redirect(method = "accept(ILnet/minecraft/text/Style;Lnet/minecraft/client/font/BakedGlyph;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/Style;isBold()Z")) - private boolean noRenderBold(Style style) { - return !(noRender.isEnabled() && !noRender.bold.getValue()) && style.isBold(); - } - - @Redirect(method = "accept(ILnet/minecraft/text/Style;Lnet/minecraft/client/font/BakedGlyph;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/Style;isUnderlined()Z")) - private boolean noRenderUnderlined(Style style) { - return !(noRender.isEnabled() && !noRender.underlined.getValue()) && style.isUnderlined(); - } - - @Redirect(method = "accept(ILnet/minecraft/text/Style;Lnet/minecraft/client/font/BakedGlyph;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/Style;isStrikethrough()Z")) - private boolean noRenderStrikethrough(Style style) { - return !(noRender.isEnabled() && !noRender.strikethrough.getValue()) && style.isStrikethrough(); - } - - @ModifyArg(method = "accept(ILnet/minecraft/text/Style;Lnet/minecraft/client/font/BakedGlyph;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer$Drawer;getRenderColor(Lnet/minecraft/text/TextColor;)I")) - private TextColor noRenderColor(TextColor original) { - return !noRender.color.is(NoRender.Colors.DEFAULT) ? TextColor.fromFormatting(noRender.color.getValue().toFormatting()) : original; - } -} diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/WeatherEffectRendererMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/WeatherEffectRendererMixin.java new file mode 100644 index 0000000..a710618 --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/render/WeatherEffectRendererMixin.java @@ -0,0 +1,41 @@ +package me.retucio.sputnik.mixin.mixins.render; + +import me.retucio.sputnik.module.ModuleManager; +import me.retucio.sputnik.module.modules.render.NoRender; +import net.minecraft.client.Camera; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.renderer.WeatherEffectRenderer; +import net.minecraft.client.renderer.state.level.WeatherRenderState; +import net.minecraft.server.level.ParticleStatus; +import net.minecraft.world.phys.Vec3; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + + +@Mixin(WeatherEffectRenderer.class) +public abstract class WeatherEffectRendererMixin { + + @Unique + NoRender noRender; + + @Inject(method = "", at = @At("TAIL")) + public void getModules(CallbackInfo ci) { + noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class); + } + + @Inject(method = "tickRainParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;addParticle(Lnet/minecraft/core/particles/ParticleOptions;DDDDDD)V"), cancellable = true) + private void noRainParticles(ClientLevel level, Camera camera, int ticks, ParticleStatus particleStatus, int weatherRadius, CallbackInfo ci) { + if (noRender.isEnabled() && !noRender.rain.getValue()) ci.cancel(); + } + + @Inject(method = "render", at = @At("HEAD")) + private void noRenderRainAndSnow(Vec3 cameraPos, WeatherRenderState renderState, CallbackInfo ci) { + if (noRender.isEnabled()) { + if (!noRender.rain.getValue()) renderState.rainColumns.clear(); + if (!noRender.snow.getValue()) renderState.snowColumns.clear(); + } + } +} diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/WeatherRenderingMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/WeatherRenderingMixin.java deleted file mode 100644 index 309c46f..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/render/WeatherRenderingMixin.java +++ /dev/null @@ -1,42 +0,0 @@ -package me.retucio.sputnik.mixin.mixins.render; - -import me.retucio.sputnik.module.ModuleManager; -import me.retucio.sputnik.module.modules.render.NoRender; -import net.minecraft.client.render.Camera; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.WeatherRendering; -import net.minecraft.client.render.state.WeatherRenderState; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.particle.ParticlesMode; -import net.minecraft.util.math.Vec3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - - -@Mixin(WeatherRendering.class) -public abstract class WeatherRenderingMixin { - - @Unique - NoRender noRender; - - @Inject(method = "", at = @At("TAIL")) - public void getModules(CallbackInfo ci) { - noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class); - } - - @Inject(method = "addParticlesAndSound", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;addParticleClient(Lnet/minecraft/particle/ParticleEffect;DDDDDD)V"), cancellable = true) - private void noRainParticles(ClientWorld world, Camera camera, int ticks, ParticlesMode particlesMode, int weatherRadius, CallbackInfo ci) { - if (noRender.isEnabled() && !noRender.rain.getValue()) ci.cancel(); - } - - @Inject(method = "renderPrecipitation", at = @At("HEAD")) - private void noRenderRainAndSnow(VertexConsumerProvider vertexConsumers, Vec3d pos, WeatherRenderState weatherRenderState, CallbackInfo ci) { - if (noRender.isEnabled()) { - if (!noRender.rain.getValue()) weatherRenderState.rainPieces.clear(); - if (!noRender.snow.getValue()) weatherRenderState.snowPieces.clear(); - } - } -} diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/WingsLayerMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/WingsLayerMixin.java new file mode 100644 index 0000000..f47cf3a --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/render/WingsLayerMixin.java @@ -0,0 +1,26 @@ +package me.retucio.sputnik.mixin.mixins.render; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import me.retucio.sputnik.module.ModuleManager; +import me.retucio.sputnik.module.modules.player.Capes; +import net.minecraft.client.model.EntityModel; +import net.minecraft.client.renderer.entity.layers.WingsLayer; +import net.minecraft.client.renderer.entity.state.HumanoidRenderState; +import net.minecraft.resources.Identifier; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(WingsLayer.class) +public abstract class WingsLayerMixin> { + + @ModifyExpressionValue( + method = "submit(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;ILnet/minecraft/client/renderer/entity/state/HumanoidRenderState;FF)V", + at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/layers/WingsLayer;getPlayerElytraTexture(Lnet/minecraft/client/renderer/entity/state/HumanoidRenderState;)Lnet/minecraft/resources/Identifier;") + ) + private Identifier modifyCapeTexture(Identifier original) { + Capes capes = ModuleManager.INSTANCE.getModuleByClass(Capes.class); + if (!capes.isEnabled()) return original; + Identifier id = capes.cape.getValue().getId(); + return id == null ? original : id; + } +} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/render/WorldRendererMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/render/WorldRendererMixin.java deleted file mode 100644 index 1b4c478..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/render/WorldRendererMixin.java +++ /dev/null @@ -1,75 +0,0 @@ -package me.retucio.sputnik.mixin.mixins.render; - -import com.llamalad7.mixinextras.sugar.Local; -import com.mojang.blaze3d.buffers.GpuBufferSlice; -import me.retucio.sputnik.Sputnik; -import me.retucio.sputnik.event.render.Render3DEvent; -import me.retucio.sputnik.event.render.RenderBlockOutlineEvent; -import me.retucio.sputnik.module.ModuleManager; -import me.retucio.sputnik.module.modules.camera.Freecam; -import me.retucio.sputnik.module.modules.render.NoRender; -import net.minecraft.client.render.*; -import net.minecraft.client.render.state.WorldRenderState; -import net.minecraft.client.util.ObjectAllocator; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.math.RotationAxis; -import net.minecraft.util.profiler.Profiler; -import org.joml.Matrix4f; -import org.joml.Vector4f; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.*; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.invoke.arg.Args; - -import static me.retucio.sputnik.Sputnik.EVENT_BUS; -import static me.retucio.sputnik.Sputnik.mc; - -@Mixin(WorldRenderer.class) -public abstract class WorldRendererMixin { - - @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;updateCamera(Lnet/minecraft/client/render/Camera;Lnet/minecraft/client/render/Frustum;Z)V"), index = 2) - private boolean renderSetupTerrainModifyArg(boolean spectator) { - return ModuleManager.INSTANCE.getModuleByClass(Freecam.class).isEnabled() || spectator; - } - - @Inject(method = "render", at = @At("RETURN")) - private void render(ObjectAllocator allocator, RenderTickCounter tickCounter, boolean renderBlockOutline, Camera camera, Matrix4f positionMatrix, Matrix4f matrix4f, Matrix4f projectionMatrix, GpuBufferSlice fogBuffer, Vector4f fogColor, boolean renderSky, CallbackInfo ci, @Local Profiler profiler) { - if (mc == null || mc.world == null) return; - - MatrixStack matrices = new MatrixStack(); - matrices.push(); - - matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(camera.getPitch())); - matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(camera.getYaw() + 180f)); - - profiler.push(Sputnik.MOD_ID + "-3d"); - EVENT_BUS.post(new Render3DEvent(matrices, tickCounter, camera)); - - profiler.pop(); - matrices.pop(); - } - - @Inject(method = "renderTargetBlockOutline", at = @At("HEAD"), cancellable = true) - private void noRenderBlockOutlinesFreecam(VertexConsumerProvider.Immediate immediate, MatrixStack matrices, boolean renderBlockOutline, WorldRenderState renderStates, CallbackInfo ci) { - Freecam freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class); - if (freecam.isEnabled() && !freecam.blockOutlines.getValue()) ci.cancel(); - } - - @Inject(method = "hasBlindnessOrDarkness(Lnet/minecraft/client/render/Camera;)Z", at = @At("HEAD"), cancellable = true) - private void hasBlindnessOrDarkness(Camera camera, CallbackInfoReturnable cir) { - NoRender noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class); - if (!noRender.isEnabled()) return; - if (!noRender.blindnessEffect.getValue() || !noRender.darknessEffect.getValue()) cir.setReturnValue(null); - } - - @ModifyArgs(method = "renderTargetBlockOutline", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;drawBlockOutline(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;DDDLnet/minecraft/client/render/state/OutlineRenderState;IF)V")) - private void modifyBlockOutline(Args args) { - // SIX SEVEN!!! (me pegan en casa) - RenderBlockOutlineEvent event = EVENT_BUS.post(new RenderBlockOutlineEvent(args.get(6), args.get(7))); - if (event.getColor() != (int) args.get(6)) - args.set(6, event.getColor()); - if (event.getLineWidth() != (float) args.get(7)) - args.set(7, event.getLineWidth()); - } -} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/screen/ChatScreenMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/screen/ChatScreenMixin.java index a9883af..b323ce5 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/screen/ChatScreenMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/screen/ChatScreenMixin.java @@ -2,8 +2,8 @@ package me.retucio.sputnik.mixin.mixins.screen; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.misc.ChatPlus; -import net.minecraft.client.gui.screen.ChatScreen; -import net.minecraft.client.gui.widget.TextFieldWidget; +import net.minecraft.client.gui.components.EditBox; +import net.minecraft.client.gui.screens.ChatScreen; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -14,11 +14,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; public abstract class ChatScreenMixin { @Shadow - protected TextFieldWidget chatField; + protected EditBox input; @Inject(method = "init", at = @At(value = "RETURN")) private void onInit(CallbackInfo info) { ChatPlus chatPlus = ModuleManager.INSTANCE.getModuleByClass(ChatPlus.class); - if (chatPlus.isEnabled() && chatPlus.noCharLimit.getValue()) chatField.setMaxLength(Integer.MAX_VALUE); + if (chatPlus.isEnabled() && chatPlus.noCharLimit.getValue()) input.setMaxLength(Integer.MAX_VALUE); } } \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/screen/ConfirmScreenMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/screen/ConfirmScreenMixin.java index f726bb9..587b52f 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/screen/ConfirmScreenMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/screen/ConfirmScreenMixin.java @@ -3,11 +3,13 @@ package me.retucio.sputnik.mixin.mixins.screen; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.network.RPackBypass; import me.retucio.sputnik.util.interfaces.IConfirmScreen; -import net.minecraft.client.gui.screen.ConfirmScreen; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.widget.ButtonWidget; -import net.minecraft.client.gui.widget.DirectionalLayoutWidget; -import net.minecraft.text.Text; + +import net.minecraft.client.gui.components.Button; +import net.minecraft.client.gui.layouts.LinearLayout; +import net.minecraft.client.gui.screens.ConfirmScreen; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.network.chat.Component; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -15,21 +17,23 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + @Mixin(ConfirmScreen.class) public abstract class ConfirmScreenMixin extends Screen implements IConfirmScreen { - @Shadow protected DirectionalLayoutWidget layout; + @Final @Shadow protected LinearLayout layout; @Unique private Runnable bypassAction = null; - protected ConfirmScreenMixin(final Text title) { + protected ConfirmScreenMixin(final Component title) { super(title); } - @Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ConfirmScreen;addButtons(Lnet/minecraft/client/gui/widget/DirectionalLayoutWidget;)V", shift = At.Shift.AFTER)) + @Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/ConfirmScreen;addButtons(Lnet/minecraft/client/gui/layouts/LinearLayout;)V", shift = At.Shift.AFTER)) protected void addBypassButton(CallbackInfo ci) { RPackBypass bypassPack = ModuleManager.INSTANCE.getModuleByClass(RPackBypass.class); - if (this.bypassAction != null && bypassPack.isEnabled()) - this.layout.add(ButtonWidget.builder(bypassPack.BYPASS_TEXT, $ -> this.bypassAction.run()).build()); + if (bypassAction != null && bypassPack.isEnabled()) { + layout.addChild(Button.builder(bypassPack.BYPASS_TEXT, button -> this.bypassAction.run()).build()); + } } @Override diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/screen/CreativeInventoryScreenMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/screen/CreativeModeInventoryScreenMixin.java similarity index 63% rename from src/main/java/me/retucio/sputnik/mixin/mixins/screen/CreativeInventoryScreenMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/screen/CreativeModeInventoryScreenMixin.java index 1ef52b5..1a31263 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/screen/CreativeInventoryScreenMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/screen/CreativeModeInventoryScreenMixin.java @@ -2,25 +2,25 @@ package me.retucio.sputnik.mixin.mixins.screen; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.sugar.Local; +import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.inventory.CreativeInventoryHotbarKeybinds; import me.retucio.sputnik.util.KeyUtil; -import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; -import net.minecraft.client.input.KeyInput; +import net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen; +import net.minecraft.client.input.KeyEvent; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import java.util.Arrays; -import static me.retucio.sputnik.Sputnik.mc; -@Mixin(CreativeInventoryScreen.class) -public abstract class CreativeInventoryScreenMixin { +@Mixin(CreativeModeInventoryScreen.class) +public abstract class CreativeModeInventoryScreenMixin { @ModifyExpressionValue(method = "keyPressed", at = @At(value = "INVOKE", target = "Ljava/util/OptionalInt;isPresent()Z")) - private boolean makeHotkeysWork(boolean original, @Local(argsOnly = true) KeyInput input) { + private boolean makeHotkeysWork(boolean original, @Local(argsOnly = true, name = "event") KeyEvent event) { if (ModuleManager.INSTANCE.getModuleByClass(CreativeInventoryHotbarKeybinds.class).isEnabled()) - return Arrays.stream(mc.options.hotbarKeys).anyMatch(keyBinding -> KeyUtil.getKey(keyBinding) == input.getKeycode()); + return Arrays.stream(Sputnik.mc.options.keyHotbarSlots).anyMatch(keyBinding -> KeyUtil.getKey(keyBinding) == event.key()); return original; } } diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/screen/DisconnectedScreenMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/screen/DisconnectedScreenMixin.java index 08eb84a..135cda8 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/screen/DisconnectedScreenMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/screen/DisconnectedScreenMixin.java @@ -3,11 +3,11 @@ package me.retucio.sputnik.mixin.mixins.screen; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.network.Reconnect; -import net.minecraft.client.gui.screen.DisconnectedScreen; -import net.minecraft.client.gui.widget.ButtonWidget; -import net.minecraft.client.gui.widget.DirectionalLayoutWidget; -import net.minecraft.text.Text; +import net.minecraft.client.gui.components.Button; +import net.minecraft.client.gui.layouts.LinearLayout; +import net.minecraft.client.gui.screens.DisconnectedScreen; +import net.minecraft.network.chat.Component; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -19,15 +19,15 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; public abstract class DisconnectedScreenMixin { @Shadow @Final - private DirectionalLayoutWidget grid; + private LinearLayout layout; - @Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/DirectionalLayoutWidget;add(Lnet/minecraft/client/gui/widget/Widget;)Lnet/minecraft/client/gui/widget/Widget;", ordinal = 2, shift = At.Shift.AFTER)) + @Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/layouts/LinearLayout;addChild(Lnet/minecraft/client/gui/layouts/LayoutElement;)Lnet/minecraft/client/gui/layouts/LayoutElement;", ordinal = 2, shift = At.Shift.AFTER)) private void addReconnectButton(CallbackInfo ci) { Reconnect reconnect = ModuleManager.INSTANCE.getModuleByClass(Reconnect.class); if (reconnect == null || !reconnect.isEnabled()) return; - grid.add(ButtonWidget.builder( - Text.literal("reconectarse"), + layout.addChild(Button.builder( + Component.literal("reconectarse"), button -> reconnect.reconnect() ).build()); } diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/screen/ScreenMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/screen/ScreenMixin.java index 15c7a2b..7c557ae 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/screen/ScreenMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/screen/ScreenMixin.java @@ -5,10 +5,10 @@ import me.retucio.sputnik.command.CommandManager; import me.retucio.sputnik.config.ConfigManager; import me.retucio.sputnik.event.input.ClientClickEvent; import me.retucio.sputnik.ui.widgets.frames.settings.ClientSettingsFrame; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.text.ClickEvent; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.network.chat.ClickEvent; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -19,19 +19,20 @@ import static me.retucio.sputnik.Sputnik.mc; @Mixin(Screen.class) public class ScreenMixin { - @Inject(method = "handleBasicClickEvent", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;Ljava/lang/Object;)V", remap = false)) - private static void handleClientClickEvents(ClickEvent clickEvent, MinecraftClient client, Screen screen, CallbackInfo ci) throws CommandSyntaxException { - if (clickEvent instanceof ClientClickEvent event && event.getValue().startsWith(CommandManager.INSTANCE.getPrefix())) - CommandManager.dispatch(event.getValue().substring(CommandManager.INSTANCE.getPrefix().length())); + @Inject(method = "defaultHandleClickEvent", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;Ljava/lang/Object;)V", remap = false)) + private static void handleClientClickEvents(ClickEvent event, Minecraft minecraft, Screen activeScreen, CallbackInfo ci) throws CommandSyntaxException { + if (event instanceof ClientClickEvent e && e.getValue().startsWith(CommandManager.INSTANCE.getPrefix())) { + CommandManager.dispatch(e.getValue().substring(CommandManager.INSTANCE.getPrefix().length())); + } } - @Inject(method = "render", at = @At("HEAD")) - private void renderWatermark(DrawContext context, int mouseX, int mouseY, float deltaTicks, CallbackInfo ci) { + @Inject(method = "extractRenderState", at = @At("HEAD")) + private void renderWatermark(GuiGraphicsExtractor gui, int mouseX, int mouseY, float a, CallbackInfo ci) { if (!ConfigManager.hasLoaded()) return; // para evitar dibujar la marca de agua por defecto String watermark = ClientSettingsFrame.guiSettings.watermark.getValue(); if (watermark == null || watermark.isEmpty()) return; - context.drawText(mc.textRenderer, watermark, - mc.getWindow().getScaledWidth() - mc.textRenderer.getWidth(watermark) - 2, 2, + gui.text(mc.font, watermark, + mc.getWindow().getGuiScaledWidth() - mc.font.width(watermark) - 2, 2, ClientSettingsFrame.guiSettings.color.getRGB(), false ); } diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/world/BlockCollisionSpliteratorMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/world/BlockCollisionSpliteratorMixin.java deleted file mode 100644 index f833489..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/world/BlockCollisionSpliteratorMixin.java +++ /dev/null @@ -1,33 +0,0 @@ -package me.retucio.sputnik.mixin.mixins.world; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import me.retucio.sputnik.Sputnik; -import me.retucio.sputnik.event.interact.BlockShapeEvent; -import net.minecraft.block.BlockState; -import net.minecraft.block.ShapeContext; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.BlockCollisionSpliterator; -import net.minecraft.world.CollisionView; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -import static me.retucio.sputnik.Sputnik.mc; - -@Mixin(BlockCollisionSpliterator.class) -public abstract class BlockCollisionSpliteratorMixin { - - @WrapOperation(method = "computeNext", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/ShapeContext;getCollisionShape(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/CollisionView;Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/util/shape/VoxelShape;")) - private VoxelShape onGetBlockShape(ShapeContext instance, BlockState state, CollisionView collisionView, BlockPos pos, Operation original) { - VoxelShape shape = original.call(instance, state, collisionView, pos); - - if (collisionView != mc.world) { - return shape; - } - - BlockShapeEvent event = Sputnik.EVENT_BUS.post(new BlockShapeEvent(state, pos, shape)); - return event.isCancelled() ? VoxelShapes.empty() : event.getShape(); - } -} diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/world/BlockCollisionsMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/world/BlockCollisionsMixin.java new file mode 100644 index 0000000..b0142de --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/world/BlockCollisionsMixin.java @@ -0,0 +1,33 @@ +package me.retucio.sputnik.mixin.mixins.world; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import me.retucio.sputnik.Sputnik; +import me.retucio.sputnik.event.interact.BlockShapeEvent; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockCollisions; +import net.minecraft.world.level.CollisionGetter; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import static me.retucio.sputnik.Sputnik.mc; + +@Mixin(BlockCollisions.class) +public abstract class BlockCollisionsMixin { + + @WrapOperation(method = "computeNext", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/shapes/CollisionContext;getCollisionShape(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/CollisionGetter;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/phys/shapes/VoxelShape;")) + private VoxelShape onGetBlockShape(CollisionContext instance, BlockState state, CollisionGetter collisionGetter, BlockPos pos, Operation original) { + VoxelShape shape = original.call(instance, state, collisionGetter, pos); + + if (collisionGetter != mc.level) { + return shape; + } + + BlockShapeEvent event = Sputnik.EVENT_BUS.post(new BlockShapeEvent(state, pos, shape)); + return event.isCancelled() ? Shapes.empty() : event.getShape(); + } +} diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/world/ClientWorldPropertiesMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/world/ClientLevelDataMixin.java similarity index 74% rename from src/main/java/me/retucio/sputnik/mixin/mixins/world/ClientWorldPropertiesMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/world/ClientLevelDataMixin.java index d8b386a..56052af 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/world/ClientWorldPropertiesMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/world/ClientLevelDataMixin.java @@ -2,16 +2,17 @@ package me.retucio.sputnik.mixin.mixins.world; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.world.TimeChanger; -import net.minecraft.client.world.ClientWorld; +import net.minecraft.client.multiplayer.ClientLevel; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(ClientWorld.Properties.class) -public abstract class ClientWorldPropertiesMixin { +@Mixin(ClientLevel.ClientLevelData.class) +public abstract class ClientLevelDataMixin { - @Inject(method = "setTimeOfDay", at = @At("HEAD"), cancellable = true) + // setDayTime? + @Inject(method = "setGameTime", at = @At("HEAD"), cancellable = true) private void setTimeOfDay(long time, CallbackInfo ci) { // de no ser por esto, se verían "flashes" del tiempo real en el cielo TimeChanger timeChanger = ModuleManager.INSTANCE.getModuleByClass(TimeChanger.class); if (timeChanger.isEnabled() && time != timeChanger.time.getLongValue()) ci.cancel(); diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/world/ClientWorldMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/world/ClientLevelMixin.java similarity index 79% rename from src/main/java/me/retucio/sputnik/mixin/mixins/world/ClientWorldMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/world/ClientLevelMixin.java index 36dc76d..9db4000 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/world/ClientWorldMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/world/ClientLevelMixin.java @@ -2,8 +2,8 @@ package me.retucio.sputnik.mixin.mixins.world; import me.retucio.sputnik.event.network.AddEntityEvent; import me.retucio.sputnik.event.network.RemoveEntityEvent; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.Entity; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.entity.Entity; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -13,11 +13,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import static me.retucio.sputnik.Sputnik.EVENT_BUS; -@Mixin(ClientWorld.class) -public abstract class ClientWorldMixin { +@Mixin(ClientLevel.class) +public abstract class ClientLevelMixin { @Shadow @Nullable - public abstract Entity getEntityById(int id); + public abstract Entity getEntity(int id); @Inject(method = "addEntity", at = @At("HEAD")) private void onAddEntity(Entity entity, CallbackInfo ci) { @@ -26,7 +26,7 @@ public abstract class ClientWorldMixin { @Inject(method = "removeEntity", at = @At("HEAD")) private void onRemoveEntity(int entityId, Entity.RemovalReason removalReason, CallbackInfo ci) { - Entity entity = getEntityById(entityId); + Entity entity = getEntity(entityId); if (entity != null) EVENT_BUS.post(new RemoveEntityEvent(entity)); } } diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/world/CritParticleMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/world/CritParticleMixin.java new file mode 100644 index 0000000..772019c --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/world/CritParticleMixin.java @@ -0,0 +1,48 @@ +package me.retucio.sputnik.mixin.mixins.world; + +import com.llamalad7.mixinextras.injector.ModifyReturnValue; +import me.retucio.sputnik.module.ModuleManager; +import me.retucio.sputnik.module.modules.render.CritsPlus; +import net.minecraft.client.particle.CritParticle; +import net.minecraft.client.particle.SingleQuadParticle; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; + +@Mixin(CritParticle.class) +public abstract class CritParticleMixin { + + @ModifyReturnValue(method = "getLayer", at = @At("RETURN")) + private SingleQuadParticle.Layer makeCritsTranslucent(SingleQuadParticle.Layer original) { + if (ModuleManager.INSTANCE.getModuleByClass(CritsPlus.class).isEnabled()) + return SingleQuadParticle.Layer.TRANSLUCENT; + + return original; + } +} + + +@Mixin(CritParticle.Provider.class) +abstract class CritParticleProviderMixin { + + @ModifyVariable(method = "createParticle(Lnet/minecraft/core/particles/SimpleParticleType;Lnet/minecraft/client/multiplayer/ClientLevel;DDDDDDLnet/minecraft/util/RandomSource;)Lnet/minecraft/client/particle/Particle;", at = @At(value = "STORE"), name = "particle") + private CritParticle modifyCritColor(CritParticle particle) { + CritsPlus crits = ModuleManager.INSTANCE.getModuleByClass(CritsPlus.class); + if (!crits.isEnabled()) return particle; + + particle.setColor( + crits.color.getR() / 255f, + crits.color.getG() / 255f, + crits.color.getB() / 255f + ); + + particle.alpha = crits.color.getA() / 255f; + particle.quadSize *= crits.scale.getFloatValue(); + particle.friction *= crits.velocityMultipler.getFloatValue(); + particle.gravity *= crits.gravity.getFloatValue(); + particle.hasPhysics = crits.collide.getValue(); + particle.setLifetime(crits.maxAge.getIntValue()); + + return particle; + } +} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/world/DamageParticleMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/world/DamageParticleMixin.java deleted file mode 100644 index 2124e88..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/world/DamageParticleMixin.java +++ /dev/null @@ -1,48 +0,0 @@ -package me.retucio.sputnik.mixin.mixins.world; - -import com.llamalad7.mixinextras.injector.ModifyReturnValue; -import me.retucio.sputnik.module.ModuleManager; -import me.retucio.sputnik.module.modules.render.CritsPlus; -import net.minecraft.client.particle.BillboardParticle; -import net.minecraft.client.particle.DamageParticle; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; - -@Mixin(DamageParticle.class) -public abstract class DamageParticleMixin { - - @ModifyReturnValue(method = "getRenderType", at = @At("RETURN")) - private BillboardParticle.RenderType makeCritsTranslucent(BillboardParticle.RenderType original) { - if (ModuleManager.INSTANCE.getModuleByClass(CritsPlus.class).isEnabled()) - return BillboardParticle.RenderType.PARTICLE_ATLAS_TRANSLUCENT; - - return original; - } -} - - -@Mixin(DamageParticle.Factory.class) -abstract class DamageParticleFactoryMixin { - - @ModifyVariable(method = "createParticle(Lnet/minecraft/particle/SimpleParticleType;Lnet/minecraft/client/world/ClientWorld;DDDDDDLnet/minecraft/util/math/random/Random;)Lnet/minecraft/client/particle/Particle;", at = @At(value = "STORE")) - private DamageParticle modifyCritColor(DamageParticle original) { - CritsPlus crits = ModuleManager.INSTANCE.getModuleByClass(CritsPlus.class); - if (!crits.isEnabled()) return original; - - original.setColor( - crits.color.getR() / 255f, - crits.color.getG() / 255f, - crits.color.getB() / 255f - ); - - original.alpha = crits.color.getA() / 255f; - original.scale *= crits.scale.getFloatValue(); - original.velocityMultiplier *= crits.velocityMultipler.getFloatValue(); - original.gravityStrength *= crits.gravity.getFloatValue(); - original.setMaxAge(crits.maxAge.getIntValue()); - original.collidesWithWorld = crits.collide.getValue(); - - return original; - } -} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/world/RenderTickCounterDynamicMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/world/DeltaTrackerTimerMixin.java similarity index 54% rename from src/main/java/me/retucio/sputnik/mixin/mixins/world/RenderTickCounterDynamicMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/world/DeltaTrackerTimerMixin.java index 71a2fab..95a1d38 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/world/RenderTickCounterDynamicMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/world/DeltaTrackerTimerMixin.java @@ -2,7 +2,7 @@ package me.retucio.sputnik.mixin.mixins.world; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.world.Timer; -import net.minecraft.client.render.RenderTickCounter; +import net.minecraft.client.DeltaTracker; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -10,14 +10,14 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(RenderTickCounter.Dynamic.class) -public abstract class RenderTickCounterDynamicMixin { +@Mixin(DeltaTracker.Timer.class) +public abstract class DeltaTrackerTimerMixin { @Shadow - private float dynamicDeltaTicks; + private float deltaTicks; - @Inject(method = "beginRenderTick(J)I", at = @At(value = "FIELD", target = "Lnet/minecraft/client/render/RenderTickCounter$Dynamic;lastTimeMillis:J", opcode = Opcodes.PUTFIELD)) + @Inject(method = "advanceGameTime(J)I", at = @At(value = "FIELD", target = "Lnet/minecraft/client/DeltaTracker$Timer;lastMs:J", opcode = Opcodes.PUTFIELD)) private void onBeingRenderTick(long timeMillis, CallbackInfoReturnable cir) { - dynamicDeltaTicks *= ModuleManager.INSTANCE.getModuleByClass(Timer.class).multiplier.getFloatValue(); + deltaTicks *= ModuleManager.INSTANCE.getModuleByClass(Timer.class).multiplier.getFloatValue(); } } diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/world/EmitterParticleMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/world/EmitterParticleMixin.java deleted file mode 100644 index 1554ce5..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/world/EmitterParticleMixin.java +++ /dev/null @@ -1,56 +0,0 @@ -package me.retucio.sputnik.mixin.mixins.world; - -import me.retucio.sputnik.module.ModuleManager; -import me.retucio.sputnik.module.modules.render.CritsPlus; -import net.minecraft.client.particle.EmitterParticle; -import net.minecraft.client.particle.NoRenderParticle; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.Entity; -import net.minecraft.particle.ParticleEffect; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(EmitterParticle.class) -public abstract class EmitterParticleMixin extends NoRenderParticle { - - @Final @Shadow private Entity entity; - @Final @Shadow private ParticleEffect parameters; - @Final @Shadow private int maxEmitterAge; - @Shadow private int emitterAge; - - protected EmitterParticleMixin(ClientWorld clientWorld, double d, double e, double f) { - super(clientWorld, d, e, f); - } - - /** - * @author retucio - * @reason porque no hay otra manera más fácil - */ - @Overwrite - public void tick() { - CritsPlus critsPlus = ModuleManager.INSTANCE.getModuleByClass(CritsPlus.class); - - double amount = 16 * (critsPlus.isEnabled() - ? critsPlus.multiplier.getValue() - : 1); - - for (int i = 0; i < amount; i++) { - double d = this.random.nextFloat() * 2.0F - 1.0F; - double e = this.random.nextFloat() * 2.0F - 1.0F; - double f = this.random.nextFloat() * 2.0F - 1.0F; - if (!(d * d + e * e + f * f > 1.0)) { - double g = this.entity.getBodyX(d / 4.0); - double h = this.entity.getBodyY(0.5 + e / 4.0); - double j = this.entity.getBodyZ(f / 4.0); - this.world.addParticleClient(this.parameters, g, h, j, d, e + 0.2, f); - } - } - - this.emitterAge++; - if (this.emitterAge >= this.maxEmitterAge) { - this.markDead(); - } - } -} diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/world/ParticleEngineMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/world/ParticleEngineMixin.java new file mode 100644 index 0000000..d744e4f --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/world/ParticleEngineMixin.java @@ -0,0 +1,23 @@ +package me.retucio.sputnik.mixin.mixins.world; + +import me.retucio.sputnik.module.ModuleManager; +import me.retucio.sputnik.module.modules.render.NoRender; +import net.minecraft.client.particle.Particle; +import net.minecraft.client.particle.ParticleEngine; +import net.minecraft.core.particles.ParticleOptions; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + + +@Mixin(ParticleEngine.class) +public abstract class ParticleEngineMixin { + + @Inject(method = "createParticle", at = @At("HEAD"), cancellable = true) + private void noRenderParticles(ParticleOptions options, double x, double y, double z, double xa, double ya, double za, CallbackInfoReturnable cir) { + NoRender noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class); + if (!noRender.isEnabled()) return; + if (!noRender.particles.isEnabled(options.getType())) cir.setReturnValue(null); + } +} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/world/ParticleManagerMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/world/ParticleManagerMixin.java deleted file mode 100644 index 3e7ae87..0000000 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/world/ParticleManagerMixin.java +++ /dev/null @@ -1,22 +0,0 @@ -package me.retucio.sputnik.mixin.mixins.world; - -import me.retucio.sputnik.module.ModuleManager; -import me.retucio.sputnik.module.modules.render.NoRender; -import net.minecraft.client.particle.Particle; -import net.minecraft.client.particle.ParticleManager; -import net.minecraft.particle.ParticleEffect; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(ParticleManager.class) -public abstract class ParticleManagerMixin { - - @Inject(method = "addParticle(Lnet/minecraft/particle/ParticleEffect;DDDDDD)Lnet/minecraft/client/particle/Particle;", at = @At("HEAD"), cancellable = true) - private void noRenderParticles(ParticleEffect parameters, double x, double y, double z, double velocityX, double velocityY, double velocityZ, CallbackInfoReturnable cir) { - NoRender noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class); - if (!noRender.isEnabled()) return; - if (!noRender.particles.isEnabled(parameters.getType())) cir.setReturnValue(null); - } -} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/world/TrackingEmitterMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/world/TrackingEmitterMixin.java new file mode 100644 index 0000000..10f4e76 --- /dev/null +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/world/TrackingEmitterMixin.java @@ -0,0 +1,58 @@ +package me.retucio.sputnik.mixin.mixins.world; + +import me.retucio.sputnik.module.ModuleManager; +import me.retucio.sputnik.module.modules.render.CritsPlus; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.particle.NoRenderParticle; +import net.minecraft.client.particle.TrackingEmitter; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.world.entity.Entity; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(TrackingEmitter.class) +public abstract class TrackingEmitterMixin extends NoRenderParticle { + + @Final @Shadow private Entity entity; + @Final @Shadow private ParticleOptions particleType; + @Final @Shadow private int lifeTime; + @Shadow private int life; + + protected TrackingEmitterMixin(ClientLevel clientWorld, double d, double e, double f) { + super(clientWorld, d, e, f); + } + + + /** + * @author retucio + * @reason porque no hay otra manera más fácil + */ + + @Overwrite + public void tick() { + CritsPlus critsPlus = ModuleManager.INSTANCE.getModuleByClass(CritsPlus.class); + + double amount = 16 * (critsPlus.isEnabled() + ? critsPlus.multiplier.getValue() : 1 + ); + + for (int i = 0; i < amount; i++) { + double xa = this.random.nextFloat() * 2.0F - 1.0F; + double ya = this.random.nextFloat() * 2.0F - 1.0F; + double za = this.random.nextFloat() * 2.0F - 1.0F; + if (!(xa * xa + ya * ya + za * za > (double)1.0F)) { + double x = this.entity.getX(xa / (double)4.0F); + double y = this.entity.getY((double)0.5F + ya / (double)4.0F); + double z = this.entity.getZ(za / (double)4.0F); + this.level.addParticle(this.particleType, x, y, z, xa, ya + 0.2, za); + } + } + + this.life++; + if (this.life >= this.lifeTime) { + this.remove(); + } + } +} diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/world/ChunkOcclusionDataBuilderMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/world/VisGraphMixin.java similarity index 67% rename from src/main/java/me/retucio/sputnik/mixin/mixins/world/ChunkOcclusionDataBuilderMixin.java rename to src/main/java/me/retucio/sputnik/mixin/mixins/world/VisGraphMixin.java index 6f52527..f090e5c 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/world/ChunkOcclusionDataBuilderMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/world/VisGraphMixin.java @@ -1,8 +1,8 @@ package me.retucio.sputnik.mixin.mixins.world; import me.retucio.sputnik.event.network.ChunkOcclusionEvent; -import net.minecraft.client.render.chunk.ChunkOcclusionDataBuilder; -import net.minecraft.util.math.BlockPos; +import net.minecraft.client.renderer.chunk.VisGraph; +import net.minecraft.core.BlockPos; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -10,10 +10,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import static me.retucio.sputnik.Sputnik.EVENT_BUS; -@Mixin(ChunkOcclusionDataBuilder.class) -public abstract class ChunkOcclusionDataBuilderMixin { +@Mixin(VisGraph.class) +public abstract class VisGraphMixin { - @Inject(method = "markClosed", at = @At("HEAD"), cancellable = true) + @Inject(method = "setOpaque", at = @At("HEAD"), cancellable = true) private void onChunkOcclusion(BlockPos pos, CallbackInfo ci) { ChunkOcclusionEvent event = EVENT_BUS.post(new ChunkOcclusionEvent()); if (event.isCancelled()) ci.cancel(); diff --git a/src/main/java/me/retucio/sputnik/module/Module.java b/src/main/java/me/retucio/sputnik/module/Module.java index 5fdf5ad..b35fbde 100644 --- a/src/main/java/me/retucio/sputnik/module/Module.java +++ b/src/main/java/me/retucio/sputnik/module/Module.java @@ -10,7 +10,7 @@ import me.retucio.sputnik.module.setting.settings.EnumSetting; import me.retucio.sputnik.module.setting.settings.KeySetting; import me.retucio.sputnik.module.setting.Setting; import me.retucio.sputnik.util.ChatUtil; -import net.minecraft.client.MinecraftClient; +import net.minecraft.client.Minecraft; import org.lwjgl.glfw.GLFW; import java.lang.reflect.Method; @@ -37,7 +37,7 @@ public class Module { protected final List sgs = new ArrayList<>(); protected final SettingGroup sgGeneral = addSg(new SettingGroup("general", true)); - protected MinecraftClient mc = MinecraftClient.getInstance(); + protected Minecraft mc = Minecraft.getInstance(); public Module(String name, String description, Category category) { diff --git a/src/main/java/me/retucio/sputnik/module/ModuleManager.java b/src/main/java/me/retucio/sputnik/module/ModuleManager.java index 88264e4..09fdb21 100644 --- a/src/main/java/me/retucio/sputnik/module/ModuleManager.java +++ b/src/main/java/me/retucio/sputnik/module/ModuleManager.java @@ -82,6 +82,7 @@ public class ModuleManager { private void addCombat() { add(new AttributeSwapper()); + add(new ChestplateSwitch()); add(new CrystalAura()); add(new MaceKill()); add(new ProjectileTrajectories()); diff --git a/src/main/java/me/retucio/sputnik/module/modules/camera/Autism.java b/src/main/java/me/retucio/sputnik/module/modules/camera/Autism.java index 06eea54..dbc1ee4 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/camera/Autism.java +++ b/src/main/java/me/retucio/sputnik/module/modules/camera/Autism.java @@ -6,7 +6,7 @@ import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.EnumSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; +import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; /** @@ -40,25 +40,25 @@ public class Autism extends Module { @Override public void onTick() { - if (mc.player == null || mc.getNetworkHandler() == null) return; + if (mc.player == null || mc.getConnection() == null) return; if (direction.is(RotationDirection.CLOCKWISE)) yaw += interval.getFloatValue(); if (direction.is(RotationDirection.COUNTERCLOCKWISE)) yaw -= interval.getFloatValue(); - mc.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.LookAndOnGround( + mc.getConnection().send(new ServerboundMovePlayerPacket.Rot( yaw, - mc.player.getPitch(), - mc.player.isOnGround(), + mc.player.getXRot(), + mc.player.onGround(), mc.player.horizontalCollision )); } @EventListener private void onPacketSend(PacketEvent.Send event) { - if (event.getPacket() instanceof PlayerMoveC2SPacket.LookAndOnGround packet - && packet.getYaw(yaw) != yaw) event.cancel(); + if (event.getPacket() instanceof ServerboundMovePlayerPacket.Rot packet + && packet.getYRot(yaw) != yaw) event.cancel(); } private enum RotationDirection { diff --git a/src/main/java/me/retucio/sputnik/module/modules/camera/Freecam.java b/src/main/java/me/retucio/sputnik/module/modules/camera/Freecam.java index 4904126..fee7439 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/camera/Freecam.java +++ b/src/main/java/me/retucio/sputnik/module/modules/camera/Freecam.java @@ -10,8 +10,8 @@ import me.retucio.sputnik.event.network.ChunkOcclusionEvent; import me.retucio.sputnik.event.network.DisconnectEvent; import me.retucio.sputnik.event.network.PacketEvent; import me.retucio.sputnik.mixin.mixins.entity.EntityMixin; -import me.retucio.sputnik.mixin.mixins.io.KeyInputMixin; -import me.retucio.sputnik.mixin.mixins.player.ClientPlayerInteractionManagerMixin; +import me.retucio.sputnik.mixin.mixins.io.KeyboardInputMixin; +import me.retucio.sputnik.mixin.mixins.player.MultiPlayerGameModeMixin; import me.retucio.sputnik.mixin.mixins.render.*; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; @@ -22,31 +22,25 @@ import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.KeyUtil; import me.retucio.sputnik.util.MiscUtil; -import net.minecraft.client.gui.Click; -import net.minecraft.client.input.KeyInput; -import net.minecraft.client.input.MouseInput; -import net.minecraft.client.option.Perspective; -import net.minecraft.network.packet.Packet; -import net.minecraft.network.packet.c2s.play.HandSwingC2SPacket; -import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; -import net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket; -import net.minecraft.network.packet.c2s.play.PlayerInteractItemC2SPacket; -import net.minecraft.network.packet.s2c.play.DeathMessageS2CPacket; -import net.minecraft.network.packet.s2c.play.HealthUpdateS2CPacket; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; +import net.minecraft.client.CameraType; +import net.minecraft.client.input.MouseButtonEvent; +import net.minecraft.client.input.MouseButtonInfo; +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.protocol.game.*; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.Vec3; import org.joml.Vector3d; import org.lwjgl.glfw.GLFW; /** continúa en: * @see CameraMixin - * @see ChunkBorderDebugRendererMixin - * @see ClientPlayerInteractionManagerMixin + * @see ChunkBorderRendererMixin + * @see MultiPlayerGameModeMixin * @see EntityMixin * @see GameRendererMixin - * @see KeyInputMixin + * @see KeyboardInputMixin * @see LivingEntityRendererMixin - * @see WorldRendererMixin + * @see LevelRendererMixin * * @author retucio */ @@ -78,7 +72,7 @@ public class Freecam extends Module { private float prevYaw, prevPitch; private final Vector3d pos = new Vector3d(); - private Perspective perspective; + private CameraType perspective; private double fovScale, speed; private boolean forward, backward, right, left, up, down, crouching, viewBobbing; private float yaw, pitch; @@ -94,26 +88,26 @@ public class Freecam extends Module { @Override public void onEnable() { - if (mc.player == null || mc.options == null) return; + if (mc.player == null) return; - fovScale = mc.options.getFovEffectScale().getValue(); - viewBobbing = mc.options.getBobView().getValue(); + fovScale = mc.options.fovEffectScale().get(); + viewBobbing = mc.options.bobView().get(); if (staticView.getValue()) { - mc.options.getFovEffectScale().setValue(0D); - mc.options.getBobView().setValue(false); + mc.options.fovEffectScale().set(0D); + mc.options.bobView().set(false); } - yaw = mc.player.getYaw(); - pitch = mc.player.getPitch(); - perspective = mc.options.getPerspective(); + yaw = mc.player.getYRot(); + pitch = mc.player.getXRot(); + perspective = mc.options.getCameraType(); speed = speedSetting.getValue(); - MiscUtil.copyVector(pos, mc.gameRenderer.getCamera().getCameraPos()); - MiscUtil.copyVector(prevPos, mc.gameRenderer.getCamera().getCameraPos()); + MiscUtil.copyVector(pos, mc.gameRenderer.getMainCamera().position()); + MiscUtil.copyVector(prevPos, mc.gameRenderer.getMainCamera().position()); - if (mc.options.getPerspective() == Perspective.THIRD_PERSON_FRONT) { + if (mc.options.getCameraType() == CameraType.THIRD_PERSON_FRONT) { yaw += 180; pitch *= -1; } @@ -121,42 +115,41 @@ public class Freecam extends Module { prevYaw = yaw; prevPitch = pitch; - crouching = mc.options.sneakKey.isPressed(); + crouching = mc.options.keyShift.isDown(); - forward = KeyUtil.isKeyDown(mc.options.forwardKey); - backward = KeyUtil.isKeyDown(mc.options.backKey); - right = KeyUtil.isKeyDown(mc.options.rightKey); - left = KeyUtil.isKeyDown(mc.options.leftKey); - up = KeyUtil.isKeyDown(mc.options.jumpKey); - down = KeyUtil.isKeyDown(mc.options.sneakKey); + forward = KeyUtil.isKeyDown(mc.options.keyUp); + backward = KeyUtil.isKeyDown(mc.options.keyDown); + right = KeyUtil.isKeyDown(mc.options.keyRight); + left = KeyUtil.isKeyDown(mc.options.keyLeft); + up = KeyUtil.isKeyDown(mc.options.keyJump); + down = KeyUtil.isKeyDown(mc.options.keyShift); unpress(); - if (reloadChunks.getValue()) mc.worldRenderer.reload(); + if (reloadChunks.getValue()) mc.levelRenderer.allChanged(); super.onEnable(); } @Override public void onDisable() { - if (reloadChunks.getValue()) mc.execute(mc.worldRenderer::reload); + if (reloadChunks.getValue()) mc.execute(mc.levelRenderer::allChanged); - mc.options.setPerspective(perspective); + mc.options.setCameraType(perspective); crouching = false; if (staticView.getValue()) { - mc.options.getFovEffectScale().setValue(fovScale); - mc.options.getBobView().setValue(viewBobbing); + mc.options.fovEffectScale().set(fovScale); + mc.options.bobView().set(viewBobbing); } // para no flaggear el anticheat, cancelar cualquier acción dejada a medias estando en modo libre if (cancelActionPackets.getValue()) { - if (mc.interactionManager != null) - mc.interactionManager.cancelBlockBreaking(); - - if (mc.options != null) { - mc.options.attackKey.setPressed(false); - mc.options.useKey.setPressed(false); + if (mc.gameMode != null) { + mc.gameMode.stopDestroyBlock(); } + + mc.options.keyAttack.setDown(false); + mc.options.keyUse.setDown(false); } super.onDisable(); @@ -166,14 +159,14 @@ public class Freecam extends Module { public void onTick() { if (mc.getCameraEntity() == null || perspective == null) return; - mc.getCameraEntity().noClip = mc.getCameraEntity().isInsideWall(); - if (!perspective.isFirstPerson()) mc.options.setPerspective(Perspective.FIRST_PERSON); + mc.getCameraEntity().noPhysics = mc.getCameraEntity().isInWall(); + if (!perspective.isFirstPerson()) mc.options.setCameraType(CameraType.FIRST_PERSON); - Vec3d forward = Vec3d.fromPolar(0, yaw); - Vec3d right = Vec3d.fromPolar(0, yaw + 90); + Vec3 forward = Vec3.directionFromRotation(0, yaw); + Vec3 right = Vec3.directionFromRotation(0, yaw + 90); double dx = 0, dy = 0, dz = 0; - double speedMultiplier = speed * (KeyUtil.isKeyDown(mc.options.sprintKey) ? 1 : 0.5); + double speedMultiplier = speed * (KeyUtil.isKeyDown(mc.options.keySprint) ? 1 : 0.5); boolean zMovement = false; if (this.forward) { @@ -215,10 +208,10 @@ public class Freecam extends Module { if (event.getStage() != Event.Stage.PRE) return; Packet packet = event.getPacket(); - if (packet instanceof PlayerActionC2SPacket - || packet instanceof PlayerInteractBlockC2SPacket - || packet instanceof PlayerInteractItemC2SPacket - || packet instanceof HandSwingC2SPacket) { + if (packet instanceof ServerboundPlayerActionPacket + || packet instanceof ServerboundUseItemOnPacket + || packet instanceof ServerboundUseItemPacket + || packet instanceof ServerboundSwingPacket) { event.cancel(); } } @@ -226,29 +219,29 @@ public class Freecam extends Module { @EventListener private void onKey(KeyEvent event) { if (KeyUtil.isKeyDown(GLFW.GLFW_KEY_F3)) return; - if (mc.currentScreen != null) return; + if (mc.screen != null) return; - KeyInput key = new KeyInput(event.getKey(), event.getScancode(), 0); + net.minecraft.client.input.KeyEvent key = new net.minecraft.client.input.KeyEvent(event.getKey(), event.getScancode(), 0); boolean shouldCancel = true; - if (mc.options.forwardKey.matchesKey(key)) { + if (mc.options.keyUp.matches(key)) { forward = event.getAction() != GLFW.GLFW_RELEASE; - mc.options.forwardKey.setPressed(false); - } else if (mc.options.backKey.matchesKey(key)) { + mc.options.keyUp.setDown(false); + } else if (mc.options.keyDown.matches(key)) { backward = event.getAction() != GLFW.GLFW_RELEASE; - mc.options.backKey.setPressed(false); - } else if (mc.options.rightKey.matchesKey(key)) { + mc.options.keyDown.setDown(false); + } else if (mc.options.keyRight.matches(key)) { right = event.getAction() != GLFW.GLFW_RELEASE; - mc.options.rightKey.setPressed(false); - } else if (mc.options.leftKey.matchesKey(key)) { + mc.options.keyRight.setDown(false); + } else if (mc.options.keyLeft.matches(key)) { left = event.getAction() != GLFW.GLFW_RELEASE; - mc.options.leftKey.setPressed(false); - } else if (mc.options.jumpKey.matchesKey(key)) { + mc.options.keyLeft.setDown(false); + } else if (mc.options.keyJump.matches(key)) { up = event.getAction() != GLFW.GLFW_RELEASE; - mc.options.jumpKey.setPressed(false); - } else if (mc.options.sneakKey.matchesKey(key)) { + mc.options.keyJump.setDown(false); + } else if (mc.options.keyShift.matches(key)) { down = event.getAction() != GLFW.GLFW_RELEASE; - mc.options.sneakKey.setPressed(false); + mc.options.keyShift.setDown(false); } else { shouldCancel = false; } @@ -259,29 +252,29 @@ public class Freecam extends Module { @EventListener private void onMouseClick(MouseClickEvent event) { // por si el restrasado del usuario usa el ratón para moverse if (KeyUtil.isKeyDown(GLFW.GLFW_KEY_F3)) return; - if (mc.currentScreen != null) return; + if (mc.screen != null) return; - Click click = new Click(0, 0, new MouseInput(event.getButton(), 0)); + MouseButtonEvent click = new MouseButtonEvent(0, 0, new MouseButtonInfo(event.getButton(), 0)); boolean shouldCancel = true; - if (mc.options.forwardKey.matchesMouse(click)) { + if (mc.options.keyUp.matchesMouse(click)) { forward = event.getAction() != GLFW.GLFW_RELEASE; - mc.options.forwardKey.setPressed(false); - } else if (mc.options.backKey.matchesMouse(click)) { + mc.options.keyUp.setDown(false); + } else if (mc.options.keyDown.matchesMouse(click)) { backward = event.getAction() != GLFW.GLFW_RELEASE; - mc.options.backKey.setPressed(false); - } else if (mc.options.rightKey.matchesMouse(click)) { + mc.options.keyDown.setDown(false); + } else if (mc.options.keyRight.matchesMouse(click)) { right = event.getAction() != GLFW.GLFW_RELEASE; - mc.options.rightKey.setPressed(false); - } else if (mc.options.leftKey.matchesMouse(click)) { + mc.options.keyRight.setDown(false); + } else if (mc.options.keyLeft.matchesMouse(click)) { left = event.getAction() != GLFW.GLFW_RELEASE; - mc.options.leftKey.setPressed(false); - } else if (mc.options.jumpKey.matchesMouse(click)) { + mc.options.keyLeft.setDown(false); + } else if (mc.options.keyJump.matchesMouse(click)) { up = event.getAction() != GLFW.GLFW_RELEASE; - mc.options.jumpKey.setPressed(false); - } else if (mc.options.sneakKey.matchesMouse(click)) { + mc.options.keyJump.setDown(false); + } else if (mc.options.keyShift.matchesMouse(click)) { down = event.getAction() != GLFW.GLFW_RELEASE; - mc.options.sneakKey.setPressed(false); + mc.options.keyShift.setDown(false); } else { shouldCancel = false; } @@ -291,7 +284,7 @@ public class Freecam extends Module { @EventListener private void onMouseScroll(MouseScrollEvent event) { - if (scrollSens.getValue() > 0 && mc.currentScreen == null && scrollKey.isDown()) { + if (scrollSens.getValue() > 0 && mc.screen == null && scrollKey.isDown()) { speed += event.getVertical() / 4 * (scrollSens.getValue() * speed); if (speed < 0.1) speed = 0.1; event.cancel(); @@ -312,10 +305,10 @@ public class Freecam extends Module { private void onPacketReceive(PacketEvent.Receive event) { if (mc.player == null) return; // el jugador probablemente nunca sea nulo bajo estas circunstancias pero quién sabe - if (event.getPacket() instanceof DeathMessageS2CPacket packet) { + if (event.getPacket() instanceof ClientboundPlayerCombatKillPacket packet) { if (mc.player.getId() == packet.playerId()) toggle(); - } else if (event.getPacket() instanceof HealthUpdateS2CPacket packet) { + } else if (event.getPacket() instanceof ClientboundSetHealthPacket packet) { if (mc.player.getHealth() - packet.getHealth() > 0 && toggleOnDamage.getValue()) { ChatUtil.info("cámara libre se ha desactivado porque has recibido daño"); toggle(); @@ -361,16 +354,16 @@ public class Freecam extends Module { yaw += (float) deltaX; pitch += (float) deltaY; - pitch = MathHelper.clamp(pitch, -90, 90); + pitch = Mth.clamp(pitch, -90, 90); } private void unpress() { - mc.options.forwardKey.setPressed(false); - mc.options.backKey.setPressed(false); - mc.options.rightKey.setPressed(false); - mc.options.leftKey.setPressed(false); - mc.options.jumpKey.setPressed(false); - mc.options.sneakKey.setPressed(false); + mc.options.keyUp.setDown(false); + mc.options.keyDown.setDown(false); + mc.options.keyRight.setDown(false); + mc.options.keyLeft.setDown(false); + mc.options.keyJump.setDown(false); + mc.options.keyShift.setDown(false); } private void stopMoving() { @@ -398,7 +391,7 @@ public class Freecam extends Module { } public float getYaw(float tickDelta) { - return MathHelper.lerp(tickDelta, prevYaw, yaw); + return Mth.lerp(tickDelta, prevYaw, yaw); } public float getPitch() { @@ -406,7 +399,7 @@ public class Freecam extends Module { } public float getPitch(float tickDelta) { - return MathHelper.lerp(tickDelta, prevPitch, pitch); + return Mth.lerp(tickDelta, prevPitch, pitch); } public float getPrevYaw() { @@ -418,15 +411,15 @@ public class Freecam extends Module { } public double getX(float tickDelta) { - return MathHelper.lerp(tickDelta, prevPos.x, pos.x); + return Mth.lerp(tickDelta, prevPos.x, pos.x); } public double getY(float tickDelta) { - return MathHelper.lerp(tickDelta, prevPos.y, pos.y); + return Mth.lerp(tickDelta, prevPos.y, pos.y); } public double getZ(float tickDelta) { - return MathHelper.lerp(tickDelta, prevPos.z, pos.z); + return Mth.lerp(tickDelta, prevPos.z, pos.z); } public boolean isCrouching() { diff --git a/src/main/java/me/retucio/sputnik/module/modules/camera/Freelook.java b/src/main/java/me/retucio/sputnik/module/modules/camera/Freelook.java index e3d79cb..962de4d 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/camera/Freelook.java +++ b/src/main/java/me/retucio/sputnik/module/modules/camera/Freelook.java @@ -7,8 +7,8 @@ import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.EnumSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.util.KeyUtil; -import net.minecraft.client.option.Perspective; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.CameraType; +import net.minecraft.util.Mth; import org.lwjgl.glfw.GLFW; /** continúa en: @@ -31,7 +31,7 @@ public class Freelook extends Module { private float yaw; private float pitch; - private Perspective prevPerspective; + private CameraType prevPerspective; public Freelook() { super("perspectiva libre", @@ -50,20 +50,20 @@ public class Freelook extends Module { public void onEnable() { if (mc.player == null) return; - yaw = mc.player.getYaw(); - pitch = mc.player.getPitch(); + yaw = mc.player.getYRot(); + pitch = mc.player.getXRot(); - prevPerspective = mc.options.getPerspective(); - if (prevPerspective != Perspective.THIRD_PERSON_BACK) - mc.options.setPerspective(Perspective.THIRD_PERSON_BACK); + prevPerspective = mc.options.getCameraType(); + if (prevPerspective != CameraType.THIRD_PERSON_BACK) + mc.options.setCameraType(CameraType.THIRD_PERSON_BACK); super.onEnable(); } @Override public void onDisable() { - if (mc.options.getPerspective() != prevPerspective) - mc.options.setPerspective(prevPerspective); + if (mc.options.getCameraType() != prevPerspective) + mc.options.setCameraType(prevPerspective); super.onDisable(); } @@ -80,23 +80,23 @@ public class Freelook extends Module { if (KeyUtil.isKeyDown(GLFW.GLFW_KEY_UP)) pitch -= 0.5f; if (KeyUtil.isKeyDown(GLFW.GLFW_KEY_DOWN)) pitch += 0.5f; } case CAMERA -> { - float yaw = mc.player.getYaw(); - float pitch = mc.player.getPitch(); + float yaw = mc.player.getYRot(); + float pitch = mc.player.getXRot(); if (KeyUtil.isKeyDown(GLFW.GLFW_KEY_LEFT)) yaw -= 0.5f; if (KeyUtil.isKeyDown(GLFW.GLFW_KEY_RIGHT)) yaw += 0.5f; if (KeyUtil.isKeyDown(GLFW.GLFW_KEY_UP)) pitch -= 0.5f; if (KeyUtil.isKeyDown(GLFW.GLFW_KEY_DOWN)) pitch += 0.5f; - mc.player.setYaw(yaw); - mc.player.setPitch(pitch); + mc.player.setYRot(yaw); + mc.player.setXRot(pitch); } } } } - mc.player.setPitch(MathHelper.clamp(mc.player.getPitch(), -90, 90)); - pitch = MathHelper.clamp(pitch, -90, 90); + mc.player.setXRot(Mth.clamp(mc.player.getXRot(), -90, 90)); + pitch = Mth.clamp(pitch, -90, 90); } public float getYaw() { diff --git a/src/main/java/me/retucio/sputnik/module/modules/camera/Fullbright.java b/src/main/java/me/retucio/sputnik/module/modules/camera/Fullbright.java index abc1870..babd469 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/camera/Fullbright.java +++ b/src/main/java/me/retucio/sputnik/module/modules/camera/Fullbright.java @@ -1,14 +1,14 @@ package me.retucio.sputnik.module.modules.camera; -import me.retucio.sputnik.mixin.accessors.StatusEffectInstanceAccessor; +import me.retucio.sputnik.mixin.accessors.MobEffectInstanceAccessor; import me.retucio.sputnik.mixin.mixins.render.LightmapTextureManagerMixin; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.ColorSetting; import me.retucio.sputnik.module.setting.settings.EnumSetting; -import net.minecraft.entity.effect.StatusEffectInstance; -import net.minecraft.entity.effect.StatusEffects; -import net.minecraft.registry.Registries; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffects; import org.lwjgl.glfw.GLFW; import java.awt.*; @@ -57,18 +57,18 @@ public class Fullbright extends Module { public void onTick() { if (mc.player == null || !mode.getValue().equals(Modes.POTION)) return; - if (mc.player.hasStatusEffect(Registries.STATUS_EFFECT.getEntry(StatusEffects.NIGHT_VISION.value()))) { - StatusEffectInstance instance = mc.player.getStatusEffect(Registries.STATUS_EFFECT.getEntry(StatusEffects.NIGHT_VISION.value())); - if (instance != null && instance.getDuration() < 5200) ((StatusEffectInstanceAccessor) instance).setDuration(5200); + if (mc.player.hasEffect(BuiltInRegistries.MOB_EFFECT.wrapAsHolder(MobEffects.NIGHT_VISION.value()))) { + MobEffectInstance instance = mc.player.getEffect(BuiltInRegistries.MOB_EFFECT.wrapAsHolder(MobEffects.NIGHT_VISION.value())); + if (instance != null && instance.getDuration() < 5200) ((MobEffectInstanceAccessor) instance).setDuration(5200); } else { - mc.player.addStatusEffect(new StatusEffectInstance(Registries.STATUS_EFFECT.getEntry(StatusEffects.NIGHT_VISION.value()), 69, 0)); + mc.player.addEffect(new MobEffectInstance(BuiltInRegistries.MOB_EFFECT.wrapAsHolder(MobEffects.NIGHT_VISION.value()), 69, 0)); } } private void disableNightVision() { if (mc.player == null) return; - if (mc.player.hasStatusEffect(Registries.STATUS_EFFECT.getEntry(StatusEffects.NIGHT_VISION.value()))) - mc.player.removeStatusEffect(Registries.STATUS_EFFECT.getEntry(StatusEffects.NIGHT_VISION.value())); + if (mc.player.hasEffect(BuiltInRegistries.MOB_EFFECT.wrapAsHolder(MobEffects.NIGHT_VISION.value()))) + mc.player.removeEffect(BuiltInRegistries.MOB_EFFECT.wrapAsHolder(MobEffects.NIGHT_VISION.value())); } diff --git a/src/main/java/me/retucio/sputnik/module/modules/camera/PerspectivePlus.java b/src/main/java/me/retucio/sputnik/module/modules/camera/PerspectivePlus.java index 4bbd7be..5198403 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/camera/PerspectivePlus.java +++ b/src/main/java/me/retucio/sputnik/module/modules/camera/PerspectivePlus.java @@ -9,6 +9,7 @@ import me.retucio.sputnik.module.setting.SettingGroup; import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.KeySetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; +import net.minecraft.client.CameraType; import org.lwjgl.glfw.GLFW; @@ -58,8 +59,8 @@ public class PerspectivePlus extends Module { @EventListener private void onMouseScroll(MouseScrollEvent event) { - if (mc.options.getPerspective() == net.minecraft.client.option.Perspective.FIRST_PERSON - || mc.currentScreen != null || scrollSens.getValue() <= 0) return; + if (mc.options.getCameraType() == CameraType.FIRST_PERSON + || mc.screen != null || scrollSens.getValue() <= 0) return; if (scrollKey.isDown()) { distance -= event.getVertical() / 4 * (scrollSens.getValue() * distance); diff --git a/src/main/java/me/retucio/sputnik/module/modules/camera/Rotations.java b/src/main/java/me/retucio/sputnik/module/modules/camera/Rotations.java index df96397..bde6508 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/camera/Rotations.java +++ b/src/main/java/me/retucio/sputnik/module/modules/camera/Rotations.java @@ -6,7 +6,7 @@ import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; +import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; /** * @author retucio @@ -30,15 +30,15 @@ public class Rotations extends Module { public void onTick() { if (mc.player == null) return; - mc.player.setYaw(yaw.getFloatValue()); - mc.player.setPitch(pitch.getFloatValue()); + mc.player.setYRot(yaw.getFloatValue()); + mc.player.setXRot(pitch.getFloatValue()); if (serverSide.getValue()) - mc.player.networkHandler.sendPacket( - new PlayerMoveC2SPacket.LookAndOnGround( + mc.player.connection.send( + new ServerboundMovePlayerPacket.Rot( yaw.getFloatValue(), pitch.getFloatValue(), - mc.player.isOnGround(), + mc.player.onGround(), mc.player.horizontalCollision ) ); diff --git a/src/main/java/me/retucio/sputnik/module/modules/camera/Zoom.java b/src/main/java/me/retucio/sputnik/module/modules/camera/Zoom.java index fb68bdf..ec4c239 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/camera/Zoom.java +++ b/src/main/java/me/retucio/sputnik/module/modules/camera/Zoom.java @@ -60,13 +60,11 @@ public class Zoom extends Module { @Override public void onEnable() { - if (mc.options == null) return; - - prevSmoothCam = mc.options.smoothCameraEnabled; - prevMouseSens = mc.options.getMouseSensitivity().getValue(); - prevFov = mc.options.getFov().getValue(); - prevHUD = mc.options.hudHidden; - mc.options.hudHidden = !showHUD.getValue(); + prevSmoothCam = mc.options.smoothCamera; + prevMouseSens = mc.options.sensitivity().get(); + prevFov = mc.options.fov().get(); + prevHUD = mc.options.hideGui; + mc.options.hideGui = !showHUD.getValue(); value = defaultZoom.getValue(); @@ -75,22 +73,21 @@ public class Zoom extends Module { @Override public void onDisable() { - if (mc.options == null) return; + mc.options.smoothCamera = prevSmoothCam; + mc.options.sensitivity().set(prevMouseSens); + mc.options.hideGui = prevHUD; - mc.options.smoothCameraEnabled = prevSmoothCam; - mc.options.getMouseSensitivity().setValue(prevMouseSens); - mc.options.hudHidden = prevHUD; - - mc.worldRenderer.scheduleTerrainUpdate(); + mc.levelRenderer.needsUpdate(); super.onDisable(); } @Override public void onTick() { - mc.options.smoothCameraEnabled = smoothCam.getValue(); - if (!smoothCam.getValue()) - mc.options.getMouseSensitivity().setValue(prevMouseSens * mouseSensMultiplier.getValue()); + mc.options.smoothCamera = smoothCam.getValue(); + if (!smoothCam.getValue()) { + mc.options.sensitivity().set(prevMouseSens * mouseSensMultiplier.getValue()); + } } @EventListener @@ -108,7 +105,7 @@ public class Zoom extends Module { private void onGetFov(GetFOVEvent event) { event.setFov((float) (event.getFov() / value)); - if (prevFov != event.getFov()) mc.worldRenderer.scheduleTerrainUpdate(); + if (prevFov != event.getFov()) mc.levelRenderer.needsUpdate(); prevFov = event.getFov(); } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/combat/ChestplateSwitch.java b/src/main/java/me/retucio/sputnik/module/modules/combat/ChestplateSwitch.java new file mode 100644 index 0000000..1adb4c2 --- /dev/null +++ b/src/main/java/me/retucio/sputnik/module/modules/combat/ChestplateSwitch.java @@ -0,0 +1,64 @@ +package me.retucio.sputnik.module.modules.combat; + +import com.github.retucio.neutrino.EventListener; +import me.retucio.sputnik.event.interact.AttackEntityEvent; +import me.retucio.sputnik.module.Category; +import me.retucio.sputnik.module.Module; +import me.retucio.sputnik.module.setting.settings.BooleanSetting; +import me.retucio.sputnik.util.ChatUtil; +import me.retucio.sputnik.util.InventoryUtil; +import net.minecraft.network.protocol.game.ServerboundAttackPacket; +import net.minecraft.network.protocol.game.ServerboundInteractPacket; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; + + +/** + * @author retucio + */ + +public class ChestplateSwitch extends Module { + + private final BooleanSetting switchBack = sgGeneral.add(new BooleanSetting( + "cambiar de vuelta", "cambiar de vuelta a elytras, si estaban puestas", true + )); + + public ChestplateSwitch() { + super("autopechera", "cambia a pechera antes de pegar con el mazo", Category.COMBAT); + } + + @EventListener + private void onAttack(AttackEntityEvent event) { + if (!mc.player.getMainHandItem().is(Items.MACE)) return; + if (mc.player.hasItemInSlot(EquipmentSlot.CHEST) || mc.player.getItemBySlot(EquipmentSlot.CHEST).is(Items.ELYTRA)) { + int slot = InventoryUtil.findSlot(this::isChestplate); + if (!Inventory.isHotbarSlot(slot)) { + ChatUtil.error("no se encontró una pechera en la hotbar"); + return; + } + + event.cancel(); + + int prevSlot = mc.player.getInventory().getSelectedSlot(); + mc.player.getInventory().setSelectedSlot(slot); + mc.startUseItem(); + mc.player.getInventory().setSelectedSlot(prevSlot); + + mc.getConnection().send(new ServerboundAttackPacket(event.getEntity().getId())); + } + } + + private boolean isChestplate(ItemStack stack) { + Item item = stack.getItem(); + return item == Items.CHAINMAIL_CHESTPLATE + || item == Items.COPPER_CHESTPLATE + || item == Items.DIAMOND_CHESTPLATE + || item == Items.GOLDEN_CHESTPLATE + || item == Items.IRON_CHESTPLATE + || item == Items.LEATHER_CHESTPLATE + || item == Items.NETHERITE_CHESTPLATE; + } +} diff --git a/src/main/java/me/retucio/sputnik/module/modules/combat/CrystalAura.java b/src/main/java/me/retucio/sputnik/module/modules/combat/CrystalAura.java index 8c317f4..c882fa5 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/combat/CrystalAura.java +++ b/src/main/java/me/retucio/sputnik/module/modules/combat/CrystalAura.java @@ -10,35 +10,40 @@ import me.retucio.sputnik.module.setting.settings.ColorSetting; import me.retucio.sputnik.module.setting.settings.ListSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.util.*; +import me.retucio.sputnik.util.misc.BlockIterator; import me.retucio.sputnik.util.render.RenderUtil; -import net.minecraft.block.Blocks; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.decoration.EndCrystalEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.Items; -import net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.hit.HitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.RaycastContext; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.network.protocol.game.ServerboundUseItemOnPacket; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.boss.enderdragon.EndCrystal; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; import java.util.ArrayList; import java.util.List; + /** * @author retucio */ + public class CrystalAura extends Module { private final SettingGroup sgPlace = addSg(new SettingGroup("colocar", false)); private final SettingGroup sgBreak = addSg(new SettingGroup("reventar", false)); private final SettingGroup sgRender = addSg(new SettingGroup("renderizado", false)); + private final ListSetting> entities = sgGeneral.add(new ListSetting<>( "entidades", "entidades a las que atacar", Lists.entityList, Lists.allFalseExcept(Lists.entityList, EntityType.PLAYER), Lists.entityNames @@ -71,9 +76,13 @@ public class CrystalAura extends Module { "rotar", "rotar para colocar cristales", false )).visibility(placeCrystals::getValue); + private final BooleanSetting placeObsidian = sgPlace.add(new BooleanSetting( + "colocar obsidiana", "colocar obsidiana si es necesario", true + )).visibility(placeCrystals::getValue); + private final BooleanSetting autoSelect = sgPlace.add(new BooleanSetting( "autoseleccionar", "seleccionar cristales automáticamente", true - )); + )).visibility(placeCrystals::getValue); // ajustes al reventar los cristales @@ -124,7 +133,6 @@ public class CrystalAura extends Module { private int placeTimer = placeDelay.getIntValue(); private int breakTimer = breakDelay.getIntValue(); - public CrystalAura() { super("aura de cristales", "coloca y revienta cristales del end por ti", Category.COMBAT); @@ -133,7 +141,7 @@ public class CrystalAura extends Module { @Override public void onTick() { - if (mc.player == null || mc.interactionManager == null || mc.world == null || mc.getCameraEntity() == null) return; + if (mc.player == null || mc.gameMode == null || mc.level == null || mc.getCameraEntity() == null) return; if (placeTimer > 0) placeTimer--; if (breakTimer > 0) breakTimer--; @@ -148,11 +156,12 @@ public class CrystalAura extends Module { } } - // colocar cristal + @SuppressWarnings("deprecation") + // colocar cristal (u obsidiana si es necesario) private void doPlace() { if (placeTimer > 0) return; - if (!canPlaceCrystal()) { + if (!hasCrystal()) { bp = null; return; } @@ -161,7 +170,7 @@ public class CrystalAura extends Module { LivingEntity primaryTarget = null; double closestTargetDist = Double.MAX_VALUE; for (LivingEntity target : targets) { - double dist = mc.player.squaredDistanceTo(target); + double dist = mc.player.distanceToSqr(target); if (dist < closestTargetDist) { closestTargetDist = dist; primaryTarget = target; @@ -172,28 +181,41 @@ public class CrystalAura extends Module { return; } - final Vec3d targetPos = primaryTarget.getEntityPos(); - final BlockPos.Mutable[] bestPos = new BlockPos.Mutable[1]; - final double[] bestDist = { Double.MAX_VALUE }; + final Vec3 targetPos = primaryTarget.position(); + + final BlockPos.MutableBlockPos[] bestExistingPos = new BlockPos.MutableBlockPos[1]; + final double[] bestExistingDist = { Double.MAX_VALUE }; + final BlockPos.MutableBlockPos[] bestObbyPlacePos = new BlockPos.MutableBlockPos[1]; + final double[] bestObbyPlaceDist = { Double.MAX_VALUE }; BlockIterator.register((int) Math.ceil(placeRange.getValue()), (int) Math.ceil(placeRange.getValue()), (pos, state) -> { - if (!state.isOf(Blocks.OBSIDIAN) && !state.isOf(Blocks.BEDROCK)) return; - if (!mc.world.isAir(pos.add(0, 1, 0))) return; - - // cálculo de mejor distancia - double dist = targetPos.squaredDistanceTo(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); - if (dist < bestDist[0]) { - bestDist[0] = dist; - if (bestPos[0] == null) bestPos[0] = new BlockPos.Mutable(); - bestPos[0].set(pos); + if ((state.is(Blocks.OBSIDIAN) || state.is(Blocks.BEDROCK)) && mc.level.isEmptyBlock(pos.above())) { + double dist = targetPos.distanceToSqr(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); + if (dist < bestExistingDist[0]) { + bestExistingDist[0] = dist; + if (bestExistingPos[0] == null) bestExistingPos[0] = new BlockPos.MutableBlockPos(); + bestExistingPos[0].set(pos); + } + } + // asegurarse de que no está dentro del bloque + if (mc.level.isEmptyBlock(pos) && mc.level.getBlockState(pos.below()).isSolid() && mc.level.isEmptyBlock(pos.above()) && targetPos.distanceTo(pos.getCenter()) > 0.6) { + double dist = targetPos.distanceToSqr(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); + if (dist < bestObbyPlaceDist[0]) { + bestObbyPlaceDist[0] = dist; + if (bestObbyPlacePos[0] == null) bestObbyPlacePos[0] = new BlockPos.MutableBlockPos(); + bestObbyPlacePos[0].set(pos); + } } }); BlockIterator.after(() -> { - if (bestPos[0] != null) { - BlockHitResult result = getBlockInfo(bestPos[0]); + if (bestExistingPos[0] != null) { + BlockHitResult result = getBlockInfo(bestExistingPos[0]); placeCrystal(result); - bp = bestPos[0].toImmutable(); // guardar para el renderizado + bp = bestExistingPos[0].immutable(); + } else if (hasObby() && bestObbyPlacePos[0] != null) { + placeObby(bestObbyPlacePos[0]); + bp = bestObbyPlacePos[0].immutable(); // mostrar el bloque donde se pondrá el cristal } else { bp = null; } @@ -204,64 +226,93 @@ public class CrystalAura extends Module { private void doBreak() { if (breakTimer > 0) return; - for (Entity entity : mc.world.getEntities()) { - if (!(entity instanceof EndCrystalEntity) || entity.distanceTo(mc.player) > mc.player.getEntityInteractionRange()) continue; - if (rotateToBreak.getValue()) EntityUtil.lookAt(entity.getEyePos()); - mc.interactionManager.attackEntity(mc.player, entity); + for (Entity entity : mc.level.getEntities().getAll()) { + if (!(entity instanceof EndCrystal) || entity.distanceTo(mc.player) > mc.player.entityInteractionRange()) continue; + if (rotateToBreak.getValue()) EntityUtil.lookAt(entity.getEyePosition()); + mc.gameMode.attack(mc.player, entity); } breakTimer = breakDelay.getIntValue(); } private void placeCrystal(BlockHitResult result) { - if (autoSelect.getValue()) { - int slot = InventoryUtil.findSlot(stack -> stack.isOf(Items.END_CRYSTAL)); - if (slot != InventoryUtil.OFFHAND_SLOT) { - if (!PlayerInventory.isValidHotbarIndex(slot)) { - InventoryUtil.swapWithHotbar(slot, mc.player.getInventory().getSelectedSlot()); - } else { - mc.player.getInventory().setSelectedSlot(slot); - } - } - } + doAutoSelect(Items.END_CRYSTAL); - Hand hand; - if (mc.player.getMainHandStack().isOf(Items.END_CRYSTAL)) { - hand = Hand.MAIN_HAND; - } else if (mc.player.getOffHandStack().isOf(Items.END_CRYSTAL)) { - hand = Hand.OFF_HAND; + InteractionHand hand; + if (mc.player.getMainHandItem().is(Items.END_CRYSTAL)) { + hand = InteractionHand.MAIN_HAND; + } else if (mc.player.getOffhandItem().is(Items.END_CRYSTAL)) { + hand = InteractionHand.OFF_HAND; } else { return; } - if (rotateToPlace.getValue()) EntityUtil.lookAt(result.getBlockPos().toCenterPos()); - mc.interactionManager.sendSequencedPacket(mc.world, (sequence) -> new PlayerInteractBlockC2SPacket(hand, result, sequence)); + if (rotateToPlace.getValue()) EntityUtil.lookAt(result.getBlockPos().getCenter()); + mc.gameMode.startPrediction(mc.level, (sequence) -> new ServerboundUseItemOnPacket(hand, result, sequence)); + } + + private void placeObby(BlockPos pos) { + doAutoSelect(Items.OBSIDIAN); + + InteractionHand hand; + if (mc.player.getMainHandItem().is(Items.OBSIDIAN)) { + hand = InteractionHand.MAIN_HAND; + } else if (mc.player.getOffhandItem().is(Items.OBSIDIAN)) { + hand = InteractionHand.OFF_HAND; + } else { + return; + } + + BlockPos supportPos = pos.below(); + BlockHitResult result = new BlockHitResult(Vec3.atCenterOf(supportPos), Direction.UP, supportPos, false); + + if (rotateToPlace.getValue()) EntityUtil.lookAt(pos.getCenter()); + mc.gameMode.startPrediction(mc.level, (sequence) -> new ServerboundUseItemOnPacket(hand, result, sequence)); + } + + private void doAutoSelect(Item item) { + int slot = InventoryUtil.findSlot(stack -> stack.is(item)); + if (slot != InventoryUtil.OFFHAND_SLOT) { + if (!Inventory.isHotbarSlot(slot)) { + InventoryUtil.swapWithHotbar(slot, mc.player.getInventory().getSelectedSlot()); + } else { + mc.player.getInventory().setSelectedSlot(slot); + } + } + } + + private boolean hasObby() { + if (!placeObsidian.getValue()) return false; + if (autoSelect.getValue()) { + return InventoryUtil.findSlot(stack -> stack.is(Items.OBSIDIAN)) != -1; + } else { + return InventoryUtil.hasInHotbar(Items.OBSIDIAN); + } } - // encontrar blancos private void findTargets() { targets.clear(); - for (Entity e : mc.world.getEntities()) { + for (Entity e : mc.level.getEntities().getAll()) { if (!(e instanceof LivingEntity entity)) continue; - if (!entity.isAlive() || entity.isInCreativeMode() || entity.equals(mc.player)) continue; + if (!entity.isAlive() || entity.hasInfiniteMaterials() || entity.equals(mc.player)) continue; if (!entities.isEnabled(entity.getType())) continue; - if (entity.squaredDistanceTo(mc.player) > targetRange.getValue() * targetRange.getValue()) continue; + if (entity.distanceToSqr(mc.player) > targetRange.getValue() * targetRange.getValue()) continue; targets.add(entity); } } private BlockHitResult getBlockInfo(BlockPos pos) { - Vec3d start = new Vec3d(mc.player.getX(), mc.player.getY() + mc.player.getEyeHeight(mc.player.getPose()), mc.player.getZ()); - Vec3d end; + Vec3 start = new Vec3(mc.player.getX(), mc.player.getY() + mc.player.getEyeHeight(mc.player.getPose()), mc.player.getZ()); + Vec3 end; for (Direction side : Direction.values()) { - end = new Vec3d( - pos.getX() + 0.5 + side.getVector().getX() * 0.5, - pos.getY() + 0.5 + side.getVector().getY() * 0.5, - pos.getZ() + 0.5 + side.getVector().getZ() * 0.5 + end = new Vec3( + pos.getX() + 0.5 + side.getUnitVec3().x() * 0.5, + pos.getY() + 0.5 + side.getUnitVec3().y() * 0.5, + pos.getZ() + 0.5 + side.getUnitVec3().z() * 0.5 ); - BlockHitResult result = mc.world.raycast(new RaycastContext( - start, end, RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.NONE, mc.player + BlockHitResult result = mc.level.clip(new ClipContext( + start, end, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, mc.player )); if (result != null && result.getType() == HitResult.Type.BLOCK && result.getBlockPos().equals(pos)) { @@ -273,9 +324,9 @@ public class CrystalAura extends Module { return new BlockHitResult(start, side, pos, false); } - private boolean canPlaceCrystal() { + private boolean hasCrystal() { if (autoSelect.getValue()) { - return InventoryUtil.findSlot(stack -> stack.isOf(Items.END_CRYSTAL)) != -1; + return InventoryUtil.findSlot(stack -> stack.is(Items.END_CRYSTAL)) != -1; } else { return InventoryUtil.hasInHotbar(Items.END_CRYSTAL); } @@ -283,13 +334,12 @@ public class CrystalAura extends Module { @EventListener private void onRenderWorld(Render3DEvent event) { - if (bp != null) { - if (outlines.getValue()) { - RenderUtil.drawBlockOutline(event.getMatrices(), bp, outlineColor.getValue(), outlineWidth.getFloatValue(), false); - } - if (fillings.getValue()) { - RenderUtil.drawBlockFilled(event.getMatrices(), bp, fillingColor.getValue(), false); - } + if (bp == null) return; + if (outlines.getValue()) { + RenderUtil.drawBlockOutline(event.getMatrices(), bp, outlineColor.getValue(), outlineWidth.getFloatValue(), false); + } + if (fillings.getValue()) { + RenderUtil.drawBlockFilled(event.getMatrices(), bp, fillingColor.getValue(), false); } } } \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/module/modules/combat/MaceKill.java b/src/main/java/me/retucio/sputnik/module/modules/combat/MaceKill.java index 6af0cf9..ac1b679 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/combat/MaceKill.java +++ b/src/main/java/me/retucio/sputnik/module/modules/combat/MaceKill.java @@ -7,14 +7,16 @@ import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.util.ChatUtil; -import net.minecraft.block.Blocks; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.Items; -import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; -import net.minecraft.network.packet.c2s.play.VehicleMoveC2SPacket; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; +import net.minecraft.core.BlockPos; +import net.minecraft.network.protocol.game.ServerboundAttackPacket; +import net.minecraft.network.protocol.game.ServerboundInteractPacket; +import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; +import net.minecraft.network.protocol.game.ServerboundMoveVehiclePacket; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.vehicle.VehicleEntity; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.phys.Vec3; /** @@ -54,22 +56,21 @@ public class MaceKill extends Module { @SuppressWarnings("ConstantConditions") private void onPacketSend(PacketEvent.Send event) { if (mc.player == null) return; - if (mc.player.getMainHandStack().getItem() == Items.MACE - && event.getPacket() instanceof PlayerInteractEntityC2SPacket packet - && packet.type.getType() == PlayerInteractEntityC2SPacket.InteractType.ATTACK) { + if (mc.player.getMainHandItem().getItem() == Items.MACE + && event.getPacket() instanceof ServerboundAttackPacket(int entityId)) { try { - if (mc.world.getEntityById(packet.entityId) instanceof LivingEntity target) { + if (mc.level.getEntity(entityId) instanceof LivingEntity target) { if (preventDeath.getValue() && (target.isBlocking() || target.isInvulnerable() - || target.isInCreativeMode() + || target.hasInfiniteMaterials() )) { return; } - Vec3d previouspos = mc.player.getEntityPos(); + Vec3 previouspos = mc.player.position(); int blocks = getMaxHeightAbovePlayer(); int packetsRequired = (int) (double) Math.abs(blocks / 10); @@ -78,76 +79,76 @@ public class MaceKill extends Module { packetsRequired = 1; } - BlockPos gap1 = (mc.player.getBlockPos().add(0, blocks, 0)); - BlockPos gap2 = (mc.player.getBlockPos().add(0, blocks + 1, 0)); + BlockPos gap1 = (mc.player.blockPosition().offset(0, blocks, 0)); + BlockPos gap2 = (mc.player.blockPosition().offset(0, blocks + 1, 0)); if (isSafeBlock(gap1) && isSafeBlock(gap2)) { if (blocks <= 22) { - if (mc.player.hasVehicle()) { + if (mc.player.isPassenger()) { for (int i = 0; i < 4; i++) { - mc.player.networkHandler.sendPacket(VehicleMoveC2SPacket.fromVehicle(mc.player.getVehicle())); + mc.player.connection.send(ServerboundMoveVehiclePacket.fromEntity(mc.player.getVehicle())); } double maxHeight = Math.min(mc.player.getVehicle().getY() + 22, mc.player.getVehicle().getY() + blocks); - mc.player.getVehicle().setPosition(mc.player.getVehicle().getX(), maxHeight + blocks, mc.player.getVehicle().getZ()); - mc.player.networkHandler.sendPacket(VehicleMoveC2SPacket.fromVehicle(mc.player.getVehicle())); + mc.player.getVehicle().setPos(mc.player.getVehicle().getX(), maxHeight + blocks, mc.player.getVehicle().getZ()); + mc.player.connection.send(ServerboundMoveVehiclePacket.fromEntity(mc.player.getVehicle())); - mc.player.getVehicle().setPosition(previouspos); - mc.player.networkHandler.sendPacket(VehicleMoveC2SPacket.fromVehicle(mc.player.getVehicle())); + mc.player.getVehicle().setPos(previouspos); + mc.player.connection.send(ServerboundMoveVehiclePacket.fromEntity(mc.player.getVehicle())); } else { for (int i = 0; i < 4; i++) { - mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false, mc.player.horizontalCollision)); + mc.player.connection.send(new ServerboundMovePlayerPacket.StatusOnly(false, mc.player.horizontalCollision)); } double maxHeight = Math.min(mc.player.getY() + 22, mc.player.getY() + blocks); - PlayerMoveC2SPacket movePacket = new PlayerMoveC2SPacket.PositionAndOnGround(mc.player.getX(), maxHeight, mc.player.getZ(), false, mc.player.horizontalCollision); - mc.player.networkHandler.sendPacket(movePacket); + ServerboundMovePlayerPacket movePacket = new ServerboundMovePlayerPacket.Pos(mc.player.getX(), maxHeight, mc.player.getZ(), false, mc.player.horizontalCollision); + mc.player.connection.send(movePacket); - PlayerMoveC2SPacket returnPacket = new PlayerMoveC2SPacket.PositionAndOnGround(previouspos.getX(), previouspos.getY(), previouspos.getZ(), false, mc.player.horizontalCollision); - mc.player.networkHandler.sendPacket(returnPacket); + ServerboundMovePlayerPacket returnPacket = new ServerboundMovePlayerPacket.Pos(previouspos.x(), previouspos.y(), previouspos.z(), false, mc.player.horizontalCollision); + mc.player.connection.send(returnPacket); } } else { - if (mc.player.hasVehicle()) { + if (mc.player.isPassenger()) { for (int packetNumber = 0; packetNumber < (packetsRequired - 1); packetNumber++) { - mc.player.networkHandler.sendPacket(VehicleMoveC2SPacket.fromVehicle(mc.player.getVehicle())); + mc.player.connection.send(ServerboundMoveVehiclePacket.fromEntity(mc.player.getVehicle())); } - mc.player.getVehicle().setPosition(mc.player.getVehicle().getX(), mc.player.getVehicle().getY() + blocks, mc.player.getVehicle().getZ()); + mc.player.getVehicle().setPos(mc.player.getVehicle().getX(), mc.player.getVehicle().getY() + blocks, mc.player.getVehicle().getZ()); double maxHeight = mc.player.getVehicle().getY() + blocks; - mc.player.getVehicle().setPosition(mc.player.getVehicle().getX(), maxHeight + blocks, mc.player.getVehicle().getZ()); - mc.player.networkHandler.sendPacket(VehicleMoveC2SPacket.fromVehicle(mc.player.getVehicle())); + mc.player.getVehicle().setPos(mc.player.getVehicle().getX(), maxHeight + blocks, mc.player.getVehicle().getZ()); + mc.player.connection.send(ServerboundMoveVehiclePacket.fromEntity(mc.player.getVehicle())); - mc.player.getVehicle().setPosition(previouspos); - mc.player.networkHandler.sendPacket(VehicleMoveC2SPacket.fromVehicle(mc.player.getVehicle())); + mc.player.getVehicle().setPos(previouspos); + mc.player.connection.send(ServerboundMoveVehiclePacket.fromEntity(mc.player.getVehicle())); } else { for (int packetNumber = 0; packetNumber < (packetsRequired - 1); packetNumber++) { - mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false, mc.player.horizontalCollision)); + mc.player.connection.send(new ServerboundMovePlayerPacket.StatusOnly(false, mc.player.horizontalCollision)); } - mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(mc.player.getX(), mc.player.getY() + blocks, mc.player.getZ(), false, mc.player.horizontalCollision)); - PlayerMoveC2SPacket movePacket = new PlayerMoveC2SPacket.PositionAndOnGround(mc.player.getX(), mc.player.getY() + blocks, mc.player.getZ(), false, mc.player.horizontalCollision); - mc.player.networkHandler.sendPacket(movePacket); + mc.player.connection.send(new ServerboundMovePlayerPacket.Pos(mc.player.getX(), mc.player.getY() + blocks, mc.player.getZ(), false, mc.player.horizontalCollision)); + ServerboundMovePlayerPacket movePacket = new ServerboundMovePlayerPacket.Pos(mc.player.getX(), mc.player.getY() + blocks, mc.player.getZ(), false, mc.player.horizontalCollision); + mc.player.connection.send(movePacket); } - if (mc.player.hasVehicle()) { - mc.player.getVehicle().setPosition(previouspos); - mc.player.networkHandler.sendPacket(VehicleMoveC2SPacket.fromVehicle(mc.player.getVehicle())); + if (mc.player.isPassenger()) { + mc.player.getVehicle().setPos(previouspos); + mc.player.connection.send(ServerboundMoveVehiclePacket.fromEntity(mc.player.getVehicle())); - mc.player.getVehicle().setPosition(previouspos); - mc.player.networkHandler.sendPacket(VehicleMoveC2SPacket.fromVehicle(mc.player.getVehicle())); + mc.player.getVehicle().setPos(previouspos); + mc.player.connection.send(ServerboundMoveVehiclePacket.fromEntity(mc.player.getVehicle())); } else { double maxHeight = mc.player.getY() + blocks; - PlayerMoveC2SPacket movePacket = new PlayerMoveC2SPacket.PositionAndOnGround(mc.player.getX(), maxHeight, mc.player.getZ(), false, mc.player.horizontalCollision); - PlayerMoveC2SPacket returnPacket = new PlayerMoveC2SPacket.PositionAndOnGround(previouspos.getX(), previouspos.getY(), previouspos.getZ(), false, mc.player.horizontalCollision); + ServerboundMovePlayerPacket movePacket = new ServerboundMovePlayerPacket.Pos(mc.player.getX(), maxHeight, mc.player.getZ(), false, mc.player.horizontalCollision); + ServerboundMovePlayerPacket returnPacket = new ServerboundMovePlayerPacket.Pos(previouspos.x(), previouspos.y(), previouspos.z(), false, mc.player.horizontalCollision); - mc.player.networkHandler.sendPacket(returnPacket); - mc.player.networkHandler.sendPacket(movePacket); - mc.player.networkHandler.sendPacket(returnPacket); + mc.player.connection.send(returnPacket); + mc.player.connection.send(movePacket); + mc.player.connection.send(returnPacket); } } } @@ -159,12 +160,12 @@ public class MaceKill extends Module { } private int getMaxHeightAbovePlayer() { - BlockPos playerPos = mc.player.getBlockPos(); + BlockPos playerPos = mc.player.blockPosition(); int maxHeight = playerPos.getY() + (max.getValue() ? 170 : height.getIntValue()); for (int i = maxHeight; i > playerPos.getY(); i--) { BlockPos isopenair1 = new BlockPos(playerPos.getX(), i, playerPos.getZ()); - BlockPos isopenair2 = isopenair1.up(1); + BlockPos isopenair2 = isopenair1.above(1); if (isSafeBlock(isopenair1) && isSafeBlock(isopenair2)) { return i - playerPos.getY(); @@ -175,8 +176,8 @@ public class MaceKill extends Module { } private boolean isSafeBlock(BlockPos pos) { - return mc.world.getBlockState(pos).isReplaceable() - && mc.world.getFluidState(pos).isEmpty() - && !mc.world.getBlockState(pos).isOf(Blocks.POWDER_SNOW); + return mc.level.getBlockState(pos).canBeReplaced() + && mc.level.getFluidState(pos).isEmpty() + && !mc.level.getBlockState(pos).is(Blocks.POWDER_SNOW); } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/combat/ProjectileTrajectories.java b/src/main/java/me/retucio/sputnik/module/modules/combat/ProjectileTrajectories.java index f01c46e..4e35620 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/combat/ProjectileTrajectories.java +++ b/src/main/java/me/retucio/sputnik/module/modules/combat/ProjectileTrajectories.java @@ -1,6 +1,7 @@ package me.retucio.sputnik.module.modules.combat; import com.github.retucio.neutrino.EventListener; +import com.mojang.blaze3d.vertex.PoseStack; import me.retucio.sputnik.event.render.Render3DEvent; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; @@ -10,23 +11,21 @@ import me.retucio.sputnik.util.Colors; import me.retucio.sputnik.util.misc.ProjectileInfo; import me.retucio.sputnik.util.render.RenderUtil; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.AreaEffectCloudEntity; -import net.minecraft.entity.Entity; -import net.minecraft.entity.ExperienceOrbEntity; -import net.minecraft.entity.ItemEntity; -import net.minecraft.entity.boss.dragon.EnderDragonEntity; -import net.minecraft.entity.projectile.ProjectileEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Arm; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.hit.HitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Box; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.RaycastContext; - +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.AreaEffectCloud; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.ExperienceOrb; +import net.minecraft.world.entity.HumanoidArm; +import net.minecraft.world.entity.boss.enderdragon.EnderDragon; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.projectile.Projectile; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; import org.joml.Vector3f; import java.awt.*; @@ -132,14 +131,14 @@ public class ProjectileTrajectories extends Module { renderProjectileTrajectory(event.getMatrices()); } - private void renderProjectileTrajectory(MatrixStack matrices) { - ItemStack mainHand = mc.player.getMainHandStack(); + private void renderProjectileTrajectory(PoseStack matrices) { + ItemStack mainHand = mc.player.getMainHandItem(); int handMultiplier = getHandMultiplier(); List projectileInfoList = ProjectileInfo.getItemsInfo(mainHand); if (projectileInfoList.isEmpty() && offhand.getValue()) { - ItemStack offHand = mc.player.getOffHandStack(); + ItemStack offHand = mc.player.getOffhandItem(); handMultiplier = -handMultiplier; projectileInfoList = ProjectileInfo.getItemsInfo(offHand); } @@ -149,13 +148,13 @@ public class ProjectileTrajectories extends Module { showProjectileTrajectory(matrices, projectileInfoList, handMultiplier); } - private void showProjectileTrajectory(MatrixStack matrices, List projectileInfoList, int handMultiplier) { - float tickProgress = mc.getRenderTickCounter().getTickProgress(false); - Vec3d eye = mc.player.getCameraPosVec(tickProgress); + private void showProjectileTrajectory(PoseStack matrices, List projectileInfoList, int handMultiplier) { + float tickProgress = mc.getDeltaTracker().getGameTimeDeltaPartialTick(false); + Vec3 eye = mc.player.getEyePosition(tickProgress); for (ProjectileInfo projectileInfo : projectileInfoList) { - Vec3d startPos = projectileInfo.position() == null ? mc.player.getEyePos() : projectileInfo.position(); - Vec3d handToEyeDelta = calculateHandToEyeDelta(projectileInfo.offset(), startPos, eye, handMultiplier, tickProgress); + Vec3 startPos = projectileInfo.position() == null ? mc.player.getEyePosition() : projectileInfo.position(); + Vec3 handToEyeDelta = calculateHandToEyeDelta(projectileInfo.offset(), startPos, eye, handMultiplier, tickProgress); PreviewImpact previewImpact = calculateTrajectory(startPos, projectileInfo); renderTargetEffects(matrices, previewImpact); @@ -163,7 +162,7 @@ public class ProjectileTrajectories extends Module { } } - private void renderTargetEffects(MatrixStack matrices, PreviewImpact previewImpact) { + private void renderTargetEffects(PoseStack matrices, PreviewImpact previewImpact) { if (previewImpact.impact != null && previewImpact.impact.getType() == HitResult.Type.BLOCK && previewImpact.impact instanceof BlockHitResult bhr) { BlockPos impactPos = bhr.getBlockPos(); if (fillingTargets.is(TrajectoryTargets.BLOCKS) || fillingTargets.is(TrajectoryTargets.BOTH)) { @@ -173,7 +172,7 @@ public class ProjectileTrajectories extends Module { RenderUtil.drawBlockOutline(matrices, impactPos, outlineColor.getValue(), outlineWidth.getFloatValue(), false); } } else if (previewImpact.entity != null) { - Box entityBoundingBox = previewImpact.entity.getBoundingBox().expand(previewImpact.entity.getTargetingMargin()); + AABB entityBoundingBox = previewImpact.entity.getBoundingBox().inflate(previewImpact.entity.getPickRadius()); if (fillingTargets.is(TrajectoryTargets.ENTITIES) || fillingTargets.is(TrajectoryTargets.BOTH)) { RenderUtil.drawFilledBox(matrices, entityBoundingBox, fillingColor.getValue(), false); } @@ -183,31 +182,31 @@ public class ProjectileTrajectories extends Module { } } - private Vec3d calculateHandToEyeDelta(Vec3d offset, Vec3d startPos, Vec3d eye, int handMultiplier, float tickProgress) { - if (mc.gameRenderer.getCamera().isThirdPerson()) { - offset = offset.multiply(0); + private Vec3 calculateHandToEyeDelta(Vec3 offset, Vec3 startPos, Vec3 eye, int handMultiplier, float tickProgress) { + if (mc.gameRenderer.getMainCamera().isDetached()) { + offset = offset.scale(0); } - float yaw = (float) Math.toRadians(-mc.player.getYaw(tickProgress)); - float pitch = (float) Math.toRadians(-mc.player.getPitch(tickProgress)); + float yaw = (float) Math.toRadians(-mc.player.getYRot(tickProgress)); + float pitch = (float) Math.toRadians(-mc.player.getXRot(tickProgress)); - Vec3d forward = mc.player.getRotationVec(tickProgress); - Vec3d up = new Vec3d(-Math.sin(pitch) * Math.sin(yaw), Math.cos(pitch), -Math.sin(pitch) * Math.cos(yaw)).normalize(); - Vec3d right = forward.crossProduct(up).normalize(); + Vec3 forward = mc.player.getViewVector(tickProgress); + Vec3 up = new Vec3(-Math.sin(pitch) * Math.sin(yaw), Math.cos(pitch), -Math.sin(pitch) * Math.cos(yaw)).normalize(); + Vec3 right = forward.cross(up).normalize(); - Vec3d offsetDelta = right.multiply(handMultiplier * offset.x) - .add(up.multiply(offset.y)) - .add(forward.multiply(offset.z)); + Vec3 offsetDelta = right.scale(handMultiplier * offset.x) + .add(up.scale(offset.y)) + .add(forward.scale(offset.z)); return offsetDelta.add(eye.subtract(startPos)); } - private void renderTrajectory(MatrixStack matrices, List trajectoryPoints, Vec3d handToEyeDelta, boolean hasHit) { + private void renderTrajectory(PoseStack matrices, List trajectoryPoints, Vec3 handToEyeDelta, boolean hasHit) { if (trajectoryPoints.isEmpty()) return; - Vec3d cameraPos = mc.gameRenderer.getCamera().getCameraPos(); + Vec3 cameraPos = mc.gameRenderer.getMainCamera().position(); - matrices.push(); + matrices.pushPose(); matrices.translate(-cameraPos.x, -cameraPos.y, -cameraPos.z); renderTrajectorySegments(matrices, trajectoryPoints, handToEyeDelta); @@ -216,27 +215,27 @@ public class ProjectileTrajectories extends Module { renderImpactPoint(matrices, trajectoryPoints.getLast()); } - matrices.pop(); + matrices.popPose(); } - private void renderTrajectorySegments(MatrixStack matrices, List points, Vec3d handToEyeDelta) { + private void renderTrajectorySegments(PoseStack matrices, List points, Vec3 handToEyeDelta) { int pointCount = points.size(); for (int i = 0; i < pointCount - 1; i++) { double lerpFactor = (pointCount - i) / (double) pointCount; double nextLerpFactor = (pointCount - (i + 1)) / (double) pointCount; - Vec3d lerpedDelta = handToEyeDelta.multiply(lerpFactor); - Vec3d nextLerpedDelta = handToEyeDelta.multiply(nextLerpFactor); + Vec3 lerpedDelta = handToEyeDelta.scale(lerpFactor); + Vec3 nextLerpedDelta = handToEyeDelta.scale(nextLerpFactor); - Vec3d start = points.get(i).add(lerpedDelta); - Vec3d end = points.get(i + 1).add(nextLerpedDelta); - Vec3d direction = end.subtract(start); + Vec3 start = points.get(i).add(lerpedDelta); + Vec3 end = points.get(i + 1).add(nextLerpedDelta); + Vec3 direction = end.subtract(start); if (trajStyle.is(TrajectoryStyle.DASHED)) { - direction = direction.multiply(0.5); + direction = direction.scale(0.5); } else if (trajStyle.is(TrajectoryStyle.DOTTED)) { - direction = direction.multiply(0.15); + direction = direction.scale(0.15); } Vector3f startVector = new Vector3f((float) start.x, (float) start.y, (float) start.z); @@ -244,27 +243,27 @@ public class ProjectileTrajectories extends Module { } } - private void renderImpactPoint(MatrixStack matrices, Vec3d impactPos) { + private void renderImpactPoint(PoseStack matrices, Vec3 impactPos) { double radius = 0.1; double diameter = 2 * radius; Vector3f xStart = new Vector3f((float) (impactPos.x - radius), (float) impactPos.y, (float) impactPos.z); - RenderUtil.drawVector(matrices, xStart, new Vec3d(diameter, 0, 0), trajColor.getValue(), trajWidth.getFloatValue()); + RenderUtil.drawVector(matrices, xStart, new Vec3(diameter, 0, 0), trajColor.getValue(), trajWidth.getFloatValue()); Vector3f yStart = new Vector3f((float) impactPos.x, (float) (impactPos.y - radius), (float) impactPos.z); - RenderUtil.drawVector(matrices, yStart, new Vec3d(0, diameter, 0), trajColor.getValue(), trajWidth.getFloatValue()); + RenderUtil.drawVector(matrices, yStart, new Vec3(0, diameter, 0), trajColor.getValue(), trajWidth.getFloatValue()); Vector3f zStart = new Vector3f((float) impactPos.x, (float) impactPos.y, (float) (impactPos.z - radius)); - RenderUtil.drawVector(matrices, zStart, new Vec3d(0, 0, diameter), trajColor.getValue(), trajWidth.getFloatValue()); + RenderUtil.drawVector(matrices, zStart, new Vec3(0, 0, diameter), trajColor.getValue(), trajWidth.getFloatValue()); } - private PreviewImpact calculateTrajectory(Vec3d startPos, ProjectileInfo projectileInfo) { - Vec3d currentPos = startPos; - Vec3d prevPos = startPos; - Vec3d playerVel = mc.player.isOnGround() ? new Vec3d(mc.player.getVelocity().x, 0, mc.player.getVelocity().z) : mc.player.getVelocity(); - Vec3d velocity = projectileInfo.initialVelocity().add(playerVel); + private PreviewImpact calculateTrajectory(Vec3 startPos, ProjectileInfo projectileInfo) { + Vec3 currentPos = startPos; + Vec3 prevPos = startPos; + Vec3 playerVel = mc.player.onGround() ? new Vec3(mc.player.getDeltaMovement().x, 0, mc.player.getDeltaMovement().z) : mc.player.getDeltaMovement(); + Vec3 velocity = projectileInfo.initialVelocity().add(playerVel); - List trajectoryPoints = new ArrayList<>(); + List trajectoryPoints = new ArrayList<>(); double drag = projectileInfo.drag(); double gravity = projectileInfo.gravity(); @@ -275,12 +274,12 @@ public class ProjectileTrajectories extends Module { for (int order : projectileInfo.order()) { switch (order) { case 0 -> currentPos = currentPos.add(velocity); - case 1 -> velocity = velocity.multiply(drag); + case 1 -> velocity = velocity.scale(drag); case 2 -> velocity = velocity.subtract(0, gravity, 0); } } - Box trajectorySegment = new Box(prevPos, currentPos).expand(1); + AABB trajectorySegment = new AABB(prevPos, currentPos).inflate(1); Optional hitEntity = findHitEntity(prevPos, currentPos, trajectorySegment); @@ -296,7 +295,7 @@ public class ProjectileTrajectories extends Module { return new PreviewImpact(currentPos, blockHit, hitEntity.orElse(null), true, trajectoryPoints); } - if (currentPos.y < mc.world.getBottomY() - 20) { + if (currentPos.y < mc.level.getMinY() - 20) { break; } @@ -306,18 +305,18 @@ public class ProjectileTrajectories extends Module { return new PreviewImpact(currentPos, null, null, false, trajectoryPoints); } - private Optional findHitEntity(Vec3d start, Vec3d end, Box searchBox) { - List entities = mc.world.getEntitiesByClass(Entity.class, searchBox, this::isValidTarget); + private Optional findHitEntity(Vec3 start, Vec3 end, AABB searchBox) { + List entities = mc.level.getEntitiesOfClass(Entity.class, searchBox, this::isValidTarget); Entity closest = null; double closestDistance = Double.MAX_VALUE; for (Entity entity : entities) { - Box entityBox = entity.getBoundingBox().expand(entity.getTargetingMargin()); - Optional raycastHit = entityBox.raycast(start, end); + AABB entityBox = entity.getBoundingBox().inflate(entity.getPickRadius()); + Optional raycastHit = entityBox.clip(start, end); if (raycastHit.isPresent()) { - double distance = start.squaredDistanceTo(raycastHit.get()); + double distance = start.distanceToSqr(raycastHit.get()); if (distance < closestDistance) { closest = entity; closestDistance = distance; @@ -331,46 +330,46 @@ public class ProjectileTrajectories extends Module { private boolean isValidTarget(Entity entity) { return !entity.isSpectator() && entity.isAlive() - && !(entity instanceof ProjectileEntity) + && !(entity instanceof Projectile) && !(entity instanceof ItemEntity) - && !(entity instanceof ExperienceOrbEntity) - && !(entity instanceof EnderDragonEntity) - && !(entity instanceof ClientPlayerEntity) - && !(entity instanceof AreaEffectCloudEntity); + && !(entity instanceof ExperienceOrb) + && !(entity instanceof EnderDragon) + && !(entity instanceof LocalPlayer) + && !(entity instanceof AreaEffectCloud); } - private HitResult performRaycast(Vec3d start, Vec3d end) { - return mc.world.raycast( - new RaycastContext( + private HitResult performRaycast(Vec3 start, Vec3 end) { + return mc.level.clip( + new ClipContext( start, end, - RaycastContext.ShapeType.COLLIDER, - RaycastContext.FluidHandling.NONE, + ClipContext.Block.COLLIDER, + ClipContext.Fluid.NONE, mc.player ) ); } - private boolean isInWater(Vec3d start, Vec3d end) { - HitResult waterHit = mc.world.raycast( - new RaycastContext(start, end, RaycastContext.ShapeType.COLLIDER, - RaycastContext.FluidHandling.WATER, mc.player) + private boolean isInWater(Vec3 start, Vec3 end) { + HitResult waterHit = mc.level.clip( + new ClipContext(start, end, ClipContext.Block.COLLIDER, + ClipContext.Fluid.WATER, mc.player) ); return waterHit.getType() != HitResult.Type.MISS; } - private boolean handleImpact(HitResult blockHit, Optional hitEntity, Vec3d prevPos, - Vec3d currentPos, List trajectoryPoints) { + private boolean handleImpact(HitResult blockHit, Optional hitEntity, Vec3 prevPos, + Vec3 currentPos, List trajectoryPoints) { double blockDistance = blockHit.getType() != HitResult.Type.MISS ? - prevPos.squaredDistanceTo(blockHit.getPos()) : Double.MAX_VALUE; + prevPos.distanceToSqr(blockHit.getLocation()) : Double.MAX_VALUE; - double entityDistance = hitEntity.map(entity -> prevPos.squaredDistanceTo(findEntityHitPos(prevPos, currentPos, entity))).orElse(Double.MAX_VALUE); + double entityDistance = hitEntity.map(entity -> prevPos.distanceToSqr(findEntityHitPos(prevPos, currentPos, entity))).orElse(Double.MAX_VALUE); if (blockDistance < entityDistance && blockHit.getType() != HitResult.Type.MISS) { - trajectoryPoints.add(blockHit.getPos()); + trajectoryPoints.add(blockHit.getLocation()); return true; } else if (hitEntity.isPresent()) { - Vec3d entityHitPos = findEntityHitPos(prevPos, currentPos, hitEntity.get()); + Vec3 entityHitPos = findEntityHitPos(prevPos, currentPos, hitEntity.get()); trajectoryPoints.add(entityHitPos); return true; } @@ -378,22 +377,22 @@ public class ProjectileTrajectories extends Module { return false; } - private Vec3d findEntityHitPos(Vec3d start, Vec3d end, Entity entity) { - Box entityBox = entity.getBoundingBox().expand(entity.getTargetingMargin()); - return entityBox.raycast(start, end).orElse(end); + private Vec3 findEntityHitPos(Vec3 start, Vec3 end, Entity entity) { + AABB entityBox = entity.getBoundingBox().inflate(entity.getPickRadius()); + return entityBox.clip(start, end).orElse(end); } private int getHandMultiplier() { - return mc.options.getMainArm().getValue() == Arm.RIGHT ? 1 : -1; + return mc.options.mainHand().get() == HumanoidArm.RIGHT ? 1 : -1; } public record PreviewImpact( - Vec3d pos, + Vec3 pos, HitResult impact, Entity entity, boolean hit, - List points + List points ) {} public enum TrajectoryStyle { diff --git a/src/main/java/me/retucio/sputnik/module/modules/combat/SpearKill.java b/src/main/java/me/retucio/sputnik/module/modules/combat/SpearKill.java index 47d7b5b..e10223b 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/combat/SpearKill.java +++ b/src/main/java/me/retucio/sputnik/module/modules/combat/SpearKill.java @@ -4,13 +4,13 @@ import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.registry.tag.ItemTags; -import net.minecraft.util.hit.HitResult; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.RaycastContext; +import net.minecraft.tags.ItemTags; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; import java.util.Comparator; import java.util.List; @@ -49,33 +49,33 @@ public class SpearKill extends Module { @Override public void onTick() { - if (mc.player == null || mc.world == null) return; + if (mc.player == null || mc.level == null) return; - if (isHoldingSpear() && mc.options.useKey.isPressed()) { + if (isHoldingSpear() && mc.options.keyUse.isDown()) { heldTicks++; if (crosshairTarget == null) crosshairTarget = getTarget(); if (crosshairTarget == null) return; if (!crosshairTarget.isAlive()) return; if (!(crosshairTarget instanceof LivingEntity)) return; - if (onlyPlayers.getValue() && !(crosshairTarget instanceof PlayerEntity)) return; + if (onlyPlayers.getValue() && !(crosshairTarget instanceof Player)) return; - Vec3d playerPos = mc.player.getEyePos(); - Vec3d targetPos = crosshairTarget.getBoundingBox().getCenter(); - Vec3d toTarget = targetPos.subtract(playerPos).normalize(); + Vec3 playerPos = mc.player.getEyePosition(); + Vec3 targetPos = crosshairTarget.getBoundingBox().getCenter(); + Vec3 toTarget = targetPos.subtract(playerPos).normalize(); float yaw = (float) (Math.toDegrees(Math.atan2(toTarget.z, toTarget.x)) - 90.0); float pitch = (float) -Math.toDegrees(Math.asin(toTarget.y)); - mc.player.setYaw(yaw); - mc.player.setHeadYaw(yaw); - mc.player.setPitch(pitch); + mc.player.setYRot(yaw); + mc.player.setYHeadRot(yaw); + mc.player.setXRot(pitch); if (heldTicks >= 10) { double lungeSpeed = speed.getValue(); - Vec3d viewDir = Vec3d.fromPolar(mc.player.getPitch(), mc.player.getYaw()); + Vec3 viewDir = Vec3.directionFromRotation(mc.player.getXRot(), mc.player.getYRot()); mc.player.setSprinting(true); - mc.player.setVelocity(viewDir.multiply(lungeSpeed)); + mc.player.setDeltaMovement(viewDir.scale(lungeSpeed)); } } else { heldTicks = 0; @@ -85,38 +85,38 @@ public class SpearKill extends Module { private boolean isHoldingSpear() { return mc.player.isHolding( - stack -> stack.streamTags().anyMatch( + stack -> stack.tags().anyMatch( tag -> tag.equals(ItemTags.SPEARS) ) ); } private Entity getTarget() { - if (mc.player == null || mc.world == null) return null; + if (mc.player == null || mc.level == null) return null; double maxRange = 256; - Vec3d eyePos = mc.player.getEyePos(); - Vec3d lookVec = mc.player.getRotationVec(1f); + Vec3 eyePos = mc.player.getEyePosition(); + Vec3 lookVec = mc.player.getViewVector(1f); - HitResult blockHit = mc.world.raycast(new RaycastContext(eyePos, - eyePos.add(lookVec.multiply(maxRange)), RaycastContext.ShapeType.COLLIDER, - RaycastContext.FluidHandling.NONE, mc.player)); + HitResult blockHit = mc.level.clip(new ClipContext(eyePos, + eyePos.add(lookVec.scale(maxRange)), ClipContext.Block.COLLIDER, + ClipContext.Fluid.NONE, mc.player)); double rayLength = blockHit.getType() == HitResult.Type.MISS ? maxRange : - eyePos.distanceTo(blockHit.getPos()); + eyePos.distanceTo(blockHit.getLocation()); - List candidates = mc.world.getOtherEntities(mc.player, - mc.player.getBoundingBox().stretch(lookVec.multiply(rayLength)), + List candidates = mc.level.getEntities(mc.player, + mc.player.getBoundingBox().expandTowards(lookVec.scale(rayLength)), e -> e instanceof LivingEntity && e.isAlive() && e != mc.player); candidates.sort(Comparator.comparingDouble(e -> - eyePos.squaredDistanceTo(e.getBoundingBox().getCenter()))); + eyePos.distanceToSqr(e.getBoundingBox().getCenter()))); double coneAngle = 0.999; for (Entity e : candidates) { if (eyePos.distanceTo(e.getBoundingBox().getCenter()) > rayLength) break; - Vec3d toEntity = e.getBoundingBox().getCenter().subtract(eyePos).normalize(); - if (lookVec.dotProduct(toEntity) > coneAngle && - (!onlyPlayers.getValue() || e instanceof PlayerEntity)) { + Vec3 toEntity = e.getBoundingBox().getCenter().subtract(eyePos).normalize(); + if (lookVec.dot(toEntity) > coneAngle && + (!onlyPlayers.getValue() || e instanceof Player)) { return e; } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/inventory/BundleDupe.java b/src/main/java/me/retucio/sputnik/module/modules/inventory/BundleDupe.java index 58678e3..9fe974c 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/inventory/BundleDupe.java +++ b/src/main/java/me/retucio/sputnik/module/modules/inventory/BundleDupe.java @@ -1,25 +1,24 @@ package me.retucio.sputnik.module.modules.inventory; import com.github.retucio.neutrino.EventListener; -import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; import me.retucio.sputnik.event.network.DisconnectEvent; import me.retucio.sputnik.event.network.PacketEvent; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.util.ChatUtil; -import net.minecraft.network.packet.c2s.common.KeepAliveC2SPacket; -import net.minecraft.network.packet.c2s.play.ClickSlotC2SPacket; -import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; -import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket; -import net.minecraft.network.packet.c2s.play.PlayerInteractItemC2SPacket; -import net.minecraft.screen.slot.SlotActionType; -import net.minecraft.screen.sync.ItemStackHash; -import net.minecraft.util.Hand; + +import net.minecraft.network.HashedStack; +import net.minecraft.network.protocol.common.ServerboundKeepAlivePacket; +import net.minecraft.network.protocol.game.*; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.inventory.ContainerInput; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; + // versión simplificada del módulo de Numberz y Nummernuts, del mod de DupersUnited (https://discord.gg/dupes) public class BundleDupe extends Module { @@ -75,11 +74,11 @@ public class BundleDupe extends Module { @EventListener private void onPacketSend(PacketEvent.Send event) { - if (this.dupeActivated && event.getPacket() instanceof PlayerActionC2SPacket) { + if (this.dupeActivated && event.getPacket() instanceof ServerboundPlayerActionPacket) { event.cancel(); } - if (event.getPacket() instanceof KeepAliveC2SPacket) { + if (event.getPacket() instanceof ServerboundKeepAlivePacket) { if (waitingForKeepAlive) { waitingForKeepAlive = false; cancelKeepAlive = true; @@ -98,11 +97,11 @@ public class BundleDupe extends Module { } private void dupe() { - if (mc.player == null || mc.getNetworkHandler() == null) return; + if (mc.player == null || mc.getConnection() == null) return; sendClickSlots(); sendInteractItem(); - mc.getNetworkHandler().sendPacket(PlayerInteractEntityC2SPacket.attack(mc.player, false)); + mc.getConnection().send(new ServerboundAttackPacket(mc.player.getId())); sendClickSlots(); delayedExecutor.schedule(() -> { @@ -113,18 +112,23 @@ public class BundleDupe extends Module { } private void sendInteractItem() { - if (mc.player == null || mc.getNetworkHandler() == null) return; + if (mc.player == null || mc.getConnection() == null) return; - PlayerInteractItemC2SPacket packet = new PlayerInteractItemC2SPacket(Hand.MAIN_HAND, 0, mc.player.getYaw(), this.mc.player.getPitch()); - mc.getNetworkHandler().sendPacket(packet); + ServerboundUseItemPacket packet = new ServerboundUseItemPacket(InteractionHand.MAIN_HAND, 0, mc.player.getYRot(), this.mc.player.getXRot()); + mc.getConnection().send(packet); } private void sendClickSlots() { - if (mc.player == null || mc.getNetworkHandler() == null) return; + if (mc.player == null || mc.getConnection() == null) return; for (int i = 0; i < this.clickslotPackets.getIntValue(); i++) { - ClickSlotC2SPacket packet = new ClickSlotC2SPacket(0, 0, (short) 0, (byte) 0, SlotActionType.PICKUP, new Int2ObjectArrayMap<>(), ItemStackHash.EMPTY); - this.mc.getNetworkHandler().sendPacket(packet); + ServerboundContainerClickPacket packet = new ServerboundContainerClickPacket( + 0, 0, (short) 0, (byte) 0, + ContainerInput.PICKUP, + new Int2ObjectArrayMap<>(), + HashedStack.EMPTY + ); + this.mc.getConnection().send(packet); } ChatUtil.info(clickslotPackets.getIntValue() + " paquetes ClickSlot enviados"); diff --git a/src/main/java/me/retucio/sputnik/module/modules/inventory/CreativeInventoryHotbarKeybinds.java b/src/main/java/me/retucio/sputnik/module/modules/inventory/CreativeInventoryHotbarKeybinds.java index 723e000..9701dbd 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/inventory/CreativeInventoryHotbarKeybinds.java +++ b/src/main/java/me/retucio/sputnik/module/modules/inventory/CreativeInventoryHotbarKeybinds.java @@ -1,12 +1,12 @@ package me.retucio.sputnik.module.modules.inventory; -import me.retucio.sputnik.mixin.mixins.screen.CreativeInventoryScreenMixin; +import me.retucio.sputnik.mixin.mixins.screen.CreativeModeInventoryScreenMixin; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; /** continúa en - * @see CreativeInventoryScreenMixin + * @see CreativeModeInventoryScreenMixin * * @author retucio */ diff --git a/src/main/java/me/retucio/sputnik/module/modules/inventory/InventoryPlus.java b/src/main/java/me/retucio/sputnik/module/modules/inventory/InventoryPlus.java index f4ba6ea..981ab19 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/inventory/InventoryPlus.java +++ b/src/main/java/me/retucio/sputnik/module/modules/inventory/InventoryPlus.java @@ -4,16 +4,17 @@ import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.EventListener; import me.retucio.sputnik.event.input.KeyEvent; import me.retucio.sputnik.event.input.MouseClickEvent; -import me.retucio.sputnik.mixin.accessors.HandledScreenAccessor; +import me.retucio.sputnik.mixin.accessors.AbstractContainerScreenAccessor; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.KeySetting; import me.retucio.sputnik.util.InventoryUtil; import me.retucio.sputnik.util.KeyUtil; -import net.minecraft.client.gui.screen.ingame.HandledScreen; -import net.minecraft.screen.slot.Slot; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.world.inventory.Slot; import org.lwjgl.glfw.GLFW; + /** * @author retucio */ @@ -43,12 +44,12 @@ public class InventoryPlus extends Module { } private void processInput(int inputCode, Event event) { - if (!(mc.currentScreen instanceof HandledScreen screen) || mc.player == null) return; + if (!(mc.screen instanceof AbstractContainerScreen screen) || mc.player == null) return; - Slot focusedSlot = ((HandledScreenAccessor) screen).getFocusedSlot(); + Slot focusedSlot = ((AbstractContainerScreenAccessor) screen).getHoveredSlot(); if (focusedSlot == null) return; - int containerSlot = focusedSlot.id; + int containerSlot = focusedSlot.index; int hotbarKeyIndex = InventoryUtil.getSlotNumberFromKey(inputCode); if (hotbarKeyIndex == -1) return; @@ -68,7 +69,7 @@ public class InventoryPlus extends Module { } } - private void swapWithRow(HandledScreen screen, int containerSlot, int column, int rowOffset) { + private void swapWithRow(AbstractContainerScreen screen, int containerSlot, int column, int rowOffset) { int targetContainerSlot = InventoryUtil.calculateTargetSlot(screen, containerSlot, column, rowOffset); if (targetContainerSlot != -1) { InventoryUtil.swapSlots(containerSlot, targetContainerSlot, screen); diff --git a/src/main/java/me/retucio/sputnik/module/modules/inventory/Offhand.java b/src/main/java/me/retucio/sputnik/module/modules/inventory/Offhand.java index 52acbc6..03e7d7a 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/inventory/Offhand.java +++ b/src/main/java/me/retucio/sputnik/module/modules/inventory/Offhand.java @@ -6,13 +6,13 @@ import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.module.setting.settings.OptionSetting; import me.retucio.sputnik.util.Lists; -import net.minecraft.item.Item; -import net.minecraft.item.Items; -import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; -import net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket; -import net.minecraft.screen.slot.SlotActionType; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.network.protocol.game.ClientboundSetHeldSlotPacket; +import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket; +import net.minecraft.world.inventory.ContainerInput; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; /** * @author retucio @@ -48,33 +48,33 @@ public class Offhand extends Module { @Override public void onTick() { - if (mc.player == null || mc.interactionManager == null) return; + if (mc.player == null || mc.gameMode == null) return; - if (holdingItem && mc.player.getOffHandStack().getItem() != item.getValue()) + if (holdingItem && mc.player.getOffhandItem().getItem() != item.getValue()) delay = Math.max(delaySetting.getIntValue(), delay); - holdingItem = mc.player.getOffHandStack().getItem() == item.getValue(); + holdingItem = mc.player.getOffhandItem().getItem() == item.getValue(); if (delay > 0) { delay--; return; } - if (holdingItem || (!mc.player.getOffHandStack().isEmpty() + if (holdingItem || (!mc.player.getOffhandItem().isEmpty() && !override.getValue())) return; - if (mc.player.playerScreenHandler == mc.player.currentScreenHandler) { + if (mc.player.containerMenu == mc.player.inventoryMenu) { for (int i = 9; i < 45; i++) { - if (mc.player.getInventory().getStack(i >= 36 ? i - 36 : i).getItem() == item.getValue()) { - boolean itemInOffhand = !mc.player.getOffHandStack().isEmpty(); + if (mc.player.getInventory().getItem(i >= 36 ? i - 36 : i).getItem() == item.getValue()) { + boolean itemInOffhand = !mc.player.getOffhandItem().isEmpty(); - mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, i, 0, SlotActionType.PICKUP, mc.player); - mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, 45, 0, SlotActionType.PICKUP, mc.player); + mc.gameMode.handleContainerInput(mc.player.containerMenu.containerId, i, 0, ContainerInput.PICKUP, mc.player); + mc.gameMode.handleContainerInput(mc.player.containerMenu.containerId, 45, 0, ContainerInput.PICKUP, mc.player); if (itemInOffhand) - mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, i, 0, SlotActionType.PICKUP, mc.player); + mc.gameMode.handleContainerInput(mc.player.containerMenu.containerId, i, 0, ContainerInput.PICKUP, mc.player); delay = delaySetting.getIntValue(); return; @@ -82,15 +82,15 @@ public class Offhand extends Module { } } else { for (int i = 0; i < 9; i++) { - if (mc.player.getInventory().getStack(i).getItem() == item.getValue()) { + if (mc.player.getInventory().getItem(i).getItem() == item.getValue()) { if (i != mc.player.getInventory().getSelectedSlot()) { mc.player.getInventory().setSelectedSlot(i); - mc.player.networkHandler.sendPacket(new UpdateSelectedSlotC2SPacket(i)); + mc.player.connection.send(new ClientboundSetHeldSlotPacket(i)); } - mc.player.networkHandler.sendPacket(new PlayerActionC2SPacket( - PlayerActionC2SPacket.Action.SWAP_ITEM_WITH_OFFHAND, - BlockPos.ORIGIN, + mc.player.connection.send(new ServerboundPlayerActionPacket( + ServerboundPlayerActionPacket.Action.SWAP_ITEM_WITH_OFFHAND, + BlockPos.ZERO, Direction.DOWN)); delay = delaySetting.getIntValue(); return; diff --git a/src/main/java/me/retucio/sputnik/module/modules/inventory/PortalGUI.java b/src/main/java/me/retucio/sputnik/module/modules/inventory/PortalGUI.java index 82d5348..f042666 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/inventory/PortalGUI.java +++ b/src/main/java/me/retucio/sputnik/module/modules/inventory/PortalGUI.java @@ -1,11 +1,11 @@ package me.retucio.sputnik.module.modules.inventory; -import me.retucio.sputnik.mixin.mixins.player.ClientPlayerEntityMixin; +import me.retucio.sputnik.mixin.mixins.player.LocalPlayerMixin; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; /** continúa en: - * @see ClientPlayerEntityMixin + * @see LocalPlayerMixin */ public class PortalGUI extends Module { diff --git a/src/main/java/me/retucio/sputnik/module/modules/inventory/Replenish.java b/src/main/java/me/retucio/sputnik/module/modules/inventory/Replenish.java index ba69e22..0aa8660 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/inventory/Replenish.java +++ b/src/main/java/me/retucio/sputnik/module/modules/inventory/Replenish.java @@ -10,11 +10,11 @@ import me.retucio.sputnik.module.setting.settings.ListSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.util.InventoryUtil; import me.retucio.sputnik.util.Lists; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.screen.PlayerScreenHandler; -import net.minecraft.util.Hand; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.InventoryMenu; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; import java.util.*; import java.util.concurrent.ConcurrentHashMap; @@ -91,16 +91,16 @@ public class Replenish extends Module { private void onUseItem(UseItemEvent event) { if (mc.player == null) return; - Hand hand = event.getHand(); + InteractionHand hand = event.getHand(); int usedSlot = getSlotFromHand(hand); if (usedSlot == -1) return; - ItemStack usedStack = hand == Hand.MAIN_HAND ? mc.player.getMainHandStack() : mc.player.getOffHandStack(); + ItemStack usedStack = hand == InteractionHand.MAIN_HAND ? mc.player.getMainHandItem() : mc.player.getOffhandItem(); if (usedStack.isEmpty()) return; if (excludedItems.isEnabled(usedStack.getItem())) return; - if (!unstackable.getValue() && usedStack.getMaxCount() == 1) return; - if (!offhand.getValue() && hand == Hand.OFF_HAND) return; + if (!unstackable.getValue() && usedStack.getMaxStackSize() == 1) return; + if (!offhand.getValue() && hand == InteractionHand.OFF_HAND) return; pendingTasks.remove(usedSlot); pendingTasks.put(usedSlot, new ReplenishTask(usedSlot, usedStack.getItem(), tickDelay.getIntValue())); @@ -113,36 +113,31 @@ public class Replenish extends Module { private void executeReplenish(int slot, Item item) { if (mc.player == null) return; - PlayerInventory inv = mc.player.getInventory(); + Inventory inv = mc.player.getInventory(); - // Get current stack in the slot - ItemStack currentStack = inv.getStack(slot); - if (currentStack.isEmpty() || !currentStack.isOf(item)) { - return; // item changed or slot empty – abort + ItemStack currentStack = inv.getItem(slot); + if (currentStack.isEmpty() || !currentStack.is(item)) { + return; } - // Check threshold if (currentStack.getCount() > minCount.getIntValue()) { - return; // still above threshold + return; } - // Find another stack of the same item in the inventory (excluding the used slot and possibly offhand) List excludeSlots = new ArrayList<>(); excludeSlots.add(slot); if (!offhand.getValue()) { excludeSlots.add(InventoryUtil.OFFHAND_SLOT); } - PlayerScreenHandler handler = mc.player.playerScreenHandler; + InventoryMenu handler = mc.player.inventoryMenu; int sourceContainerSlot = -1; - // Iterate over all player inventory slots (0-40) for (int playerIndex = 0; playerIndex <= 40; playerIndex++) { if (excludeSlots.contains(playerIndex)) continue; - ItemStack stack = inv.getStack(playerIndex); - if (!stack.isEmpty() && stack.isOf(item) && ItemStack.areItemsAndComponentsEqual(stack, currentStack)) { - // Found a match, convert to container slot + ItemStack stack = inv.getItem(playerIndex); + if (!stack.isEmpty() && stack.is(item) && ItemStack.isSameItemSameComponents(stack, currentStack)) { int containerSlot = InventoryUtil.getContainerSlotByPlayerIndex(handler, playerIndex); if (containerSlot != -1) { sourceContainerSlot = containerSlot; @@ -151,18 +146,17 @@ public class Replenish extends Module { } } - if (sourceContainerSlot == -1) return; // no source found + if (sourceContainerSlot == -1) return; - // Target container slot is the used slot int targetContainerSlot = InventoryUtil.getContainerSlotByPlayerIndex(handler, slot); if (targetContainerSlot == -1) return; InventoryUtil.swapSlots(sourceContainerSlot, targetContainerSlot, handler); } - private int getSlotFromHand(Hand hand) { + private int getSlotFromHand(InteractionHand hand) { if (mc.player == null) return -1; - if (hand == Hand.MAIN_HAND) { + if (hand == InteractionHand.MAIN_HAND) { return mc.player.getInventory().getSelectedSlot(); } else { return InventoryUtil.OFFHAND_SLOT; // 40 diff --git a/src/main/java/me/retucio/sputnik/module/modules/inventory/ShulkerPeek.java b/src/main/java/me/retucio/sputnik/module/modules/inventory/ShulkerPeek.java index 5dc996f..1afb885 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/inventory/ShulkerPeek.java +++ b/src/main/java/me/retucio/sputnik/module/modules/inventory/ShulkerPeek.java @@ -2,7 +2,7 @@ package me.retucio.sputnik.module.modules.inventory; import com.github.retucio.neutrino.EventListener; import me.retucio.sputnik.event.input.KeyEvent; -import me.retucio.sputnik.mixin.accessors.HandledScreenAccessor; +import me.retucio.sputnik.mixin.accessors.AbstractContainerScreenAccessor; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.BooleanSetting; @@ -10,17 +10,16 @@ import me.retucio.sputnik.module.setting.settings.KeySetting; import me.retucio.sputnik.ui.screen.PreviewScreen; import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.Colors; - import me.retucio.sputnik.util.InventoryUtil; -import net.minecraft.block.ShulkerBoxBlock; -import net.minecraft.client.gui.screen.ingame.HandledScreen; -import net.minecraft.component.DataComponentTypes; -import net.minecraft.component.type.ContainerComponent; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.core.component.DataComponents; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.component.ItemContainerContents; +import net.minecraft.world.level.block.ShulkerBoxBlock; import org.lwjgl.glfw.GLFW; import java.awt.*; @@ -70,7 +69,7 @@ public class ShulkerPeek extends Module { } if (event.getAction() == GLFW.GLFW_REPEAT) { - if (mc.currentScreen instanceof PreviewScreen preview) { + if (mc.screen instanceof PreviewScreen preview) { if (preview.getType() != PreviewScreen.PreviewType.SHULKER) openPreviewScreen(); } else openPreviewScreen(); @@ -78,20 +77,20 @@ public class ShulkerPeek extends Module { } if (event.getAction() == GLFW.GLFW_RELEASE) { - if (mc.currentScreen instanceof PreviewScreen preview) - preview.close(); + if (mc.screen instanceof PreviewScreen preview) + preview.onClose(); } } private void openPreviewScreen() { ItemStack stack; - if (mc.currentScreen instanceof PreviewScreen previewScreen) { + if (mc.screen instanceof PreviewScreen previewScreen) { int focusedSlot = previewScreen.getFocusedSlot(); if (focusedSlot == -1) return; stack = previewScreen.getInventory().get(focusedSlot); - } else if (mc.currentScreen instanceof HandledScreen handledScreen) { - stack = ((HandledScreenAccessor) handledScreen).getFocusedSlot().getStack(); + } else if (mc.screen instanceof AbstractContainerScreen handledScreen) { + stack = ((AbstractContainerScreenAccessor) handledScreen).getHoveredSlot().getItem(); } else return; if (stack.getItem() == Items.ENDER_CHEST) { @@ -99,12 +98,12 @@ public class ShulkerPeek extends Module { ChatUtil.warn("abre un enderchest primero"); return; } - mc.setScreen(new PreviewScreen(InventoryUtil.getEchestInv(), mc.currentScreen)); + mc.setScreen(new PreviewScreen(InventoryUtil.getEchestInv(), mc.screen)); return; } else if (isShulkerEmpty(stack)) return; - mc.setScreen(new PreviewScreen(stack, mc.currentScreen)); + mc.setScreen(new PreviewScreen(stack, mc.screen)); } public static boolean isShulkerEmpty(ItemStack stack) { @@ -112,9 +111,10 @@ public class ShulkerPeek extends Module { if (!(stack.getItem() instanceof BlockItem blockItem)) return true; if (!(blockItem.getBlock() instanceof ShulkerBoxBlock)) return true; - ContainerComponent container = stack.get(DataComponentTypes.CONTAINER); + ItemContainerContents container = stack.get(DataComponents.CONTAINER); if (container == null) return true; - return container.stream().allMatch(ItemStack::isEmpty); + // .stream()? + return container.allItemsCopyStream().allMatch(ItemStack::isEmpty); } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/inventory/UIMove.java b/src/main/java/me/retucio/sputnik/module/modules/inventory/UIMove.java index a7d041e..cdb2ae0 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/inventory/UIMove.java +++ b/src/main/java/me/retucio/sputnik/module/modules/inventory/UIMove.java @@ -7,10 +7,10 @@ import me.retucio.sputnik.ui.screen.ClickGUI; import me.retucio.sputnik.util.KeyUtil; import me.retucio.sputnik.util.Lists; -import net.minecraft.client.gui.screen.ingame.HandledScreen; -import net.minecraft.client.option.KeyBinding; -import net.minecraft.screen.GenericContainerScreenHandler; -import net.minecraft.screen.ScreenHandlerType; +import net.minecraft.client.KeyMapping; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.world.inventory.ChestMenu; +import net.minecraft.world.inventory.MenuType; import java.util.Arrays; import java.util.List; @@ -18,15 +18,15 @@ import java.util.List; public class UIMove extends Module { - public ListSetting> screens = sgGeneral.add(new ListSetting<>("interfaces", "interfaces en las que te podrás mover", + public ListSetting> screens = sgGeneral.add(new ListSetting<>("interfaces", "interfaces en las que te podrás mover", Lists.screenList, Lists.allTrue(Lists.screenList), Lists.screenNames)); - private List movementKeys; + private List movementKeys; - private final ScreenHandlerType inventoryHandlerType = ScreenHandlerType.register( - "player_inventory", GenericContainerScreenHandler::createGeneric9x3); - private final ScreenHandlerType clickGuiHandlerType = ScreenHandlerType.register( - "sputnik_clickgui", GenericContainerScreenHandler::createGeneric9x3); // 9x3 porque no importa (creo) + private final MenuType inventoryHandlerType = MenuType.register( + "player_inventory", ChestMenu::threeRows); + private final MenuType clickGuiHandlerType = MenuType.register( + "sputnik_clickgui", ChestMenu::threeRows); // 9x3 porque no importa (creo) public UIMove() { super("moverse en interfaz", @@ -42,13 +42,13 @@ public class UIMove extends Module { @Override public void onEnable() { movementKeys = Arrays.asList( - mc.options.forwardKey, - mc.options.backKey, - mc.options.leftKey, - mc.options.rightKey, - mc.options.jumpKey, - mc.options.sneakKey, - mc.options.sprintKey); + mc.options.keyUp, + mc.options.keyDown, + mc.options.keyLeft, + mc.options.keyRight, + mc.options.keyJump, + mc.options.keyShift, + mc.options.keySprint); super.onEnable(); } @@ -60,15 +60,15 @@ public class UIMove extends Module { @Override public void onTick() { - if (mc.player == null || mc.options == null || mc.currentScreen == null) return; + if (mc.player == null || mc.screen == null) return; - ScreenHandlerType handler = null; - if (mc.currentScreen == ClickGUI.INSTANCE) + MenuType handler = null; + if (mc.screen == ClickGUI.INSTANCE) handler = clickGuiHandlerType; - if (mc.currentScreen instanceof HandledScreen screen) { + if (mc.screen instanceof AbstractContainerScreen screen) { try { - handler = screen.getScreenHandler().getType(); + handler = screen.getMenu().getType(); } catch (UnsupportedOperationException e) { handler = inventoryHandlerType; } @@ -76,15 +76,15 @@ public class UIMove extends Module { if (handler == null || !screens.isEnabled(handler)) return; - for (KeyBinding kb : movementKeys) { - kb.setPressed(KeyUtil.isKeyDown(KeyUtil.getKey(kb))); + for (KeyMapping kb : movementKeys) { + kb.setDown(KeyUtil.isKeyDown(KeyUtil.getKey(kb))); } } private void unpress() { if (movementKeys == null) return; - for (KeyBinding kb : movementKeys) { - kb.setPressed(false); + for (KeyMapping kb : movementKeys) { + kb.setDown(false); } } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/inventory/XCarry.java b/src/main/java/me/retucio/sputnik/module/modules/inventory/XCarry.java index 8b3a717..e51cc49 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/inventory/XCarry.java +++ b/src/main/java/me/retucio/sputnik/module/modules/inventory/XCarry.java @@ -4,8 +4,8 @@ import com.github.retucio.neutrino.EventListener; import me.retucio.sputnik.event.network.PacketEvent; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; -import me.retucio.sputnik.util.ChatUtil; -import net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket; +import net.minecraft.network.protocol.game.ServerboundContainerClosePacket; + public class XCarry extends Module { @@ -18,7 +18,7 @@ public class XCarry extends Module { @Override public void onEnable() { if (mc.player != null) { - mc.player.networkHandler.sendPacket(new CloseHandledScreenC2SPacket(mc.player.playerScreenHandler.syncId)); + mc.player.connection.send(new ServerboundContainerClosePacket(mc.player.inventoryMenu.containerId)); } invOpen = false; super.onEnable(); @@ -27,7 +27,7 @@ public class XCarry extends Module { @Override public void onDisable() { if (invOpen && mc.player != null) { - mc.player.networkHandler.sendPacket(new CloseHandledScreenC2SPacket(mc.player.playerScreenHandler.syncId)); + mc.player.connection.send(new ServerboundContainerClosePacket(mc.player.inventoryMenu.containerId)); } super.onDisable(); } @@ -35,8 +35,8 @@ public class XCarry extends Module { @EventListener public void onSendPacket(PacketEvent.Send event) { - if (event.getPacket() instanceof CloseHandledScreenC2SPacket packet - && packet.getSyncId() == mc.player.playerScreenHandler.syncId) { + if (event.getPacket() instanceof ServerboundContainerClosePacket packet + && packet.getContainerId() == mc.player.inventoryMenu.containerId) { invOpen = true; event.cancel(); } diff --git a/src/main/java/me/retucio/sputnik/module/modules/misc/AnvilFont.java b/src/main/java/me/retucio/sputnik/module/modules/misc/AnvilFont.java index 49bb742..017df40 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/misc/AnvilFont.java +++ b/src/main/java/me/retucio/sputnik/module/modules/misc/AnvilFont.java @@ -4,10 +4,10 @@ import me.retucio.sputnik.mixin.accessors.AnvilScreenAccessor; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.EnumSetting; -import net.minecraft.client.gui.screen.ingame.AnvilScreen; -import net.minecraft.client.gui.widget.TextFieldWidget; +import net.minecraft.client.gui.components.EditBox; import me.retucio.sputnik.module.modules.misc.AnvilFont.CustomFont.CharMap; +import net.minecraft.client.gui.screens.inventory.AnvilScreen; import java.util.Arrays; import java.util.HashMap; @@ -74,20 +74,20 @@ public class AnvilFont extends Module { @Override public void onTick() { - if (mc.currentScreen == null) return; + if (mc.screen == null) return; - if (mc.currentScreen instanceof AnvilScreen) { - TextFieldWidget nameField = ((AnvilScreenAccessor) mc.currentScreen).getNameField(); + if (mc.screen instanceof AnvilScreen) { + EditBox nameField = ((AnvilScreenAccessor) mc.screen).getNameField(); if (fontMode.getValue() != FontMode.NORMAL) - text = fonts.get(fontMode.getIndex()).replace(nameField.getText()); + text = fonts.get(fontMode.getIndex()).replace(nameField.getValue()); else - text = nameField.getText(); + text = nameField.getValue(); - if (!text.equals(nameField.getText())) - nameField.setText(text); + if (!text.equals(nameField.getValue())) + nameField.setValue(text); - ((AnvilScreenAccessor) mc.currentScreen).setNameField(nameField); + ((AnvilScreenAccessor) mc.screen).setNameField(nameField); } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/misc/BookBot.java b/src/main/java/me/retucio/sputnik/module/modules/misc/BookBot.java index 32422c0..5a44e0c 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/misc/BookBot.java +++ b/src/main/java/me/retucio/sputnik/module/modules/misc/BookBot.java @@ -10,17 +10,18 @@ import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.module.setting.settings.StringSetting; import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.InventoryUtil; -import net.minecraft.client.font.TextHandler; -import net.minecraft.component.DataComponentTypes; -import net.minecraft.component.type.WritableBookContentComponent; -import net.minecraft.component.type.WrittenBookContentComponent; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.network.packet.c2s.play.BookUpdateC2SPacket; -import net.minecraft.text.*; +import net.minecraft.client.StringSplitter; +import net.minecraft.core.component.DataComponents; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.Style; +import net.minecraft.network.protocol.game.ServerboundEditBookPacket; +import net.minecraft.server.network.Filterable; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.component.WritableBookContent; +import net.minecraft.world.item.component.WrittenBookContent; import java.util.ArrayList; -import java.util.List; import java.util.Optional; import java.util.PrimitiveIterator; import java.util.Random; @@ -100,20 +101,20 @@ public class BookBot extends Module { if (mc.player == null) return; Predicate bookPredicate = stack -> { - WritableBookContentComponent component = stack.get(DataComponentTypes.WRITABLE_BOOK_CONTENT); + WritableBookContent component = stack.get(DataComponents.WRITABLE_BOOK_CONTENT); return stack.getItem() == Items.WRITABLE_BOOK && (component == null || component.pages().isEmpty()); }; - ItemStack book = InventoryUtil.find(bookPredicate); + ItemStack book = InventoryUtil.findStack(bookPredicate); if (book == null) { ChatUtil.warn("no se encontró ningún libro"); toggle(); return; } - if (mc.player.getMainHandStack() != book) { + if (mc.player.getMainHandItem() != book) { InventoryUtil.swapWithHotbar( - mc.player.getInventory().getSlotWithStack(book), + mc.player.getInventory().findSlotMatchingItem(book), mc.player.getInventory().getSelectedSlot() ); } @@ -144,10 +145,10 @@ public class BookBot extends Module { private void writeBook(PrimitiveIterator.OfInt chars) { ArrayList pages = new ArrayList<>(); - ArrayList> filteredPages = new ArrayList<>(); + ArrayList> filteredPages = new ArrayList<>(); int maxPages = this.pages.getIntValue(); - TextHandler.WidthRetriever widthRetriever = mc.textRenderer.getTextHandler().widthRetriever; + StringSplitter.WidthProvider widthRetriever = mc.font.getSplitter().widthProvider; int pageIndex = 0; int lineIndex = 0; final StringBuilder page = new StringBuilder(); @@ -177,7 +178,7 @@ public class BookBot extends Module { } if (lineIndex == 14) { - filteredPages.add(RawFilteredPair.of(Text.of(page.toString()))); + filteredPages.add(Filterable.passThrough(Component.nullToEmpty(page.toString()))); pages.add(page.toString()); page.setLength(0); pageIndex++; @@ -187,7 +188,7 @@ public class BookBot extends Module { } if (!page.isEmpty() && pageIndex < maxPages) { - filteredPages.add(RawFilteredPair.of(Text.of(page.toString()))); + filteredPages.add(Filterable.passThrough(Component.nullToEmpty(page.toString()))); pages.add(page.toString()); } @@ -198,51 +199,19 @@ public class BookBot extends Module { createBook(pages, filteredPages); } - private void processLinesToPages(List lines, ArrayList pages, ArrayList> filteredPages, int maxPages) { - int pageIndex = 0; - int lineIndex = 0; - StringBuilder currentPage = new StringBuilder(); - - for (StringVisitable line : lines) { - String lineText = line.getString(); - - if (!currentPage.isEmpty()) { - currentPage.append('\n'); - } - - currentPage.append(lineText); - lineIndex++; - - if (lineIndex == 14) { - filteredPages.add(RawFilteredPair.of(Text.of(currentPage.toString()))); - pages.add(currentPage.toString()); - currentPage.setLength(0); - pageIndex++; - lineIndex = 0; - - if (pageIndex == maxPages) break; - } - } - - if (!currentPage.isEmpty() && pageIndex < maxPages) { - filteredPages.add(RawFilteredPair.of(Text.of(currentPage.toString()))); - pages.add(currentPage.toString()); - } - } - - private void createBook(ArrayList pages, ArrayList> filteredPages) { + private void createBook(ArrayList pages, ArrayList> filteredPages) { String title = name.getValue(); if (count.getValue() && bookCount != 0) title += " #" + bookCount; - mc.player.getMainHandStack().set(DataComponentTypes.WRITTEN_BOOK_CONTENT, new WrittenBookContentComponent( - RawFilteredPair.of(title), + mc.player.getMainHandItem().set(DataComponents.WRITTEN_BOOK_CONTENT, new WrittenBookContent( + Filterable.passThrough(title), mc.player.getGameProfile().name(), 0, filteredPages, true )); - mc.player.networkHandler.sendPacket(new BookUpdateC2SPacket( + mc.player.connection.send(new ServerboundEditBookPacket( mc.player.getInventory().getSelectedSlot(), pages, sign.getValue() diff --git a/src/main/java/me/retucio/sputnik/module/modules/misc/BossbarStack.java b/src/main/java/me/retucio/sputnik/module/modules/misc/BossbarStack.java index 4b0bf55..00b0094 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/misc/BossbarStack.java +++ b/src/main/java/me/retucio/sputnik/module/modules/misc/BossbarStack.java @@ -6,13 +6,14 @@ import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; -import net.minecraft.client.gui.hud.ClientBossBar; -import net.minecraft.text.Text; +import net.minecraft.client.gui.components.LerpingBossEvent; +import net.minecraft.network.chat.Component; import java.util.HashMap; import java.util.Map; import java.util.WeakHashMap; + public class BossbarStack extends Module { private final BooleanSetting stackBars = sgGeneral.add(new BooleanSetting( @@ -35,7 +36,7 @@ public class BossbarStack extends Module { )); - private final Map bossBarMap = new WeakHashMap<>(); + private final Map bossBarMap = new WeakHashMap<>(); public BossbarStack() { super("apilar bossbars", @@ -46,11 +47,11 @@ public class BossbarStack extends Module { @EventListener private void onRenderBossText(RenderBossbarEvent.BossText event) { if (hideNames.getValue()) { - event.setName(Text.empty()); + event.setName(Component.empty()); return; } else if (bossBarMap.isEmpty() || !stackBars.getValue()) return; - ClientBossBar bar = event.getBossBar(); + LerpingBossEvent bar = event.getBossBar(); Integer amount = bossBarMap.get(bar); bossBarMap.remove(bar); @@ -66,7 +67,7 @@ public class BossbarStack extends Module { @EventListener private void onRenderBossBars(RenderBossbarEvent.BossIterator event) { if (stackBars.getValue()) { - HashMap chosenBarMap = new HashMap<>(); + HashMap chosenBarMap = new HashMap<>(); event.getIterator().forEachRemaining(bar -> { String name = bar.getName().getString(); if (chosenBarMap.containsKey(name)) diff --git a/src/main/java/me/retucio/sputnik/module/modules/misc/ChatPlus.java b/src/main/java/me/retucio/sputnik/module/modules/misc/ChatPlus.java index 715104e..11c58fe 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/misc/ChatPlus.java +++ b/src/main/java/me/retucio/sputnik/module/modules/misc/ChatPlus.java @@ -4,13 +4,14 @@ import com.github.retucio.neutrino.EventListener; import com.mojang.authlib.GameProfile; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; +import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.command.CommandManager; import me.retucio.sputnik.event.input.ClientClickEvent; import me.retucio.sputnik.event.network.ReceiveMessageEvent; import me.retucio.sputnik.event.network.SendMessageEvent; -import me.retucio.sputnik.mixin.mixins.hud.ChatHudMixin; +import me.retucio.sputnik.mixin.mixins.hud.ChatComponentMixin; import me.retucio.sputnik.mixin.mixins.hud.InGameHudMixin; -import me.retucio.sputnik.mixin.mixins.misc.StringHelperMixin; +import me.retucio.sputnik.mixin.mixins.misc.StringUtilMixin; import me.retucio.sputnik.mixin.mixins.screen.ChatScreenMixin; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; @@ -18,17 +19,20 @@ import me.retucio.sputnik.module.setting.SettingGroup; import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.util.ChatUtil; -import me.retucio.sputnik.util.interfaces.IChatHudLine; -import me.retucio.sputnik.util.interfaces.IChatHudLineVisible; +import me.retucio.sputnik.util.interfaces.IGuiMessage; +import me.retucio.sputnik.util.interfaces.IGuiMessageLine; import me.retucio.sputnik.util.interfaces.TextVisitor; -import net.minecraft.client.gl.RenderPipelines; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.PlayerSkinDrawer; -import net.minecraft.client.gui.hud.ChatHudLine; -import net.minecraft.client.network.PlayerListEntry; -import net.minecraft.text.*; -import net.minecraft.util.Formatting; -import net.minecraft.util.Identifier; +import net.minecraft.ChatFormatting; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.client.gui.components.PlayerFaceExtractor; +import net.minecraft.client.multiplayer.PlayerInfo; +import net.minecraft.client.multiplayer.chat.GuiMessage; +import net.minecraft.client.renderer.RenderPipelines; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.HoverEvent; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.Style; +import net.minecraft.resources.Identifier; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -39,10 +43,10 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; /** continúa en: - * @see ChatHudMixin + * @see ChatComponentMixin * @see ChatScreenMixin * @see InGameHudMixin - * @see StringHelperMixin + * @see StringUtilMixin */ public class ChatPlus extends Module { @@ -67,12 +71,12 @@ public class ChatPlus extends Module { Category.MISC); updateDateFormat(); updateClientName(); - timestamps.onUpdate(v -> timestampSecs.visibility(v)); - timestampSecs.onUpdate(x -> updateDateFormat()); + timestamps.onUpdate(timestampSecs::visibility); + timestampSecs.onUpdate(v -> updateDateFormat()); } public final IntList lines = new IntArrayList(); - public ChatHudLine.Visible line; + public GuiMessage.Line line; private record CustomHeadEntry(String prefix, Identifier texture) {} private static final List CUSTOM_HEAD_ENTRIES = new ArrayList<>(); @@ -85,19 +89,19 @@ public class ChatPlus extends Module { @EventListener private void onReceiveMessage(ReceiveMessageEvent event) { - Text message = event.getMessage(); + Component message = event.getMessage(); // registrar mensajes para evitar su eliminación if (logger.getValue()) { String messageString = message.getString(); if (loggerRegex.matcher(messageString).find()) { - MutableText newMessage = Text.empty(); + MutableComponent newMessage = Component.empty(); TextVisitor.visit(message, (text, style, string) -> { Matcher antiClearMatcher = loggerRegex.matcher(string); if (antiClearMatcher.find()) - newMessage.append(Text.literal(antiClearMatcher.replaceAll("\n\n")).setStyle(style)); + newMessage.append(Component.literal(antiClearMatcher.replaceAll("\n\n")).setStyle(style)); else - newMessage.append(text.copyContentOnly().setStyle(style)); + newMessage.append(text.plainCopy().setStyle(style)); return Optional.empty(); }, Style.EMPTY); @@ -107,8 +111,8 @@ public class ChatPlus extends Module { // agregar sellos de tiempo a los mensajes if (timestamps.getValue()) { - Text timestamp = Text.literal("[" + dateFormat.format(new Date()) + "] ").formatted(Formatting.GRAY); - message = Text.empty().append(timestamp).append(message); + Component timestamp = Component.literal("[" + dateFormat.format(new Date()) + "] ").withStyle(ChatFormatting.GRAY); + message = Component.empty().append(timestamp).append(message); } // modificar el mensaje final @@ -119,7 +123,7 @@ public class ChatPlus extends Module { private void onSendMessage(SendMessageEvent event) { // evitar mandar coordenadas por el chat if (coordsProtection.getValue() && containsCoordinates(event.getMessage())) { - ChatUtil.warn(Text.literal("cuidadito con las coordenadas chavalín").append( + ChatUtil.warn(Component.literal("cuidadito con las coordenadas chavalín").append( getSendButton(event.getMessage()))); event.cancel(); @@ -127,16 +131,16 @@ public class ChatPlus extends Module { } public void updateClientName() { - CUSTOM_HEAD_ENTRIES.add(new CustomHeadEntry(ChatUtil.getPrefixNoFormatting(), Identifier.of(me.retucio.sputnik.Sputnik.MOD_ID, "icon_chat.png"))); // no funciona con formato de colores - CUSTOM_HEAD_ENTRIES.add(new CustomHeadEntry("[Debug]", Identifier.of(me.retucio.sputnik.Sputnik.MOD_ID, "icon_mc.png"))); + CUSTOM_HEAD_ENTRIES.add(new CustomHeadEntry(ChatUtil.getPrefixNoFormatting(), Identifier.fromNamespaceAndPath(Sputnik.MOD_ID, "icon_chat.png"))); // no funciona con formato de colores + CUSTOM_HEAD_ENTRIES.add(new CustomHeadEntry("[Debug]", Identifier.fromNamespaceAndPath(Sputnik.MOD_ID, "icon_mc.png"))); } @SuppressWarnings("DataFlowIssue") - public void beforeDrawMessage(DrawContext context, int y, int color) { + public void beforeDrawMessage(GuiGraphicsExtractor context, int y, int color) { if (!isEnabled() || !showHeads.getValue() || lines == null) return; - if (((IChatHudLineVisible) (Object) line).sputnik$isStartOfEntry()) { - drawTexture(context, (IChatHudLine) (Object) line, y, color); + if (((IGuiMessageLine) (Object) line).sputnik$isStartOfEntry()) { + drawTexture(context, (IGuiMessage) (Object) line, y, color); } } @@ -144,8 +148,9 @@ public class ChatPlus extends Module { if (!isEnabled() || !showHeads.getValue()) return; line = null; } + @SuppressWarnings("DataFlowIssue") - private void drawTexture(DrawContext context, IChatHudLine line, int y, int color) { + private void drawTexture(GuiGraphicsExtractor gui, IGuiMessage line, int y, int color) { String text = line.sputnik$getText().trim(); int startOffset = 0; @@ -158,7 +163,7 @@ public class ChatPlus extends Module { for (CustomHeadEntry entry : CUSTOM_HEAD_ENTRIES) { if (text.startsWith(entry.prefix(), startOffset)) { - context.drawTexture(RenderPipelines.GUI_TEXTURED, entry.texture(), 0, y, 0, 0, 8, 8, 64, 64, 64, 64, color); + gui.blit(RenderPipelines.GUI_TEXTURED, entry.texture(), 0, y, 0, 0, 8, 8, 64, 64, 64, 64, color); return; } } @@ -166,14 +171,14 @@ public class ChatPlus extends Module { GameProfile sender = getSender(line, text); if (sender == null) return; - PlayerListEntry entry = mc.getNetworkHandler().getPlayerListEntry(sender.id()); + PlayerInfo entry = mc.getConnection().getPlayerInfo(sender.id()); if (entry == null) return; - PlayerSkinDrawer.draw(context, entry.getSkinTextures(), 0, y, 8, color); + PlayerFaceExtractor.extractRenderState(gui, entry.getSkin(), 0, y, 8, color); } @SuppressWarnings("DataFlowIssue") - private GameProfile getSender(IChatHudLine line, String text) { + private GameProfile getSender(IGuiMessage line, String text) { // obtener el jugador que envió un mensaje GameProfile sender = line.sputnik$getSender(); @@ -185,7 +190,7 @@ public class ChatPlus extends Module { if (username == null) username = usernameMatcher.group(2); - PlayerListEntry entry = mc.getNetworkHandler().getPlayerListEntry(username); + PlayerInfo entry = mc.getConnection().getPlayerInfo(username); if (entry != null) sender = entry.getProfile(); } } @@ -193,19 +198,19 @@ public class ChatPlus extends Module { } @SuppressWarnings("DataFlowIssue") - private MutableText getSendButton(String message) { + private MutableComponent getSendButton(String message) { // botón para enviar mensaje con coordenadas de todos modos - MutableText sendButton = Text.literal("\n[ME LA SUDA]"); - MutableText hintBaseText = Text.literal(""); + MutableComponent sendButton = Component.literal("\n[ME LA SUDA]"); + MutableComponent hintBaseText = Component.literal(""); - MutableText hintMsg = Text.literal("enviar de todos modos:"); - hintMsg.setStyle(hintBaseText.getStyle().withFormatting(Formatting.GRAY)); + MutableComponent hintMsg = Component.literal("enviar de todos modos:"); + hintMsg.setStyle(hintBaseText.getStyle().applyFormat(ChatFormatting.GRAY)); hintBaseText.append(hintMsg); - hintBaseText.append(Text.literal("\n" + message)); + hintBaseText.append(Component.literal("\n" + message)); sendButton.setStyle(sendButton.getStyle() - .withFormatting(Formatting.DARK_RED) + .applyFormat(ChatFormatting.DARK_RED) .withClickEvent(new ClientClickEvent(CommandManager.getCommandByName("send").toString(message))) .withHoverEvent(new HoverEvent.ShowText(hintBaseText))); diff --git a/src/main/java/me/retucio/sputnik/module/modules/misc/FakePlayer.java b/src/main/java/me/retucio/sputnik/module/modules/misc/FakePlayer.java index 95e1511..6fb28db 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/misc/FakePlayer.java +++ b/src/main/java/me/retucio/sputnik/module/modules/misc/FakePlayer.java @@ -4,17 +4,19 @@ import com.mojang.authlib.GameProfile; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.StringSetting; -import net.minecraft.client.network.OtherClientPlayerEntity; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.client.player.RemotePlayer; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import org.jspecify.annotations.NonNull; import java.util.UUID; + public class FakePlayer extends Module { private final StringSetting name = sgGeneral.add(new StringSetting("nombre", "qué nombre asignarle al jugador", "apio boy", 22)); - private OtherClientPlayerEntity player = null; + private RemotePlayer player = null; public FakePlayer() { super("jugador falso", @@ -24,36 +26,36 @@ public class FakePlayer extends Module { @Override public void onEnable() { - if (mc.world == null) return; + if (mc.level == null) return; addPlayer(mc.player, name.getValue()); super.onEnable(); } @Override public void onDisable() { - if (mc.world == null || player == null) return; + if (mc.level == null || player == null) return; removePlayer(); super.onDisable(); } // intento miserable de hacer que no colisione con jugadores - public OtherClientPlayerEntity addPlayer(PlayerEntity playerToCopy, String dummyName) { - player = new OtherClientPlayerEntity(mc.world, new GameProfile(UUID.randomUUID(), dummyName)) { - @Override public void onPlayerCollision(PlayerEntity player) {} + public RemotePlayer addPlayer(Player playerToCopy, String dummyName) { + player = new RemotePlayer(mc.level, new GameProfile(UUID.randomUUID(), dummyName)) { + @Override public void playerTouch(@NonNull Player player) {} }; - player.copyFrom(playerToCopy); + player.restoreFrom(playerToCopy); player.setCustomNameVisible(true); - player.noClip = true; + player.noPhysics = true; player.horizontalCollision = false; player.verticalCollision = false; - mc.world.addEntity(player); + mc.level.addEntity(player); return player; } public void removePlayer() { player.setRemoved(Entity.RemovalReason.KILLED); - player.onRemoved(); + player.onClientRemoval(); player = null; } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/misc/ScreenshotPlus.java b/src/main/java/me/retucio/sputnik/module/modules/misc/ScreenshotPlus.java index 117ff16..aac6d7e 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/misc/ScreenshotPlus.java +++ b/src/main/java/me/retucio/sputnik/module/modules/misc/ScreenshotPlus.java @@ -1,20 +1,20 @@ package me.retucio.sputnik.module.modules.misc; +import com.mojang.blaze3d.platform.NativeImage; import me.retucio.sputnik.command.CommandManager; import me.retucio.sputnik.event.input.ClientClickEvent; -import me.retucio.sputnik.mixin.mixins.io.ScreenshotRecorderMixin; +import me.retucio.sputnik.mixin.mixins.io.ScreenshotMixin; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.SettingGroup; import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.EnumSetting; import me.retucio.sputnik.util.ChatUtil; -import net.minecraft.client.texture.NativeImage; -import net.minecraft.text.ClickEvent; -import net.minecraft.text.HoverEvent; -import net.minecraft.text.MutableText; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.ClickEvent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.HoverEvent; +import net.minecraft.network.chat.MutableComponent; import org.jetbrains.annotations.NotNull; import java.awt.*; @@ -27,7 +27,7 @@ import java.io.IOException; /** continúa en: - * @see ScreenshotRecorderMixin + * @see ScreenshotMixin */ public class ScreenshotPlus extends Module { @@ -52,7 +52,7 @@ public class ScreenshotPlus extends Module { } public void sendScreenshotMessage() { - MutableText baseText = Text.literal("captura de pantalla tomada\n"); + MutableComponent baseText = Component.literal("captura de pantalla tomada\n"); if (saveButton.getValue() && !defaultAction.is(ScreenshotActions.SAVE)) baseText.append(getSaveButton().append(" ")); if (copyButton.getValue()) baseText.append(getCopyButton().append(" ")); if (openButton.getValue() && defaultAction.is(ScreenshotActions.SAVE)) baseText.append(getOpenButton().append(" ")); @@ -68,7 +68,7 @@ public class ScreenshotPlus extends Module { BufferedImage bufferedImage = new BufferedImage(nativeImage.getWidth(), nativeImage.getHeight(), BufferedImage.TYPE_INT_ARGB); for (int x = 0; x < nativeImage.getWidth(); x++) for (int y = 0; y < nativeImage.getHeight(); y++) - bufferedImage.setRGB(x, y, nativeImage.getColorArgb(x, y)); + bufferedImage.setRGB(x, y, nativeImage.getPixel(x, y)); ScreenshotPlus.TransferableImage trans = new TransferableImage(bufferedImage); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(trans, null); @@ -84,11 +84,11 @@ public class ScreenshotPlus extends Module { } public void saveScreenshot(NativeImage image) throws IOException { - image.writeTo(screenshotFile); - ChatUtil.info(Text.literal("captura guardada como: ").append( - Text.literal(screenshotFile.getName()) - .formatted(Formatting.UNDERLINE) - .styled(style -> style.withClickEvent(new ClickEvent.OpenFile(screenshotFile.getAbsoluteFile()))) + image.writeToFile(screenshotFile); + ChatUtil.info(Component.literal("captura guardada como: ").append( + Component.literal(screenshotFile.getName()) + .withStyle(ChatFormatting.UNDERLINE) + .withStyle(style -> style.withClickEvent(new ClickEvent.OpenFile(screenshotFile.getAbsoluteFile()))) ) ); } @@ -128,16 +128,16 @@ public class ScreenshotPlus extends Module { // botones para el mensaje @SuppressWarnings("DataFlowIssue") - private MutableText getSaveButton() { - MutableText button = Text.literal("[GUARDAR]"); - MutableText hintBaseText = Text.literal(""); + private MutableComponent getSaveButton() { + MutableComponent button = Component.literal("[GUARDAR]"); + MutableComponent hintBaseText = Component.literal(""); - MutableText hintMsg = Text.literal(ScreenshotActions.SAVE.toString()); - hintMsg.setStyle(hintBaseText.getStyle().withFormatting(Formatting.GRAY)); + MutableComponent hintMsg = Component.literal(ScreenshotActions.SAVE.toString()); + hintMsg.setStyle(hintBaseText.getStyle().applyFormat(ChatFormatting.GRAY)); hintBaseText.append(hintMsg); button.setStyle(button.getStyle() - .withFormatting(Formatting.BOLD, Formatting.GOLD) + .applyFormats(ChatFormatting.BOLD, ChatFormatting.GOLD) .withClickEvent(new ClientClickEvent(CommandManager.getCommandByName("guardarcaptura").toString())) .withHoverEvent(new HoverEvent.ShowText(hintBaseText))); @@ -145,32 +145,32 @@ public class ScreenshotPlus extends Module { } @SuppressWarnings("DataFlowIssue") - private MutableText getCopyButton() { - MutableText button = Text.literal("[COPIAR]"); - MutableText hintBaseText = Text.literal(""); + private MutableComponent getCopyButton() { + MutableComponent button = Component.literal("[COPIAR]"); + MutableComponent hintBaseText = Component.literal(""); - MutableText hintMsg = Text.literal(ScreenshotActions.COPY.toString()); - hintMsg.setStyle(hintBaseText.getStyle().withFormatting(Formatting.GRAY)); + MutableComponent hintMsg = Component.literal(ScreenshotActions.COPY.toString()); + hintMsg.setStyle(hintBaseText.getStyle().withColor(ChatFormatting.GRAY)); hintBaseText.append(hintMsg); button.setStyle(button.getStyle() - .withFormatting(Formatting.BOLD, Formatting.AQUA) + .applyFormats(ChatFormatting.BOLD, ChatFormatting.AQUA) .withClickEvent(new ClientClickEvent(CommandManager.getCommandByName("copiarcaptura").toString())) .withHoverEvent(new HoverEvent.ShowText(hintBaseText))); return button; } - private MutableText getOpenButton() { - MutableText button = Text.literal("[ABRIR]"); - MutableText hintBaseText = Text.literal(""); + private MutableComponent getOpenButton() { + MutableComponent button = Component.literal("[ABRIR]"); + MutableComponent hintBaseText = Component.literal(""); - MutableText hintMsg = Text.literal("abrir archivo de imagen"); - hintMsg.setStyle(hintBaseText.getStyle().withFormatting(Formatting.GRAY)); + MutableComponent hintMsg = Component.literal("abrir archivo de imagen"); + hintMsg.setStyle(hintBaseText.getStyle().applyFormats(ChatFormatting.GRAY)); hintBaseText.append(hintMsg); button.setStyle(button.getStyle() - .withFormatting(Formatting.BOLD, Formatting.GRAY) + .applyFormats(ChatFormatting.BOLD, ChatFormatting.GRAY) .withClickEvent(new ClickEvent.OpenFile(screenshotFile)) .withHoverEvent(new HoverEvent.ShowText(hintBaseText))); @@ -178,16 +178,16 @@ public class ScreenshotPlus extends Module { } @SuppressWarnings("DataFlowIssue") - private MutableText getDiscardButton() { - MutableText button = Text.literal("[DESCARTAR]"); - MutableText hintBaseText = Text.literal(""); + private MutableComponent getDiscardButton() { + MutableComponent button = Component.literal("[DESCARTAR]"); + MutableComponent hintBaseText = Component.literal(""); - MutableText hintMsg = Text.literal(ScreenshotActions.NONE.toString()); - hintMsg.setStyle(hintBaseText.getStyle().withFormatting(Formatting.GRAY)); + MutableComponent hintMsg = Component.literal(ScreenshotActions.NONE.toString()); + hintMsg.setStyle(hintBaseText.getStyle().applyFormats(ChatFormatting.GRAY)); hintBaseText.append(hintMsg); button.setStyle(button.getStyle() - .withFormatting(Formatting.BOLD, Formatting.DARK_RED) + .applyFormats(ChatFormatting.BOLD, ChatFormatting.DARK_RED) .withClickEvent(new ClientClickEvent(CommandManager.getCommandByName("purgar").toString("1"))) .withHoverEvent(new HoverEvent.ShowText(hintBaseText))); diff --git a/src/main/java/me/retucio/sputnik/module/modules/movement/BoatFly.java b/src/main/java/me/retucio/sputnik/module/modules/movement/BoatFly.java index 84411a9..5a4bb22 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/movement/BoatFly.java +++ b/src/main/java/me/retucio/sputnik/module/modules/movement/BoatFly.java @@ -7,8 +7,9 @@ import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; -import net.minecraft.network.packet.s2c.play.VehicleMoveS2CPacket; -import net.minecraft.util.math.Vec3d; +import net.minecraft.network.protocol.game.ServerboundMoveVehiclePacket; +import net.minecraft.world.phys.Vec3; + public class BoatFly extends Module { @@ -52,20 +53,20 @@ public class BoatFly extends Module { @EventListener private void onBoatMove(BoatMoveEvent event) { if (event.getBoat().getControllingPassenger() != mc.player) return; - event.getBoat().setYaw(mc.player.getYaw()); + event.getBoat().setYRot(mc.player.getYRot()); - float yaw = event.getBoat().getYaw(); + float yaw = event.getBoat().getYRot(); int dx = 0, dy = 0, dz = 0; - if (mc.options.rightKey.isPressed()) dx++; - if (mc.options.leftKey.isPressed()) dx--; + if (mc.options.keyRight.isDown()) dx++; + if (mc.options.keyLeft.isDown()) dx--; - if (mc.options.jumpKey.isPressed()) dy++; - if (mc.options.sprintKey.isPressed()) dy--; + if (mc.options.keyJump.isDown()) dy++; + if (mc.options.keySprint.isDown()) dy--; // ctrl para bajar, en vez de shift, porque si no te desmontas - if (mc.options.backKey.isPressed()) dz++; - if (mc.options.forwardKey.isPressed()) dz--; + if (mc.options.keyDown.isDown()) dz++; + if (mc.options.keyUp.isDown()) dz--; double speed = this.speed.getValue(); double sin = Math.sin(Math.toRadians(yaw)); @@ -78,12 +79,12 @@ public class BoatFly extends Module { x += speed * dx * -cos; z += speed * dx * -sin; - event.getBoat().setVelocity(new Vec3d(x, y, z)); + event.getBoat().setDeltaMovement(new Vec3(x, y, z)); } @EventListener private void onReceivePacket(PacketEvent.Receive event) { - if (event.getPacket() instanceof VehicleMoveS2CPacket && cancelPackets.getValue()) { + if (event.getPacket() instanceof ServerboundMoveVehiclePacket && cancelPackets.getValue()) { event.cancel(); } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/movement/Dolphin.java b/src/main/java/me/retucio/sputnik/module/modules/movement/Dolphin.java index f8b25bf..291a1f3 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/movement/Dolphin.java +++ b/src/main/java/me/retucio/sputnik/module/modules/movement/Dolphin.java @@ -13,11 +13,11 @@ public class Dolphin extends Module { public void onTick() { if (mc.player == null) return; - if (mc.player.isTouchingWater()) { + if (mc.player.isInWater()) { mc.player.setSwimming(true); - if (mc.player.isSwimming() && mc.player.isSubmergedInWater()) { - mc.player.jump(); + if (mc.player.isSwimming() && mc.player.isUnderWater()) { + mc.player.jumpFromGround(); } } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/movement/ElytraBounce.java b/src/main/java/me/retucio/sputnik/module/modules/movement/ElytraBounce.java index e3feee8..6f01e86 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/movement/ElytraBounce.java +++ b/src/main/java/me/retucio/sputnik/module/modules/movement/ElytraBounce.java @@ -2,12 +2,13 @@ package me.retucio.sputnik.module.modules.movement; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.effect.StatusEffects; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; +import net.minecraft.network.protocol.game.ServerboundPlayerCommandPacket; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; + // https://github.com/InLieuOfLuna/elytra-recast/ public class ElytraBounce extends Module { @@ -18,36 +19,35 @@ public class ElytraBounce extends Module { public boolean bounce() { if (canUseElytra() && canBounce()) { - if (mc.getNetworkHandler() != null) - mc.getNetworkHandler().sendPacket(new ClientCommandC2SPacket( + if (mc.getConnection() != null) + mc.getConnection().send(new ServerboundPlayerCommandPacket( mc.player, - ClientCommandC2SPacket - .Mode.START_FALL_FLYING) - ); + ServerboundPlayerCommandPacket + .Action.START_FALL_FLYING + )); return true; - } else { return false; } } public boolean canUseElytra() { - if (mc.player.input.playerInput.jump() + if (mc.player.input.keyPresses.jump() && !mc.player.getAbilities().flying - && !mc.player.hasVehicle() - && !mc.player.isClimbing()) { - ItemStack stack = mc.player.getEquippedStack(EquipmentSlot.CHEST); - return stack.isOf(Items.ELYTRA) && LivingEntity.canGlideWith(stack, EquipmentSlot.CHEST); + && !mc.player.isPassenger() + && !mc.player.onClimbable()) { + ItemStack stack = mc.player.getItemBySlot(EquipmentSlot.CHEST); + return stack.is(Items.ELYTRA) && LivingEntity.canGlideUsing(stack, EquipmentSlot.CHEST); } else { return false; } } public boolean canBounce() { - if (!mc.player.isTouchingWater() && !mc.player.hasStatusEffect(StatusEffects.LEVITATION)) { - ItemStack stack = mc.player.getEquippedStack(EquipmentSlot.CHEST); - if (stack.isOf(Items.ELYTRA) && LivingEntity.canGlideWith(stack, EquipmentSlot.CHEST)) { - mc.player.startGliding(); + if (!mc.player.isInWater() && !mc.player.hasEffect(MobEffects.LEVITATION)) { + ItemStack stack = mc.player.getItemBySlot(EquipmentSlot.CHEST); + if (stack.is(Items.ELYTRA) && LivingEntity.canGlideUsing(stack, EquipmentSlot.CHEST)) { + mc.player.startFallFlying(); return true; } else return false; diff --git a/src/main/java/me/retucio/sputnik/module/modules/movement/ElytraFly.java b/src/main/java/me/retucio/sputnik/module/modules/movement/ElytraFly.java index 8f341eb..d51fc88 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/movement/ElytraFly.java +++ b/src/main/java/me/retucio/sputnik/module/modules/movement/ElytraFly.java @@ -3,10 +3,10 @@ package me.retucio.sputnik.module.modules.movement; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.NumberSetting; -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.math.Vec3d; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.phys.Vec3; public class ElytraFly extends Module { @@ -26,19 +26,19 @@ public class ElytraFly extends Module { @Override public void onTick() { - if (mc.player == null || !mc.player.isGliding() || !wearingElytra()) return; + if (mc.player == null || !mc.player.isFallFlying() || !wearingElytra()) return; - float yaw = mc.player.getYaw(); + float yaw = mc.player.getYRot(); int dx = 0, dy = 0, dz = 0; - if (mc.options.rightKey.isPressed()) dx++; - if (mc.options.leftKey.isPressed()) dx--; + if (mc.options.keyRight.isDown()) dx++; + if (mc.options.keyLeft.isDown()) dx--; - if (mc.options.jumpKey.isPressed()) dy++; - if (mc.options.sneakKey.isPressed()) dy--; + if (mc.options.keyJump.isDown()) dy++; + if (mc.options.keyShift.isDown()) dy--; - if (mc.options.backKey.isPressed()) dz++; - if (mc.options.forwardKey.isPressed()) dz--; + if (mc.options.keyDown.isDown()) dz++; + if (mc.options.keyUp.isDown()) dz--; double speed = this.speed.getValue(); double sin = Math.sin(Math.toRadians(yaw)); @@ -51,11 +51,11 @@ public class ElytraFly extends Module { x += speed * dx * -cos; z += speed * dx * -sin; - mc.player.setVelocity(new Vec3d(x, y, z)); + mc.player.setDeltaMovement(new Vec3(x, y, z)); } private boolean wearingElytra() { - ItemStack equippedStack = mc.player.getEquippedStack(EquipmentSlot.CHEST); - return equippedStack != null && equippedStack.getItem() == Items.ELYTRA; + ItemStack equippedStack = mc.player.getItemBySlot(EquipmentSlot.CHEST); + return equippedStack.getItem() == Items.ELYTRA; } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/movement/FastStairs.java b/src/main/java/me/retucio/sputnik/module/modules/movement/FastStairs.java index 1157c3d..4d66cea 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/movement/FastStairs.java +++ b/src/main/java/me/retucio/sputnik/module/modules/movement/FastStairs.java @@ -3,8 +3,9 @@ package me.retucio.sputnik.module.modules.movement; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.BooleanSetting; -import net.minecraft.block.Block; -import net.minecraft.block.StairsBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.StairBlock; + public class FastStairs extends Module { @@ -26,15 +27,15 @@ public class FastStairs extends Module { @Override public void onTick() { - if (mc.player == null || mc.world == null) return; + if (mc.player == null || mc.level == null) return; if (!mc.player.isSprinting() && onlyWhenSprinting.getValue()) return; - Block nextBlock = mc.world.getBlockState(mc.player.getBlockPos().add(mc.player.getHorizontalFacing().getVector())).getBlock(); - if (!(nextBlock instanceof StairsBlock && onlyWhenStairsNext.getValue())) return; + Block nextBlock = mc.level.getBlockState(mc.player.blockPosition().offset(mc.player.getDirection().getUnitVec3i())).getBlock(); + if (!(nextBlock instanceof StairBlock && onlyWhenStairsNext.getValue())) return; - if (mc.world.getBlockState(mc.player.getBlockPos().down()).getBlock() instanceof StairsBlock - && mc.player.forwardSpeed > 0 && mc.player.isOnGround()) { - mc.player.jump(); + if (mc.level.getBlockState(mc.player.blockPosition().below()).getBlock() instanceof StairBlock + && mc.player.zza > 0 && mc.player.onGround()) { + mc.player.jumpFromGround(); } } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/movement/Headhitters.java b/src/main/java/me/retucio/sputnik/module/modules/movement/Headhitters.java index 71ed321..644ee2d 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/movement/Headhitters.java +++ b/src/main/java/me/retucio/sputnik/module/modules/movement/Headhitters.java @@ -17,6 +17,6 @@ public class Headhitters extends Module { @Override public void onTick() { if (mc.player == null) return; - mc.player.jumpingCooldown = delay.getIntValue(); + mc.player.noJumpDelay = delay.getIntValue(); } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/movement/HitboxDesync.java b/src/main/java/me/retucio/sputnik/module/modules/movement/HitboxDesync.java index 448eed5..4f7d8ee 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/movement/HitboxDesync.java +++ b/src/main/java/me/retucio/sputnik/module/modules/movement/HitboxDesync.java @@ -2,13 +2,15 @@ package me.retucio.sputnik.module.modules.movement; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; -import net.minecraft.util.math.Box; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import org.jspecify.annotations.NonNull; /** * @link + * * @author retucio */ @@ -23,14 +25,14 @@ public class HitboxDesync extends Module { @Override public void onTick() { - if (mc.world == null || mc.player == null) return; + if (mc.level == null || mc.player == null) return; - Direction dir = mc.player.getFacing(); - Box box = mc.player.getBoundingBox(); - Vec3d center = box.getCenter(); - Vec3d offset = new Vec3d(dir.getOffsetX(), dir.getOffsetY(), dir.getOffsetZ()); - Vec3d posVec = merge(new Vec3d(Math.floor(center.x) + 0.5, Math.floor(center.y), Math.floor(center.z) + 0.5) - .add(new Vec3d( + Direction dir = mc.player.getNearestViewDirection(); + AABB box = mc.player.getBoundingBox(); + Vec3 center = box.getCenter(); + Vec3 offset = new Vec3(dir.getStepX(), dir.getStepY(), dir.getStepZ()); + Vec3 posVec = merge(new Vec3(Math.floor(center.x) + 0.5, Math.floor(center.y), Math.floor(center.z) + 0.5) + .add(new Vec3( offset.x * MAGIC_OFFSET, offset.y * MAGIC_OFFSET, offset.z * MAGIC_OFFSET @@ -40,7 +42,7 @@ public class HitboxDesync extends Module { toggle(); } - private Vec3d merge(Vec3d a, Direction facing) { - return new Vec3d(a.x * Math.abs(facing.getOffsetX()), a.y * Math.abs(facing.getOffsetY()), a.z * Math.abs(facing.getOffsetZ())); + private Vec3 merge(@NonNull Vec3 a, Direction facing) { + return new Vec3(a.x * Math.abs(facing.getStepX()), a.y * Math.abs(facing.getStepY()), a.z * Math.abs(facing.getStepZ())); } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/movement/InfiniteElytra.java b/src/main/java/me/retucio/sputnik/module/modules/movement/InfiniteElytra.java index 7aee642..f6ea6ea 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/movement/InfiniteElytra.java +++ b/src/main/java/me/retucio/sputnik/module/modules/movement/InfiniteElytra.java @@ -5,9 +5,10 @@ import me.retucio.sputnik.event.interact.UseItemEvent; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.NumberSetting; -import net.minecraft.item.Items; -import net.minecraft.util.math.Box; -import net.minecraft.util.math.Vec3d; +import net.minecraft.world.item.Items; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; + // "pedido prestado" de: https://github.com/meanwhile131/elytra-infinite public class InfiniteElytra extends Module { @@ -72,7 +73,7 @@ public class InfiniteElytra extends Module { @Override public void onTick() { - if (mc.player == null || mc.world == null || !mc.player.isGliding()) { + if (mc.player == null || mc.level == null || !mc.player.isFallFlying()) { state = FlyState.NOT_FLYING; return; } @@ -82,7 +83,7 @@ public class InfiniteElytra extends Module { pitch = pitchDown.getFloatValue(); } else if (state == FlyState.PITCHING_DOWN) { pitch += Math.min(pitchDown.getFloatValue() - pitch, pitchDownSpeed.getFloatValue()); - boolean movingDownwards = mc.player.getVelocity().y <= 0 && mc.player.getY() > lowestY; + boolean movingDownwards = mc.player.getDeltaMovement().y <= 0 && mc.player.getY() > lowestY; if (pitch >= pitchDown.getFloatValue() || movingDownwards) { pitch = pitchDown.getFloatValue(); @@ -91,34 +92,34 @@ public class InfiniteElytra extends Module { } else if (state == FlyState.GLIDING_DOWN) { boolean willCollide = willCollideWhileGliding(ticksCollisionLookAhead.getIntValue()); - if (willCollide || mc.player.getVelocity().horizontalLengthSquared() > Math.pow(pitchUpVelocity.getFloatValue(), 2)) { + if (willCollide || mc.player.getDeltaMovement().horizontalDistanceSqr() > Math.pow(pitchUpVelocity.getFloatValue(), 2)) { pitch = pitchUp.getFloatValue(); state = FlyState.PITCHING_DOWN; lowestY = mc.player.getY(); } } - mc.player.setPitch(pitch); + mc.player.setXRot(pitch); } @EventListener private void onUseItem(UseItemEvent event) { if (mc.player == null) return; - if (mc.player.getStackInHand(event.getHand()).getItem() == Items.FIREWORK_ROCKET && !mc.player.isSpectator() && mc.player.isGliding()) { + if (mc.player.getItemInHand(event.getHand()).getItem() == Items.FIREWORK_ROCKET && !mc.player.isSpectator() && mc.player.isFallFlying()) { pitch = pitchUp.getFloatValue(); - mc.player.setPitch(pitch); + mc.player.setXRot(pitch); state = FlyState.PITCHING_DOWN; lowestY = mc.player.getY(); } } private boolean willCollideWhileGliding(int ticks) { - Vec3d velocity = mc.player.getVelocity(); - Box boundingBox = mc.player.getBoundingBox(); + Vec3 velocity = mc.player.getDeltaMovement(); + AABB boundingBox = mc.player.getBoundingBox(); for (int i = 0; i < ticks; i++) { - velocity = mc.player.calcGlidingVelocity(velocity); - boundingBox = boundingBox.offset(velocity); - if (!mc.world.isSpaceEmpty(null, boundingBox, true)) { + velocity = mc.player.updateFallFlyingMovement(velocity); + boundingBox = boundingBox.move(velocity); + if (!mc.level.noCollision(null, boundingBox, true)) { return true; } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/movement/Jesus.java b/src/main/java/me/retucio/sputnik/module/modules/movement/Jesus.java index b2f0c62..f155f74 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/movement/Jesus.java +++ b/src/main/java/me/retucio/sputnik/module/modules/movement/Jesus.java @@ -8,12 +8,13 @@ import me.retucio.sputnik.module.setting.SettingGroup; import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.EnumSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; -import net.minecraft.block.Blocks; -import net.minecraft.entity.Entity; -import net.minecraft.fluid.FluidState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; -import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.phys.shapes.Shapes; + public class Jesus extends Module { @@ -65,10 +66,10 @@ public class Jesus extends Module { @Override public void onTick() { - if (mc.player == null || mc.world == null) return; + if (mc.player == null || mc.level == null) return; Entity entity = mc.player.getRootVehicle(); - if (entity.isSneaking() && allowSneaking.getValue()) { + if (entity.isCrouching() && allowSneaking.getValue()) { return; } @@ -78,20 +79,20 @@ public class Jesus extends Module { if (!mode.is(JesusMode.VIBRATE)) return; - if (isSubmerged(entity.getEntityPos().add(new Vec3d(0, 0.3, 0)))) { - entity.setVelocity(entity.getVelocity().x, 0.08, entity.getVelocity().z); + if (isSubmerged(entity.position().add(new Vec3(0, 0.3, 0)))) { + entity.setDeltaMovement(entity.getDeltaMovement().x, 0.08, entity.getDeltaMovement().z); } - else if (isSubmerged(entity.getEntityPos().add(new Vec3d(0, 0.1, 0)))) { - entity.setVelocity(entity.getVelocity().x, 0.05, entity.getVelocity().z); + else if (isSubmerged(entity.position().add(new Vec3(0, 0.1, 0)))) { + entity.setDeltaMovement(entity.getDeltaMovement().x, 0.05, entity.getDeltaMovement().z); } - else if (isSubmerged(entity.getEntityPos().add(new Vec3d(0, 0.05, 0)))) { - entity.setVelocity(entity.getVelocity().x, 0.01, entity.getVelocity().z); + else if (isSubmerged(entity.position().add(new Vec3(0, 0.05, 0)))) { + entity.setDeltaMovement(entity.getDeltaMovement().x, 0.01, entity.getDeltaMovement().z); } - else if (isSubmerged(entity.getEntityPos())) { - entity.setVelocity(entity.getVelocity().x, -0.005, entity.getVelocity().z); + else if (isSubmerged(entity.position())) { + entity.setDeltaMovement(entity.getDeltaMovement().x, -0.005, entity.getDeltaMovement().z); entity.setOnGround(true); } } @@ -103,22 +104,22 @@ public class Jesus extends Module { if (event.getState().getBlock() == Blocks.POWDER_SNOW && !powderedSnow.getValue()) return; if (mode.getValue() == JesusMode.SOLID) if (event.getState().getBlock() == Blocks.POWDER_SNOW - && !mc.player.isSneaking() + && !mc.player.isCrouching() && mc.player.getY() > event.getPos().getY() + 1) { - event.setShape(VoxelShapes.cuboid(0, 0, 0, 1, 1.01, 1)); - } else if (!mc.world.getFluidState(event.getPos()).isEmpty() - && !mc.player.isSneaking() - && !mc.player.isTouchingWater() + event.setShape(Shapes.box(0, 0, 0, 1, 1.01, 1)); + } else if (!mc.level.getFluidState(event.getPos()).isEmpty() + && !mc.player.isCrouching() + && !mc.player.isInWater() && mc.player.getY() >= event.getPos().getY() + 0.9) { - event.setShape(VoxelShapes.cuboid(0, 0, 0, 1, 0.9, 1)); + event.setShape(Shapes.box(0, 0, 0, 1, 0.9, 1)); } } - private boolean isSubmerged(Vec3d pos) { - BlockPos blockPos = BlockPos.ofFloored(pos); - FluidState state = mc.world.getFluidState(blockPos); + private boolean isSubmerged(Vec3 pos) { + BlockPos blockPos = BlockPos.containing(pos); + FluidState state = mc.level.getFluidState(blockPos); - return !state.isEmpty() && pos.y - blockPos.getY() <= state.getHeight(); + return !state.isEmpty() && pos.y - blockPos.getY() <= state.getOwnHeight(); } private enum JesusMode { diff --git a/src/main/java/me/retucio/sputnik/module/modules/movement/Parkour.java b/src/main/java/me/retucio/sputnik/module/modules/movement/Parkour.java index e58b130..ec92d70 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/movement/Parkour.java +++ b/src/main/java/me/retucio/sputnik/module/modules/movement/Parkour.java @@ -5,8 +5,8 @@ import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; -import net.minecraft.util.math.Box; -import net.minecraft.util.shape.VoxelShape; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.shapes.VoxelShape; import java.util.stream.Stream; @@ -45,19 +45,19 @@ public class Parkour extends Module { @Override public void onTick() { - if (mc.player == null || mc.world == null) return; + if (mc.player == null || mc.level == null) return; - if (!(mc.player.isSprinting() || mc.options.sprintKey.isPressed()) && onlyWhenSprinting.getValue()) return; - if ((mc.player.isSneaking() || mc.options.sneakKey.isPressed()) && dontWhenSneaking.getValue()) return; + if (!(mc.player.isSprinting() || mc.options.keySprint.isDown()) && onlyWhenSprinting.getValue()) return; + if ((mc.player.isCrouching() || mc.options.keyShift.isDown()) && dontWhenSneaking.getValue()) return; - if(!mc.player.isOnGround() || mc.options.jumpKey.isPressed()) return; + if(!mc.player.onGround() || mc.options.keyJump.isDown()) return; - Box box = mc.player.getBoundingBox(); - Box adjustedBox = box.offset(0, -0.5, 0).expand(-offset.getValue(), 0, -offset.getValue()); + AABB box = mc.player.getBoundingBox(); + AABB adjustedBox = box.move(0, -0.5, 0).inflate(-offset.getValue(), 0, -offset.getValue()); - Stream blockCollisions = Streams.stream(mc.world.getBlockCollisions(mc.player, adjustedBox)); + Stream blockCollisions = Streams.stream(mc.level.getBlockCollisions(mc.player, adjustedBox)); if (blockCollisions.findAny().isPresent()) return; - mc.player.jump(); + mc.player.jumpFromGround(); } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/movement/ReverseStep.java b/src/main/java/me/retucio/sputnik/module/modules/movement/ReverseStep.java index bd14939..c1eb9e1 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/movement/ReverseStep.java +++ b/src/main/java/me/retucio/sputnik/module/modules/movement/ReverseStep.java @@ -4,10 +4,11 @@ import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; -import net.minecraft.util.hit.HitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.RaycastContext; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; + public class ReverseStep extends Module { @@ -40,41 +41,41 @@ public class ReverseStep extends Module { @Override public void onTick() { - if (mc.player == null || mc.world == null) return; + if (mc.player == null || mc.level == null) return; - if (!mc.player.isOnGround()) { + if (!mc.player.onGround()) { if (jumping.getValue()) return; } - if ((mc.player.isTouchingWater() || mc.player.isInLava())) { + if ((mc.player.isInWater() || mc.player.isInLava())) { if (disableInWater.getValue()) return; } double dropHeight = getHeight(); if (dropHeight > 0 && dropHeight <= height.getValue()) { - double dy = (-height.getValue() + mc.player.getVelocity().getY()) * velocity.getValue(); - mc.player.addVelocity(0, dy, 0); + double dy = (-height.getValue() + mc.player.getDeltaMovement().y()) * velocity.getValue(); + mc.player.push(0, dy, 0); } } private double getHeight() { - Vec3d start = new Vec3d(mc.player.getX(), mc.player.getY() - 0.1, mc.player.getZ()); - Vec3d end = new Vec3d(mc.player.getX(), mc.player.getY() - height.getValue() - 1, mc.player.getZ()); + Vec3 start = new Vec3(mc.player.getX(), mc.player.getY() - 0.1, mc.player.getZ()); + Vec3 end = new Vec3(mc.player.getX(), mc.player.getY() - height.getValue() - 1, mc.player.getZ()); - RaycastContext context = new RaycastContext( + ClipContext context = new ClipContext( start, end, - RaycastContext.ShapeType.COLLIDER, - RaycastContext.FluidHandling.ANY, + ClipContext.Block.COLLIDER, + ClipContext.Fluid.ANY, mc.player ); - HitResult hit = mc.world.raycast(context); + HitResult hit = mc.level.clip(context); - if (hit != null && hit.getType() == HitResult.Type.BLOCK) { + if (hit.getType() == HitResult.Type.BLOCK) { BlockPos hitPos = new BlockPos( - (int) hit.getPos().x, - (int) hit.getPos().y, - (int) hit.getPos().z + (int) hit.getLocation().x, + (int) hit.getLocation().y, + (int) hit.getLocation().z ); return mc.player.getY() - (hitPos.getY()); diff --git a/src/main/java/me/retucio/sputnik/module/modules/movement/SafeWalk.java b/src/main/java/me/retucio/sputnik/module/modules/movement/SafeWalk.java index cfffc71..09b9ce2 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/movement/SafeWalk.java +++ b/src/main/java/me/retucio/sputnik/module/modules/movement/SafeWalk.java @@ -5,11 +5,12 @@ import me.retucio.sputnik.event.interact.ClipAtLedgeEvent; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.NumberSetting; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.hit.HitResult; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.Heightmap; -import net.minecraft.world.RaycastContext; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.level.levelgen.Heightmap; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; + public class SafeWalk extends Module { @@ -23,33 +24,33 @@ public class SafeWalk extends Module { @EventListener private void onClipAtLedge(ClipAtLedgeEvent event) { - if (mc.player == null || mc.world == null) return; + if (mc.player == null || mc.level == null) return; if (fallDistance.getValue() > 1) { - int surface = mc.world.getWorldChunk( - mc.player.getBlockPos()) - .getHeightmap(Heightmap.Type.MOTION_BLOCKING) - .get(mc.player.getBlockX() & 15, mc.player.getBlockZ() & 15); + int surface = mc.level.getChunkAt( + mc.player.blockPosition()) + .getOrCreateHeightmapUnprimed(Heightmap.Types.MOTION_BLOCKING) + .getFirstAvailable(mc.player.getBlockX() & 15, mc.player.getBlockZ() & 15); if (mc.player.getBlockY() >= surface) if (mc.player.getBlockY() - surface < fallDistance.getValue()) return; else { - BlockHitResult raycastResult = mc.world.raycast(new RaycastContext( - mc.player.getEntityPos(), - new Vec3d(mc.player.getX(), - mc.world.getBottomY(), + BlockHitResult raycastResult = mc.level.clip(new ClipContext( + mc.player.position(), + new Vec3(mc.player.getX(), + mc.level.getMinY(), mc.player.getZ()), - RaycastContext.ShapeType.COLLIDER, - RaycastContext.FluidHandling.WATER, + ClipContext.Block.COLLIDER, + ClipContext.Fluid.WATER, mc.player)); if (raycastResult.getType() != HitResult.Type.MISS) - if ((int) (mc.player.getY() - raycastResult.getBlockPos().up().getY()) < fallDistance.getValue()) return; + if ((int) (mc.player.getY() - raycastResult.getBlockPos().above().getY()) < fallDistance.getValue()) return; } } - if (!mc.player.isSneaking()) + if (!mc.player.isCrouching()) event.setClipping(true); } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/movement/Scaffold.java b/src/main/java/me/retucio/sputnik/module/modules/movement/Scaffold.java index 047fd79..78e0ce2 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/movement/Scaffold.java +++ b/src/main/java/me/retucio/sputnik/module/modules/movement/Scaffold.java @@ -12,26 +12,27 @@ import me.retucio.sputnik.module.setting.settings.*; import me.retucio.sputnik.util.*; import me.retucio.sputnik.util.render.RenderUtil; -import net.minecraft.block.Block; -import net.minecraft.block.FallingBlock; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.BlockItem; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Box; -import net.minecraft.util.math.Vec3d; +import net.minecraft.core.BlockPos; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.FallingBlock; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import org.jspecify.annotations.NonNull; import java.awt.*; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; + public class Scaffold extends Module { private final SettingGroup sgBlocks = addSg(new SettingGroup("bloques", false)); private final SettingGroup sgBridge = addSg(new SettingGroup("puente", true)); - private final SettingGroup sgRender = addSg(new SettingGroup("render", false)); + private final SettingGroup sgRender = addSg(new SettingGroup("renderizado", false)); // todo: arreglar esta puta mierda private final BooleanSetting rotate = sgGeneral.add(new BooleanSetting( @@ -186,7 +187,7 @@ public class Scaffold extends Module { )).visibility(showLastPlaced::getValue); - private final BlockPos.Mutable bp = new BlockPos.Mutable(); + private final BlockPos.MutableBlockPos bp = new BlockPos.MutableBlockPos(); private final List lastPlacedBlocks = new ArrayList<>(); private Integer mjY = null; @@ -204,13 +205,13 @@ public class Scaffold extends Module { @Override public void onTick() { - if (mc.player == null || mc.world == null) return; + if (mc.player == null || mc.level == null) return; - Vec3d pos = mc.player.getEntityPos(); + Vec3 pos = mc.player.position(); // extender puente si se está moviendo hacia adelante - if (extend.getValue() && isMoving() && mc.player.forwardSpeed > 0) { - Vec3d dir = Vec3d.fromPolar(0, mc.player.getYaw()).normalize().multiply(extendDistance.getValue()); + if (extend.getValue() && isMoving() && mc.player.zza > 0) { + Vec3 dir = Vec3.directionFromRotation(0, mc.player.getYRot()).normalize().scale(extendDistance.getValue()); pos = pos.add(dir.x, 0, dir.z); } @@ -228,8 +229,8 @@ public class Scaffold extends Module { } // descender con la tecla de agacharse - if (sneakForDown.getValue() && mc.options.sneakKey.isPressed()) { - if (mc.world.isAir(bp.withY(bp.getY() - 1))) { + if (sneakForDown.getValue() && mc.options.keyShift.isDown()) { + if (mc.level.isEmptyBlock(bp.atY(bp.getY() - 1))) { y -= 1; } } @@ -239,26 +240,26 @@ public class Scaffold extends Module { place(bp); // colocar bloque encima de la cabeza - if (headhitter.getValue() && mc.options.jumpKey.isPressed() && !mc.options.sneakKey.isPressed()) { - place(mc.player.getBlockPos().up(2)); + if (headhitter.getValue() && mc.options.keyJump.isDown() && !mc.options.keyShift.isDown()) { + place(mc.player.blockPosition().above(2)); } // poner bloques a los pies del jugador mientras asciende para hacer la torre if (tower.getValue() - && mc.options.jumpKey.isPressed() - && !mc.options.sneakKey.isPressed() - && mc.player.getInventory().getSelectedStack().getItem() instanceof BlockItem - && !mc.world.isAir(mc.player.getBlockPos().down())) { - Vec3d velocity = mc.player.getVelocity(); - Box playerBox = mc.player.getBoundingBox(); + && mc.options.keyJump.isDown() + && !mc.options.keyShift.isDown() + && mc.player.getInventory().getSelectedItem().getItem() instanceof BlockItem + && !mc.level.isEmptyBlock(mc.player.blockPosition().below())) { + Vec3 velocity = mc.player.getDeltaMovement(); + AABB playerBox = mc.player.getBoundingBox(); - if (Streams.stream(mc.world.getBlockCollisions(mc.player, playerBox.offset(0, 1, 0))).toList().isEmpty()) { + if (Streams.stream(mc.level.getBlockCollisions(mc.player, playerBox.move(0, 1, 0))).toList().isEmpty()) { if (towerWhileMoving.getValue() || !isMoving()) { - velocity = new Vec3d(velocity.x, towerSpeed.getValue(), velocity.z); + velocity = new Vec3(velocity.x, towerSpeed.getValue(), velocity.z); } - mc.player.setVelocity(velocity); + mc.player.setDeltaMovement(velocity); } else { - mc.player.setVelocity(velocity.x, Math.ceil(mc.player.getY()) - mc.player.getY(), velocity.z); + mc.player.setDeltaMovement(velocity.x, Math.ceil(mc.player.getY()) - mc.player.getY(), velocity.z); mc.player.setOnGround(true); } } @@ -271,7 +272,7 @@ public class Scaffold extends Module { if (!showLastPlaced.getValue()) return; for (PlacedBlock block : lastPlacedBlocks) { - if (bp.asVector3i().equals(block.pos.asVector3i())) continue; + if (bp.toMutable().equals(block.pos.toMutable())) continue; if (fillings.getValue()) { Color fc = fade.getValue() ? Colors.withAlpha(fillingColor.getValue(), (int) ((1 - ((float) block.age / (float) block.lifeTime)) * fillingColor.getA())) @@ -309,7 +310,7 @@ public class Scaffold extends Module { if (autoSelectItem.getValue()) { List slots = InventoryUtil.findAllSlots(this::isValidBlock); for (int s : slots) { - if (PlayerInventory.isValidHotbarIndex(s)) { + if (Inventory.isHotbarSlot(s)) { slot = s; break; } @@ -326,14 +327,14 @@ public class Scaffold extends Module { // colocar bloque if (NetworkUtil.placeBlock( - pos, Hand.MAIN_HAND, + pos, InteractionHand.MAIN_HAND, mc.player.getInventory().getSelectedSlot(), rotate.getValue(), false, true, true )) { - lastPlacedBlocks.add(new PlacedBlock(pos.toImmutable(), lifeTime.getIntValue() * 20)); + lastPlacedBlocks.add(new PlacedBlock(pos.immutable(), lifeTime.getIntValue() * 20)); } } @@ -350,7 +351,7 @@ public class Scaffold extends Module { } // método helper para ver si un bloque cumple con el filtro - private boolean isValidBlock(ItemStack stack) { + private boolean isValidBlock(@NonNull ItemStack stack) { if (!(stack.getItem() instanceof BlockItem)) return false; Block block = ((BlockItem) stack.getItem()).getBlock(); @@ -358,20 +359,20 @@ public class Scaffold extends Module { if (blocksFilter.is(ListMode.BLACKLIST) && contains) return false; if (blocksFilter.is(ListMode.WHITELIST) && !contains) return false; - if (!Block.isShapeFullCube(block.getDefaultState().getCollisionShape(mc.world, BlockPos.ORIGIN))) { + if (!Block.isShapeFullBlock(block.defaultBlockState().getCollisionShape(mc.level, BlockPos.ZERO))) { return false; } if (block instanceof FallingBlock) { - return !FallingBlock.canFallThrough(mc.world.getBlockState(mc.player.getBlockPos().down())); + return !FallingBlock.isFree(mc.level.getBlockState(mc.player.blockPosition().below())); } return true; } private boolean isMoving() { - return mc.player.forwardSpeed != 0 - || mc.player.sidewaysSpeed != 0; + return mc.player.zza != 0 + || mc.player.xxa != 0; } public enum ListMode { diff --git a/src/main/java/me/retucio/sputnik/module/modules/movement/Slippy.java b/src/main/java/me/retucio/sputnik/module/modules/movement/Slippy.java index f7620db..d2365da 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/movement/Slippy.java +++ b/src/main/java/me/retucio/sputnik/module/modules/movement/Slippy.java @@ -1,15 +1,16 @@ package me.retucio.sputnik.module.modules.movement; -import me.retucio.sputnik.mixin.accessors.AbstractBlockAccessor; +import me.retucio.sputnik.mixin.accessors.BlockBehaviourAccessor; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.NumberSetting; -import net.minecraft.block.Block; -import net.minecraft.util.math.Vec3i; +import net.minecraft.core.Vec3i; +import net.minecraft.world.level.block.Block; import java.util.HashMap; import java.util.Map; + public class Slippy extends Module { private final NumberSetting slipperiness = sgGeneral.add(new NumberSetting( @@ -30,16 +31,16 @@ public class Slippy extends Module { @Override public void onDisable() { for (Block block : modifiedBlocks.keySet()) { - ((AbstractBlockAccessor) block).setSlipperiness(modifiedBlocks.get(block)); + ((BlockBehaviourAccessor) block).setSlipperiness(modifiedBlocks.get(block)); } } @Override public void onTick() { - if (mc.player == null || mc.world == null) return; - Block block = mc.world.getBlockState(mc.player.getBlockPos().add(new Vec3i(0, -1, 0))).getBlock(); - if (block.getSlipperiness() == slipperiness.getFloatValue()) return; - if (!modifiedBlocks.containsKey(block)) modifiedBlocks.put(block, block.getSlipperiness()); - ((AbstractBlockAccessor) block).setSlipperiness(slipperiness.getFloatValue()); + if (mc.player == null || mc.level == null) return; + Block block = mc.level.getBlockState(mc.player.blockPosition().offset(new Vec3i(0, -1, 0))).getBlock(); + if (block.getFriction() == slipperiness.getFloatValue()) return; + if (!modifiedBlocks.containsKey(block)) modifiedBlocks.put(block, block.getFriction()); + ((BlockBehaviourAccessor) block).setSlipperiness(slipperiness.getFloatValue()); } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/movement/Velocity.java b/src/main/java/me/retucio/sputnik/module/modules/movement/Velocity.java index 9d78985..d68efd0 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/movement/Velocity.java +++ b/src/main/java/me/retucio/sputnik/module/modules/movement/Velocity.java @@ -2,16 +2,16 @@ package me.retucio.sputnik.module.modules.movement; import com.github.retucio.neutrino.EventListener; import me.retucio.sputnik.event.network.PacketEvent; -import me.retucio.sputnik.mixin.accessors.EntityVelocityUpdateS2CPacketAccessor; -import me.retucio.sputnik.mixin.accessors.ExplosionS2CPacketAccessor; +import me.retucio.sputnik.mixin.accessors.ClientboundSetEntityMotionPacketAccessor; +import me.retucio.sputnik.mixin.accessors.ClientboundExplodePacketAccessor; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.SettingGroup; import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; -import net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket; -import net.minecraft.network.packet.s2c.play.ExplosionS2CPacket; -import net.minecraft.util.math.Vec3d; +import net.minecraft.network.protocol.game.ClientboundExplodePacket; +import net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket; +import net.minecraft.world.phys.Vec3; import java.util.Optional; @@ -78,15 +78,15 @@ public class Velocity extends Module { @EventListener private void onReceivePacket(PacketEvent.Receive event) { - if (event.getPacket() instanceof ExplosionS2CPacket explosionPacket && !explosions.getValue()) { - explosionPacket.playerKnockback().ifPresent(kb -> ((ExplosionS2CPacketAccessor) (Object) explosionPacket).setKnockback(Optional.of(new Vec3d( + if (event.getPacket() instanceof ClientboundExplodePacket explosionPacket && !explosions.getValue()) { + explosionPacket.playerKnockback().ifPresent(kb -> ((ClientboundExplodePacketAccessor) (Object) explosionPacket).setKnockback(Optional.of(new Vec3( kb.x * xPercentage.getValue() / 100, kb.y * yPercentage.getValue() / 100, kb.z * zPercentage.getValue() / 100 )))); - } else if (event.getPacket() instanceof EntityVelocityUpdateS2CPacket velocityPacket) { - Vec3d kb = velocityPacket.getVelocity(); - ((EntityVelocityUpdateS2CPacketAccessor) velocityPacket).setVelocity(new Vec3d( + } else if (event.getPacket() instanceof ClientboundSetEntityMotionPacket velocityPacket) { + Vec3 kb = velocityPacket.movement(); + ((ClientboundSetEntityMotionPacketAccessor) (Object) velocityPacket).setVelocity(new Vec3( kb.x * xPercentage.getValue() / 100, kb.y * yPercentage.getValue() / 100, kb.z * zPercentage.getValue() / 100 diff --git a/src/main/java/me/retucio/sputnik/module/modules/network/LogoutSpots.java b/src/main/java/me/retucio/sputnik/module/modules/network/LogoutSpots.java index 4130a6c..06d0042 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/network/LogoutSpots.java +++ b/src/main/java/me/retucio/sputnik/module/modules/network/LogoutSpots.java @@ -1,6 +1,7 @@ package me.retucio.sputnik.module.modules.network; import com.github.retucio.neutrino.EventListener; +import com.mojang.blaze3d.vertex.PoseStack; import me.retucio.sputnik.event.network.AddEntityEvent; import me.retucio.sputnik.event.render.Render3DEvent; import me.retucio.sputnik.module.Category; @@ -13,15 +14,14 @@ import me.retucio.sputnik.module.setting.settings.ColorSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.util.MiscUtil; import me.retucio.sputnik.util.render.RenderUtil; -import net.minecraft.client.network.OtherClientPlayerEntity; -import net.minecraft.client.network.PlayerListEntry; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Box; -import net.minecraft.util.math.Direction; -import net.minecraft.world.dimension.DimensionType; +import net.minecraft.client.multiplayer.PlayerInfo; +import net.minecraft.client.player.RemotePlayer; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.dimension.DimensionType; +import net.minecraft.world.phys.AABB; import java.awt.*; import java.util.ArrayList; @@ -48,8 +48,8 @@ public class LogoutSpots extends Module { private final BooleanSetting dummy = sgMisc.add(new BooleanSetting("monigote", "spawnear un monigote para marcar la posición", true)); private final List players = new ArrayList<>(); - private final List lastPlayerList = new ArrayList<>(); - private final List lastPlayers = new ArrayList<>(); + private final List lastPlayerList = new ArrayList<>(); + private final List lastPlayers = new ArrayList<>(); private int timer; private DimensionType lastDimension; @@ -76,15 +76,15 @@ public class LogoutSpots extends Module { @Override public void onEnable() { - if (mc.getNetworkHandler() != null) { + if (mc.getConnection() != null) { lastPlayerList.clear(); - lastPlayerList.addAll(mc.getNetworkHandler().getPlayerList()); + lastPlayerList.addAll(mc.getConnection().getOnlinePlayers()); } updateLastPlayers(); timer = 10; - if (mc.world != null) lastDimension = mc.world.getDimension(); + if (mc.level != null) lastDimension = mc.level.dimensionType(); super.onEnable(); } @@ -102,22 +102,22 @@ public class LogoutSpots extends Module { @Override public void onTick() { - if (mc.world == null || mc.getNetworkHandler() == null) return; + if (mc.level == null || mc.getConnection() == null) return; - if (mc.getNetworkHandler().getPlayerList().size() != lastPlayerList.size()) { - for (PlayerListEntry entry : lastPlayerList) { - boolean stillOnline = mc.getNetworkHandler().getPlayerList().stream() + if (mc.getConnection().getOnlinePlayers().size() != lastPlayerList.size()) { + for (PlayerInfo entry : lastPlayerList) { + boolean stillOnline = mc.getConnection().getOnlinePlayers().stream() .anyMatch(playerEntry -> playerEntry.getProfile().id().equals(entry.getProfile().id())); if (stillOnline) continue; // encontrar al jugador que se ha desconectado - for (PlayerEntity player : lastPlayers) { - if (player.getUuid().equals(entry.getProfile().id())) { + for (Player player : lastPlayers) { + if (player.getUUID().equals(entry.getProfile().id())) { LogoutEntry logoutEntry = new LogoutEntry(player); - if (mc.world != null && !mc.world.hasEntity(logoutEntry.dummy) && dummy.getValue()) - mc.world.addEntity(logoutEntry.dummy); + if (mc.level != null && !mc.level.isTickingEntity(logoutEntry.dummy) && dummy.getValue()) + mc.level.addEntity(logoutEntry.dummy); addLogoutSpot(logoutEntry); break; @@ -126,7 +126,7 @@ public class LogoutSpots extends Module { } lastPlayerList.clear(); - lastPlayerList.addAll(mc.getNetworkHandler().getPlayerList()); + lastPlayerList.addAll(mc.getConnection().getOnlinePlayers()); updateLastPlayers(); } @@ -138,12 +138,12 @@ public class LogoutSpots extends Module { } // borrar todos los logout spots al cambiar de dimensión - DimensionType currentDimension = mc.world.getDimension(); + DimensionType currentDimension = mc.level.dimensionType(); if (currentDimension != lastDimension) { for (LogoutEntry entry : players) { if (entry.dummy != null) { entry.dummy.remove(Entity.RemovalReason.KILLED); - entry.dummy.onRemoved(); + entry.dummy.onClientRemoval(); } } players.clear(); @@ -153,13 +153,13 @@ public class LogoutSpots extends Module { @EventListener private void onEntityAdded(AddEntityEvent event) { - if (event.getEntity() instanceof PlayerEntity player) { + if (event.getEntity() instanceof Player player) { for (LogoutEntry entry : players) { - if (entry.uuid.equals(player.getUuid())) { - if (entry.dummy != null && mc.world != null) { - if (mc.world.getEntityById(entry.dummy.getId()) != null) { + if (entry.uuid.equals(player.getUUID())) { + if (entry.dummy != null && mc.level != null) { + if (mc.level.getEntity(entry.dummy.getId()) != null) { entry.dummy.remove(Entity.RemovalReason.KILLED); - entry.dummy.onRemoved(); + entry.dummy.onClientRemoval(); } } players.remove(entry); @@ -171,7 +171,7 @@ public class LogoutSpots extends Module { @EventListener private void onWorldRender(Render3DEvent event) { - if (mc.player == null || mc.world == null) return; + if (mc.player == null || mc.level == null) return; for (LogoutEntry entry : players) entry.renderBox(event.getMatrices()); @@ -180,10 +180,10 @@ public class LogoutSpots extends Module { private void addLogoutSpot(LogoutEntry entry) { for (LogoutEntry e : players) { if (e.uuid.equals(entry.uuid)) { - if (e.dummy != null && mc.world != null) { - if (mc.world.getEntityById(e.dummy.getId()) != null) { + if (e.dummy != null && mc.level != null) { + if (mc.level.getEntity(e.dummy.getId()) != null) { e.dummy.remove(Entity.RemovalReason.KILLED); - e.dummy.onRemoved(); + e.dummy.onClientRemoval(); } } players.remove(e); @@ -195,11 +195,11 @@ public class LogoutSpots extends Module { } private void updateLastPlayers() { - if (mc.world == null) return; + if (mc.level == null) return; lastPlayers.clear(); - for (Entity entity : mc.world.getEntities()) - if (entity instanceof PlayerEntity player && player != mc.player) + for (Entity entity : mc.level.getEntities().getAll()) + if (entity instanceof Player player && player != mc.player) lastPlayers.add(player); } @@ -207,7 +207,7 @@ public class LogoutSpots extends Module { for (LogoutEntry entry : players) { if (entry.dummy != null) { entry.dummy.remove(Entity.RemovalReason.KILLED); - entry.dummy.onRemoved(); + entry.dummy.onClientRemoval(); } } } @@ -223,45 +223,45 @@ public class LogoutSpots extends Module { public final String logoutTime; public final String dummyName; - public final OtherClientPlayerEntity dummy; + public final RemotePlayer dummy; - public LogoutEntry(PlayerEntity player) { - this.halfWidth = player.getWidth() / 2; + public LogoutEntry(Player player) { + this.halfWidth = player.getBbWidth() / 2; this.x = player.getX() - halfWidth; this.y = player.getY(); this.z = player.getZ() - halfWidth; - Box box = player.getBoundingBox(); - this.xWidth = box.getLengthX(); - this.zWidth = box.getLengthZ(); - this.height = box.getLengthY(); + AABB box = player.getBoundingBox(); + this.xWidth = box.getXsize(); + this.zWidth = box.getYsize(); + this.height = box.getZsize(); - this.uuid = player.getUuid(); + this.uuid = player.getUUID(); this.name = player.getName().getString(); this.logoutTime = MiscUtil.getCurrentFormattedTime(); this.dummyName = name + " (" + logoutTime + ")"; this.dummy = ModuleManager.INSTANCE.getModuleByClass(FakePlayer.class).addPlayer(player, dummyName); - this.dummy.updatePositionAndAngles(x + halfWidth, y, z + halfWidth, - player.getYaw(), player.getPitch()); + this.dummy.absSnapTo(x + halfWidth, y, z + halfWidth, + player.getYRot(), player.getXRot()); } - public void renderBox(MatrixStack matrices) { + public void renderBox(PoseStack matrices) { if (fullHeight.getValue()) { if (outlines.getValue()) - RenderUtil.drawOutlineBox(matrices, new Box(x, y, z, x + xWidth, y + height, z + zWidth), outlineColor.getValue(), lineWidth.getFloatValue(), true); + RenderUtil.drawOutlineBox(matrices, new AABB(x, y, z, x + xWidth, y + height, z + zWidth), outlineColor.getValue(), lineWidth.getFloatValue(), true); if (filling.getValue()) - RenderUtil.drawFilledBox(matrices, new Box(x, y, z, x + xWidth, y + height, z + zWidth), fillingColor.getValue(), true); + RenderUtil.drawFilledBox(matrices, new AABB(x, y, z, x + xWidth, y + height, z + zWidth), fillingColor.getValue(), true); } else { if (outlines.getValue()) { RenderUtil.drawBlockFaceOutlines(matrices, - BlockPos.ofFloored(x + halfWidth, y, z + halfWidth), + BlockPos.containing(x + halfWidth, y, z + halfWidth), Direction.UP, outlineColor.getValue(), lineWidth.getFloatValue(), true); } if (filling.getValue()) { RenderUtil.drawBlockFaceFilled(matrices, - BlockPos.ofFloored(x + halfWidth, y, z + halfWidth), + BlockPos.containing(x + halfWidth, y, z + halfWidth), Direction.UP, fillingColor.getValue(), 0.001f, true); } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/network/PacketDelay.java b/src/main/java/me/retucio/sputnik/module/modules/network/PacketDelay.java index 742ec2c..562aad5 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/network/PacketDelay.java +++ b/src/main/java/me/retucio/sputnik/module/modules/network/PacketDelay.java @@ -9,12 +9,10 @@ import me.retucio.sputnik.module.setting.settings.EnumSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.NetworkUtil; - -import net.minecraft.network.ClientConnection; -import net.minecraft.network.listener.PacketListener; -import net.minecraft.network.packet.Packet; -import net.minecraft.network.packet.c2s.common.KeepAliveC2SPacket; -import net.minecraft.network.packet.s2c.common.KeepAliveS2CPacket; +import net.minecraft.network.Connection; +import net.minecraft.network.PacketListener; +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.protocol.common.ServerboundKeepAlivePacket; import java.util.*; import java.util.concurrent.CopyOnWriteArrayList; @@ -47,7 +45,7 @@ public class PacketDelay extends Module { @Override public void onTick() { - if (mc.player == null || mc.world == null || mc.getNetworkHandler() == null) { + if (mc.player == null || mc.level == null || mc.getConnection() == null) { delayedPackets.clear(); return; } @@ -71,8 +69,8 @@ public class PacketDelay extends Module { @EventListener private void onPacketSend(PacketEvent.Send event) { if (directions.is(Directions.S2C) - || mc.player == null || mc.world == null || mc.getNetworkHandler() == null - || (event.getPacket() instanceof KeepAliveC2SPacket && !packets.is(Packets.OTHERS))) + || mc.player == null || mc.level == null || mc.getConnection() == null + || (event.getPacket() instanceof ServerboundKeepAlivePacket && !packets.is(Packets.OTHERS))) return; event.cancel(); @@ -81,20 +79,22 @@ public class PacketDelay extends Module { event.getPacket(), System.currentTimeMillis() + delay.getLongValue(), true, - mc.getNetworkHandler().getConnection().getPacketListener() + mc.getConnection().getConnection().getPacketListener() )); } @EventListener private void onPacketReceive(PacketEvent.Receive event) { - if (mc.player == null || mc.world == null - || mc.getNetworkHandler() == null || mc.getNetworkHandler().getConnection() == null - || (event.getPacket() instanceof KeepAliveS2CPacket && !packets.is(Packets.OTHERS))) + if (mc.player == null || mc.level == null + || mc.getConnection() == null + || event.getPacket() instanceof ServerboundKeepAlivePacket + && !packets.is(Packets.OTHERS)) { return; + } event.cancel(); - ClientConnection connection = mc.getNetworkHandler().getConnection(); + Connection connection = mc.getConnection().getConnection(); delayedPackets.add(new DelayedPacket( event.getPacket(), @@ -111,12 +111,12 @@ public class PacketDelay extends Module { } private void processDelayedPacket(DelayedPacket delayedPacket) { - if (mc.getNetworkHandler() == null) return; + if (mc.getConnection() == null) return; if (delayedPacket.isOutgoing()) { NetworkUtil.sendPacketNoEvent(delayedPacket.packet()); } else { - if (delayedPacket.packetListener != null && mc.getNetworkHandler().getConnection() != null) { + if (delayedPacket.packetListener != null) { NetworkUtil.receivePacketNoEvent(delayedPacket.packet(), delayedPacket.packetListener()); } else { NetworkUtil.receivePacketNoEvent(delayedPacket.packet()); diff --git a/src/main/java/me/retucio/sputnik/module/modules/network/PacketMine.java b/src/main/java/me/retucio/sputnik/module/modules/network/PacketMine.java index 3e3f202..42824b7 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/network/PacketMine.java +++ b/src/main/java/me/retucio/sputnik/module/modules/network/PacketMine.java @@ -1,7 +1,6 @@ package me.retucio.sputnik.module.modules.network; import com.github.retucio.neutrino.EventListener; -import it.unimi.dsi.fastutil.booleans.BooleanSet; import me.retucio.sputnik.event.interact.AttackBlockEvent; import me.retucio.sputnik.event.render.Render3DEvent; import me.retucio.sputnik.module.Category; @@ -13,16 +12,13 @@ import me.retucio.sputnik.module.setting.settings.EnumSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.EntityUtil; -import me.retucio.sputnik.util.MiscUtil; import me.retucio.sputnik.util.render.RenderUtil; -import net.minecraft.command.argument.EntityAnchorArgumentType; -import net.minecraft.item.ItemStack; -import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import net.minecraft.util.shape.VoxelShape; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.phys.shapes.VoxelShape; import java.awt.*; import java.util.ArrayList; @@ -132,7 +128,7 @@ public class PacketMine extends Module { @Override public void onTick() { - if (mc.player == null || mc.world == null || mc.interactionManager == null) return; + if (mc.player == null || mc.level == null || mc.gameMode == null) return; if (miningBlocks.isEmpty()) { currentOrderIndex = 0; return; @@ -141,7 +137,7 @@ public class PacketMine extends Module { Iterator iterator = miningBlocks.iterator(); while (iterator.hasNext()) { MiningBlock block = iterator.next(); - if (mc.world.getBlockState(block.pos).isAir()) { + if (mc.level.getBlockState(block.pos).isAir()) { iterator.remove(); if (currentOrderIndex >= miningBlocks.size()) { currentOrderIndex = 0; @@ -223,7 +219,7 @@ public class PacketMine extends Module { private boolean processBlock(MiningBlock block) { // por si las moscas - if (mc.world.getBlockState(block.pos).isAir()) { + if (mc.level.getBlockState(block.pos).isAir()) { return false; } @@ -266,14 +262,14 @@ public class PacketMine extends Module { } public boolean mine() { - if (pos.getSquaredDistance(mc.player.getEntityPos()) > Math.pow(mc.player.getBlockInteractionRange(), 2) + if (mc.player.position().distanceToSqr(Vec3.atLowerCornerOf(pos)) > Math.pow(mc.player.blockInteractionRange(), 2) && cancelOutOfReach.getValue()) { return false; } if (dontBreak.getValue() - && mc.player.isHolding(ItemStack::isDamageable) - && mc.player.getMainHandStack().getMaxDamage() - mc.player.getMainHandStack().getDamage() <= 1) { + && mc.player.isHolding(ItemStack::isDamageableItem) + && mc.player.getMainHandItem().getMaxDamage() - mc.player.getMainHandItem().getDamageValue() <= 1) { ChatUtil.warn("pico por romperse"); toggle(); return false; @@ -281,17 +277,17 @@ public class PacketMine extends Module { rotate(); - mc.interactionManager.sendSequencedPacket(mc.world, sequence -> - new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, pos, dir, sequence)); + mc.gameMode.startPrediction(mc.level, sequence -> + new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, pos, dir, sequence)); mining = true; - mc.interactionManager.sendSequencedPacket(mc.world, sequence -> - new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, pos, dir, sequence)); + mc.gameMode.startPrediction(mc.level, sequence -> + new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, pos, dir, sequence)); return true; } public void render(Render3DEvent event) { - VoxelShape shape = mc.world.getBlockState(pos).getOutlineShape(mc.world, pos); + VoxelShape shape = mc.level.getBlockState(pos).getShape(mc.level, pos); if (shape.isEmpty()) return; RenderUtil.drawVoxelShapeOutline( @@ -305,7 +301,7 @@ public class PacketMine extends Module { } private void rotate() { - Vec3d pos = Vec3d.of(this.pos); + Vec3 pos = Vec3.atLowerCornerOf(this.pos); switch (rotate.getValue()) { case CLIENT -> EntityUtil.lookAtClient(pos); case SERVER -> EntityUtil.lookAtServer(pos); diff --git a/src/main/java/me/retucio/sputnik/module/modules/network/RPackBypass.java b/src/main/java/me/retucio/sputnik/module/modules/network/RPackBypass.java index 7f0e846..fb0ffbd 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/network/RPackBypass.java +++ b/src/main/java/me/retucio/sputnik/module/modules/network/RPackBypass.java @@ -1,22 +1,17 @@ package me.retucio.sputnik.module.modules.network; -import me.retucio.sputnik.mixin.mixins.network.ClientCommonNetworkHandlerMixin; -import me.retucio.sputnik.mixin.mixins.network.ResourcePackPolicyMixin; -import me.retucio.sputnik.mixin.mixins.network.ServerConnectorMixin; -import me.retucio.sputnik.mixin.mixins.network.ServerInfoMixin; -import me.retucio.sputnik.mixin.mixins.screen.ConfirmScreenMixin; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; -import net.minecraft.client.network.ServerInfo; -import net.minecraft.text.Text; +import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.network.chat.Component; /** continúa en: * @see ClientCommonNetworkHandlerMixin * @see ConfirmScreenMixin - * @see ResourcePackPolicyMixin + * @see ServerPackStatusMixin * @see ServerConnectorMixin - * @see ServerInfoMixin + * @see ServerDataMixin */ // https://github.com/emilyy-dev/bypass-resource-pack @@ -24,7 +19,7 @@ public class RPackBypass extends Module { public String TAG_NAME = "bypassTextures"; public String ENUM_NAME = "BYPASS"; - public Text BYPASS_TEXT = Text.literal("nuh uh"); + public Component BYPASS_TEXT = Component.literal("nuh uh"); public RPackBypass() { super("bypassear packs", @@ -32,7 +27,7 @@ public class RPackBypass extends Module { Category.NETWORK); } - public ServerInfo.ResourcePackPolicy getPolicy() { - return ServerInfo.ResourcePackPolicy.valueOf(ENUM_NAME); + public ServerData.ServerPackStatus getStatus() { + return ServerData.ServerPackStatus.valueOf(ENUM_NAME); } } \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/module/modules/network/Reconnect.java b/src/main/java/me/retucio/sputnik/module/modules/network/Reconnect.java index e7975f7..88a346e 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/network/Reconnect.java +++ b/src/main/java/me/retucio/sputnik/module/modules/network/Reconnect.java @@ -4,13 +4,15 @@ import com.github.retucio.neutrino.EventListener; import me.retucio.sputnik.event.network.DisconnectEvent; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; -import net.minecraft.client.gui.screen.multiplayer.ConnectScreen; -import net.minecraft.client.network.ServerAddress; -import net.minecraft.client.network.ServerInfo; +import net.minecraft.client.gui.screens.ConnectScreen; +import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.client.multiplayer.TransferState; +import net.minecraft.client.multiplayer.resolver.ServerAddress; + public class Reconnect extends Module { - private ServerInfo lastServer = null; + private ServerData lastServer = null; public Reconnect() { super("reconectar", @@ -25,10 +27,10 @@ public class Reconnect extends Module { public void reconnect() { if (lastServer == null) return; - ConnectScreen.connect( + ConnectScreen.startConnecting( null, mc, - ServerAddress.parse(lastServer.address), + ServerAddress.parseString(lastServer.ip), lastServer, false, null diff --git a/src/main/java/me/retucio/sputnik/module/modules/player/AirPlace.java b/src/main/java/me/retucio/sputnik/module/modules/player/AirPlace.java index f415936..2b3993c 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/player/AirPlace.java +++ b/src/main/java/me/retucio/sputnik/module/modules/player/AirPlace.java @@ -16,18 +16,17 @@ import me.retucio.sputnik.util.Colors; import me.retucio.sputnik.util.NetworkUtil; import me.retucio.sputnik.util.render.RenderUtil; -import net.minecraft.item.BlockItem; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.hit.HitResult; -import net.minecraft.util.math.Vec3d; - +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; import org.lwjgl.glfw.GLFW; public class AirPlace extends Module { private final SettingGroup sgScroll = addSg(new SettingGroup("scrolleo", true)); - private final SettingGroup sgRender = addSg(new SettingGroup("render", true)); + private final SettingGroup sgRender = addSg(new SettingGroup("extractRenderState", true)); // general @@ -56,7 +55,7 @@ public class AirPlace extends Module { 0.1 )); - // render + // extractRenderState private final BooleanSetting outlines = sgRender.add(new BooleanSetting( "contorno", "renderizar contorno de la caja de prev.", @@ -102,18 +101,18 @@ public class AirPlace extends Module { @Override public void onTick() { if (rangeValue == null) rangeValue = range.getIntValue(); - if (mc.player == null || mc.world == null || mc.interactionManager == null || mc.getCameraEntity() == null) return; - result = mc.getCameraEntity().raycast(rangeValue, 0, false); + if (mc.player == null || mc.level == null || mc.gameMode == null || mc.getCameraEntity() == null) return; + result = mc.getCameraEntity().pick(rangeValue, 0, false); } @EventListener private void onUseItem(UseItemEvent event) { if (!(result instanceof BlockHitResult bhr) || !(event.getStack().getItem() instanceof BlockItem)) return; - Vec3d hitPos = Vec3d.ofCenter(bhr.getBlockPos()); + Vec3 hitPos = Vec3.atCenterOf(bhr.getBlockPos()); BlockHitResult result = new BlockHitResult( - hitPos, mc.player.getMovementDirection().getOpposite(), bhr.getBlockPos(), false); - if (mc.player.canPlaceOn(bhr.getBlockPos(), bhr.getSide().getOpposite(), event.getStack()) && range.isValid(rangeValue)) + hitPos, mc.player.getMotionDirection().getOpposite(), bhr.getBlockPos(), false); + if (mc.player.mayUseItemAt(bhr.getBlockPos(), bhr.getDirection().getOpposite(), event.getStack()) && range.isValid(rangeValue)) NetworkUtil.interactBlock(result, event.getHand(), true); } @@ -134,9 +133,9 @@ public class AirPlace extends Module { @EventListener private void onRenderWorld(Render3DEvent event) { if (!(result instanceof BlockHitResult bhr) - || (mc.crosshairTarget != null - && mc.crosshairTarget.getType() != HitResult.Type.MISS) - || !mc.world.getBlockState(bhr.getBlockPos()).isReplaceable()) + || (mc.hitResult != null + && mc.hitResult.getType() != HitResult.Type.MISS) + || !mc.level.getBlockState(bhr.getBlockPos()).canBeReplaced()) return; if (outlines.getValue()) diff --git a/src/main/java/me/retucio/sputnik/module/modules/player/AntiHunger.java b/src/main/java/me/retucio/sputnik/module/modules/player/AntiHunger.java index 411d77b..7e959fc 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/player/AntiHunger.java +++ b/src/main/java/me/retucio/sputnik/module/modules/player/AntiHunger.java @@ -4,8 +4,9 @@ import com.github.retucio.neutrino.EventListener; import me.retucio.sputnik.event.network.PacketEvent; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; -import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; +import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; +import net.minecraft.network.protocol.game.ServerboundPlayerCommandPacket; + public class AntiHunger extends Module { @@ -16,26 +17,26 @@ public class AntiHunger extends Module { @EventListener private void onPacketSend(PacketEvent.Send event) { if (mc.player == null) return; - if (mc.player.hasVehicle() || mc.player.isTouchingWater() || mc.player.isSubmergedInWater()) return; + if (mc.player.isPassenger() || mc.player.isInWater() || mc.player.isUnderWater()) return; - if (event.getPacket() instanceof ClientCommandC2SPacket packet) { - if (packet.getMode() == ClientCommandC2SPacket.Mode.START_SPRINTING) { + if (event.getPacket() instanceof ServerboundPlayerCommandPacket packet) { + if (packet.getAction() == ServerboundPlayerCommandPacket.Action.START_SPRINTING) { event.cancel(); - if (mc.player.isGliding()) { - mc.player.stopGliding(); + if (mc.player.isFallFlying()) { + mc.player.stopFallFlying(); } } } - if (event.getPacket() instanceof PlayerMoveC2SPacket packet + if (event.getPacket() instanceof ServerboundMovePlayerPacket packet && packet.isOnGround() && mc.player.fallDistance <= 0 - && !mc.interactionManager.isBreakingBlock()) { + && !mc.gameMode.isDestroying()) { event.cancel(); - mc.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.Full( - mc.player.getEntityPos(), - mc.player.getYaw(), - mc.player.getPitch(), + mc.getConnection().send(new ServerboundMovePlayerPacket.PosRot( + mc.player.position(), + mc.player.getYRot(), + mc.player.getXRot(), false, mc.player.horizontalCollision )); diff --git a/src/main/java/me/retucio/sputnik/module/modules/player/AutoFish.java b/src/main/java/me/retucio/sputnik/module/modules/player/AutoFish.java index eafc628..0e30c5d 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/player/AutoFish.java +++ b/src/main/java/me/retucio/sputnik/module/modules/player/AutoFish.java @@ -2,7 +2,7 @@ package me.retucio.sputnik.module.modules.player; import com.github.retucio.neutrino.EventListener; import me.retucio.sputnik.event.interact.SwitchSlotEvent; -import me.retucio.sputnik.mixin.accessors.FishingBobberEntityAccessor; +import me.retucio.sputnik.mixin.accessors.FishingHookAccessor; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.SettingGroup; @@ -10,15 +10,16 @@ import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.InventoryUtil; -import net.minecraft.block.Blocks; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.hit.HitResult; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; import java.util.List; + // todo: catch delay, seleccionar la mejor caña public class AutoFish extends Module { @@ -82,16 +83,16 @@ public class AutoFish extends Module { @Override public void onTick() { - if (mc.player == null || mc.getCameraEntity() == null) return; + if (mc.player == null || mc.getCameraEntity() == null || mc.level == null) return; if (delay >= 0) delay++; - if (mc.player.isHolding(Items.FISHING_ROD) && mc.player.fishHook == null && autoRecast.getValue()) { - HitResult result = mc.getCameraEntity().raycast(recastRaycastDistance.getIntValue(), 0, true); + if (mc.player.isHolding(Items.FISHING_ROD) && mc.player.fishing == null && autoRecast.getValue()) { + HitResult result = mc.getCameraEntity().pick(recastRaycastDistance.getIntValue(), 0, true); if (onlyRecastIfLookingAtWater.getValue()) { if (result instanceof BlockHitResult bhr && bhr.getType().equals(HitResult.Type.BLOCK)) { - if (mc.world.getBlockState(bhr.getBlockPos()).isOf(Blocks.WATER) && delay >= recastDelay.getIntValue()) { + if (mc.level.getBlockState(bhr.getBlockPos()).is(Blocks.WATER) && delay >= recastDelay.getIntValue()) { useFishingRod(); return; } @@ -102,14 +103,14 @@ public class AutoFish extends Module { } } - if (mc.player.fishHook == null) { + if (mc.player.fishing == null) { if (delay >= recastDelay.getIntValue() && shouldRecast) { useFishingRod(); } return; } - FishingBobberEntityAccessor fishHook = (FishingBobberEntityAccessor) mc.player.fishHook; + FishingHookAccessor fishHook = (FishingHookAccessor) mc.player.fishing; if (fishHook.caughtFish()) { useFishingRod(); @@ -125,8 +126,8 @@ public class AutoFish extends Module { int slot = switchToFishingRod(); if (slot == -1) return; - ItemStack rod = mc.player.getInventory().getStack(slot); - if (rod.getDamage() >= rod.getMaxDamage() - 1 && dontBreak.getValue()) { + ItemStack rod = mc.player.getInventory().getItem(slot); + if (rod.getDamageValue() >= rod.getMaxDamage() - 1 && dontBreak.getValue()) { if (!warned) { ChatUtil.warn("caña a punto de romperse"); warned = true; @@ -134,16 +135,16 @@ public class AutoFish extends Module { return; } - mc.doItemUse(); + mc.startUseItem(); delay = 0; shouldRecast = false; } private int switchToFishingRod() { - if (mc.player.getActiveItem().isOf(Items.FISHING_ROD)) return mc.player.getInventory().getSelectedSlot(); - List slots = InventoryUtil.findAllSlots(stack -> stack.isOf(Items.FISHING_ROD)); + if (mc.player.getActiveItem().is(Items.FISHING_ROD)) return mc.player.getInventory().getSelectedSlot(); + List slots = InventoryUtil.findAllSlots(stack -> stack.is(Items.FISHING_ROD)); for (int slot : slots) { - if (PlayerInventory.isValidHotbarIndex(slot)) { + if (Inventory.isHotbarSlot(slot)) { mc.player.getInventory().setSelectedSlot(slot); return slot; } diff --git a/src/main/java/me/retucio/sputnik/module/modules/player/FastUse.java b/src/main/java/me/retucio/sputnik/module/modules/player/FastUse.java index 8fce3a1..5f4a308 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/player/FastUse.java +++ b/src/main/java/me/retucio/sputnik/module/modules/player/FastUse.java @@ -4,10 +4,12 @@ import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; -import net.minecraft.item.BlockItem; -import net.minecraft.item.ItemStack; + +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.ItemStack; import org.lwjgl.glfw.GLFW; + public class FastUse extends Module { private final BooleanSetting items = sgGeneral.add(new BooleanSetting( @@ -61,8 +63,8 @@ public class FastUse extends Module { Category.PLAYER, GLFW.GLFW_KEY_F6); - items.onUpdate(v -> itemCooldown.visibility(v)); - blocks.onUpdate(v -> blockCooldown.visibility(v)); + items.onUpdate(itemCooldown::visibility); + blocks.onUpdate(blockCooldown::visibility); } public int getCooldown(ItemStack stack) { diff --git a/src/main/java/me/retucio/sputnik/module/modules/player/HandView.java b/src/main/java/me/retucio/sputnik/module/modules/player/HandView.java index 423a30c..670b5e7 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/player/HandView.java +++ b/src/main/java/me/retucio/sputnik/module/modules/player/HandView.java @@ -1,20 +1,21 @@ package me.retucio.sputnik.module.modules.player; import com.github.retucio.neutrino.EventListener; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.math.Axis; import me.retucio.sputnik.event.render.RenderHeldItemEvent; import me.retucio.sputnik.event.render.RenderArmEvent; -import me.retucio.sputnik.mixin.mixins.render.HeldItemRendererMixin; +import me.retucio.sputnik.mixin.mixins.render.ItemInHandRendererMixin; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.SettingGroup; import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.math.RotationAxis; -import net.minecraft.util.math.Vec3d; +import net.minecraft.world.phys.Vec3; + /** continúa en: - * @see HeldItemRendererMixin + * @see ItemInHandRendererMixin */ public class HandView extends Module { @@ -105,36 +106,36 @@ public class HandView extends Module { private void onRenderHand(RenderHeldItemEvent event) { switch (event.getHand()) { case MAIN_HAND -> { - scale(event.getMatrices(), new Vec3d(scaleMainX.getValue(), scaleMainY.getValue(), scaleMainZ.getValue())); - translate(event.getMatrices(), new Vec3d(posMainX.getValue(), posMainY.getValue(), posMainZ.getValue())); - rotate(event.getMatrices(), new Vec3d(rotMainX.getValue(), rotMainY.getValue(), rotMainZ.getValue())); + scale(event.getMatrices(), new Vec3(scaleMainX.getValue(), scaleMainY.getValue(), scaleMainZ.getValue())); + translate(event.getMatrices(), new Vec3(posMainX.getValue(), posMainY.getValue(), posMainZ.getValue())); + rotate(event.getMatrices(), new Vec3(rotMainX.getValue(), rotMainY.getValue(), rotMainZ.getValue())); } case OFF_HAND -> { - scale(event.getMatrices(), new Vec3d(scaleOffX.getValue(), scaleOffY.getValue(), scaleOffZ.getValue())); - translate(event.getMatrices(), new Vec3d(posOffX.getValue(), posOffY.getValue(), posOffZ.getValue())); - rotate(event.getMatrices(), new Vec3d(rotOffX.getValue(), rotOffY.getValue(), rotOffZ.getValue())); + scale(event.getMatrices(), new Vec3(scaleOffX.getValue(), scaleOffY.getValue(), scaleOffZ.getValue())); + translate(event.getMatrices(), new Vec3(posOffX.getValue(), posOffY.getValue(), posOffZ.getValue())); + rotate(event.getMatrices(), new Vec3(rotOffX.getValue(), rotOffY.getValue(), rotOffZ.getValue())); } } } @EventListener private void onRenderArm(RenderArmEvent event) { - scale(event.getMatrices(), new Vec3d(scaleArmX.getValue(), scaleArmY.getValue(), scaleArmZ.getValue())); - translate(event.getMatrices(), new Vec3d(posArmX.getValue(), posArmY.getValue(), posArmZ.getValue())); - rotate(event.getMatrices(), new Vec3d(rotArmX.getValue(), rotArmY.getValue(), rotArmZ.getValue())); + scale(event.getMatrices(), new Vec3(scaleArmX.getValue(), scaleArmY.getValue(), scaleArmZ.getValue())); + translate(event.getMatrices(), new Vec3(posArmX.getValue(), posArmY.getValue(), posArmZ.getValue())); + rotate(event.getMatrices(), new Vec3(rotArmX.getValue(), rotArmY.getValue(), rotArmZ.getValue())); } - private void rotate(MatrixStack matrix, Vec3d rotation) { - matrix.multiply(RotationAxis.POSITIVE_X.rotationDegrees((float) rotation.x)); - matrix.multiply(RotationAxis.POSITIVE_Y.rotationDegrees((float) rotation.y)); - matrix.multiply(RotationAxis.POSITIVE_Z.rotationDegrees((float) rotation.z)); + private void rotate(PoseStack matrix, Vec3 rotation) { + matrix.mulPose(Axis.XP.rotationDegrees((float) rotation.x)); + matrix.mulPose(Axis.YP.rotationDegrees((float) rotation.y)); + matrix.mulPose(Axis.ZP.rotationDegrees((float) rotation.z)); } - private void scale(MatrixStack matrix, Vec3d scale) { + private void scale(PoseStack matrix, Vec3 scale) { matrix.scale((float) scale.x, (float) scale.y, (float) scale.z); } - private void translate(MatrixStack matrix, Vec3d translation) { + private void translate(PoseStack matrix, Vec3 translation) { matrix.translate((float) translation.x, (float) translation.y, (float) translation.z); } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/player/KeyPearl.java b/src/main/java/me/retucio/sputnik/module/modules/player/KeyPearl.java index 0917d45..9fa3b28 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/player/KeyPearl.java +++ b/src/main/java/me/retucio/sputnik/module/modules/player/KeyPearl.java @@ -5,8 +5,9 @@ import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.InventoryUtil; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.Items; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.item.Items; + public class KeyPearl extends Module { @@ -44,16 +45,16 @@ public class KeyPearl extends Module { } private void switchToPearl() { - PlayerInventory inv = mc.player.getInventory(); + Inventory inv = mc.player.getInventory(); - int slot = InventoryUtil.findSlot(stack -> stack.isOf(Items.ENDER_PEARL)); + int slot = InventoryUtil.findSlot(stack -> stack.is(Items.ENDER_PEARL)); if (slot < 0) { ChatUtil.error("no tienes perlas"); toggle(); return; } - if (PlayerInventory.isValidHotbarIndex(slot)) { + if (Inventory.isHotbarSlot(slot)) { prevSlot = inv.getSelectedSlot(); inv.setSelectedSlot(slot); return; @@ -65,8 +66,8 @@ public class KeyPearl extends Module { } private void throwPearl() { - if (!mc.player.getMainHandStack().isOf(Items.ENDER_PEARL)) return; - mc.doItemUse(); + if (!mc.player.getMainHandItem().is(Items.ENDER_PEARL)) return; + mc.startUseItem(); } private void switchBack() { diff --git a/src/main/java/me/retucio/sputnik/module/modules/player/NoFall.java b/src/main/java/me/retucio/sputnik/module/modules/player/NoFall.java index 74c0370..349fd37 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/player/NoFall.java +++ b/src/main/java/me/retucio/sputnik/module/modules/player/NoFall.java @@ -11,20 +11,20 @@ import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.InventoryUtil; import me.retucio.sputnik.util.Lists; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; -import net.minecraft.util.ActionResult; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.hit.HitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; +import net.minecraft.core.BlockPos; +import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; import java.util.List; @@ -90,38 +90,38 @@ public class NoFall extends Module { @Override public void onTick() { if (mc.player == null - || mc.world == null + || mc.level == null || mc.getCameraEntity() == null - || mc.interactionManager == null) + || mc.gameMode == null) return; - if (mc.player.isOnGround()) { + if (mc.player.onGround()) { placed = false; shouldUse = false; } if (shouldUse) { - mc.doItemUse(); + mc.startUseItem(); } if (mode.is(NoFallMode.CLUTCH) && mc.player.fallDistance >= distance.getValue() - && !mc.player.isOnGround() + && !mc.player.onGround() && !placed) { if (center.getValue()) { - Vec3d diff = mc.player.getEntityPos().subtract(mc.player.getBlockPos().toCenterPos()); - if (diff.lengthSquared() > 10e-3) { - Vec3d impulse = new Vec3d(-diff.x * 0.05, 0, -diff.z * 0.05); - mc.player.addVelocity(impulse.x, impulse.y, impulse.z); + Vec3 diff = mc.player.position().subtract(mc.player.blockPosition().getCenter()); + if (diff.lengthSqr() > 10e-3) { + Vec3 impulse = new Vec3(-diff.x * 0.05, 0, -diff.z * 0.05); + mc.player.push(impulse.x, impulse.y, impulse.z); } } - HitResult result = mc.getCameraEntity().raycast(3, 0, true); + HitResult result = mc.getCameraEntity().pick(3, 0, true); if (result instanceof BlockHitResult bhr) { BlockPos pos = bhr.getBlockPos(); - while (mc.world.getBlockState(pos).isOf(Blocks.AIR)) { - pos = pos.down(); + while (mc.level.getBlockState(pos).is(Blocks.AIR)) { + pos = pos.below(); } if (isSafeBlock(pos)) return; @@ -140,9 +140,9 @@ public class NoFall extends Module { } // mirar abajo - mc.player.setPitch(180); + mc.player.setXRot(180); - int slot = mc.player.getInventory().getSlotWithStack(mlgItem); + int slot = mc.player.getInventory().findSlotMatchingItem(mlgItem); mc.player.getInventory().setSelectedSlot(slot); // usar bloque @@ -153,8 +153,8 @@ public class NoFall extends Module { } // usar ítem - ActionResult didPlace = mc.interactionManager.interactItem(mc.player, Hand.MAIN_HAND); - if (didPlace.isAccepted()) + InteractionResult didPlace = mc.gameMode.useItem(mc.player, InteractionHand.MAIN_HAND); + if (didPlace.consumesAction()) placed = true; } } @@ -163,13 +163,13 @@ public class NoFall extends Module { @EventListener private void onPacketSend(PacketEvent.Send event) { if (mc.player == null - || mc.getNetworkHandler() == null + || mc.getConnection() == null || !mode.is(NoFallMode.PACKET) - || mc.player.getAbilities().creativeMode + || mc.player.getAbilities().instabuild || mc.player.fallDistance < distance.getValue()) return; - if (event.getPacket() instanceof PlayerMoveC2SPacket packet) { + if (event.getPacket() instanceof ServerboundMovePlayerPacket packet) { if (!packet.isOnGround()) { if (mc.player.fallDistance >= 3) { event.cancel(); @@ -180,12 +180,12 @@ public class NoFall extends Module { } private void sendOnGroundPacket() { - mc.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.Full( + mc.getConnection().send(new ServerboundMovePlayerPacket.PosRot( mc.player.getX(), mc.player.getY(), mc.player.getZ(), - mc.player.getYaw(), - mc.player.getPitch(), + mc.player.getYRot(), + mc.player.getXRot(), true, mc.player.horizontalCollision )); @@ -193,8 +193,8 @@ public class NoFall extends Module { private ItemStack getMlgItem() { for (Item item : items.getEnabledOptions()) { - ItemStack stack = InventoryUtil.find(itemStack -> itemStack.isOf(item)); - if (stack != null && PlayerInventory.isValidHotbarIndex(mc.player.getInventory().getSlotWithStack(stack))) { + ItemStack stack = InventoryUtil.findStack(itemStack -> itemStack.is(item)); + if (stack != null && Inventory.isHotbarSlot(mc.player.getInventory().findSlotMatchingItem(stack))) { return stack; } } @@ -202,7 +202,7 @@ public class NoFall extends Module { } private boolean isSafeBlock(BlockPos pos) { - return safeBlocks.contains(mc.world.getBlockState(pos).getBlock()); + return safeBlocks.contains(mc.level.getBlockState(pos).getBlock()); } private enum NoFallMode { diff --git a/src/main/java/me/retucio/sputnik/module/modules/player/WarnLowDurability.java b/src/main/java/me/retucio/sputnik/module/modules/player/WarnLowDurability.java index 15a13c8..e29d65e 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/player/WarnLowDurability.java +++ b/src/main/java/me/retucio/sputnik/module/modules/player/WarnLowDurability.java @@ -8,13 +8,13 @@ import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.module.setting.settings.OptionSetting; import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.Lists; -import net.minecraft.item.ItemStack; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvent; -import net.minecraft.sound.SoundEvents; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; -import net.minecraft.util.Hand; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.item.ItemStack; import java.util.ArrayList; import java.util.List; @@ -32,7 +32,7 @@ public class WarnLowDurability extends Module { private final BooleanSetting playSound = sgWarn.add(new BooleanSetting("reproducir sonido", "reproducir un sonido para alertar al usuario", true)); private final OptionSetting sound = sgSound.add(new OptionSetting<>("sonido", "qué sonido reproducir", - Lists.soundList, SoundEvents.BLOCK_NOTE_BLOCK_BELL.value(), Lists.soundNames)); + Lists.soundList, SoundEvents.NOTE_BLOCK_BELL.value(), Lists.soundNames)); private final NumberSetting volume = sgSound.add(new NumberSetting("volumen", "volumen del sonido", 70, 0, 125, 1)); private final NumberSetting pitch = sgSound.add(new NumberSetting("frecuencia", "altura del sonido", 70, 0, 125, 1)); @@ -53,27 +53,27 @@ public class WarnLowDurability extends Module { @Override public void onTick() { - if (mc.player == null || mc.world == null) return; - ItemStack stack = mc.player.getStackInHand(Hand.MAIN_HAND); + if (mc.player == null || mc.level == null) return; + ItemStack stack = mc.player.getItemInHand(InteractionHand.MAIN_HAND); if (warned.contains(stack)) return; - float percentage = (1 - (float) stack.getDamage() / stack.getMaxDamage()) * 100; + float percentage = (1 - (float) stack.getDamageValue() / stack.getMaxDamage()) * 100; if (percentage <= limitPercentage.getValue() && percentage < prevPercentage) { if (playSound.getValue()) - mc.world.playSound(mc.player, mc.player.getBlockPos(), + mc.level.playSound(mc.player, mc.player.blockPosition(), sound.getValue(), - SoundCategory.AMBIENT, + SoundSource.AMBIENT, toExponential(volume), toExponential(pitch) ); if (message.getValue()) { String customName = stack.getCustomName() == null ? "" : " \"" + stack.getCustomName().getString() + "\""; - Text text = Text.literal(Formatting.AQUA + stack.getItemName().getString() - + Formatting.GREEN + customName + Formatting.RESET - + " a " + Formatting.GOLD + ((int) percentage + "") + "%" - + Formatting.RESET + " de durabilidad"); + Component text = Component.literal(ChatFormatting.AQUA + stack.getItemName().getString() + + ChatFormatting.GREEN + customName + ChatFormatting.RESET + + " a " + ChatFormatting.GOLD + ((int) percentage + "") + "%" + + ChatFormatting.RESET + " de durabilidad"); ChatUtil.warn(text); } diff --git a/src/main/java/me/retucio/sputnik/module/modules/render/BlockESP.java b/src/main/java/me/retucio/sputnik/module/modules/render/BlockESP.java index 119e43a..967d39d 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/render/BlockESP.java +++ b/src/main/java/me/retucio/sputnik/module/modules/render/BlockESP.java @@ -1,6 +1,7 @@ package me.retucio.sputnik.module.modules.render; import com.github.retucio.neutrino.EventListener; +import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.event.render.Render3DEvent; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; @@ -12,10 +13,11 @@ import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.util.Colors; import me.retucio.sputnik.util.Lists; import me.retucio.sputnik.util.render.RenderUtil; -import net.minecraft.block.Block; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; -import net.minecraft.util.shape.VoxelShape; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Vec3i; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.phys.shapes.VoxelShape; import java.awt.*; import java.util.*; @@ -140,7 +142,7 @@ public class BlockESP extends Module { @EventListener private void onRenderWorld(Render3DEvent event) { - if (mc.player == null || mc.world == null) return; + if (mc.player == null || mc.level == null) return; // aplicar el intervalo if (searchTimer++ >= searchInterval.getIntValue()) { @@ -148,7 +150,7 @@ public class BlockESP extends Module { searchBlocks(); } - Vec3d cameraPos = mc.gameRenderer.getCamera().getCameraPos(); + Vec3 cameraPos = mc.gameRenderer.getMainCamera().position(); int rendered = 0; Iterator> iterator = cachedBlocks.entrySet().iterator(); @@ -164,7 +166,7 @@ public class BlockESP extends Module { } // validación de distancia - double distance = Math.sqrt(pos.getSquaredDistance(cameraPos)); + double distance = Math.sqrt(pos.distSqr(new Vec3i((int) cameraPos.x, (int) cameraPos.y, (int) cameraPos.z))); if (distance > radius.getIntValue()) { iterator.remove(); continue; @@ -202,14 +204,14 @@ public class BlockESP extends Module { } private void searchBlocks() { - if (mc.player == null || mc.world == null || enabledBlocks.isEmpty()) return; + if (mc.player == null || mc.level == null || enabledBlocks.isEmpty()) return; - BlockPos playerPos = mc.player.getBlockPos(); + BlockPos playerPos = mc.player.blockPosition(); int currentRadius = radius.getIntValue(); // si el jugador no se ha movido mucho, omitir la búsqueda if (lastPlayerPos != null && lastRadius == currentRadius && - playerPos.getSquaredDistance(lastPlayerPos) < (distanceToMove.getValue() * distanceToMove.getIntValue())) { + playerPos.distSqr(lastPlayerPos) < (distanceToMove.getValue() * distanceToMove.getIntValue())) { return; } @@ -227,7 +229,7 @@ public class BlockESP extends Module { } finally { isSearching = false; } - }, "sputnik-blockESP-search").start(); + }, Sputnik.MOD_ID + "-blockESP-search").start(); } else { performBlockSearch(playerPos, currentRadius); } @@ -243,13 +245,13 @@ public class BlockESP extends Module { for (int z = -radius; z <= radius; z++) { if (x*x + y*y + z*z > radiusSq) continue; - BlockPos pos = center.add(x, y, z); - Block block = mc.world.getBlockState(pos).getBlock(); + BlockPos pos = center.offset(x, y, z); + Block block = mc.level.getBlockState(pos).getBlock(); if (enabledBlocks.contains(block)) { - VoxelShape shape = mc.world.getBlockState(pos).getOutlineShape(mc.world, pos); + VoxelShape shape = mc.level.getBlockState(pos).getShape(mc.level, pos); if (!shape.isEmpty()) { - newBlocks.put(pos.toImmutable(), shape); + newBlocks.put(pos.immutable(), shape); } } } @@ -264,8 +266,8 @@ public class BlockESP extends Module { // verificar que el bloque sea válido @SuppressWarnings("deprecation") private boolean isValidBlock(BlockPos pos) { - if (mc.world == null || !mc.world.isChunkLoaded(pos)) return false; - Block block = mc.world.getBlockState(pos).getBlock(); + if (mc.level == null || !mc.level.hasChunkAt(pos)) return false; + Block block = mc.level.getBlockState(pos).getBlock(); return enabledBlocks.contains(block); } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/render/BlockOutline.java b/src/main/java/me/retucio/sputnik/module/modules/render/BlockOutline.java index 14b4065..dcef9cd 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/render/BlockOutline.java +++ b/src/main/java/me/retucio/sputnik/module/modules/render/BlockOutline.java @@ -2,7 +2,7 @@ package me.retucio.sputnik.module.modules.render; import com.github.retucio.neutrino.EventListener; import me.retucio.sputnik.event.render.RenderBlockOutlineEvent; -import me.retucio.sputnik.mixin.mixins.render.WorldRendererMixin; +import me.retucio.sputnik.mixin.mixins.render.LevelRendererMixin; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.ColorSetting; @@ -10,7 +10,7 @@ import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.util.Colors; /** continúa en: - * @see WorldRendererMixin + * @see LevelRendererMixin */ public class BlockOutline extends Module { diff --git a/src/main/java/me/retucio/sputnik/module/modules/render/Breadcrumbs.java b/src/main/java/me/retucio/sputnik/module/modules/render/Breadcrumbs.java index 8c13022..76c0891 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/render/Breadcrumbs.java +++ b/src/main/java/me/retucio/sputnik/module/modules/render/Breadcrumbs.java @@ -8,9 +8,8 @@ import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.ColorSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.util.Colors; -import me.retucio.sputnik.util.MiscUtil; import me.retucio.sputnik.util.render.RenderUtil; -import net.minecraft.util.math.Vec3d; +import net.minecraft.world.phys.Vec3; import java.awt.*; import java.util.ArrayList; @@ -56,7 +55,7 @@ public class Breadcrumbs extends Module { )); private final List crumbs = new ArrayList<>(); - private Vec3d lastPos = null; + private Vec3 lastPos = null; public Breadcrumbs() { super("recorrido", "muestra tu recorrido", Category.RENDER); @@ -85,17 +84,18 @@ public class Breadcrumbs extends Module { } if (lastPos != null) { - crumbs.add(new Breadcrumb(lastPos, mc.player.getEntityPos(), (int) (lifeTime.getValue() * 20))); + crumbs.add(new Breadcrumb(lastPos, mc.player.position(), (int) (lifeTime.getValue() * 20))); } - lastPos = mc.player.getEntityPos(); + + lastPos = mc.player.position(); } private static class Breadcrumb { - Vec3d from, to; + Vec3 from, to; int lifeTime, age; - public Breadcrumb(Vec3d from, Vec3d to, int lifeTime) { + public Breadcrumb(Vec3 from, Vec3 to, int lifeTime) { this.from = from; this.to = to; this.lifeTime = lifeTime; diff --git a/src/main/java/me/retucio/sputnik/module/modules/render/BreakingProgress.java b/src/main/java/me/retucio/sputnik/module/modules/render/BreakingProgress.java index 65d938a..b237930 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/render/BreakingProgress.java +++ b/src/main/java/me/retucio/sputnik/module/modules/render/BreakingProgress.java @@ -10,13 +10,14 @@ import me.retucio.sputnik.module.setting.settings.ColorSetting; import me.retucio.sputnik.module.setting.settings.EnumSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.util.render.RenderUtil; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Box; -import net.minecraft.util.shape.VoxelShape; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.VoxelShape; import java.awt.*; + public class BreakingProgress extends Module { private final SettingGroup sgOulines = addSg(new SettingGroup("contorno", true)); @@ -43,30 +44,30 @@ public class BreakingProgress extends Module { @EventListener private void onRenderWorld(Render3DEvent event) { - if (mc.interactionManager == null || mc.world == null) return; - if (!(mc.crosshairTarget instanceof BlockHitResult hitResult)) return; + if (mc.gameMode == null || mc.level == null) return; + if (!(mc.hitResult instanceof BlockHitResult hitResult)) return; BlockPos pos = hitResult.getBlockPos(); - int breakingProgress = mc.interactionManager.getBlockBreakingProgress(); + int breakingProgress = mc.gameMode.getDestroyStage(); if (breakingProgress <= 0) return; float progress = breakingProgress / 10f; - VoxelShape shape = mc.world.getBlockState(pos).getOutlineShape(mc.world, pos); + VoxelShape shape = mc.level.getBlockState(pos).getShape(mc.level, pos); if (shape.isEmpty()) return; - Box box = shape.getBoundingBox().offset(pos); + AABB box = shape.bounds().move(pos); float shrinkFactor = breakMode.is(BreakMode.INWARDS) ? 1f - progress : progress; - Box scaledBox = scaleBox(box, shrinkFactor); + AABB scaledBox = scaleBox(box, shrinkFactor); if (outlines.getValue()) RenderUtil.drawOutlineBox(event.getMatrices(), scaledBox, outlineColor.getValue(), lineWidth.getFloatValue(), false); if (fillings.getValue()) RenderUtil.drawFilledBox(event.getMatrices(), scaledBox, fillingColor.getValue(), false); } - private static Box scaleBox(Box box, float shrinkFactor) { + private static AABB scaleBox(AABB box, float shrinkFactor) { double centerX = (box.minX + box.maxX) / 2; double centerY = (box.minY + box.maxY) / 2; double centerZ = (box.minZ + box.maxZ) / 2; @@ -75,7 +76,7 @@ public class BreakingProgress extends Module { double shrunkY = (box.maxY - box.minY) / 2 * shrinkFactor; double shrunkZ = (box.maxZ - box.minZ) / 2 * shrinkFactor; - return new Box( + return new AABB( centerX - shrunkX, centerY - shrunkY, centerZ - shrunkZ, centerX + shrunkX, centerY + shrunkZ, centerZ + shrunkZ ); diff --git a/src/main/java/me/retucio/sputnik/module/modules/render/Confetti.java b/src/main/java/me/retucio/sputnik/module/modules/render/Confetti.java index 426b0ff..61d0365 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/render/Confetti.java +++ b/src/main/java/me/retucio/sputnik/module/modules/render/Confetti.java @@ -10,6 +10,7 @@ import me.retucio.sputnik.util.Colors; * continúa en: * @see me.retucio.sputnik.mixin.mixins.world.TotemParticleMixin */ + public class Confetti extends Module { public ColorSetting color1 = sgGeneral.add(new ColorSetting( diff --git a/src/main/java/me/retucio/sputnik/module/modules/render/CritsPlus.java b/src/main/java/me/retucio/sputnik/module/modules/render/CritsPlus.java index 3535873..8146a6d 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/render/CritsPlus.java +++ b/src/main/java/me/retucio/sputnik/module/modules/render/CritsPlus.java @@ -1,6 +1,6 @@ package me.retucio.sputnik.module.modules.render; -import me.retucio.sputnik.mixin.mixins.world.DamageParticleMixin; +import me.retucio.sputnik.mixin.mixins.world.CritParticleMixin; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.SettingGroup; @@ -9,9 +9,10 @@ import me.retucio.sputnik.module.setting.settings.ColorSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.util.Colors; + /** continúa en: - * @see DamageParticleMixin - * @see me.retucio.sputnik.mixin.DamageParticleMixin$DamageParticleFactoryMixin + * @see CritParticleMixin + * @see DamageParticleMixin$DamageParticleFactoryMixin */ public class CritsPlus extends Module { diff --git a/src/main/java/me/retucio/sputnik/module/modules/render/DamageOverlay.java b/src/main/java/me/retucio/sputnik/module/modules/render/DamageOverlay.java index 89ea699..de0c1fd 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/render/DamageOverlay.java +++ b/src/main/java/me/retucio/sputnik/module/modules/render/DamageOverlay.java @@ -1,17 +1,17 @@ package me.retucio.sputnik.module.modules.render; +import com.mojang.blaze3d.platform.NativeImage; import me.retucio.sputnik.mixin.accessors.OverlayTextureAccessor; import me.retucio.sputnik.mixin.mixins.render.OverlayTextureMixin; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.ColorSetting; - import me.retucio.sputnik.util.Colors; -import net.minecraft.client.texture.NativeImage; -import net.minecraft.client.texture.NativeImageBackedTexture; +import net.minecraft.client.renderer.texture.DynamicTexture; import java.awt.*; + /** continúa en: * @see OverlayTextureMixin */ @@ -25,7 +25,7 @@ public class DamageOverlay extends Module { false )); - private NativeImageBackedTexture texture = null; + private DynamicTexture texture = null; public DamageOverlay() { super("superposición de daño", @@ -53,11 +53,12 @@ public class DamageOverlay extends Module { } private void reloadOverlayIfReady() { - if (texture != null && texture.getImage() != null) reloadOverlay(texture); + if (texture != null) reloadOverlay(texture); } // recargar el overlay (superposición) - public void reloadOverlay(NativeImageBackedTexture texture) { + public void reloadOverlay(DynamicTexture texture) { + if (mc.gameRenderer == null) return; if (this.texture == null) this.texture = texture; int color = isEnabled() @@ -69,19 +70,17 @@ public class DamageOverlay extends Module { ).getRGB() : new Color(255, 0, 0, 178).getRGB(); - NativeImage image = texture.getImage(); + NativeImage image = texture.getPixels(); for (int y = 0; y < 8; y++) for (int x = 0; x < 16; x++) - image.setColorArgb(x, y, color); + image.setPixel(x, y, color); uploadTexture(); } // resubir las texturas private void uploadTexture() { - if (mc.gameRenderer == null) return; - - ((OverlayTextureAccessor) mc.gameRenderer.getOverlayTexture()) + ((OverlayTextureAccessor) mc.gameRenderer.overlayTexture()) .setTexture(this.texture); texture.upload(); diff --git a/src/main/java/me/retucio/sputnik/module/modules/render/EntityESP.java b/src/main/java/me/retucio/sputnik/module/modules/render/EntityESP.java index a95a36e..c47d78a 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/render/EntityESP.java +++ b/src/main/java/me/retucio/sputnik/module/modules/render/EntityESP.java @@ -1,6 +1,7 @@ package me.retucio.sputnik.module.modules.render; import com.github.retucio.neutrino.EventListener; +import com.mojang.blaze3d.vertex.PoseStack; import me.retucio.sputnik.event.render.Render3DEvent; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; @@ -12,9 +13,9 @@ import me.retucio.sputnik.module.setting.settings.ListSetting; import me.retucio.sputnik.util.Colors; import me.retucio.sputnik.util.Lists; import me.retucio.sputnik.util.render.RenderUtil; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; + public class EntityESP extends Module { @@ -78,8 +79,8 @@ public class EntityESP extends Module { fillingColor.visibility(filling.isVisible()); }); - outlines.onUpdate(v -> outlineColor.visibility(v)); - filling.onUpdate(v -> fillingColor.visibility(v)); + outlines.onUpdate(outlineColor::visibility); + filling.onUpdate(fillingColor::visibility); } @EventListener @@ -87,8 +88,8 @@ public class EntityESP extends Module { if (mode.is(ESPMode.BOX)) drawBoxes(event.getMatrices()); } - private void drawBoxes(MatrixStack matrices) { - for (Entity entity : mc.world.getEntities()) { + private void drawBoxes(PoseStack matrices) { + for (Entity entity : mc.level.getEntities().getAll()) { if (!entities.isEnabled(entity.getType())) continue; if (filling.getValue()) RenderUtil.drawFilledBox(matrices, entity.getBoundingBox(), fillingColor.getValue(), false); if (outlines.getValue()) RenderUtil.drawOutlineBox(matrices, entity.getBoundingBox(), outlineColor.getValue(), 2, false); diff --git a/src/main/java/me/retucio/sputnik/module/modules/render/Fonts.java b/src/main/java/me/retucio/sputnik/module/modules/render/Fonts.java index 49d8511..0605c80 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/render/Fonts.java +++ b/src/main/java/me/retucio/sputnik/module/modules/render/Fonts.java @@ -39,7 +39,7 @@ public class Fonts extends Module { private void reload() { if (mc.getResourceManager() != null && reload.getValue()) { - mc.reloadResources(); + mc.reloadResourcePacks(); } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/render/GlintPlus.java b/src/main/java/me/retucio/sputnik/module/modules/render/GlintPlus.java index c7aacd7..f731fb5 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/render/GlintPlus.java +++ b/src/main/java/me/retucio/sputnik/module/modules/render/GlintPlus.java @@ -1,21 +1,21 @@ package me.retucio.sputnik.module.modules.render; -import me.retucio.sputnik.mixin.mixins.render.BufferStorageMixin; -import me.retucio.sputnik.mixin.mixins.render.EquipmentRendererMixin; -import me.retucio.sputnik.mixin.mixins.render.ItemRendererMixin; +import me.retucio.sputnik.mixin.mixins.render.RenderBuffersMixin; +import me.retucio.sputnik.mixin.mixins.render.EquipmentLayerRendererMixin; +import me.retucio.sputnik.mixin.mixins.render.ItemFeatureRendererMixin; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.EnumSetting; -import me.retucio.sputnik.util.render.GlintRenderLayer; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.RenderLayers; -import net.minecraft.util.DyeColor; +import me.retucio.sputnik.util.render.GlintRenderType; +import net.minecraft.client.renderer.rendertype.RenderType; +import net.minecraft.client.renderer.rendertype.RenderTypes; +import net.minecraft.world.item.DyeColor; /** continúa en: - * @see BufferStorageMixin - * @see EquipmentRendererMixin - * @see ItemRendererMixin + * @see RenderBuffersMixin + * @see EquipmentLayerRendererMixin + * @see ItemFeatureRendererMixin */ public class GlintPlus extends Module { @@ -45,22 +45,22 @@ public class GlintPlus extends Module { Category.RENDER); } - public RenderLayer getGlint() { + public RenderType getGlint() { int color = getColor(); - if (!isEnabled() || !items.getValue()) return RenderLayers.glint(); - return GlintRenderLayer.glintColor.get(color); + if (!isEnabled() || !items.getValue()) return RenderTypes.glint(); + return GlintRenderType.glintColor.get(color); } - public RenderLayer getEntityGlint() { + public RenderType getEntityGlint() { int color = getColor(); - if (!isEnabled() || !items.getValue()) return RenderLayers.entityGlint(); - return GlintRenderLayer.entityGlintColor.get(color); + if (!isEnabled() || !items.getValue()) return RenderTypes.entityGlint(); + return GlintRenderType.entityGlintColor.get(color); } - public RenderLayer getArmorEntityGlint() { + public RenderType getArmorEntityGlint() { int color = getColor(); - if (!isEnabled() || !armor.getValue()) return RenderLayers.armorEntityGlint(); - return GlintRenderLayer.armorEntityGlintColor.get(color); + if (!isEnabled() || !armor.getValue()) return RenderTypes.armorEntityGlint(); + return GlintRenderType.armorEntityGlintColor.get(color); } public int getColor() { @@ -74,7 +74,7 @@ public class GlintPlus extends Module { } for (DyeColor dye : DyeColor.values()) - if (dye.name().equalsIgnoreCase(colorName)) return dye.getIndex(); + if (dye.name().equalsIgnoreCase(colorName)) return dye.getId(); return -1; } diff --git a/src/main/java/me/retucio/sputnik/module/modules/render/Nametags.java b/src/main/java/me/retucio/sputnik/module/modules/render/Nametags.java index fcc7442..f73fb48 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/render/Nametags.java +++ b/src/main/java/me/retucio/sputnik/module/modules/render/Nametags.java @@ -5,7 +5,7 @@ import com.google.gson.JsonParser; import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.mixin.mixins.entity.EntityMixin; import me.retucio.sputnik.mixin.mixins.entity.ItemEntityMixin; -import me.retucio.sputnik.mixin.mixins.player.PlayerEntityMixin; +import me.retucio.sputnik.mixin.mixins.player.PlayerMixin; import me.retucio.sputnik.mixin.mixins.render.LivingEntityRendererMixin; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; @@ -14,18 +14,19 @@ import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.EnumSetting; import me.retucio.sputnik.module.setting.settings.ListSetting; import me.retucio.sputnik.util.Lists; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.LazyEntityReference; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.TntEntity; -import net.minecraft.entity.damage.DamageSource; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.projectile.PersistentProjectileEntity; -import net.minecraft.item.Item; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.entity.EntityQueriable; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.Mth; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.EntityReference; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.item.PrimedTnt; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.projectile.arrow.AbstractArrow; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.level.entity.UUIDLookup; +import net.minecraft.world.level.entity.UniquelyIdentifyable; import java.io.InputStreamReader; import java.net.HttpURLConnection; @@ -36,11 +37,12 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; + /** continúa en: * @see EntityMixin * @see ItemEntityMixin * @see LivingEntityRendererMixin - * @see PlayerEntityMixin + * @see PlayerMixin */ public class Nametags extends Module { @@ -97,39 +99,39 @@ public class Nametags extends Module { } // literalmente cómo lo calcula Minecraft - public String getArrowDamage(PersistentProjectileEntity arrow) { + public String getArrowDamage(AbstractArrow arrow) { if (mc.player == null) return "0"; double initialDamage = 2; - double velocity = arrow.getVelocity().length(); - DamageSource damageSource = arrow.getDamageSources().arrow(arrow, arrow.getOwner()); + double velocity = arrow.getDeltaMovement().length(); + DamageSource damageSource = arrow.damageSources().arrow(arrow, arrow.getOwner()); - if (arrow.getWeaponStack() != null && arrow.getEntityWorld() instanceof ServerWorld world) - initialDamage = EnchantmentHelper.getDamage(world, arrow.getWeaponStack(), mc.player, damageSource, (float) initialDamage); + if (arrow.getWeaponItem() != null && arrow.level() instanceof ServerLevel world) + initialDamage = EnchantmentHelper.modifyDamage(world, arrow.getWeaponItem(), mc.player, damageSource, (float) initialDamage); - int finalDamage = MathHelper.ceil(MathHelper.clamp(velocity * initialDamage, 0, 2.147483647E9)); + int finalDamage = Mth.ceil(Mth.clamp(velocity * initialDamage, 0, 2.147483647E9)); long bonus = 0; - if (arrow.isCritical()) bonus = finalDamage / 2 - 1; + if (arrow.isCritArrow()) bonus = finalDamage / 2 - 1; if (healthMode.is(HealthMode.HEARTS)) finalDamage /= 2; return finalDamage + (bonus > 0 ? " ~ " + (finalDamage + bonus) : ""); } - public String getTntPrimeTime(TntEntity tnt) { + public String getTntPrimeTime(PrimedTnt tnt) { return String.format("%.2f\"", ((float) tnt.getFuse() / 20)); } @SuppressWarnings("deprecation") - public String getOwnerName(LazyEntityReference owner) { + public String getOwnerName(EntityReference owner) { // si el dueño está en línea (de manera segura) - if (mc.world instanceof EntityQueriable queriableWorld) { + if (mc.level instanceof UniquelyIdentifyable queriableWorld) { // UUIDLookup ?? LivingEntity ownerEntity = owner.resolve(queriableWorld, LivingEntity.class); - if (ownerEntity instanceof PlayerEntity playerEntity) return playerEntity.getName().getString(); + if (ownerEntity instanceof Player playerEntity) return playerEntity.getName().getString(); } // mirar si ya está en la caché - UUID uuid = owner.getUuid(); + UUID uuid = owner.getUUID(); String cachedName = cache.get(uuid); if (cachedName != null) return cachedName; diff --git a/src/main/java/me/retucio/sputnik/module/modules/render/NoRender.java b/src/main/java/me/retucio/sputnik/module/modules/render/NoRender.java index 471e331..5849966 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/render/NoRender.java +++ b/src/main/java/me/retucio/sputnik/module/modules/render/NoRender.java @@ -1,9 +1,9 @@ package me.retucio.sputnik.module.modules.render; import me.retucio.sputnik.mixin.mixins.hud.InGameHudMixin; -import me.retucio.sputnik.mixin.mixins.network.ClientPlayNetworkHandlerMixin; +import me.retucio.sputnik.mixin.mixins.network.ClientPacketListenerMixin; import me.retucio.sputnik.mixin.mixins.render.*; -import me.retucio.sputnik.mixin.mixins.world.ParticleManagerMixin; +import me.retucio.sputnik.mixin.mixins.world.ParticleEngineMixin; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.SettingGroup; @@ -11,20 +11,20 @@ import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.EnumSetting; import me.retucio.sputnik.module.setting.settings.ListSetting; import me.retucio.sputnik.util.Lists; -import net.minecraft.particle.ParticleType; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; +import net.minecraft.core.particles.ParticleType; /** continúa en: - * @see ClientPlayNetworkHandlerMixin + * @see ClientPacketListenerMixin * @see FogRendererMixin * @see GameRendererMixin * @see InGameHudMixin - * @see InGameOverlayRendererMixin - * @see ParticleManagerMixin - * @see StatusEffectFogModifierMixin - * @see StuckArrowsFeatureRendererMixin - * @see TextRendererDrawerMixin - * @see WeatherRenderingMixin + * @see ScreenEffectRendererMixin + * @see ParticleEngineMixin + * @see MobEffectFogEnvironmentMixin + * @see ArrowLayerMixin + * @see PreparedTextBuilderMixin + * @see WeatherEffectRendererMixin */ public class NoRender extends Module { @@ -66,7 +66,7 @@ public class NoRender extends Module { public final BooleanSetting stuckArrows = sgMisc.add(new BooleanSetting("flechas clavadas", "renderizar flechas clavadas en jugadores", false)); public NoRender() { - super("no render", + super("no extractRenderState", "customiza qué se renderiza y qué no", Category.RENDER); } @@ -93,6 +93,6 @@ public class NoRender extends Module { private final String name; Colors(String name) { this.name = name; } @Override public String toString() { return name; } - public Formatting toFormatting() { return (Formatting.byColorIndex(this.ordinal())); } + public ChatFormatting toFormatting() { return ChatFormatting.getById(this.ordinal()); } } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/render/Particles.java b/src/main/java/me/retucio/sputnik/module/modules/render/Particles.java index d8a0ed6..e98887c 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/render/Particles.java +++ b/src/main/java/me/retucio/sputnik/module/modules/render/Particles.java @@ -6,15 +6,16 @@ import me.retucio.sputnik.module.setting.SettingGroup; import me.retucio.sputnik.module.setting.settings.ListSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.util.Lists; -import net.minecraft.particle.SimpleParticleType; -import net.minecraft.registry.Registries; -import net.minecraft.text.Text; -import net.minecraft.util.math.Vec3d; +import net.minecraft.core.particles.SimpleParticleType; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.network.chat.Component; +import net.minecraft.world.phys.Vec3; import java.util.List; import java.util.Map; import java.util.Random; + public class Particles extends Module { private final SettingGroup sgDispersion = addSg(new SettingGroup("dispersión", true)); @@ -26,8 +27,8 @@ public class Particles extends Module { .toList(); Map particleNames = Lists.getMapOfLists(particleList, - particleList.stream().map(particle -> Text.translatable( - Registries.PARTICLE_TYPE.getId(particle).toShortTranslationKey()).getString()) + particleList.stream().map(particle -> Component.translatable( + BuiltInRegistries.PARTICLE_TYPE.getKey(particle).toShortLanguageKey()).getString()) .toList()); private final ListSetting particles = sgGeneral.add(new ListSetting<>( @@ -121,7 +122,7 @@ public class Particles extends Module { @Override public void onTick() { - if (mc.player == null || mc.world == null) return; + if (mc.player == null || mc.level == null) return; tickCounter++; if (tickCounter < spawnInterval.getIntValue()) { @@ -132,7 +133,7 @@ public class Particles extends Module { List enabledParticles = particles.getEnabledOptions(); if (enabledParticles.isEmpty()) return; - Vec3d basePos = new Vec3d( + Vec3 basePos = new Vec3( mc.player.getX(), mc.player.getY() + mc.player.getEyeHeight(mc.player.getPose()), mc.player.getZ() @@ -143,14 +144,14 @@ public class Particles extends Module { random.nextInt(enabledParticles.size()) ); - Vec3d pos = getPos(basePos); - Vec3d vel = getVel(); + Vec3 pos = getPos(basePos); + Vec3 vel = getVel(); - double yaw = Math.toRadians(mc.player.getYaw()); + double yaw = Math.toRadians(mc.player.getYRot()); double offX = offsetX.getValue() * Math.cos(yaw) - offsetZ.getValue() * Math.sin(yaw); double offZ = offsetX.getValue() * Math.sin(yaw) + offsetZ.getValue() * Math.cos(yaw); - mc.world.addParticleClient( + mc.level.addParticle( particle, pos.x + offX, pos.y + offsetY.getValue(), @@ -160,24 +161,24 @@ public class Particles extends Module { } } - private Vec3d getPos(Vec3d basePos) { + private Vec3 getPos(Vec3 basePos) { double randX = (random.nextDouble() - 0.5) * 2 * positionRandomness.getValue(); double randY = (random.nextDouble() - 0.5) * 2 * positionRandomness.getValue(); double randZ = (random.nextDouble() - 0.5) * 2 * positionRandomness.getValue(); - return new Vec3d( + return new Vec3( basePos.x + (random.nextDouble() - 0.5) * spreadX.getValue() + randX, basePos.y + (random.nextDouble() - 0.5) * spreadY.getValue() + randY, basePos.z + (random.nextDouble() - 0.5) * spreadZ.getValue() + randZ ); } - private Vec3d getVel() { + private Vec3 getVel() { double randX = (random.nextDouble() - 0.5) * 2 * velocityRandomness.getValue(); double randY = (random.nextDouble() - 0.5) * 2 * velocityRandomness.getValue(); double randZ = (random.nextDouble() - 0.5) * 2 * velocityRandomness.getValue(); - return new Vec3d( + return new Vec3( (random.nextDouble() - 0.5) * velocity.getValue() + randX, (random.nextDouble() - 0.5) * velocity.getValue() + randY, (random.nextDouble() - 0.5) * velocity.getValue() + randZ diff --git a/src/main/java/me/retucio/sputnik/module/modules/render/Tracers.java b/src/main/java/me/retucio/sputnik/module/modules/render/Tracers.java index eb9194b..049555d 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/render/Tracers.java +++ b/src/main/java/me/retucio/sputnik/module/modules/render/Tracers.java @@ -1,7 +1,6 @@ package me.retucio.sputnik.module.modules.render; import com.github.retucio.neutrino.EventListener; -import com.ibm.icu.impl.TimeZoneGenericNames; import me.retucio.sputnik.event.render.Render3DEvent; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; @@ -13,15 +12,15 @@ import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.util.Colors; import me.retucio.sputnik.util.Lists; import me.retucio.sputnik.util.render.RenderUtil; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.phys.Vec3; import java.awt.*; import java.util.Map; + public class Tracers extends Module { private final SettingGroup sgColors = addSg(new SettingGroup("colores", false)); @@ -94,10 +93,10 @@ public class Tracers extends Module { @EventListener private void onRenderWorld(Render3DEvent event) { - for (Entity entity : mc.world.getEntities()) { + for (Entity entity : mc.level.getEntities().getAll()) { Color color = getColor(entity); if (color == null) continue; - Vec3d interpolatedPos = entity.getLerpedPos(event.getTickDelta()).add(0, mc.player.getEyeHeight(mc.player.getPose()), 0); + Vec3 interpolatedPos = entity.getPosition(event.getTickDelta()).add(0, mc.player.getEyeHeight(mc.player.getPose()), 0); RenderUtil.drawTracer(event.getMatrices(), interpolatedPos, color, lineWidth.getFloatValue()); } } @@ -105,9 +104,9 @@ public class Tracers extends Module { private Color getColor(Entity entity) { if (!entities.isEnabled(entity.getType())) return null; if (!self.getValue() && mc.player == entity) return null; - if (entity instanceof PlayerEntity) return playerColor.getValue(); + if (entity instanceof Player) return playerColor.getValue(); - return switch (entity.getType().getSpawnGroup()) { + return switch (entity.getType().getCategory()) { case CREATURE -> animalsColor.getValue().getAlpha() > 0 ? animalsColor.getValue() : null; case MONSTER -> monstersColor.getValue().getAlpha() > 0 ? monstersColor.getValue() : null; case AMBIENT, WATER_AMBIENT -> ambientColor.getValue().getAlpha() > 0 ? ambientColor.getValue() : null; diff --git a/src/main/java/me/retucio/sputnik/module/modules/world/AutoSign.java b/src/main/java/me/retucio/sputnik/module/modules/world/AutoSign.java index abbf3eb..33e60dc 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/world/AutoSign.java +++ b/src/main/java/me/retucio/sputnik/module/modules/world/AutoSign.java @@ -7,10 +7,11 @@ import me.retucio.sputnik.mixin.accessors.AbstractSignEditScreenAccessor; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.util.ChatUtil; -import net.minecraft.block.entity.SignBlockEntity; -import net.minecraft.client.gui.screen.ingame.AbstractSignEditScreen; -import net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket; -import net.minecraft.util.math.BlockPos; +import net.minecraft.client.gui.screens.inventory.AbstractSignEditScreen; +import net.minecraft.core.BlockPos; +import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket; +import net.minecraft.world.level.block.entity.SignBlockEntity; + public class AutoSign extends Module { @@ -39,20 +40,20 @@ public class AutoSign extends Module { if (event.getScreen() instanceof AbstractSignEditScreen screen && text != null && mc != null && mc.player != null) { event.cancel(); SignBlockEntity sign = ((AbstractSignEditScreenAccessor) screen).getBlockEntity(); - fillText(sign.getPos(), sign.isPlayerFacingFront(mc.player), text); + fillText(sign.getBlockPos(), sign.isFacingFrontText(mc.player), text); } } @EventListener private void onSendPacket(PacketEvent.Send event) { - if (event.getPacket() instanceof UpdateSignC2SPacket packet) { - if (text == null) text = packet.getText().clone(); - else System.arraycopy(text, 0, packet.getText(), 0, 4); + if (event.getPacket() instanceof ServerboundSignUpdatePacket packet) { + if (text == null) text = packet.getLines().clone(); + else System.arraycopy(text, 0, packet.getLines(), 0, 4); } } private void fillText(BlockPos blockPos, boolean front, String[] text) { - mc.getNetworkHandler().sendPacket(new UpdateSignC2SPacket( + mc.getConnection().send(new ServerboundSignUpdatePacket( blockPos, front, text[0], text[1], text[2], text[3] )); } diff --git a/src/main/java/me/retucio/sputnik/module/modules/world/AutoTool.java b/src/main/java/me/retucio/sputnik/module/modules/world/AutoTool.java index 7bd0b04..7b64e73 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/world/AutoTool.java +++ b/src/main/java/me/retucio/sputnik/module/modules/world/AutoTool.java @@ -11,18 +11,19 @@ import me.retucio.sputnik.util.InventoryUtil; import me.retucio.sputnik.util.KeyUtil; import me.retucio.sputnik.util.MiscUtil; -import net.minecraft.block.BlockState; -import net.minecraft.component.DataComponentTypes; -import net.minecraft.component.type.ToolComponent; -import net.minecraft.item.ItemStack; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.hit.HitResult; +import net.minecraft.core.component.DataComponents; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.component.Tool; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; import org.lwjgl.glfw.GLFW; import java.util.HashMap; import java.util.List; import java.util.Map; + public class AutoTool extends Module { private final NumberSetting delaySetting = sgGeneral.add(new NumberSetting( @@ -59,7 +60,7 @@ public class AutoTool extends Module { public AutoTool() { super("auto herramienta", "cambia a la herramienta adecuada automáticamente", Category.WORLD); - switchBack.onUpdate(v -> switchBackDelaySetting.visibility(v)); + switchBack.onUpdate(switchBackDelaySetting::visibility); } @Override @@ -84,7 +85,7 @@ public class AutoTool extends Module { @Override public void onTick() { - if (mc.player == null || mc.player.getInventory() == null) return; + if (mc.player == null) return; if (startedMining && delaySetting.getIntValue() > 0) { delay++; @@ -116,8 +117,8 @@ public class AutoTool extends Module { } private void handle(int key, int action) { - if (mc.player == null || mc.player.getInventory() == null) return; - if (key != KeyUtil.getKey(mc.options.attackKey)) return; + if (mc.player == null) return; + if (key != KeyUtil.getKey(mc.options.keyAttack)) return; if (action == GLFW.GLFW_PRESS) { onStartMining(); @@ -157,26 +158,26 @@ public class AutoTool extends Module { } private void selectFastestTool() { - if (mc.player == null || mc.getCameraEntity() == null || mc.world == null) return; + if (mc.player == null || mc.getCameraEntity() == null || mc.level == null) return; - HitResult result = mc.getCameraEntity().raycast(mc.player.getBlockInteractionRange(), 0, false); + HitResult result = mc.getCameraEntity().pick(mc.player.blockInteractionRange(), 0, false); if (result.getType() == HitResult.Type.MISS || !(result instanceof BlockHitResult bhr)) return; - BlockState state = mc.world.getBlockState(bhr.getBlockPos()); + BlockState state = mc.level.getBlockState(bhr.getBlockPos()); - List tools = InventoryUtil.find(DataComponentTypes.TOOL); + List tools = InventoryUtil.findAllStacks(stack -> stack.has(DataComponents.TOOL)); if (tools.isEmpty()) return; Map speeds = new HashMap<>(); for (ItemStack tool : tools) { - ToolComponent toolComponent = tool.get(DataComponentTypes.TOOL); + Tool toolComponent = tool.get(DataComponents.TOOL); if (toolComponent != null) { - speeds.put(toolComponent.getSpeed(state), tool); + speeds.put(toolComponent.getMiningSpeed(state), tool); } } Float fastestSpeed = MiscUtil.getHighest(speeds.keySet().stream().toList()); ItemStack fastestTool = speeds.get(fastestSpeed); - int slot = mc.player.getInventory().getSlotWithStack(fastestTool); + int slot = mc.player.getInventory().findSlotMatchingItem(fastestTool); if (slot != -1) { if (switchBack.getValue()) prevSlot = mc.player.getInventory().getSelectedSlot(); diff --git a/src/main/java/me/retucio/sputnik/module/modules/world/BlockInfo.java b/src/main/java/me/retucio/sputnik/module/modules/world/BlockInfo.java index ffd6601..7daae70 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/world/BlockInfo.java +++ b/src/main/java/me/retucio/sputnik/module/modules/world/BlockInfo.java @@ -5,16 +5,18 @@ import com.google.gson.Gson; import me.retucio.sputnik.event.input.KeyEvent; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; +import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.EnumSetting; import me.retucio.sputnik.module.setting.settings.KeySetting; import me.retucio.sputnik.util.ChatUtil; -import net.minecraft.block.BlockState; -import net.minecraft.state.property.Property; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.hit.HitResult; -import net.minecraft.util.math.Vec3d; -import org.lwjgl.glfw.GLFW; +import net.minecraft.world.inventory.DataSlot; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.Property; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; +import org.lwjgl.glfw.GLFW; import java.util.Collection; @@ -33,6 +35,12 @@ public class BlockInfo extends Module { CopyMode.COMMAND )); + private final BooleanSetting withLiquids = sgGeneral.add(new BooleanSetting( + "líquidos", + "también incluir líquidos en el raycast", + false + )); + public BlockInfo() { super("info. de bloque", "muestra el contenido nbt del bloque al que se está apuntando", @@ -41,24 +49,25 @@ public class BlockInfo extends Module { @EventListener private void onKey(KeyEvent event) { - if (mc.player == null || mc.world == null) return; + if (mc.player == null || mc.level == null) return; if (event.getKey() != key.getValue() || event.getAction() != GLFW.GLFW_PRESS) return; - HitResult result = mc.player.getCrosshairTarget( - mc.getRenderTickCounter().getTickProgress(false), - mc.getCameraEntity() + HitResult result = mc.player.pick( + mc.player.blockInteractionRange(), + mc.getDeltaTracker().getGameTimeDeltaTicks(), + withLiquids.getValue() ); - if (result == null) { + if (result.getType() == HitResult.Type.MISS) { ChatUtil.warn("no estás apuntando a ningún bloque"); return; } if (result instanceof BlockHitResult blockHitResult) { - BlockState state = mc.world.getBlockState(blockHitResult.getBlockPos()); + BlockState state = mc.level.getBlockState(blockHitResult.getBlockPos()); Collection> data = state.getProperties(); for (Property property : data) { - ChatUtil.info(property.getName() + ": " + state.get(property)); + ChatUtil.info(property.getName() + ": " + state.getValue(property)); } copy(blockHitResult, data); } else { @@ -68,11 +77,11 @@ public class BlockInfo extends Module { private void copy(BlockHitResult result, Collection> data) { String json = new Gson().toJson(data); - String name = mc.world.getBlockState(result.getBlockPos()).getBlock().getTranslationKey(); - Vec3d pos = result.getPos(); + String name = mc.level.getBlockState(result.getBlockPos()).getBlock().getDescriptionId(); + Vec3 pos = result.getLocation(); switch (copy.getValue()) { - case JSON -> mc.keyboard.setClipboard(json); - case COMMAND -> mc.keyboard.setClipboard( + case JSON -> mc.keyboardHandler.setClipboard(json); + case COMMAND -> mc.keyboardHandler.setClipboard( String.format("/setblock %f %f %f %s %s", pos.x, pos.y, pos.z, name, json)); } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/world/ColoredSigns.java b/src/main/java/me/retucio/sputnik/module/modules/world/ColoredSigns.java index bad7d8c..5d201eb 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/world/ColoredSigns.java +++ b/src/main/java/me/retucio/sputnik/module/modules/world/ColoredSigns.java @@ -5,7 +5,8 @@ import me.retucio.sputnik.event.network.PacketEvent; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.StringSetting; -import net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket; +import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket; + public class ColoredSigns extends Module { @@ -24,9 +25,9 @@ public class ColoredSigns extends Module { @EventListener private void onSendPacket(PacketEvent.Send event) { - if (event.getPacket() instanceof UpdateSignC2SPacket packet) { + if (event.getPacket() instanceof ServerboundSignUpdatePacket packet) { for (int i = 0; i < 4; i++) { - packet.getText()[i] = packet.getText()[i].replace(symbol.getValue(), "\247" + "\247a"); + packet.getLines()[i] = packet.getLines()[i].replace(symbol.getValue(), "\247" + "\247a"); } } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/world/LightOverlay.java b/src/main/java/me/retucio/sputnik/module/modules/world/LightOverlay.java index 29c2c0a..4837eca 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/world/LightOverlay.java +++ b/src/main/java/me/retucio/sputnik/module/modules/world/LightOverlay.java @@ -1,6 +1,7 @@ package me.retucio.sputnik.module.modules.world; import com.github.retucio.neutrino.EventListener; +import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.event.render.Render3DEvent; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; @@ -8,25 +9,30 @@ import me.retucio.sputnik.module.setting.SettingGroup; import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.ColorSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; +import me.retucio.sputnik.util.MiscUtil; import me.retucio.sputnik.util.render.RenderUtil; -import net.minecraft.block.*; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.Heightmap; -import net.minecraft.world.LightType; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.LightLayer; +import net.minecraft.world.level.block.*; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.levelgen.Heightmap; +import net.minecraft.world.phys.Vec3; import java.awt.*; import java.util.*; import java.util.concurrent.ConcurrentHashMap; + public class LightOverlay extends Module { private final SettingGroup sgDetection = addSg(new SettingGroup("detección", true)); private final SettingGroup sgColors = addSg(new SettingGroup("colores", true)); private final SettingGroup sgOptimization = addSg(new SettingGroup("optimización", true)); + // detección + private final NumberSetting radius = sgDetection.add(new NumberSetting( "radio", "radio a tener en cuenta al renderizar superposición", @@ -46,7 +52,9 @@ public class LightOverlay extends Module { "mostrar superposición a través de bloques para poder verla desde fuera del agua", false)); + // optimización, porque iba como la mierda + private final NumberSetting updateInterval = sgOptimization.add(new NumberSetting( "intervalo de búsqueda", "cada cuántos ticks actualizar la búsqueda de bloques", @@ -67,7 +75,9 @@ public class LightOverlay extends Module { "actualizar solo los bloques nuevos / eliminados en lugar de recalcular todo", true)); + // colores + private final ColorSetting lightColor = sgColors.add(new ColorSetting( "color de la luz", "color de los bloques con luz", @@ -80,6 +90,7 @@ public class LightOverlay extends Module { // caché y estado + private final Set cachedBlocks = Collections.newSetFromMap(new ConcurrentHashMap<>()); private final Set blocksToRender = Collections.newSetFromMap(new ConcurrentHashMap<>()); private BlockPos lastPlayerPos = null; @@ -88,7 +99,9 @@ public class LightOverlay extends Module { private int updateTimer = 0; private boolean isSearching = false; + // para actualizaciones incrementales + private int incrementalLayer = 0; private boolean fullRescanNeeded = false; @@ -97,7 +110,7 @@ public class LightOverlay extends Module { "te muestra el nivel de luz en bloques, para prevenir mob spawns", Category.WORLD); - onWater.onUpdate(v -> dontCullWater.visibility(v)); + onWater.onUpdate(dontCullWater::visibility); } @Override @@ -125,7 +138,7 @@ public class LightOverlay extends Module { @SuppressWarnings("deprecation") @EventListener private void onRenderWorld(Render3DEvent event) { - if (mc.player == null || mc.world == null) return; + if (mc.player == null || mc.level == null) return; // actualización periódica if (updateTimer++ >= updateInterval.getIntValue()) { @@ -134,14 +147,14 @@ public class LightOverlay extends Module { } // renderizado - Vec3d cameraPos = mc.gameRenderer.getCamera().getCameraPos(); + Vec3 cameraPos = mc.gameRenderer.getMainCamera().position(); int radiusValue = radius.getIntValue(); double radiusSq = radiusValue * radiusValue; // actualizar lista de renderizado basado en distancia blocksToRender.clear(); for (BlockPos pos : cachedBlocks) { - double distanceSq = pos.getSquaredDistance(cameraPos); + double distanceSq = pos.distSqr(MiscUtil.vec3iOf(cameraPos)); if (distanceSq <= radiusSq) { blocksToRender.add(pos); } @@ -149,15 +162,15 @@ public class LightOverlay extends Module { // renderizar bloques visibles for (BlockPos block : blocksToRender) { - if (!mc.world.isChunkLoaded(block)) continue; + if (!mc.level.hasChunkAt(block)) continue; - BlockState state = mc.world.getBlockState(block); - BlockState aboveState = mc.world.getBlockState(block.up()); + BlockState state = mc.level.getBlockState(block); + BlockState aboveState = mc.level.getBlockState(block.above()); if (!isValidSpawnSurface(block, state, aboveState)) continue; // nivel de luz - int light = mc.world.getLightLevel(LightType.BLOCK, block.up()); + int light = mc.level.getBrightness(LightLayer.BLOCK, block.above()); // color Color color; @@ -174,15 +187,15 @@ public class LightOverlay extends Module { } // renderizar - boolean shouldCull = !(onWater.getValue() && aboveState.isOf(Blocks.WATER) && dontCullWater.getValue()); + boolean shouldCull = !(onWater.getValue() && aboveState.is(Blocks.WATER) && dontCullWater.getValue()); RenderUtil.drawBlockFaceFilled(event.getMatrices(), block, Direction.UP, color, 0.001f, shouldCull); } } private void updateBlocks() { - if (mc.player == null || mc.world == null) return; + if (mc.player == null || mc.level == null) return; - BlockPos playerPos = mc.player.getBlockPos(); + BlockPos playerPos = mc.player.blockPosition(); int currentRadius = radius.getIntValue(); int currentYRadius = yRadius.getIntValue(); @@ -191,7 +204,7 @@ public class LightOverlay extends Module { lastRadius != currentRadius || lastYRadius != currentYRadius || (lastPlayerPos != null && - playerPos.getSquaredDistance(lastPlayerPos) > (movementThreshold.getValue() * movementThreshold.getValue())); + playerPos.distSqr(lastPlayerPos) > (movementThreshold.getValue() * movementThreshold.getValue())); if (!needsUpdate && incrementalUpdates.getValue() && incrementalLayer >= 0) { // actualización incremental de una sola capa @@ -220,7 +233,7 @@ public class LightOverlay extends Module { } finally { isSearching = false; } - }, "sputnik-lightoverlay-search").start(); + }, Sputnik.MOD_ID + "-lightoverlay-search").start(); } else { performFullBlockSearch(playerPos, currentRadius, currentYRadius); } @@ -231,24 +244,24 @@ public class LightOverlay extends Module { Set newBlocks = new HashSet<>(); int radiusSq = radius * radius; - int minY = Math.max(mc.world.getBottomY(), center.getY() - yRadius); - int maxY = Math.min(mc.world.getTopY(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, mc.player.getBlockPos()) - 1, center.getY() + yRadius); + int minY = Math.max(mc.level.getMinY(), center.getY() - yRadius); + int maxY = Math.min(mc.level.getHeight(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, mc.player.blockPosition()) - 1, center.getY() + yRadius); for (int x = -radius; x <= radius; x++) { for (int z = -radius; z <= radius; z++) { if (x*x + z*z > radiusSq) continue; for (int y = minY; y <= maxY; y++) { - BlockPos pos = center.add(x, y - center.getY(), z); + BlockPos pos = center.offset(x, y - center.getY(), z); // nuh uh si el chunk no está cargado - if (!mc.world.isChunkLoaded(pos)) continue; + if (!mc.level.hasChunkAt(pos)) continue; - BlockState state = mc.world.getBlockState(pos); - BlockState aboveState = mc.world.getBlockState(pos.up()); + BlockState state = mc.level.getBlockState(pos); + BlockState aboveState = mc.level.getBlockState(pos.above()); if (isValidSpawnSurface(pos, state, aboveState)) { - newBlocks.add(pos.toImmutable()); + newBlocks.add(pos.immutable()); } } } @@ -267,8 +280,8 @@ public class LightOverlay extends Module { int currentX = center.getX() - radius + incrementalLayer; int radiusSq = radius * radius; - int minY = Math.max(mc.world.getBottomY(), center.getY() - yRadius); - int maxY = Math.min(mc.world.getTopY(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, mc.player.getBlockPos()) - 1, center.getY() + yRadius); + int minY = Math.max(mc.level.getMinY(), center.getY() - yRadius); + int maxY = Math.min(mc.level.getHeight(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, mc.player.blockPosition()) - 1, center.getY() + yRadius); // buscar en una columna específica (x fijo, variar z) for (int z = -radius; z <= radius; z++) { @@ -278,15 +291,15 @@ public class LightOverlay extends Module { for (int y = minY; y <= maxY; y++) { BlockPos pos = new BlockPos(currentX, y, center.getZ() + z); - if (!mc.world.isChunkLoaded(pos)) continue; + if (!mc.level.hasChunkAt(pos)) continue; - BlockState state = mc.world.getBlockState(pos); - BlockState aboveState = mc.world.getBlockState(pos.up()); + BlockState state = mc.level.getBlockState(pos); + BlockState aboveState = mc.level.getBlockState(pos.above()); boolean isValid = isValidSpawnSurface(pos, state, aboveState); if (isValid) { - cachedBlocks.add(pos.toImmutable()); + cachedBlocks.add(pos.immutable()); } else { cachedBlocks.remove(pos); } @@ -317,7 +330,7 @@ public class LightOverlay extends Module { } private boolean isValidSpawnSurface(BlockPos pos, BlockState state, BlockState aboveState) { - if (state.isAir() || !state.isOpaque() || !state.isFullCube(mc.world, pos)) { + if (state.isAir() || !state.canOcclude() || !state.isCollisionShapeFullBlock(mc.level, pos)) { return false; } @@ -325,15 +338,15 @@ public class LightOverlay extends Module { if (aboveState.isAir()) return true; if (aboveBlock == Blocks.WATER && onWater.getValue()) return true; - if (aboveBlock instanceof PlantBlock) return true; + if (aboveBlock instanceof VegetationBlock) return true; if (aboveBlock instanceof SlabBlock || - aboveBlock instanceof StairsBlock || + aboveBlock instanceof StairBlock || aboveBlock instanceof ButtonBlock || aboveBlock instanceof CarpetBlock || aboveBlock instanceof PressurePlateBlock || - aboveBlock instanceof PaneBlock || - aboveBlock instanceof TrapdoorBlock || + aboveBlock instanceof IronBarsBlock || + aboveBlock instanceof TrapDoorBlock || aboveBlock instanceof FenceBlock || aboveBlock instanceof WallBlock || aboveBlock instanceof AnvilBlock || @@ -354,6 +367,6 @@ public class LightOverlay extends Module { return false; } - return !aboveState.isOpaque() || !aboveState.isFullCube(mc.world, pos.up()); + return !aboveState.canOcclude() || !aboveState.isCollisionShapeFullBlock(mc.level, pos.above()); } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/world/NoMiningInterruptions.java b/src/main/java/me/retucio/sputnik/module/modules/world/NoMiningInterruptions.java index 7a404f1..a6adb45 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/world/NoMiningInterruptions.java +++ b/src/main/java/me/retucio/sputnik/module/modules/world/NoMiningInterruptions.java @@ -5,9 +5,10 @@ import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.ListSetting; import me.retucio.sputnik.util.Lists; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.registry.tag.ItemTags; +import net.minecraft.tags.ItemTags; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; + public class NoMiningInterruptions extends Module { @@ -26,8 +27,8 @@ public class NoMiningInterruptions extends Module { boolean pickaxe = true; if (withPickaxeOnly.getValue()) - pickaxe = (mc.player.getMainHandStack().isIn(ItemTags.PICKAXES) - || mc.player.getOffHandStack().isIn(ItemTags.PICKAXES)); + pickaxe = (mc.player.getMainHandItem().is(ItemTags.PICKAXES) + || mc.player.getOffhandItem().is(ItemTags.PICKAXES)); return entities.isEnabled(entity.getType()) && pickaxe; } diff --git a/src/main/java/me/retucio/sputnik/module/modules/world/Racist.java b/src/main/java/me/retucio/sputnik/module/modules/world/Racist.java index c383c16..601b568 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/world/Racist.java +++ b/src/main/java/me/retucio/sputnik/module/modules/world/Racist.java @@ -3,16 +3,17 @@ package me.retucio.sputnik.module.modules.world; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.util.EntityUtil; -import net.minecraft.entity.Entity; -import net.minecraft.entity.mob.EndermanEntity; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.monster.EnderMan; import java.util.ArrayList; import java.util.List; + public class Racist extends Module { private int lookTimer; - private final List lookedEndermen = new ArrayList<>(); + private final List lookedEndermen = new ArrayList<>(); public Racist() { super("racismo", @@ -28,10 +29,10 @@ public class Racist extends Module { @Override public void onTick() { - if (mc.world == null || mc.player == null) return; + if (mc.level == null || mc.player == null) return; - for (Entity entity : mc.world.getEntities()) { - if (!(entity instanceof EndermanEntity enderman)) continue; + for (Entity entity : mc.level.getEntities().getAll()) { + if (!(entity instanceof EnderMan enderman)) continue; if (shouldLookAt(enderman)) { lookAtEnderman(enderman); @@ -45,16 +46,16 @@ public class Racist extends Module { lookTimer++; } - private boolean shouldLookAt(EndermanEntity enderman) { + private boolean shouldLookAt(EnderMan enderman) { return !(lookedEndermen.contains(enderman)) && lookTimer >= 10 && EntityUtil.hasLineOfSight(mc.player, enderman); } - private void lookAtEnderman(EndermanEntity enderman) { + private void lookAtEnderman(EnderMan enderman) { double yaw = EntityUtil.getYaw(enderman); double pitch = EntityUtil.getPitch(enderman, EntityUtil.Target.HEAD); - mc.player.setYaw((float) yaw); - mc.player.setPitch((float) pitch); + mc.player.setYRot((float) yaw); + mc.player.setXRot((float) pitch); } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/world/StrongholdTriangulator.java b/src/main/java/me/retucio/sputnik/module/modules/world/StrongholdTriangulator.java index 0914a4e..996e6bb 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/world/StrongholdTriangulator.java +++ b/src/main/java/me/retucio/sputnik/module/modules/world/StrongholdTriangulator.java @@ -6,17 +6,18 @@ import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.EntityUtil; -import net.minecraft.entity.EyeOfEnderEntity; -import net.minecraft.item.Items; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; -import net.minecraft.util.Hand; -import net.minecraft.util.math.Vec3d; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.projectile.EyeOfEnder; +import net.minecraft.world.item.Items; +import net.minecraft.world.phys.Vec3; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; + // https://benwoodworth.com/minecraft/stronghold-calculator/index.js public class StrongholdTriangulator extends Module { @@ -29,12 +30,12 @@ public class StrongholdTriangulator extends Module { private boolean firstEyeThrown; private boolean secondEyeThrown; - private Vec3d a; - private Vec3d b; + private Vec3 a; + private Vec3 b; private float alpha; private float beta; - // usar un ejecutor retrasado para esperar a que el ojo de ender adquiera su ángulo + // usar un ejecutor programado (no retrasado jajsj) para esperar a que el ojo de ender adquiera su ángulo private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); @Override @@ -53,17 +54,17 @@ public class StrongholdTriangulator extends Module { @Override public void onTick() { - if (mc.player == null || mc.world == null) return; + if (mc.player == null || mc.level == null) return; if (firstEyeThrown && secondEyeThrown) { StrongholdResult result = getIntersection(); if (result != null) { if (result.errorMessage == null) { - ChatUtil.info(Text.literal("stronghold aproximadamente en: " - + Formatting.GREEN + ChatUtil.info(Component.literal("stronghold aproximadamente en: " + + ChatFormatting.GREEN + String.format("%.2f, %.2f", result.x, result.z) - + Formatting.RESET + + ChatFormatting.RESET )); } else { ChatUtil.error(result.errorMessage); @@ -78,40 +79,36 @@ public class StrongholdTriangulator extends Module { @EventListener private void onAddEntity(AddEntityEvent event) { - if (mc.player == null || mc.world == null) return; - if (mc.player.getStackInHand(Hand.MAIN_HAND).getItem() != Items.ENDER_EYE) return; + if (mc.player == null || mc.level == null) return; + if (mc.player.getItemInHand(InteractionHand.MAIN_HAND).getItem() != Items.ENDER_EYE) return; - if (event.getEntity() instanceof EyeOfEnderEntity eye) { - Vec3d throwPos = mc.player.getEntityPos(); + if (event.getEntity() instanceof EyeOfEnder eye) { + Vec3 throwPos = mc.player.position(); int entityId = eye.getId(); scheduler.schedule(() -> { // ejecutar en el hilo principal mc.execute(() -> { - EyeOfEnderEntity currentEye = findEyeEntity(entityId); + EyeOfEnder currentEye = findEyeEntity(entityId); if (currentEye != null) { - Vec3d eyeTargetPos = eye.getEntityPos(); + Vec3 eyeTargetPos = eye.position(); - if (eyeTargetPos != null) { - float yaw = (float) EntityUtil.getYaw(eyeTargetPos); + float yaw = (float) EntityUtil.getYaw(eyeTargetPos); - if (!firstEyeThrown) { - a = throwPos; - alpha = yaw; - firstEyeThrown = true; - ChatUtil.info("primer ojo registrado: " - + String.format("%.1f, %.1f (%.1f°)", a.x, a.z, alpha)); - ChatUtil.info("ahora muévete unos 200 bloques en una dirección distinta a la del ojo para lanzar el segundo"); - ChatUtil.info("cuanta más distancia te separes, más preciso será el resultado"); - } else if (!secondEyeThrown) { - b = throwPos; - beta = yaw; - secondEyeThrown = true; - ChatUtil.info("segundo ojo registrado: " + - String.format("%.1f, %.1f (%.1f°)", b.x, b.z, beta)); - } - } else { - ChatUtil.error("upsi dupsi"); + if (!firstEyeThrown) { + a = throwPos; + alpha = yaw; + firstEyeThrown = true; + ChatUtil.info("primer ojo registrado: " + + String.format("%.1f, %.1f (%.1f°)", a.x, a.z, alpha)); + ChatUtil.info("ahora muévete unos 200 bloques en una dirección distinta a la del ojo para lanzar el segundo"); + ChatUtil.info("cuanta más distancia te separes, más preciso será el resultado"); + } else if (!secondEyeThrown) { + b = throwPos; + beta = yaw; + secondEyeThrown = true; + ChatUtil.info("segundo ojo registrado: " + + String.format("%.1f, %.1f (%.1f°)", b.x, b.z, beta)); } } }); @@ -119,9 +116,9 @@ public class StrongholdTriangulator extends Module { } } - private EyeOfEnderEntity findEyeEntity(int entityId) { - if (mc.world == null) return null; - return (EyeOfEnderEntity) mc.world.getEntityById(entityId); + private EyeOfEnder findEyeEntity(int entityId) { + if (mc.level == null) return null; + return (EyeOfEnder) mc.level.getEntity(entityId); } private StrongholdResult getIntersection() { diff --git a/src/main/java/me/retucio/sputnik/module/modules/world/TimeChanger.java b/src/main/java/me/retucio/sputnik/module/modules/world/TimeChanger.java index e9c2fbb..8501432 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/world/TimeChanger.java +++ b/src/main/java/me/retucio/sputnik/module/modules/world/TimeChanger.java @@ -3,18 +3,18 @@ package me.retucio.sputnik.module.modules.world; import com.github.retucio.neutrino.EventListener; import me.retucio.sputnik.event.network.PacketEvent; import me.retucio.sputnik.mixin.mixins.render.SkyRendererMixin; -import me.retucio.sputnik.mixin.mixins.world.ClientWorldPropertiesMixin; +import me.retucio.sputnik.mixin.mixins.world.ClientLevelDataMixin; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.SettingGroup; import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.EnumSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; -import net.minecraft.network.packet.s2c.play.WorldTimeUpdateS2CPacket; +import net.minecraft.network.protocol.game.ClientboundSetTimePacket; /** continúa en: - * @see ClientWorldPropertiesMixin + * @see ClientLevelDataMixin * @see SkyRendererMixin */ @@ -42,28 +42,28 @@ public class TimeChanger extends Module { @Override public void onEnable() { - if (mc.world == null) return; - realTime = mc.world.getTime(); + if (mc.level == null) return; + realTime = mc.level.getGameTime(); super.onEnable(); } @Override public void onDisable() { - if (mc.world == null) return; - mc.world.getLevelProperties().setTimeOfDay(realTime); + if (mc.level == null) return; + mc.level.getLevelData().setGameTime(realTime); super.onDisable(); } @Override public void onTick() { - if (mc.world == null) return; - mc.world.getLevelProperties().setTimeOfDay(time.getLongValue()); + if (mc.level == null) return; + mc.level.getLevelData().setGameTime(time.getLongValue()); } @EventListener private void onPacketReceive(PacketEvent.Receive event) { - if (event.getPacket() instanceof WorldTimeUpdateS2CPacket packet) { - realTime = packet.timeOfDay(); + if (event.getPacket() instanceof ClientboundSetTimePacket packet) { + realTime = packet.gameTime(); event.cancel(); } } diff --git a/src/main/java/me/retucio/sputnik/module/setting/settings/ColorSetting.java b/src/main/java/me/retucio/sputnik/module/setting/settings/ColorSetting.java index 5a38daa..a7052a5 100644 --- a/src/main/java/me/retucio/sputnik/module/setting/settings/ColorSetting.java +++ b/src/main/java/me/retucio/sputnik/module/setting/settings/ColorSetting.java @@ -2,7 +2,7 @@ package me.retucio.sputnik.module.setting.settings; import me.retucio.sputnik.module.setting.Setting; import me.retucio.sputnik.util.Colors; -import net.minecraft.text.Text; +import net.minecraft.network.chat.Component; import java.awt.*; import java.util.HashMap; @@ -227,9 +227,9 @@ public class ColorSetting extends Setting { return getValue().getRGB(); } - public Text getTooltipText() { - if (rainbow) return Text.literal("arcoíris"); - return Text.literal(Colors.getFormatting(value) + Colors.ARGBtoHex(a, r, g, b)); + public Component getTooltipText() { + if (rainbow) return Component.literal("arcoíris"); + return Component.literal(Colors.getFormatting(value) + Colors.ARGBtoHex(a, r, g, b)); } public void reset() { diff --git a/src/main/java/me/retucio/sputnik/ui/hud/HudEditorScreen.java b/src/main/java/me/retucio/sputnik/ui/hud/HudEditorScreen.java index 89aef9f..53f43d9 100644 --- a/src/main/java/me/retucio/sputnik/ui/hud/HudEditorScreen.java +++ b/src/main/java/me/retucio/sputnik/ui/hud/HudEditorScreen.java @@ -7,21 +7,24 @@ import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.client.HUD; import me.retucio.sputnik.ui.widgets.frames.settings.ClientSettingsFrame; import me.retucio.sputnik.util.Colors; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.Click; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.text.Text; +import me.retucio.sputnik.util.KeyUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.input.MouseButtonEvent; +import net.minecraft.network.chat.Component; import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NonNull; import org.lwjgl.glfw.GLFW; import java.util.ArrayList; import java.util.List; + public class HudEditorScreen extends Screen { public static HudEditorScreen INSTANCE; - private final MinecraftClient mc = MinecraftClient.getInstance(); + private final Minecraft mc = Minecraft.getInstance(); private final HUD hud = ModuleManager.INSTANCE.getModuleByClass(HUD.class); private final List elements = new ArrayList<>(); @@ -31,7 +34,7 @@ public class HudEditorScreen extends Screen { private int dragX, dragY; public HudEditorScreen() { - super(Text.literal("editor del HUD")); + super(Component.literal("editor del HUD")); Sputnik.EVENT_BUS.subscribe(this); } @@ -41,34 +44,34 @@ public class HudEditorScreen extends Screen { } @Override - public void render(DrawContext ctx, int mouseX, int mouseY, float delta) { - ctx.fill(0, 0, this.width, this.height, Colors.hudEditorScreenBackgroundColor.getRGB()); + public void extractRenderState(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) { + gui.fill(0, 0, this.width, this.height, Colors.hudEditorScreenBackgroundColor.getRGB()); // instrucciones - ctx.drawCenteredTextWithShadow(mc.textRenderer, title, - this.width / 2, this.height / 2 - mc.textRenderer.fontHeight, -1); - ctx.drawCenteredTextWithShadow(mc.textRenderer, - Text.literal("arrastrar para mover · clic derecho para visibilidad · ESC para guardar y salir · shift + clic derecho para restablecer"), - this.width / 2, this.height / 2 + mc.textRenderer.fontHeight, Colors.instructionsTextColor.getRGB()); + gui.centeredText(mc.font, title, this.width / 2, this.height / 2 - mc.font.lineHeight, -1); + gui.centeredText(mc.font, + Component.literal("arrastrar para mover · clic derecho para visibilidad · ESC para guardar y salir · shift + clic derecho para restablecer"), + this.width / 2, this.height / 2 + mc.font.lineHeight, Colors.instructionsTextColor.getRGB()); // movimiento axial if (hud.axialMovement.getValue()) { - int centerX = mc.getWindow().getScaledWidth() / 2; + int centerX = mc.getWindow().getGuiScaledWidth() / 2; if (dragging && selected != null && Math.abs(centerX - mouseX) < hud.axisOffset.getValue()) { dragX = mouseX - centerX + selected.getW() / 2; - ctx.drawVerticalLine(centerX, 0, mc.getWindow().getScaledHeight(), Colors.CELESTE.getRGB()); + gui.verticalLine(centerX, 0, mc.getWindow().getGuiScaledHeight(), Colors.CELESTE.getRGB()); } - int centerY = mc.getWindow().getScaledHeight() / 2; + int centerY = mc.getWindow().getGuiScaledHeight() / 2; if (dragging && selected != null && Math.abs(centerY - mouseY) < hud.axisOffset.getValue()) { dragY = mouseY - centerY + selected.getH() / 2; - ctx.drawHorizontalLine(0, mc.getWindow().getScaledWidth(), centerY, Colors.CELESTE.getRGB()); + gui.horizontalLine(0, mc.getWindow().getGuiScaledWidth(), centerY, Colors.CELESTE.getRGB()); } } // elementos - for (HudElement element : elements) - element.renderInEditor(ctx, hud); + for (HudElement element : elements) { + element.renderInEditor(gui, hud); + } // tooltips if (!dragging) { @@ -76,19 +79,19 @@ public class HudEditorScreen extends Screen { if (!element.isVisible()) continue; if (element.isHovered(mouseX, mouseY)) { - List tooltip = element.getTooltip(); + List tooltip = element.getTooltip(); if (!tooltip.isEmpty()) - ctx.drawTooltip(mc.textRenderer, tooltip, mouseX + 7, mouseY + 20); + gui.setComponentTooltipForNextFrame(mc.font, tooltip, mouseX + 7, mouseY + 20); break; } } } - super.render(ctx, mouseX, mouseY, delta); + super.extractRenderState(gui, mouseX, mouseY, delta); } @Override - public boolean mouseClicked(Click click, boolean doubled) { + public boolean mouseClicked(@NonNull MouseButtonEvent click, boolean doubled) { int mouseX = (int) click.x(); int mouseY = (int) click.y(); @@ -106,7 +109,7 @@ public class HudEditorScreen extends Screen { return true; } else if (click.button() == 1) { - if (mc.isShiftPressed()) { + if (KeyUtil.isShiftDown()) { selected.resetPosition(); } else { selected.setVisible(!selected.isVisible()); @@ -121,7 +124,7 @@ public class HudEditorScreen extends Screen { } @Override - public boolean mouseDragged(Click click, double deltaX, double deltaY) { + public boolean mouseDragged(@NonNull MouseButtonEvent click, double deltaX, double deltaY) { if (!dragging || selected == null || click.button() != 0) return super.mouseDragged(click, deltaX, deltaY); @@ -131,15 +134,15 @@ public class HudEditorScreen extends Screen { int newX = mouseX - dragX; int newY = mouseY - dragY; - newX = Math.max(1, Math.min(newX, width - selected.getW() - 1)); - newY = Math.max(1, Math.min(newY, height - selected.getH() - 1)); + newX = Math.clamp(newX, 1, width - selected.getW() - 1); + newY = Math.clamp(newY, 1, height - selected.getH() - 1); selected.setPosition(newX, newY); return true; } @Override - public boolean mouseReleased(Click click) { + public boolean mouseReleased(@NonNull MouseButtonEvent click) { if (dragging && click.button() == 0) { dragging = false; if (selected != null) @@ -154,7 +157,7 @@ public class HudEditorScreen extends Screen { // he sustituído el método del súper por un evento para ver si así se podían // registrar dos teclas a la vez, pero resulta que no :P public void onKey(KeyEvent event) { - if (!(mc.currentScreen == INSTANCE)) return; + if (!(mc.screen == INSTANCE)) return; if (event.getAction() == GLFW.GLFW_RELEASE) return; event.cancel(); @@ -171,13 +174,13 @@ public class HudEditorScreen extends Screen { selected.setY(Math.max(1, selected.getY() - offset)); } if (event.getKey() == GLFW.GLFW_KEY_DOWN) { - selected.setY(Math.min(mc.getWindow().getScaledHeight() - selected.getH() + 1, selected.getY() + offset)); + selected.setY(Math.min(mc.getWindow().getGuiScaledHeight() - selected.getH() + 1, selected.getY() + offset)); } if (event.getKey() == GLFW.GLFW_KEY_LEFT) { selected.setX(Math.max(1, selected.getX() - offset)); } if (event.getKey() == GLFW.GLFW_KEY_RIGHT) { - selected.setX(Math.min(mc.getWindow().getScaledWidth() - selected.getW() + 1, selected.getX() + offset)); + selected.setX(Math.min(mc.getWindow().getGuiScaledWidth() - selected.getW() + 1, selected.getX() + offset)); } } } @@ -195,9 +198,9 @@ public class HudEditorScreen extends Screen { } @Override - protected void applyBlur(DrawContext ctx) { + protected void extractBlurredBackground(@NonNull GuiGraphicsExtractor gui) { if (ClientSettingsFrame.guiSettings.blur.getValue()) { - super.applyBlur(ctx); + super.extractBlurredBackground(gui); } } diff --git a/src/main/java/me/retucio/sputnik/ui/hud/HudElement.java b/src/main/java/me/retucio/sputnik/ui/hud/HudElement.java index ccb0303..d741719 100644 --- a/src/main/java/me/retucio/sputnik/ui/hud/HudElement.java +++ b/src/main/java/me/retucio/sputnik/ui/hud/HudElement.java @@ -2,11 +2,12 @@ package me.retucio.sputnik.ui.hud; import me.retucio.sputnik.module.modules.client.HUD; import me.retucio.sputnik.ui.widgets.Widget; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.text.Text; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.network.chat.Component; import java.util.List; + public abstract class HudElement extends Widget { private final String id; @@ -21,9 +22,9 @@ public abstract class HudElement extends Widget { this.visible = true; } - public abstract void renderInGame(DrawContext ctx, float delta, HUD hud); - public abstract void renderInEditor(DrawContext ctx, HUD hud); - public abstract List getTooltip(); + public abstract void renderInGame(GuiGraphicsExtractor gui, float delta, HUD hud); + public abstract void renderInEditor(GuiGraphicsExtractor gui, HUD hud); + public abstract List getTooltip(); public String getId() { return id; } diff --git a/src/main/java/me/retucio/sputnik/ui/hud/HudRenderer.java b/src/main/java/me/retucio/sputnik/ui/hud/HudRenderer.java index 321cd00..398612b 100644 --- a/src/main/java/me/retucio/sputnik/ui/hud/HudRenderer.java +++ b/src/main/java/me/retucio/sputnik/ui/hud/HudRenderer.java @@ -4,21 +4,21 @@ import me.retucio.sputnik.config.ConfigManager; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.client.HUD; import me.retucio.sputnik.ui.hud.elements.*; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.ChatScreen; -import net.minecraft.client.gui.screen.TitleScreen; -import net.minecraft.client.render.RenderTickCounter; +import net.minecraft.client.DeltaTracker; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.client.gui.screens.ChatScreen; +import net.minecraft.client.gui.screens.TitleScreen; import java.awt.*; import java.util.ArrayList; import java.util.List; import java.util.Map; + public class HudRenderer { - private static final MinecraftClient mc = MinecraftClient.getInstance(); + private static final Minecraft mc = Minecraft.getInstance(); private static final List elements = new ArrayList<>(); private static boolean initialized = false; @@ -79,26 +79,26 @@ public class HudRenderer { return hud.color.getValue(); } - public static void drawSnappedText(DrawContext ctx, String text, int x, int y, int color, boolean shadow) { - int textWidth = mc.textRenderer.getWidth(text); - int screenWidth = mc.getWindow().getScaledWidth(); - int screenHeight = mc.getWindow().getScaledHeight(); + public static void drawSnappedText(GuiGraphicsExtractor gui, String text, int x, int y, int color, boolean shadow) { + int textWidth = mc.font.width(text); + int screenWidth = mc.getWindow().getGuiScaledWidth(); + int screenHeight = mc.getWindow().getGuiScaledHeight(); boolean snapRight = x > screenWidth / 2; int drawX = snapRight ? x + (textWidth + 2) - textWidth : x; - drawX = Math.max(0, Math.min(drawX, screenWidth - textWidth)); - y = Math.max(0, Math.min(y, screenHeight - mc.textRenderer.fontHeight)); + drawX = Math.clamp(drawX, 0, screenWidth - textWidth); + y = Math.clamp(y, 0, screenHeight - mc.font.lineHeight); - ctx.drawText(mc.textRenderer, text, drawX, y, color, shadow); + gui.text(mc.font, text, drawX, y, color, shadow); } - public static void render(DrawContext ctx, RenderTickCounter tickCounter) { + public static void render(GuiGraphicsExtractor gui, DeltaTracker dt) { HUD hud = ModuleManager.INSTANCE.getModuleByClass(HUD.class); for (HudElement element : elements) { if (element.isVisible() && !shouldSkipRendering()) { - element.renderInGame(ctx, tickCounter.getDynamicDeltaTicks(), hud); + element.renderInGame(gui, dt.getGameTimeDeltaTicks(), hud); } } } @@ -108,12 +108,12 @@ public class HudRenderer { return ModuleManager.INSTANCE == null || mc.player == null || mc.getCameraEntity() == null - || mc.currentScreen instanceof TitleScreen - || mc.options.hudHidden + || mc.screen instanceof TitleScreen + || mc.options.hideGui || !hud.isEnabled() - || (mc.debugHudEntryList.isF3Enabled() && !hud.showOnF3.getValue()) - || (mc.currentScreen instanceof ChatScreen && !hud.showOnChat.getValue()) - || mc.currentScreen instanceof HudEditorScreen; + || (mc.debugEntries.isOverlayVisible() && !hud.showOnF3.getValue()) + || (mc.screen instanceof ChatScreen && !hud.showOnChat.getValue()) + || mc.screen instanceof HudEditorScreen; } public static List getElements() { diff --git a/src/main/java/me/retucio/sputnik/ui/hud/ImageHudElement.java b/src/main/java/me/retucio/sputnik/ui/hud/ImageHudElement.java index 5b2b949..f19682c 100644 --- a/src/main/java/me/retucio/sputnik/ui/hud/ImageHudElement.java +++ b/src/main/java/me/retucio/sputnik/ui/hud/ImageHudElement.java @@ -1,29 +1,30 @@ package me.retucio.sputnik.ui.hud; +import com.mojang.blaze3d.platform.NativeImage; import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.module.modules.client.HUD; import me.retucio.sputnik.util.Colors; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.client.renderer.RenderPipelines; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.resources.Identifier; -import net.minecraft.client.gl.RenderPipelines; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.texture.NativeImage; -import net.minecraft.client.texture.NativeImageBackedTexture; -import net.minecraft.util.Identifier; import java.io.InputStream; import java.util.function.Supplier; + public abstract class ImageHudElement extends HudElement { protected Identifier textureId; protected int imageWidth = 64; protected int imageHeight = 64; protected boolean textureLoaded = false; - protected NativeImageBackedTexture texture; + protected DynamicTexture texture; public ImageHudElement(String id, int defaultX, int defaultY) { super(id, defaultX, defaultY); - this.textureId = Identifier.of(Sputnik.MOD_ID, "textures/" + id); + this.textureId = Identifier.fromNamespaceAndPath(Sputnik.MOD_ID, "textures/" + id); this.w = imageWidth; this.h = imageHeight; } @@ -37,25 +38,26 @@ public abstract class ImageHudElement extends HudElement { try { // cargar - Identifier resourceId = Identifier.of(Sputnik.MOD_ID, imagePath); - try (InputStream stream = mc.getResourceManager().getResource(resourceId).get().getInputStream()) { + Identifier resourceId = Identifier.fromNamespaceAndPath(Sputnik.MOD_ID, imagePath); + try (InputStream stream = mc.getResourceManager().getResource(resourceId).get().open()) { NativeImage image = NativeImage.read(stream); // deshacerse de la textura vieja if (texture != null) texture.close(); - if (mc.getTextureManager().getTexture(textureId) != null) - mc.getTextureManager().destroyTexture(textureId); + if (mc.getTextureManager().getTexture(textureId) != null) { + mc.getTextureManager().release(textureId); + } // crear la textura nueva Supplier nameSupplier = () -> textureId.toString(); - texture = new NativeImageBackedTexture(nameSupplier, image); + texture = new DynamicTexture(nameSupplier, image); this.imageWidth = image.getWidth(); this.imageHeight = image.getHeight(); this.w = imageWidth; this.h = imageHeight; - mc.getTextureManager().registerTexture(textureId, texture); + mc.getTextureManager().register(textureId, texture); textureLoaded = true; Sputnik.LOGGER.info("textura para el elemento del HUD {} cargada", getId()); @@ -66,10 +68,10 @@ public abstract class ImageHudElement extends HudElement { } @Override - public void renderInGame(DrawContext ctx, float delta, HUD hud) { + public void renderInGame(GuiGraphicsExtractor gui, float delta, HUD hud) { if (!textureLoaded || !isVisible()) return; - ctx.drawTexture( + gui.blit( RenderPipelines.GUI_TEXTURED, textureId, x, y, @@ -80,14 +82,14 @@ public abstract class ImageHudElement extends HudElement { } @Override - public void renderInEditor(DrawContext ctx, HUD hud) { + public void renderInEditor(GuiGraphicsExtractor gui, HUD hud) { w = imageWidth; h = imageHeight; - drawEditorBackground(ctx); + drawEditorBackground(gui); if (textureLoaded) { - ctx.drawTexture( + gui.blit( RenderPipelines.GUI_TEXTURED, textureId, x, y, @@ -97,26 +99,26 @@ public abstract class ImageHudElement extends HudElement { ); } else { String placeholder = "imagen: " + getId(); - int textWidth = mc.textRenderer.getWidth(placeholder); + int textWidth = mc.font.width(placeholder); int textX = x + Math.max(0, (w - textWidth) / 2); - int textY = y + Math.max(0, (h - mc.textRenderer.fontHeight) / 2); - ctx.drawText(mc.textRenderer, placeholder, textX, textY, -1, true); + int textY = y + Math.max(0, (h - mc.font.lineHeight) / 2); + gui.text(mc.font, placeholder, textX, textY, -1, true); } } - protected void drawEditorBackground(DrawContext ctx) { + protected void drawEditorBackground(GuiGraphicsExtractor gui) { int bgColor = visible ? Colors.visibleHudElementColor.getRGB() : Colors.disabledHudElementColor.getRGB(); int outlineColor = HudEditorScreen.INSTANCE != null && HudEditorScreen.INSTANCE.isSelected(this) ? Colors.selectedHudElementOutlineColor.getRGB() : Colors.unselectedHudElementOutlineColor.getRGB(); // fondo - ctx.fill(x - 1, y - 1, x + w + 1, y + h + 1, bgColor); + gui.fill(x - 1, y - 1, x + w + 1, y + h + 1, bgColor); // contorno - ctx.fill(x - 1, y - 1, x + w + 1, y, outlineColor); - ctx.fill(x - 1, y + h, x + w + 1, y + h + 1, outlineColor); - ctx.fill(x - 1, y, x, y + h, outlineColor); - ctx.fill(x + w, y, x + w + 1, y + h, outlineColor); + gui.fill(x - 1, y - 1, x + w + 1, y, outlineColor); + gui.fill(x - 1, y + h, x + w + 1, y + h + 1, outlineColor); + gui.fill(x - 1, y, x, y + h, outlineColor); + gui.fill(x + w, y, x + w + 1, y + h, outlineColor); } } \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/ui/hud/TextHudElement.java b/src/main/java/me/retucio/sputnik/ui/hud/TextHudElement.java index 07c9b06..5659cfe 100644 --- a/src/main/java/me/retucio/sputnik/ui/hud/TextHudElement.java +++ b/src/main/java/me/retucio/sputnik/ui/hud/TextHudElement.java @@ -2,7 +2,7 @@ package me.retucio.sputnik.ui.hud; import me.retucio.sputnik.module.modules.client.HUD; import me.retucio.sputnik.util.Colors; -import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.GuiGraphicsExtractor; public abstract class TextHudElement extends HudElement { @@ -15,39 +15,39 @@ public abstract class TextHudElement extends HudElement { public abstract String getPreviewText(); @Override - public void renderInGame(DrawContext ctx, float delta, HUD hud) { + public void renderInGame(GuiGraphicsExtractor gui, float delta, HUD hud) { String text = getText(delta, hud); int color = hud != null ? hud.color.getValue().getRGB() : -1; boolean shadow = hud != null && hud.shadow.getValue(); - HudRenderer.drawSnappedText(ctx, text, x, y, color, shadow); + HudRenderer.drawSnappedText(gui, text, x, y, color, shadow); } @Override - public void renderInEditor(DrawContext ctx, HUD hud) { + public void renderInEditor(GuiGraphicsExtractor gui, HUD hud) { String previewText = getPreviewText(); - w = mc.textRenderer.getWidth(previewText); - h = mc.textRenderer.fontHeight; + w = mc.font.width(previewText); + h = mc.font.lineHeight; - drawEditorBackground(ctx); + drawEditorBackground(gui); int color = hud != null ? hud.color.getValue().getRGB() : -1; boolean shadow = hud != null && hud.shadow.getValue(); - HudRenderer.drawSnappedText(ctx, previewText, x, y, color, shadow); + HudRenderer.drawSnappedText(gui, previewText, x, y, color, shadow); } - protected void drawEditorBackground(DrawContext ctx) { + protected void drawEditorBackground(GuiGraphicsExtractor gui) { int bgColor = visible ? Colors.visibleHudElementColor.getRGB() : Colors.disabledHudElementColor.getRGB(); int outlineColor = HudEditorScreen.INSTANCE != null && HudEditorScreen.INSTANCE.isSelected(this) ? Colors.selectedHudElementOutlineColor.getRGB() : Colors.unselectedHudElementOutlineColor.getRGB(); // fondo - ctx.fill(x - 1, y - 1, x + w + 1, y + h + 1, bgColor); + gui.fill(x - 1, y - 1, x + w + 1, y + h + 1, bgColor); // contorno - ctx.fill(x - 1, y - 1, x + w + 1, y, outlineColor); - ctx.fill(x - 1, y + h, x + w + 1, y + h + 1, outlineColor); - ctx.fill(x - 1, y, x, y + h, outlineColor); - ctx.fill(x + w, y, x + w + 1, y + h, outlineColor); + gui.fill(x - 1, y - 1, x + w + 1, y, outlineColor); + gui.fill(x - 1, y + h, x + w + 1, y + h + 1, outlineColor); + gui.fill(x - 1, y, x, y + h, outlineColor); + gui.fill(x + w, y, x + w + 1, y + h, outlineColor); } } \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/ui/hud/elements/CoordsElement.java b/src/main/java/me/retucio/sputnik/ui/hud/elements/CoordsElement.java index 2a9c1ab..1297a7e 100644 --- a/src/main/java/me/retucio/sputnik/ui/hud/elements/CoordsElement.java +++ b/src/main/java/me/retucio/sputnik/ui/hud/elements/CoordsElement.java @@ -4,25 +4,26 @@ import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.camera.Freecam; import me.retucio.sputnik.module.modules.client.HUD; import me.retucio.sputnik.ui.hud.TextHudElement; -import net.minecraft.text.Text; -import net.minecraft.util.math.Vec3d; +import net.minecraft.network.chat.Component; +import net.minecraft.world.phys.Vec3; import java.util.List; + public class CoordsElement extends TextHudElement { public CoordsElement() { - super("coords", 2, mc.getWindow().getScaledHeight() - mc.textRenderer.fontHeight); + super("coords", 2, mc.getWindow().getGuiScaledHeight() - mc.font.lineHeight); } @Override public String getText(float delta, HUD hud) { Freecam freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class); - Vec3d pos = freecam != null && freecam.isEnabled() - ? new Vec3d(freecam.getX(delta), freecam.getY(delta), freecam.getZ(delta)) + Vec3 pos = freecam != null && freecam.isEnabled() + ? new Vec3(freecam.getX(delta), freecam.getY(delta), freecam.getZ(delta)) : mc.player == null - ? new Vec3d(67, 67, 67) - : mc.player.getEntityPos(); + ? new Vec3(67, 67, 67) + : mc.player.position(); String overworldCoords = (int) pos.x + " " + (int) pos.y + " " + (int) pos.z; String netherCoords = (int) pos.x / 8 + " " + (int) pos.y / 8 + " " + (int) pos.z / 8; @@ -39,15 +40,15 @@ public class CoordsElement extends TextHudElement { @Override public String getPreviewText() { return getText( - mc.getRenderTickCounter().getDynamicDeltaTicks(), + mc.getDeltaTracker().getGameTimeDeltaTicks(), ModuleManager.INSTANCE.getModuleByClass(HUD.class)); } @Override - public List getTooltip() { + public List getTooltip() { return List.of( - Text.literal(getId()), - Text.literal("te muestra tu posición XYZ en el mundo") + Component.literal(getId()), + Component.literal("te muestra tu posición XYZ en el mundo") ); } } \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/ui/hud/elements/CustomTextElement.java b/src/main/java/me/retucio/sputnik/ui/hud/elements/CustomTextElement.java index a040b1a..283b7dc 100644 --- a/src/main/java/me/retucio/sputnik/ui/hud/elements/CustomTextElement.java +++ b/src/main/java/me/retucio/sputnik/ui/hud/elements/CustomTextElement.java @@ -1,17 +1,18 @@ package me.retucio.sputnik.ui.hud.elements; +import com.github.retucio.neutrino.EventListener; import me.retucio.sputnik.event.sputnik.UpdateSettingEvent; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.client.HUD; import me.retucio.sputnik.ui.hud.TextHudElement; -import net.minecraft.text.Text; +import net.minecraft.network.chat.Component; import java.util.List; public class CustomTextElement extends TextHudElement { public CustomTextElement() { - super("customText", mc.getWindow().getScaledWidth() / 2 - 40, 2); + super("customText", mc.getWindow().getGuiScaledWidth() / 2 - 40, 2); } @Override @@ -29,18 +30,19 @@ public class CustomTextElement extends TextHudElement { } @Override - public List getTooltip() { + public List getTooltip() { return List.of( - Text.literal("texto custom"), - Text.literal("texto que tú eliges") + Component.literal("texto custom"), + Component.literal("texto que tú eliges") ); } + @EventListener public void onUpdateSetting(UpdateSettingEvent event) { if (ModuleManager.INSTANCE == null) return; HUD hud = ModuleManager.INSTANCE.getModuleByClass(HUD.class); if (hud != null && event.getSetting() == hud.customText) { - int newX = mc.getWindow().getScaledWidth() / 2 - mc.textRenderer.getWidth(hud.customText.getValue()) / 2; + int newX = mc.getWindow().getGuiScaledWidth() / 2 - mc.font.width(hud.customText.getValue()) / 2; setPosition(newX, y); } } diff --git a/src/main/java/me/retucio/sputnik/ui/hud/elements/DynoElement.java b/src/main/java/me/retucio/sputnik/ui/hud/elements/DynoElement.java index 303b3d3..0ada713 100644 --- a/src/main/java/me/retucio/sputnik/ui/hud/elements/DynoElement.java +++ b/src/main/java/me/retucio/sputnik/ui/hud/elements/DynoElement.java @@ -3,18 +3,19 @@ package me.retucio.sputnik.ui.hud.elements; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.client.HUD; import me.retucio.sputnik.ui.hud.ImageHudElement; -import net.minecraft.text.Text; +import net.minecraft.network.chat.Component; import java.util.List; + public class DynoElement extends ImageHudElement { private HUD.Dynosaurs dyno; public DynoElement() { super("dyno", - mc.getWindow().getScaledWidth() - 100, - mc.getWindow().getScaledHeight() - 100); + mc.getWindow().getGuiScaledWidth() - 100, + mc.getWindow().getGuiScaledHeight() - 100); reloadTexture(); } @@ -32,10 +33,10 @@ public class DynoElement extends ImageHudElement { } @Override - public List getTooltip() { + public List getTooltip() { return List.of( - Text.literal("dinosaurio: " + dyno), - Text.literal("que viva el autismo joder") + Component.literal("dinosaurio: " + dyno), + Component.literal("que viva el autismo joder") ); } } diff --git a/src/main/java/me/retucio/sputnik/ui/hud/elements/EchestElement.java b/src/main/java/me/retucio/sputnik/ui/hud/elements/EchestElement.java index c79ee90..9c713af 100644 --- a/src/main/java/me/retucio/sputnik/ui/hud/elements/EchestElement.java +++ b/src/main/java/me/retucio/sputnik/ui/hud/elements/EchestElement.java @@ -4,15 +4,16 @@ import me.retucio.sputnik.module.modules.client.HUD; import me.retucio.sputnik.ui.hud.ImageHudElement; import me.retucio.sputnik.util.Colors; import me.retucio.sputnik.util.InventoryUtil; -import net.minecraft.client.gl.RenderPipelines; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.inventory.Inventory; -import net.minecraft.item.ItemStack; -import net.minecraft.text.Text; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.client.renderer.RenderPipelines; +import net.minecraft.network.chat.Component; +import net.minecraft.world.Container; +import net.minecraft.world.item.ItemStack; import java.util.ArrayList; import java.util.List; + public class EchestElement extends ImageHudElement { public EchestElement() { @@ -26,10 +27,10 @@ public class EchestElement extends ImageHudElement { } @Override - public void renderInGame(DrawContext ctx, float delta, HUD hud) { + public void renderInGame(GuiGraphicsExtractor gui, float delta, HUD hud) { if (!textureLoaded || !isVisible()) return; - ctx.drawTexture( + gui.blit( RenderPipelines.GUI_TEXTURED, textureId, x, y, @@ -39,25 +40,26 @@ public class EchestElement extends ImageHudElement { Colors.PURPLE.getRGB() ); - ctx.drawText( - mc.textRenderer, + + gui.text( + mc.font, "echest", - x + w / 2 - mc.textRenderer.getWidth("echest") / 2, - y + mc.textRenderer.fontHeight - 3, + x + w / 2 - mc.font.width("echest") / 2, + y + mc.font.lineHeight - 3, Colors.instructionsTextColor.getRGB(), false ); - renderItems(ctx, InventoryUtil.getEchestInv()); + renderItems(gui, InventoryUtil.getEchestInv()); } @Override - public void renderInEditor(DrawContext ctx, HUD hud) { + public void renderInEditor(GuiGraphicsExtractor gui, HUD hud) { if (!textureLoaded) return; - drawEditorBackground(ctx); + drawEditorBackground(gui); - ctx.drawTexture( + gui.blit( RenderPipelines.GUI_TEXTURED, textureId, x, y, @@ -69,27 +71,27 @@ public class EchestElement extends ImageHudElement { : Colors.RED.getRGB() ); - ctx.drawText( - mc.textRenderer, + gui.text( + mc.font, "echest", - x + w / 2 - mc.textRenderer.getWidth("echest") / 2, - y + mc.textRenderer.fontHeight - 3, + x + w / 2 - mc.font.width("echest") / 2, + y + mc.font.lineHeight - 3, Colors.instructionsTextColor.getRGB(), false ); - renderItems(ctx, InventoryUtil.getEchestInv()); + renderItems(gui, InventoryUtil.getEchestInv()); } @Override - public List getTooltip() { - List tooltip = new ArrayList<>(); - tooltip.add(Text.literal("echest")); - tooltip.add(Text.literal("items en tu echest")); + public List getTooltip() { + List tooltip = new ArrayList<>(); + tooltip.add(Component.literal("echest")); + tooltip.add(Component.literal("items en tu echest")); return tooltip; } - private void renderItems(DrawContext ctx, Inventory inventory) { + private void renderItems(GuiGraphicsExtractor gui, Container inventory) { if (inventory == null) return; int drawX = x + 7; @@ -102,8 +104,8 @@ public class EchestElement extends ImageHudElement { for (ItemStack item : inventory) { if (item.isEmpty()) continue; - ctx.drawItem(item, drawX, drawY); - ctx.drawStackOverlay(mc.textRenderer, item, drawX, drawY); + gui.item(item, drawX, drawY); + gui.itemDecorations(mc.font, item, drawX, drawY); drawX += 18; count++; diff --git a/src/main/java/me/retucio/sputnik/ui/hud/elements/FpsElement.java b/src/main/java/me/retucio/sputnik/ui/hud/elements/FpsElement.java index 9dcd9a9..e0d0955 100644 --- a/src/main/java/me/retucio/sputnik/ui/hud/elements/FpsElement.java +++ b/src/main/java/me/retucio/sputnik/ui/hud/elements/FpsElement.java @@ -2,11 +2,11 @@ package me.retucio.sputnik.ui.hud.elements; import me.retucio.sputnik.module.modules.client.HUD; import me.retucio.sputnik.ui.hud.TextHudElement; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.text.Text; +import net.minecraft.network.chat.Component; import java.util.List; + public class FpsElement extends TextHudElement { public FpsElement() { @@ -15,24 +15,19 @@ public class FpsElement extends TextHudElement { @Override public String getText(float delta, HUD hud) { - return "FPS: " + mc.getCurrentFps(); + return "FPS: " + mc.getFps(); } @Override public String getPreviewText() { - return "FPS: " + mc.getCurrentFps(); + return "FPS: " + mc.getFps(); } @Override - public List getTooltip() { + public List getTooltip() { return List.of( - Text.literal("FPS"), - Text.literal("te muestra los fotogramas por segundo a los que corre el juego") + Component.literal("FPS"), + Component.literal("te muestra los fotogramas por segundo a los que corre el juego") ); } - - @Override - public void render(DrawContext ctx, int mouseX, int mouseY, float delta) { - - } } \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/ui/hud/elements/PingElement.java b/src/main/java/me/retucio/sputnik/ui/hud/elements/PingElement.java index a87dc2c..f6077d3 100644 --- a/src/main/java/me/retucio/sputnik/ui/hud/elements/PingElement.java +++ b/src/main/java/me/retucio/sputnik/ui/hud/elements/PingElement.java @@ -2,23 +2,24 @@ package me.retucio.sputnik.ui.hud.elements; import me.retucio.sputnik.module.modules.client.HUD; import me.retucio.sputnik.ui.hud.TextHudElement; -import net.minecraft.client.network.PlayerListEntry; -import net.minecraft.text.Text; +import net.minecraft.client.multiplayer.PlayerInfo; +import net.minecraft.network.chat.Component; import java.util.List; + public class PingElement extends TextHudElement { public PingElement() { - super("ping", 2, 2 * (mc.textRenderer.fontHeight + 4)); + super("ping", 2, 2 * (mc.font.lineHeight + 4)); } @Override public String getText(float delta, HUD hud) { - if (mc.getNetworkHandler() == null || mc.player == null) return "? ms"; - if (mc.isInSingleplayer()) return "-1 ms"; + if (mc.getConnection() == null || mc.player == null) return "? ms"; + if (mc.isSingleplayer()) return "-1 ms"; - PlayerListEntry playerListEntry = mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()); + PlayerInfo playerListEntry = mc.getConnection().getPlayerInfo(mc.player.getUUID()); return playerListEntry != null ? playerListEntry.getLatency() + " ms" : "? ms"; } @@ -28,10 +29,10 @@ public class PingElement extends TextHudElement { } @Override - public List getTooltip() { + public List getTooltip() { return List.of( - Text.literal("ping"), - Text.literal("latencia entre cliente y servidor, en milisegundos") + Component.literal("ping"), + Component.literal("latencia entre cliente y servidor, en milisegundos") ); } } \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/ui/hud/elements/RotationElement.java b/src/main/java/me/retucio/sputnik/ui/hud/elements/RotationElement.java index 4c72645..07d50a9 100644 --- a/src/main/java/me/retucio/sputnik/ui/hud/elements/RotationElement.java +++ b/src/main/java/me/retucio/sputnik/ui/hud/elements/RotationElement.java @@ -3,36 +3,40 @@ package me.retucio.sputnik.ui.hud.elements; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.client.HUD; import me.retucio.sputnik.ui.hud.TextHudElement; -import net.minecraft.text.Text; +import net.minecraft.network.chat.Component; import java.util.List; + public class RotationElement extends TextHudElement { public RotationElement() { - super("rotation", mc.getWindow().getScaledWidth() - mc.textRenderer.getWidth("180º 180º (N)"), mc.getWindow().getScaledHeight() - mc.textRenderer.fontHeight); + super("rotation", + mc.getWindow().getGuiScaledWidth() - mc.font.width("180° 180° (N)"), + mc.getWindow().getGuiScaledHeight() - mc.font.lineHeight + ); } @Override public String getText(float delta, HUD hud) { if (mc.player == null) return getPreviewText(); - return String.format("%.2f", mc.player.getYaw() % 360) + "º " + String.format("%.2f", mc.player.getPitch()) + "º (" + getDirection() + ")"; + return String.format("%.2f", mc.player.getYRot() % 360) + "° " + String.format("%.2f", mc.player.getXRot()) + "° (" + getDirection() + ")"; } @Override public String getPreviewText() { if (mc.player == null) - return "69º 69º (W)"; - return getText(mc.getRenderTickCounter().getDynamicDeltaTicks(), ModuleManager.INSTANCE.getModuleByClass(HUD.class)); + return "69° 69° (W)"; + return getText(mc.getDeltaTracker().getGameTimeDeltaTicks(), ModuleManager.INSTANCE.getModuleByClass(HUD.class)); } @Override - public List getTooltip() { + public List getTooltip() { return List.of(); } private String getDirection() { - return switch (mc.player.getHorizontalFacing()) { + return switch (mc.player.getDirection()) { case NORTH -> "N"; case SOUTH -> "S"; case EAST -> "E"; diff --git a/src/main/java/me/retucio/sputnik/ui/hud/elements/TimeElement.java b/src/main/java/me/retucio/sputnik/ui/hud/elements/TimeElement.java index c092d06..e374119 100644 --- a/src/main/java/me/retucio/sputnik/ui/hud/elements/TimeElement.java +++ b/src/main/java/me/retucio/sputnik/ui/hud/elements/TimeElement.java @@ -3,14 +3,15 @@ package me.retucio.sputnik.ui.hud.elements; import me.retucio.sputnik.module.modules.client.HUD; import me.retucio.sputnik.ui.hud.TextHudElement; import me.retucio.sputnik.util.MiscUtil; -import net.minecraft.text.Text; +import net.minecraft.network.chat.Component; import java.util.List; + public class TimeElement extends TextHudElement { public TimeElement() { - super("time", mc.getWindow().getScaledWidth() - 50, mc.getWindow().getScaledHeight() - mc.textRenderer.fontHeight - 2); + super("time", mc.getWindow().getGuiScaledWidth() - 50, mc.getWindow().getGuiScaledHeight() - mc.font.lineHeight - 2); } @Override @@ -24,10 +25,10 @@ public class TimeElement extends TextHudElement { } @Override - public List getTooltip() { + public List getTooltip() { return List.of( - Text.literal("hora"), - Text.literal("hora y minutos de la zona horaria seleccionada") + Component.literal("hora"), + Component.literal("hora y minutos de la zona horaria seleccionada") ); } } \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/ui/hud/elements/TotemsElement.java b/src/main/java/me/retucio/sputnik/ui/hud/elements/TotemsElement.java index 47d19d1..c725cc0 100644 --- a/src/main/java/me/retucio/sputnik/ui/hud/elements/TotemsElement.java +++ b/src/main/java/me/retucio/sputnik/ui/hud/elements/TotemsElement.java @@ -2,13 +2,14 @@ package me.retucio.sputnik.ui.hud.elements; import me.retucio.sputnik.module.modules.client.HUD; import me.retucio.sputnik.ui.hud.ImageHudElement; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.text.Text; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.network.chat.Component; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import java.util.List; + public class TotemsElement extends ImageHudElement { public TotemsElement() { @@ -24,7 +25,7 @@ public class TotemsElement extends ImageHudElement { } @Override - public void renderInGame(DrawContext ctx, float delta, HUD hud) { + public void renderInGame(GuiGraphicsExtractor gui, float delta, HUD hud) { if (!isVisible()) return; int count = 0; @@ -37,11 +38,11 @@ public class TotemsElement extends ImageHudElement { count = 69; } - drawItem(ctx, new ItemStack(Items.TOTEM_OF_UNDYING, Math.max(1, count)), count); + drawItem(gui, new ItemStack(Items.TOTEM_OF_UNDYING, Math.max(1, count)), count); } @Override - public void renderInEditor(DrawContext ctx, HUD hud) { + public void renderInEditor(GuiGraphicsExtractor gui, HUD hud) { int count = 0; if (mc.player != null) { for (ItemStack stack : mc.player.getInventory()) { @@ -52,25 +53,25 @@ public class TotemsElement extends ImageHudElement { count = 69; } - drawEditorBackground(ctx); - drawItem(ctx, new ItemStack(Items.TOTEM_OF_UNDYING, Math.max(1, count)), count); + drawEditorBackground(gui); + drawItem(gui, new ItemStack(Items.TOTEM_OF_UNDYING, Math.max(1, count)), count); } @Override - public List getTooltip() { - return List.of(Text.of("totems disponibles")); + public List getTooltip() { + return List.of(Component.literal("totems disponibles")); } - private void drawItem(DrawContext ctx, ItemStack stack, int count) { - ctx.drawItem(stack, x, y); + private void drawItem(GuiGraphicsExtractor gui, ItemStack stack, int count) { + gui.item(stack, x, y); if (count > 1) { - ctx.drawStackOverlay(mc.textRenderer, stack, x, y); + gui.itemDecorations(mc.font, stack, x, y); } else { String text = String.valueOf(count); int textX = x + 10; int textY = y + 9; - ctx.drawText( - mc.textRenderer, + gui.text( + mc.font, text, textX, textY, diff --git a/src/main/java/me/retucio/sputnik/ui/hud/elements/TpsElement.java b/src/main/java/me/retucio/sputnik/ui/hud/elements/TpsElement.java index ddd8da1..6d989a8 100644 --- a/src/main/java/me/retucio/sputnik/ui/hud/elements/TpsElement.java +++ b/src/main/java/me/retucio/sputnik/ui/hud/elements/TpsElement.java @@ -3,14 +3,15 @@ package me.retucio.sputnik.ui.hud.elements; import me.retucio.sputnik.module.modules.client.HUD; import me.retucio.sputnik.ui.hud.TextHudElement; import me.retucio.sputnik.util.NetworkUtil; -import net.minecraft.text.Text; +import net.minecraft.network.chat.Component; import java.util.List; + public class TpsElement extends TextHudElement { public TpsElement() { - super("tps", 2, mc.textRenderer.fontHeight + 4); + super("tps", 2, mc.font.lineHeight + 4); } @Override @@ -24,10 +25,10 @@ public class TpsElement extends TextHudElement { } @Override - public List getTooltip() { + public List getTooltip() { return List.of( - Text.literal("TPS"), - Text.literal("te muestra la tasa de ticks por segundo del servidor (TPS óptimo: 20)") + Component.literal("TPS"), + Component.literal("te muestra la tasa de ticks por segundo del servidor (TPS óptimo: 20)") ); } } \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/ui/hud/elements/UptimeElement.java b/src/main/java/me/retucio/sputnik/ui/hud/elements/UptimeElement.java index 23ba91b..67e5f93 100644 --- a/src/main/java/me/retucio/sputnik/ui/hud/elements/UptimeElement.java +++ b/src/main/java/me/retucio/sputnik/ui/hud/elements/UptimeElement.java @@ -4,14 +4,15 @@ import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.client.HUD; import me.retucio.sputnik.ui.hud.TextHudElement; -import net.minecraft.text.Text; +import net.minecraft.network.chat.Component; import java.util.List; + public class UptimeElement extends TextHudElement { public UptimeElement() { - super("uptime", mc.getWindow().getScaledWidth() - 50, mc.getWindow().getScaledHeight() - 2 * (mc.textRenderer.fontHeight + 2)); + super("uptime", mc.getWindow().getGuiScaledWidth() - 50, mc.getWindow().getGuiScaledHeight() - 2 * (mc.font.lineHeight + 2)); } @Override @@ -27,11 +28,11 @@ public class UptimeElement extends TextHudElement { @Override public String getPreviewText() { - return getText(mc.getRenderTickCounter().getDynamicDeltaTicks(), ModuleManager.INSTANCE.getModuleByClass(HUD.class)); + return getText(mc.getDeltaTracker().getGameTimeDeltaTicks(), ModuleManager.INSTANCE.getModuleByClass(HUD.class)); } @Override - public List getTooltip() { - return List.of(Text.of("tiempo jugando")); + public List getTooltip() { + return List.of(Component.literal("tiempo jugando")); } } diff --git a/src/main/java/me/retucio/sputnik/ui/screen/ClickGUI.java b/src/main/java/me/retucio/sputnik/ui/screen/ClickGUI.java index 7ee072d..2d44210 100644 --- a/src/main/java/me/retucio/sputnik/ui/screen/ClickGUI.java +++ b/src/main/java/me/retucio/sputnik/ui/screen/ClickGUI.java @@ -25,13 +25,14 @@ import me.retucio.sputnik.ui.widgets.misc.SearchBarWidget; import me.retucio.sputnik.util.KeyUtil; import me.retucio.sputnik.util.MiscUtil; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.Click; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.text.Text; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.input.MouseButtonEvent; +import net.minecraft.network.chat.Component; import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NonNull; import org.lwjgl.glfw.GLFW; import java.util.ArrayList; @@ -41,10 +42,11 @@ import java.util.Optional; import static me.retucio.sputnik.ui.widgets.frames.settings.ClientSettingsFrame.guiSettings; + // interfaz gráfica, se abre con el shift derecho por defecto. aquí se encuentran los módulos y sus ajustes public class ClickGUI extends Screen { - private final MinecraftClient mc = MinecraftClient.getInstance(); + private final Minecraft mc = Minecraft.getInstance(); public static ClickGUI INSTANCE; private boolean anyFocused; @@ -61,21 +63,21 @@ public class ClickGUI extends Screen { private final List miscWidgets = Arrays.asList(scrollBar, searchBar); public ClickGUI() { - super(Text.of("interfaz")); + super(Component.nullToEmpty("interfaz")); settingsFrames.add(guiSettingsFrame); Sputnik.EVENT_BUS.subscribe(this); } @Override - public void render(DrawContext ctx, int mouseX, int mouseY, float delta) { - scrollBar.setWindowHeight(mc.getWindow().getScaledHeight()); + public void extractRenderState(@NonNull GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) { + scrollBar.setWindowHeight(mc.getWindow().getGuiScaledHeight()); scrollBar.setContentHeight(calculateContentHeight()); - scrollBar.render(ctx, mouseX, mouseY, delta); + scrollBar.render(gui, mouseX, mouseY, delta); int scrollOffset = scrollBar.getScrollOffset(); searchBar.updateRenderY(scrollOffset); - searchBar.render(ctx, mouseX, mouseY, delta); + searchBar.render(gui, mouseX, mouseY, delta); searchBar.updatePosition(mouseX, mouseY); // actualizar la posición de renderizado vertical de los marcos cada tick @@ -85,27 +87,27 @@ public class ClickGUI extends Screen { // renderizar el marco de los ajustes de cada módulo que lo tenga abierto. se abre haciendo clic derecho sobre el módulo for (SettingsFrame sf : settingsFrames.reversed()) { - sf.render(ctx, mouseX, mouseY, delta); + sf.render(gui, mouseX, mouseY, delta); sf.updatePosition(mouseX, mouseY); } // renderizar el marco de los módulos - modulesFrame.render(ctx, mouseX, mouseY, delta); + modulesFrame.render(gui, mouseX, mouseY, delta); modulesFrame.updatePosition(mouseX, mouseY); for (SettingsFrame sf : settingsFrames) - sf.drawTooltips(ctx, mouseX, mouseY); + sf.drawTooltips(gui, mouseX, mouseY); filterSearchResults(); - renderBottomGradient(ctx, scrollOffset); + renderBottomGradient(gui, scrollOffset); - super.render(ctx, mouseX, mouseY, delta); + super.extractRenderState(gui, mouseX, mouseY, delta); } // renderizar un gradiente negro leve en la parte inferior de la pantalla si el contenido excede el límite inferior de la pantalla, para indicarlo visualmente - private void renderBottomGradient(DrawContext ctx, int scrollOffset) { - int screenHeight = mc.getWindow().getScaledHeight(); + private void renderBottomGradient(GuiGraphicsExtractor ctx, int scrollOffset) { + int screenHeight = mc.getWindow().getGuiScaledHeight(); int totalContentHeight = calculateContentHeight(); if (scrollOffset + screenHeight < totalContentHeight) { @@ -116,7 +118,7 @@ public class ClickGUI extends Screen { float alpha = (float) y / gradientHeight; int color = (int) (alpha * 0.7 * 255) << 24; - ctx.fill(0, startY + y, mc.getWindow().getScaledWidth(), startY + y + 1, color); + ctx.fill(0, startY + y, mc.getWindow().getGuiScaledWidth(), startY + y + 1, color); } } } @@ -130,7 +132,7 @@ public class ClickGUI extends Screen { } @Override - public boolean mouseClicked(Click click, boolean doubled) { + public boolean mouseClicked(MouseButtonEvent click, boolean doubled) { miscWidgets.forEach(w -> w.mouseClicked( (int) click.x(), (int) click.y(), @@ -146,7 +148,7 @@ public class ClickGUI extends Screen { } @Override - public boolean mouseReleased(Click click) { + public boolean mouseReleased(MouseButtonEvent click) { miscWidgets.forEach(w -> w.mouseReleased( (int) click.x(), (int) click.y(), @@ -161,7 +163,7 @@ public class ClickGUI extends Screen { } @Override - public boolean mouseDragged(Click click, double deltaX, double deltaY) { + public boolean mouseDragged(MouseButtonEvent click, double deltaX, double deltaY) { miscWidgets.forEach(w -> w.mouseDragged( (int) click.x(), (int) click.y())); @@ -186,9 +188,9 @@ public class ClickGUI extends Screen { @EventListener public void onMouseMiddleButton(MouseClickEvent event) { // mover todos los marcos a un punto visible al presionar shift + la rueda del ratón - if (Sputnik.mc.currentScreen != this || event.getButton() != 2 || !KeyUtil.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT)) return; + if (Sputnik.mc.screen != this || event.getButton() != 2 || !KeyUtil.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT)) return; - int h = Sputnik.mc.getWindow().getScaledHeight(); + int h = Sputnik.mc.getWindow().getGuiScaledHeight(); int minY = Math.min(modulesFrame.getY(), settingsFrames.stream().mapToInt(Frame::getY).min().orElse(modulesFrame.getY())); int maxY = Math.max(modulesFrame.getY() + modulesFrame.getH(), settingsFrames.stream().mapToInt(sf -> sf.getY() + sf.getH()).max().orElse(modulesFrame.getY() + modulesFrame.getH())); int correction = minY < 0 ? -minY + 4 : (maxY > h ? h - maxY - 4 : 0); @@ -272,8 +274,8 @@ public class ClickGUI extends Screen { // abrir un marco donde se encuentran los ajustes del módulo deseado public void openSettingsFrame(Module module, int x, int y) { // asegurarse de que no se sale de la pantalla - x = Math.clamp(x, 0, mc.getWindow().getScaledWidth() - 80); - y = Math.clamp(y, 0, mc.getWindow().getScaledHeight() - 120); + x = Math.clamp(x, 0, mc.getWindow().getGuiScaledWidth() - 80); + y = Math.clamp(y, 0, mc.getWindow().getGuiScaledHeight() - 120); SettingsFrame frame = new SettingsFrame(module, x, y, 100, 20); settingsFrames.add(frame); @@ -354,18 +356,18 @@ public class ClickGUI extends Screen { // métodos del súper @Override - public void close() { // evitar que al reabrir la interfaz sin previamente haber soltado el clic, se sigan arrastrando objetos + public void onClose() { // evitar que al reabrir la interfaz sin previamente haber soltado el clic, se sigan arrastrando objetos modulesFrame.mouseReleased(0, 0, 0); settingsFrames.forEach(sf -> sf.mouseReleased(0, 0, 0)); scrollBar.mouseReleased(0, 0, 0); searchBar.mouseReleased(0, 0, 0); unselect(selected); - super.close(); + super.onClose(); } - @Override - public boolean shouldPause() { + + public boolean isPauseScreen() { // no pausar el juego cuando se abre la interfaz return false; } @@ -376,8 +378,8 @@ public class ClickGUI extends Screen { } @Override - protected void applyBlur(DrawContext ctx) { - if (guiSettings.blur.getValue()) super.applyBlur(ctx); + protected void extractBlurredBackground(GuiGraphicsExtractor ctx) { + if (guiSettings.blur.getValue()) super.extractBlurredBackground(ctx); } diff --git a/src/main/java/me/retucio/sputnik/ui/screen/PreviewScreen.java b/src/main/java/me/retucio/sputnik/ui/screen/PreviewScreen.java index 19e49e1..6794f84 100644 --- a/src/main/java/me/retucio/sputnik/ui/screen/PreviewScreen.java +++ b/src/main/java/me/retucio/sputnik/ui/screen/PreviewScreen.java @@ -4,30 +4,32 @@ import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.module.modules.inventory.ShulkerPeek; import me.retucio.sputnik.ui.widgets.frames.settings.ClientSettingsFrame; import me.retucio.sputnik.util.Colors; -import net.minecraft.client.gl.RenderPipelines; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.component.DataComponentTypes; -import net.minecraft.inventory.Inventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.text.Text; -import net.minecraft.util.Identifier; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.renderer.RenderPipelines; +import net.minecraft.core.component.DataComponents; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.Identifier; +import net.minecraft.world.Container; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import org.jspecify.annotations.NonNull; import java.awt.*; import java.util.ArrayList; import java.util.List; + public class PreviewScreen extends Screen { - private static final Identifier TEXTURE = Identifier.of(Sputnik.MOD_ID, "textures/gui/preview.png"); + private static final Identifier TEXTURE = Identifier.fromNamespaceAndPath(Sputnik.MOD_ID, "textures/gui/preview.png"); private int x, y; private final int bgWidth = 176; private final int bgHeight = 78; private final Color color; - private final Text title; + private final Component title; private final List inventory; private final Screen parent; private final PreviewType type; @@ -35,24 +37,25 @@ public class PreviewScreen extends Screen { private int focusedSlot; public PreviewScreen(ItemStack shulker, Screen parent) { - super(Text.literal("previsualización del shulker")); + super(Component.literal("previsualización del shulker")); this.color = ShulkerPeek.SHULKER_COLORS.get(shulker.getItem()); - this.title = shulker.getName(); - this.inventory = shulker.get(DataComponentTypes.CONTAINER).stream().toList(); + this.title = shulker.getHoverName(); + this.inventory = shulker.get(DataComponents.CONTAINER).allItemsCopyStream().toList(); this.parent = parent; this.type = PreviewType.SHULKER; } - public PreviewScreen(Inventory inventory, Screen parent) { - super(Text.literal("echest")); + public PreviewScreen(Container inventory, Screen parent) { + super(Component.literal("echest")); this.color = Colors.PURPLE; - this.title = Text.of("echest"); + this.title = Component.literal("echest"); this.inventory = new ArrayList<>(); this.parent = parent; this.type = PreviewType.ECHEST; - for (int i = 0; i < inventory.size(); i++) - this.inventory.add(inventory.getStack(i)); + for (int i = 0; i < inventory.getContainerSize(); i++) { + this.inventory.add(inventory.getItem(i)); + } } @Override @@ -62,32 +65,33 @@ public class PreviewScreen extends Screen { } @Override - public void render(DrawContext ctx, int mouseX, int mouseY, float delta) { - super.render(ctx, mouseX, mouseY, delta); + public void extractRenderState(@NonNull GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) { + super.extractRenderState(gui, mouseX, mouseY, delta); - this.renderBackground(ctx, mouseX, mouseY, delta); - this.renderItems(ctx, inventory, x + 8, y + 18); + this.extractBackground(gui, mouseX, mouseY, delta); + this.renderItems(gui, inventory, x + 8, y + 18); int selectedSlot = getSlot(mouseX, mouseY); - if (selectedSlot > -1 && selectedSlot < inventory.size() && !inventory.get(selectedSlot).isOf(Items.AIR)) - renderTooltip(ctx, inventory.get(selectedSlot), mouseX, mouseY); + if (selectedSlot > -1 && selectedSlot < inventory.size() && !inventory.get(selectedSlot).is(Items.AIR)) { + renderTooltip(gui, inventory.get(selectedSlot), mouseX, mouseY); + } focusedSlot = selectedSlot; } @Override - public void renderBackground(DrawContext ctx, int mouseX, int mouseY, float delta) { - ctx.fill(0, 0, width, height, Colors.hudEditorScreenBackgroundColor.getRGB()); - ctx.drawTexture(RenderPipelines.GUI_TEXTURED, TEXTURE, x, y, 0, 0, bgWidth, bgHeight, 256, 256, color.getRGB()); - ctx.drawText(textRenderer, title, x + 8, y + 6, Colors.instructionsTextColor.getRGB(), false); + public void extractBackground(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) { + gui.fill(0, 0, width, height, Colors.hudEditorScreenBackgroundColor.getRGB()); + gui.blit(RenderPipelines.GUI_TEXTURED, TEXTURE, x, y, 0, 0, bgWidth, bgHeight, 256, 256, color.getRGB()); + gui.text(font, title, x + 8, y + 6, Colors.instructionsTextColor.getRGB(), false); } - private void renderItems(DrawContext context, List inventory, int x, int y) { + private void renderItems(GuiGraphicsExtractor gui, List inventory, int x, int y) { int baseX = x; int count = 0; for (ItemStack item : inventory) { count++; - context.drawItem(item, x, y); - context.drawStackOverlay(textRenderer, item, x, y); + gui.item(item, x, y); + gui.itemDecorations(font, item, x, y); x += 18; if (count % 9 == 0) { x = baseX; @@ -109,22 +113,22 @@ public class PreviewScreen extends Screen { return slotX + slotY * 9; } - private void renderTooltip(DrawContext ctx, ItemStack stack, int x, int y) { - ctx.drawItemTooltip(textRenderer, stack, x, y); + private void renderTooltip(GuiGraphicsExtractor gui, ItemStack stack, int x, int y) { + gui.setTooltipForNextFrame(font, stack, x, y); } @Override - public void close() { - client.setScreen(parent); + public void onClose() { + minecraft.setScreen(parent); } @Override - public void applyBlur(DrawContext ctx) { - if (ClientSettingsFrame.guiSettings.blur.getValue()) super.applyBlur(ctx); + public void extractBlurredBackground(@NonNull GuiGraphicsExtractor gui) { + if (ClientSettingsFrame.guiSettings.blur.getValue()) super.extractBlurredBackground(gui); } @Override - public boolean shouldPause() { + public boolean isPauseScreen() { return false; } diff --git a/src/main/java/me/retucio/sputnik/ui/screen/UpdateScreen.java b/src/main/java/me/retucio/sputnik/ui/screen/UpdateScreen.java index f066e9d..c2445ef 100644 --- a/src/main/java/me/retucio/sputnik/ui/screen/UpdateScreen.java +++ b/src/main/java/me/retucio/sputnik/ui/screen/UpdateScreen.java @@ -1,26 +1,24 @@ package me.retucio.sputnik.ui.screen; import me.retucio.sputnik.Sputnik; -import me.retucio.sputnik.util.VersionChecker; +import me.retucio.sputnik.util.misc.VersionChecker; import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.Click; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.widget.ButtonWidget; -import net.minecraft.client.gui.widget.DirectionalLayoutWidget; -import net.minecraft.client.gui.widget.SimplePositioningWidget; -import net.minecraft.client.gui.widget.TextWidget; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.components.Button; +import net.minecraft.client.gui.components.StringWidget; +import net.minecraft.client.gui.layouts.FrameLayout; +import net.minecraft.client.gui.layouts.LinearLayout; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.network.chat.Component; import java.net.URI; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.TimeUnit; + public class UpdateScreen extends Screen { - private final MinecraftClient mc = MinecraftClient.getInstance(); - private final DirectionalLayoutWidget grid = DirectionalLayoutWidget.vertical(); + private final Minecraft mc = Minecraft.getInstance(); + private final LinearLayout grid = LinearLayout.vertical(); private final URI updateLink = URI.create(FabricLoader.getInstance() .getModContainer(Sputnik.MOD_ID) @@ -32,46 +30,46 @@ public class UpdateScreen extends Screen { + "/releases/latest" ); - private final Text outdatedText = Text.of("version desactualizada: " + Sputnik.MOD_VERSION); - private final Text updateText = Text.of("descarga la última versión (" + VersionChecker.getLatestVersion() + ") desde aquí:"); + private final Component outdatedText = Component.literal("version desactualizada: " + Sputnik.MOD_VERSION); + private final Component updateText = Component.literal("descarga la última versión (" + VersionChecker.getLatestVersion() + ") desde aquí:"); - private final ButtonWidget idgafButton = ButtonWidget.builder( - Text.of("me la pela"), - button -> this.close() + private final Button idgafButton = Button.builder( + Component.literal("me la pela"), + button -> this.onClose() ).build(); - private final ButtonWidget updateButton = ButtonWidget.builder( - Text.of("CLIC AQUÍ"), - button -> handleOpenUri(mc, this, updateLink) + private final Button updateButton = Button.builder( + Component.literal("CLIC AQUÍ"), + button -> clickUrlAction(mc, this, updateLink) ).build(); public UpdateScreen() { - super(Text.literal(Formatting.BOLD + "actualizar")); + super(Component.literal(ChatFormatting.BOLD + "actualizar")); } @Override protected void init() { super.init(); - this.grid.getMainPositioner().alignHorizontalCenter().margin(10); + this.grid.defaultCellSetting().alignHorizontallyCenter().padding(10); - this.grid.add(new TextWidget(this.title, this.textRenderer)); - this.grid.add(new TextWidget(outdatedText, this.textRenderer)); - this.grid.add(new TextWidget(updateText, this.textRenderer)); + this.grid.addChild(new StringWidget(this.title, this.font)); + this.grid.addChild(new StringWidget(outdatedText, this.font)); + this.grid.addChild(new StringWidget(updateText, this.font)); - this.grid.getMainPositioner().margin(2); + this.grid.defaultCellSetting().padding(2); - this.grid.add(updateButton); - this.grid.add(idgafButton); + this.grid.addChild(updateButton); + this.grid.addChild(idgafButton); - this.grid.refreshPositions(); - this.grid.forEachChild(this::addDrawableChild); - this.refreshWidgetPositions(); + this.grid.arrangeElements(); + this.grid.visitWidgets(this::addRenderableWidget); + this.repositionElements(); } @Override - protected void refreshWidgetPositions() { - SimplePositioningWidget.setPos(this.grid, this.getNavigationFocus()); + protected void repositionElements() { + FrameLayout.centerInRectangle(this.grid, this.getRectangle()); } @Override @@ -80,7 +78,7 @@ public class UpdateScreen extends Screen { } @Override - public boolean canInterruptOtherScreen() { + public boolean canInterruptWithAnotherScreen() { return true; } } diff --git a/src/main/java/me/retucio/sputnik/ui/widgets/Button.java b/src/main/java/me/retucio/sputnik/ui/widgets/Button.java index dd98d41..ed36b37 100644 --- a/src/main/java/me/retucio/sputnik/ui/widgets/Button.java +++ b/src/main/java/me/retucio/sputnik/ui/widgets/Button.java @@ -1,6 +1,6 @@ package me.retucio.sputnik.ui.widgets; -import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.GuiGraphicsExtractor; public abstract class Button extends Widget { @@ -14,7 +14,7 @@ public abstract class Button extends Widget { } - public abstract void drawTooltip(DrawContext ctx, int mouseX, int mouseY); + public abstract void drawTooltip(GuiGraphicsExtractor gui, int mouseX, int mouseY); public int getOffset() { return offset; diff --git a/src/main/java/me/retucio/sputnik/ui/widgets/Frame.java b/src/main/java/me/retucio/sputnik/ui/widgets/Frame.java index 15ecd5c..a711da4 100644 --- a/src/main/java/me/retucio/sputnik/ui/widgets/Frame.java +++ b/src/main/java/me/retucio/sputnik/ui/widgets/Frame.java @@ -1,10 +1,11 @@ package me.retucio.sputnik.ui.widgets; -import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.GuiGraphicsExtractor; import java.util.ArrayList; import java.util.List; + public abstract class Frame extends Widget { protected String title; @@ -23,8 +24,8 @@ public abstract class Frame extends Widget { this.title = title; } - public void drawTooltips(DrawContext ctx, int mouseX, int mouseY) { - for (Button button : visibleButtons) button.drawTooltip(ctx, mouseX, mouseY); + public void drawTooltips(GuiGraphicsExtractor gui, int mouseX, int mouseY) { + for (Button button : visibleButtons) button.drawTooltip(gui, mouseX, mouseY); } protected abstract void updateWidth(); diff --git a/src/main/java/me/retucio/sputnik/ui/widgets/Widget.java b/src/main/java/me/retucio/sputnik/ui/widgets/Widget.java index db1880e..204069b 100644 --- a/src/main/java/me/retucio/sputnik/ui/widgets/Widget.java +++ b/src/main/java/me/retucio/sputnik/ui/widgets/Widget.java @@ -1,12 +1,12 @@ package me.retucio.sputnik.ui.widgets; import me.retucio.sputnik.ui.screen.ClickGUI; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphicsExtractor; public abstract class Widget { - protected static final MinecraftClient mc = MinecraftClient.getInstance(); + protected static final Minecraft mc = Minecraft.getInstance(); protected int x, y, w, h; @@ -18,7 +18,7 @@ public abstract class Widget { } - public void render(DrawContext ctx, int mouseX, int mouseY, float delta) {} + public void render(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) {} // input diff --git a/src/main/java/me/retucio/sputnik/ui/widgets/buttons/ModuleButton.java b/src/main/java/me/retucio/sputnik/ui/widgets/buttons/ModuleButton.java index 9d7d0a7..0ddcd3f 100644 --- a/src/main/java/me/retucio/sputnik/ui/widgets/buttons/ModuleButton.java +++ b/src/main/java/me/retucio/sputnik/ui/widgets/buttons/ModuleButton.java @@ -5,8 +5,9 @@ import me.retucio.sputnik.ui.screen.ClickGUI; import me.retucio.sputnik.ui.widgets.frames.ModuleFrame; import me.retucio.sputnik.ui.widgets.Button; import me.retucio.sputnik.util.Colors; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.text.Text; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.network.chat.Component; + // clase para el botón para cada módulo public class ModuleButton extends Button { @@ -20,25 +21,26 @@ public class ModuleButton extends Button { } @Override - public void render(DrawContext ctx, int mouseX, int mouseY, float delta) { - ctx.fill( // dibujar el contorno del botón + public void render(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) { + gui.fill( // dibujar el contorno del botón parent.getX() + 2, parent.getRenderY() + offset + 3, parent.getX() + parent.getW() - 2 , parent.getRenderY() + height + offset, determineColor(mouseX, mouseY)); - ctx.drawText( // dibujar el nombre del módulo - mc.textRenderer, module.getName(), - parent.getX() + 5, parent.getRenderY() + offset + (height / 2) - (mc.textRenderer.fontHeight / 2) + 2, + gui.text( // dibujar el nombre del módulo + mc.font, module.getName(), + parent.getX() + 5, parent.getRenderY() + offset + (height / 2) - (mc.font.lineHeight / 2) + 2, -1, true); // dibujar "tooltips" (cajas de texto) al pasar el puntero encima del botón, para mostrar su descripción - if (isHovered(mouseX, mouseY)) - drawTooltip(ctx, mouseX, mouseY); + if (isHovered(mouseX, mouseY)) { + drawTooltip(gui, mouseX, mouseY); + } } @Override - public void drawTooltip(DrawContext ctx, int mouseX, int mouseY) { - ctx.drawTooltip(Text.of(module.getDescription()), mouseX, mouseY + 20); + public void drawTooltip(GuiGraphicsExtractor gui, int mouseX, int mouseY) { + gui.setTooltipForNextFrame(Component.literal(module.getDescription()), mouseX, mouseY + 20); } @Override diff --git a/src/main/java/me/retucio/sputnik/ui/widgets/buttons/SettingButton.java b/src/main/java/me/retucio/sputnik/ui/widgets/buttons/SettingButton.java index 100cfad..86ee91f 100644 --- a/src/main/java/me/retucio/sputnik/ui/widgets/buttons/SettingButton.java +++ b/src/main/java/me/retucio/sputnik/ui/widgets/buttons/SettingButton.java @@ -1,11 +1,10 @@ package me.retucio.sputnik.ui.widgets.buttons; import me.retucio.sputnik.module.setting.Setting; -import me.retucio.sputnik.ui.widgets.Frame; import me.retucio.sputnik.ui.widgets.frames.SettingsFrame; import me.retucio.sputnik.ui.widgets.Button; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.text.Text; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.network.chat.Component; // clase base para los botones de los ajustes public abstract class SettingButton> extends Button { @@ -20,9 +19,9 @@ public abstract class SettingButton> extends Button { // dibujar "tooltips" (cajitas de texto bajo el puntero del ratón) // con la descripción para asistir al usuario en el caso de que tenga down @Override - public void drawTooltip(DrawContext ctx, int mouseX, int mouseY) { + public void drawTooltip(GuiGraphicsExtractor gui, int mouseX, int mouseY) { if (isHovered(mouseX, mouseY)) - ctx.drawTooltip(Text.of(setting.getDescription()), mouseX, mouseY + 20); + gui.setTooltipForNextFrame(Component.literal(setting.getDescription()), mouseX, mouseY + 20); } @Override diff --git a/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/BindButton.java b/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/BindButton.java index f5ff00e..d25f354 100644 --- a/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/BindButton.java +++ b/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/BindButton.java @@ -8,11 +8,11 @@ import me.retucio.sputnik.ui.widgets.frames.SettingsFrame; import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.Colors; import me.retucio.sputnik.util.KeyUtil; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.input.KeyInput; -import net.minecraft.client.option.KeyBinding; -import net.minecraft.client.resource.language.I18n; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; +import net.minecraft.client.KeyMapping; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.client.input.KeyEvent; +import net.minecraft.client.resources.language.I18n; import org.lwjgl.glfw.GLFW; import java.util.ArrayList; @@ -30,16 +30,16 @@ public class BindButton extends SettingButton { } @Override - public void render(DrawContext ctx, int mouseX, int mouseY, float delta) { + public void render(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) { // fondo int bgColor = isHovered(mouseX, mouseY) ? Colors.buttonColor.brighter().getRGB() : Colors.buttonColor.getRGB(); - ctx.fill(x, y, x + w, y + h, bgColor); + gui.fill(x, y, x + w, y + h, bgColor); // texto String label = setting.getName() + ": " + (listening ? "..." : setting.getKeyName()); - ctx.drawText(mc.textRenderer, label, x + 5, y + 3, -1, true); + gui.text(mc.font, label, x + 5, y + 3, -1, true); } @Override @@ -48,15 +48,15 @@ public class BindButton extends SettingButton { if (hovered && ClickGUI.INSTANCE.trySelect(this)) { if (listening) { - List keys = new ArrayList<>(List.of(mc.options.allKeys)); + List keys = new ArrayList<>(List.of(mc.options.keyMappings)); keys.removeAll(List.of(mc.options.debugKeys)); boolean allowMultiple = ClientSettingsFrame.guiSettings.multipleKeybinds.getValue(); - for (KeyBinding bind : keys) { - if (bind.matchesKey(new KeyInput(button, 0, 0))) { + for (KeyMapping bind : keys) { + if (bind.matches(new KeyEvent(button, 0, 0))) { if (!allowMultiple) { ChatUtil.warn("esa tecla ya está cogida por " - + Formatting.GREEN + "\"" + I18n.translate(bind.getId()) + "\""); + + ChatFormatting.GREEN + "\"" + I18n.get(bind.getName()) + "\""); listening = false; return; } @@ -85,16 +85,16 @@ public class BindButton extends SettingButton { if (key == GLFW.GLFW_KEY_ESCAPE) { setting.setValue(GLFW.GLFW_KEY_UNKNOWN); } else { - List keys = new ArrayList<>(List.of(mc.options.allKeys)); + List keys = new ArrayList<>(List.of(mc.options.keyMappings)); keys.removeAll(List.of(mc.options.debugKeys)); - for (KeyBinding bind : keys) { + for (KeyMapping bind : keys) { // no permitir usar la misma tecla para varias acciones, si el ajuste para esto está activado - boolean keyAlreadyBound = bind.matchesKey(new KeyInput(key, 0, 0)); + boolean keyAlreadyBound = bind.matches(new KeyEvent(key, 0, 0)); boolean allowMultiple = ClientSettingsFrame.guiSettings.multipleKeybinds.getValue(); if (keyAlreadyBound && !allowMultiple) { ChatUtil.warn("esa tecla ya está cogida por " - + Formatting.GREEN + "\"" + I18n.translate(bind.getId()) + "\""); + + ChatFormatting.GREEN + "\"" + I18n.get(bind.getName()) + "\""); listening = false; return; } diff --git a/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/ChooseButton.java b/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/ChooseButton.java index dcf9b1b..b693ce7 100644 --- a/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/ChooseButton.java +++ b/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/ChooseButton.java @@ -9,12 +9,13 @@ import me.retucio.sputnik.ui.widgets.frames.SettingsFrame; import me.retucio.sputnik.ui.screen.ClickGUI; import me.retucio.sputnik.util.Colors; import me.retucio.sputnik.util.KeyUtil; -import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.GuiGraphicsExtractor; import java.util.Comparator; import java.util.HashMap; import java.util.Map; + // botón para los ajustes de selección única public class ChooseButton extends SettingButton> { @@ -39,23 +40,23 @@ public class ChooseButton extends SettingButton> { } @Override - public void render(DrawContext ctx, int mouseX, int mouseY, float delta) { + public void render(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) { // fondo int bgColor = isHovered(mouseX, mouseY) ? Colors.buttonColor.brighter().getRGB() : Colors.buttonColor.getRGB(); - ctx.fill(x, y, x + w, y + h, bgColor); + gui.fill(x, y, x + w, y + h, bgColor); // texto String label = setting.getName() + ": " + setting.getDisplayName(setting.getValue()); - ctx.drawText(mc.textRenderer, label, x + 5, y + 3, -1, true); + gui.text(mc.font, label, x + 5, y + 3, -1, true); } @Override public void mouseClicked(int mouseX, int mouseY, int button) { if (isHovered(mouseX, mouseY) && ClickGUI.INSTANCE.trySelect(this)) { // click izquierdo / derecho: abrir marco - if (button <= 1 && !mc.isShiftPressed()) { + if (button <= 1 && !KeyUtil.isShiftDown()) { openFrame(); // shift + clic derecho: restablecer valores } else if (button == 1 && KeyUtil.isShiftDown()) { diff --git a/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/ColorButton.java b/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/ColorButton.java index 5dbd857..09a4250 100644 --- a/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/ColorButton.java +++ b/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/ColorButton.java @@ -7,8 +7,8 @@ import me.retucio.sputnik.ui.widgets.frames.SettingsFrame; import me.retucio.sputnik.util.Colors; import me.retucio.sputnik.util.KeyUtil; import me.retucio.sputnik.util.render.DrawUtil; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.text.Text; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.network.chat.Component; import java.awt.*; import java.util.ArrayList; @@ -23,31 +23,35 @@ public class ColorButton extends SettingButton { } @Override - public void render(DrawContext ctx, int mouseX, int mouseY, float delta) { + public void render(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) { // fondo Color bgColor = isHovered(mouseX, mouseY) ? Colors.buttonColor.brighter() : Colors.buttonColor; - ctx.fill(x, y, x + w, y + h, bgColor.getRGB()); + gui.fill(x, y, x + w, y + h, bgColor.getRGB()); // prev. del color int previewSize = h - 6; int previewX = x + 5; int previewY = y + 3; - DrawUtil.drawBorder(ctx, previewX - 1, previewY - 1, previewSize + 2, previewSize + 2, Colors.withAlpha(Colors.getOppositeColor(setting.getValue(), true), 255).getRGB()); - ctx.fill(previewX, previewY, previewX + previewSize, previewY + previewSize, setting.getValue().getRGB()); + DrawUtil.drawBorder(gui, + previewX - 1, previewY - 1, previewSize + 2, previewSize + 2, + Colors.withAlpha(Colors.getOppositeColor(setting.getValue(), true), 255).getRGB() + ); + + gui.fill(previewX, previewY, previewX + previewSize, previewY + previewSize, setting.getValue().getRGB()); // texto String label = setting.getName(); int textX = previewX + previewSize + 5; - ctx.drawText(mc.textRenderer, label, textX, y + 3, -1, true); + gui.text(mc.font, label, textX, y + 3, -1, true); // valor actual String valueText = setting.isRainbow() ? "gay." : Colors.ARGBtoHex(setting.getA(), setting.getR(), setting.getG(), setting.getB()); - int valueWidth = mc.textRenderer.getWidth(valueText); - ctx.drawText(mc.textRenderer, valueText, x + w - valueWidth - 5, y + 3, -1, true); + int valueWidth = mc.font.width(valueText); + gui.text(mc.font, valueText, x + w - valueWidth - 5, y + 3, -1, true); } @Override @@ -67,13 +71,13 @@ public class ColorButton extends SettingButton { } @Override - public void drawTooltip(DrawContext ctx, int mouseX, int mouseY) { + public void drawTooltip(GuiGraphicsExtractor ctx, int mouseX, int mouseY) { if (isHovered(mouseX, mouseY)) { - List tooltip = new ArrayList<>(); - tooltip.add(Text.of(setting.getDescription())); + List tooltip = new ArrayList<>(); + tooltip.add(Component.literal(setting.getDescription())); tooltip.add(setting.getTooltipText()); - ctx.drawTooltip(mc.textRenderer, tooltip, mouseX, mouseY + 20); + ctx.setComponentTooltipForNextFrame(mc.font, tooltip, mouseX, mouseY + 20); } } } diff --git a/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/CycleButton.java b/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/CycleButton.java index 113e043..1ad5147 100644 --- a/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/CycleButton.java +++ b/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/CycleButton.java @@ -6,10 +6,10 @@ import me.retucio.sputnik.ui.widgets.buttons.SettingButton; import me.retucio.sputnik.ui.widgets.frames.SettingsFrame; import me.retucio.sputnik.util.Colors; import me.retucio.sputnik.util.KeyUtil; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.network.chat.Component; import java.util.ArrayList; import java.util.List; @@ -24,17 +24,17 @@ public class CycleButton> extends SettingButton } @Override - public void render(DrawContext ctx, int mouseX, int mouseY, float delta) { + public void render(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) { // fondo int bgColor = isHovered(mouseX, mouseY) ? Colors.buttonColor.brighter().getRGB() : Colors.buttonColor.getRGB(); - ctx.fill(x, y, x + w, y + h, bgColor); + gui.fill(x, y, x + w, y + h, bgColor); // texto del botón: nombre + valor de texto del enum String label = setting.getName() + ": " + setting.getValue().toString(); - ctx.drawText(mc.textRenderer, label, x + 5, y + 3, -1, true); + gui.text(mc.font, label, x + 5, y + 3, -1, true); } @@ -54,27 +54,27 @@ public class CycleButton> extends SettingButton } @Override - public void drawTooltip(DrawContext ctx, int mouseX, int mouseY) { + public void drawTooltip(GuiGraphicsExtractor ctx, int mouseX, int mouseY) { if (isHovered(mouseX, mouseY)) { - Screen currentScreen = mc.currentScreen; + Screen currentScreen = mc.screen; if (currentScreen != null) { - if (mc.isShiftPressed()) { + if (KeyUtil.isShiftDown()) { // lista de opciones disponibles - List lines = new ArrayList<>(); - lines.add(Text.literal("modos disponibles:")); + List lines = new ArrayList<>(); + lines.add(Component.literal("modos disponibles:")); for (Enum val : setting.getValues()) { if (val == setting.getValue()) - lines.add(Text.literal("> " + val.toString() + " <").formatted(Formatting.GREEN)); + lines.add(Component.literal("> " + val.toString() + " <").withStyle(ChatFormatting.GREEN)); else - lines.add(Text.literal(val.toString())); + lines.add(Component.literal(val.toString())); } - ctx.drawTooltip(mc.textRenderer, lines, mouseX, mouseY + 20); + ctx.setComponentTooltipForNextFrame(mc.font, lines, mouseX, mouseY + 20); } else { // descripción normal del ajuste - ctx.drawTooltip(Text.of(setting.getDescription()), mouseX, mouseY + 20); + ctx.setTooltipForNextFrame(Component.literal(setting.getDescription()), mouseX, mouseY + 20); } } } diff --git a/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/ListButton.java b/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/ListButton.java index 8145232..74ca189 100644 --- a/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/ListButton.java +++ b/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/ListButton.java @@ -9,8 +9,8 @@ import me.retucio.sputnik.ui.screen.ClickGUI; import me.retucio.sputnik.ui.widgets.frames.SettingsFrame; import me.retucio.sputnik.util.Colors; import me.retucio.sputnik.util.KeyUtil; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.text.Text; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.network.chat.Component; import java.util.*; @@ -40,22 +40,22 @@ public class ListButton extends SettingButton> { } @Override - public void render(DrawContext ctx, int mouseX, int mouseY, float delta) { + public void render(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) { // fondo int bgColor = isHovered(mouseX, mouseY) ? Colors.buttonColor.brighter().getRGB() : Colors.buttonColor.getRGB(); - ctx.fill(x, y, x + w, y + h, bgColor); + gui.fill(x, y, x + w, y + h, bgColor); // texto: nombre + número de opciones seleccionadas / total de opciones String label = setting.getName() + " (" + countEnabled() + "/" + setting.getOptions().size() + ")"; - ctx.drawText(mc.textRenderer, label, x + 5, y + 3, -1, true); + gui.text(mc.font, label, x + 5, y + 3, -1, true); } @Override - public void drawTooltip(DrawContext ctx, int mouseX, int mouseY) { + public void drawTooltip(GuiGraphicsExtractor gui, int mouseX, int mouseY) { if (isHovered(mouseX, mouseY)) - ctx.drawTooltip(Text.of( + gui.setTooltipForNextFrame(Component.literal( setting.getDescription() + " (" + countEnabled() + " de " + setting.getOptions().size() + ")"), diff --git a/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/SliderButton.java b/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/SliderButton.java index 3fe60f8..f53a727 100644 --- a/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/SliderButton.java +++ b/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/SliderButton.java @@ -7,7 +7,7 @@ import me.retucio.sputnik.ui.widgets.frames.SettingsFrame; import me.retucio.sputnik.ui.widgets.frames.settings.ClientSettingsFrame; import me.retucio.sputnik.util.Colors; import me.retucio.sputnik.util.KeyUtil; -import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.GuiGraphicsExtractor; import org.lwjgl.glfw.GLFW; import java.awt.*; @@ -27,7 +27,7 @@ public class SliderButton extends SettingButton { } @Override - public void render(DrawContext ctx, int mouseX, int mouseY, float delta) { + public void render(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) { // fondo Color bgColor = Colors.buttonColor; Color fillingColor = Colors.mainColor; @@ -37,20 +37,20 @@ public class SliderButton extends SettingButton { fillingColor = fillingColor.brighter(); } - ctx.fill(x, y, x + w, y + h, bgColor.getRGB()); + gui.fill(x, y, x + w, y + h, bgColor.getRGB()); // calcular cómo de lleno tendría que estar el "slider" double percent = (setting.getValue() - setting.getMin()) / (setting.getMax() - setting.getMin()); int filled = (int) (percent * w); - ctx.fill(x, y, x + filled, y + h, fillingColor.getRGB()); + gui.fill(x, y, x + filled, y + h, fillingColor.getRGB()); String label = setting.getName() + ": " + df.format(setting.getValue()); - ctx.drawText(mc.textRenderer, label, x + 5, y + 3, -1, true); + gui.text(mc.font, label, x + 5, y + 3, -1, true); // lógica para arrastrar el valor if (dragging) { double newVal = setting.getMin() + ((mouseX - x) / (double) w) * (setting.getMax() - setting.getMin()); - newVal = Math.max(setting.getMin(), Math.min(setting.getMax(), newVal)); + newVal = Math.clamp(newVal, setting.getMin(), setting.getMax()); newVal = Math.round(newVal / setting.getIncrement()) * setting.getIncrement(); setting.setValue((float) newVal); } @@ -80,4 +80,4 @@ public class SliderButton extends SettingButton { super.mouseReleased(mouseX, mouseY, button); if (button == 0) dragging = false; } -} \ No newline at end of file +} diff --git a/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/TextButton.java b/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/TextButton.java index 0f1790b..0e58aec 100644 --- a/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/TextButton.java +++ b/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/TextButton.java @@ -7,7 +7,7 @@ import me.retucio.sputnik.ui.widgets.frames.SettingsFrame; import me.retucio.sputnik.util.Colors; import me.retucio.sputnik.util.KeyUtil; import me.retucio.sputnik.util.MiscUtil; -import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.GuiGraphicsExtractor; import org.lwjgl.glfw.GLFW; @@ -25,16 +25,16 @@ public class TextButton extends SettingButton { } @Override - public void render(DrawContext ctx, int mouseX, int mouseY, float delta) { + public void render(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) { // fondo int bgColor = isHovered(mouseX, mouseY) ? Colors.buttonColor.brighter().getRGB() : Colors.buttonColor.getRGB(); - ctx.fill(x, y, x + w, y + h, bgColor); + gui.fill(x, y, x + w, y + h, bgColor); // texto String label = setting.getName() + ": " + (typing ? buffer + "_" : setting.getValue()); - ctx.drawText(mc.textRenderer, label, x + 5, y + 3, -1, true); + gui.text(mc.font, label, x + 5, y + 3, -1, true); } @Override @@ -44,7 +44,7 @@ public class TextButton extends SettingButton { typing = true; buffer.setLength(0); buffer.append(setting.getValue()); // precargar valor anterior - } else if (button == 1 && mc.isShiftPressed()) { + } else if (button == 1 && KeyUtil.isShiftDown()) { typing = false; setting.reset(); } @@ -88,7 +88,10 @@ public class TextButton extends SettingButton { private void charTyped(char c) { if (!typing) return; buffer.append(c); - if (mc.textRenderer.getWidth(setting.getName() + ": " + buffer + "_") > w - 8) onBackspace(); + + if (mc.font.width(setting.getName() + ": " + buffer + "_") > w - 8) { + onBackspace(); + } } public boolean isFocused() { diff --git a/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/ToggleButton.java b/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/ToggleButton.java index c8cbab5..dd12a47 100644 --- a/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/ToggleButton.java +++ b/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/ToggleButton.java @@ -6,7 +6,7 @@ import me.retucio.sputnik.ui.screen.ClickGUI; import me.retucio.sputnik.ui.widgets.frames.SettingsFrame; import me.retucio.sputnik.util.Colors; import me.retucio.sputnik.util.KeyUtil; -import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.GuiGraphicsExtractor; import java.awt.*; @@ -22,7 +22,7 @@ public class ToggleButton extends SettingButton { } @Override - public void render(DrawContext ctx, int mouseX, int mouseY, float delta) { + public void render(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) { // fondo Color color = setting.getValue() ? Colors.enabledToggleButtonColor @@ -31,10 +31,10 @@ public class ToggleButton extends SettingButton { if (isHovered(mouseX, mouseY)) color = color.brighter(); - ctx.fill(x, y, x + w, y + h, color.getRGB()); + gui.fill(x, y, x + w, y + h, color.getRGB()); // texto - ctx.drawText(mc.textRenderer, setting.getName(), x + 5, y + 3, -1, true); + gui.text(mc.font, setting.getName(), x + 5, y + 3, -1, true); } @Override diff --git a/src/main/java/me/retucio/sputnik/ui/widgets/frames/ModuleFrame.java b/src/main/java/me/retucio/sputnik/ui/widgets/frames/ModuleFrame.java index 0980a9a..384795f 100644 --- a/src/main/java/me/retucio/sputnik/ui/widgets/frames/ModuleFrame.java +++ b/src/main/java/me/retucio/sputnik/ui/widgets/frames/ModuleFrame.java @@ -8,11 +8,10 @@ import me.retucio.sputnik.ui.screen.ClickGUI; import me.retucio.sputnik.ui.widgets.buttons.ModuleButton; import me.retucio.sputnik.ui.widgets.Frame; import me.retucio.sputnik.util.Colors; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.network.chat.Component; import java.util.List; @@ -22,7 +21,7 @@ public class ModuleFrame extends Frame { public boolean extended; - public MinecraftClient mc = MinecraftClient.getInstance(); + public Minecraft mc = Minecraft.getInstance(); public ModuleFrame(int x, int y, int w, int h) { super("módulos", x, y, w, h); @@ -33,7 +32,6 @@ public class ModuleFrame extends Frame { int offset = h; for (Module module : ModuleManager.INSTANCE.getModules()) { buttons.add(new ModuleButton(module, this, offset)); - updateWidth(); offset += h; } } @@ -41,31 +39,30 @@ public class ModuleFrame extends Frame { @Override protected void updateWidth() { // asegurarse de que todos los botones caben en el marco, haciendo que la anchura se ajuste al texto más largo - if (mc.textRenderer == null) return; - int maxWidth = mc.textRenderer.getWidth(title); + int maxWidth = mc.font.width(title); for (ModuleButton button : buttons) { String text = button.getModule().getName(); - int textWidth = mc.textRenderer.getWidth(text); + int textWidth = mc.font.width(text); maxWidth = Math.max(maxWidth, textWidth); } this.w = maxWidth + 22; } @Override - public void render(DrawContext ctx, int mouseX, int mouseY, float delta) { + public void render(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) { updateWidth(); - ctx.fill(x, renderY, x + w, renderY + h, Colors.mainColor.getRGB()); // cabeza del marco + gui.fill(x, renderY, x + w, renderY + h, Colors.mainColor.getRGB()); // cabeza del marco // título del marco - ctx.drawText(mc.textRenderer, Text.literal(Formatting.BOLD + title), + gui.text(mc.font, Component.literal(ChatFormatting.BOLD + title), x + 8, - renderY + (h / 2) - (mc.textRenderer.fontHeight / 2), + renderY + (h / 2) - (mc.font.lineHeight / 2), -1, true); - ctx.drawText(mc.textRenderer, extended ? "-" : "+", - x + w - mc.textRenderer.getWidth("+") - 8, // '+' y '-' tienen la misma anchura, o sea que no importa cuál use - renderY + (h / 2) - (mc.textRenderer.fontHeight / 2), + gui.text(mc.font, extended ? "-" : "+", + x + w - mc.font.width("+") - 8, // '+' y '-' tienen la misma anchura, o sea que no importa cuál use + renderY + (h / 2) - (mc.font.lineHeight / 2), -1, true); List visibleButtons = buttons.stream() @@ -75,7 +72,7 @@ public class ModuleFrame extends Frame { // dibujar sus módulos solo si está extendido if (extended) { totalHeight = visibleButtons.size() * h + 3; - ctx.fill( // fondo para los botones + gui.fill( // fondo para los botones x, renderY + h + 1, x + w, renderY + h + totalHeight, Colors.frameBGColor.getRGB()); @@ -84,7 +81,7 @@ public class ModuleFrame extends Frame { int buttonY = renderY + h + 1; for (ModuleButton moduleButton : visibleButtons) { moduleButton.setOffset(buttonY - renderY); - moduleButton.render(ctx, mouseX, mouseY, delta); + moduleButton.render(gui, mouseX, mouseY, delta); buttonY += h; } } else { @@ -136,12 +133,6 @@ public class ModuleFrame extends Frame { Sputnik.EVENT_BUS.post(new ModuleFrameEvent.Move()); } - @Override - public void mouseDragged(int mouseX, int mouseY) {} - - @Override - public void onKey(int key, int action) {} - // actualizar la posición al arrastrar el marco public void updatePosition(double mouseX, double mouseY) { if (dragging) { diff --git a/src/main/java/me/retucio/sputnik/ui/widgets/frames/SettingsFrame.java b/src/main/java/me/retucio/sputnik/ui/widgets/frames/SettingsFrame.java index 149a4e8..c6faca8 100644 --- a/src/main/java/me/retucio/sputnik/ui/widgets/frames/SettingsFrame.java +++ b/src/main/java/me/retucio/sputnik/ui/widgets/frames/SettingsFrame.java @@ -11,7 +11,7 @@ import me.retucio.sputnik.ui.widgets.buttons.*; import me.retucio.sputnik.ui.widgets.Frame; import me.retucio.sputnik.util.Colors; -import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.GuiGraphicsExtractor; import java.awt.*; import java.util.ArrayList; @@ -38,14 +38,14 @@ public class SettingsFrame extends Frame>> { } @Override - public void render(DrawContext ctx, int mouseX, int mouseY, float delta) { + public void render(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) { updateWidth(); // cabezal int centerX = x + w / 2; int centerY = renderY + h / 2; int titleX = x + 2 * PADDING; - int titleY = centerY - mc.textRenderer.fontHeight / 2; + int titleY = centerY - mc.font.lineHeight / 2; int headerColor = module.isEnabled() ? Colors.enabledToggleButtonColor.getRGB() @@ -55,9 +55,9 @@ public class SettingsFrame extends Frame>> { ? Color.RED.getRGB() : -1; - ctx.fill(x, renderY, x + w, renderY + h, headerColor); - ctx.drawText(mc.textRenderer, title, titleX, titleY, -1, true); - ctx.drawText(mc.textRenderer, "×", x + w - mc.textRenderer.getWidth("×") - 2 * PADDING, titleY, closeButtonColor, true); + gui.fill(x, renderY, x + w, renderY + h, headerColor); + gui.text(mc.font, title, titleX, titleY, -1, true); + gui.text(mc.font, "×", x + w - mc.font.width("×") - 2 * PADDING, titleY, closeButtonColor, true); // filtrar botones visibles visibleButtons = buttons.stream() @@ -68,7 +68,7 @@ public class SettingsFrame extends Frame>> { List descLines = wrapDescription(module.getDescription(), w - 2 * PADDING); int lineSpacing = 2; - int descHeight = descLines.size() * mc.textRenderer.fontHeight + (descLines.size() - 1) * lineSpacing; + int descHeight = descLines.size() * mc.font.lineHeight + (descLines.size() - 1) * lineSpacing; int descBoxTop = renderY + h + PADDING; int descBoxBottom = descBoxTop + descHeight + PADDING * 2; @@ -98,10 +98,10 @@ public class SettingsFrame extends Frame>> { } // fondo del marco - ctx.fill(x, descBoxTop - PADDING + 1, x + w, descBoxTop + totalHeight, Colors.frameBGColor.getRGB()); + gui.fill(x, descBoxTop - PADDING + 1, x + w, descBoxTop + totalHeight, Colors.frameBGColor.getRGB()); // fondo de la descripción - ctx.fill(x + PADDING, descBoxTop, x + w - PADDING, descBoxBottom, Colors.buttonColor.getRGB()); + gui.fill(x + PADDING, descBoxTop, x + w - PADDING, descBoxBottom, Colors.buttonColor.getRGB()); // restablecer currentY currentY = descBoxBottom + PADDING; @@ -114,9 +114,9 @@ public class SettingsFrame extends Frame>> { ? Colors.buttonColor.brighter().getRGB() : Colors.buttonColor.getRGB(); - ctx.fill(x + PADDING, currentY, x + w - PADDING, currentY + h, groupHeaderColor); - ctx.drawText(mc.textRenderer, group.getName(), x + PADDING * 2, currentY + (h - mc.textRenderer.fontHeight) / 2, -1, true); - ctx.drawText(mc.textRenderer, group.isExtended() ? "-" : "+", x + w - 4 * PADDING, currentY + (h - mc.textRenderer.fontHeight) / 2, -1, true); + gui.fill(x + PADDING, currentY, x + w - PADDING, currentY + h, groupHeaderColor); + gui.text(mc.font, group.getName(), x + PADDING * 2, currentY + (h - mc.font.lineHeight) / 2, -1, true); + gui.text(mc.font, group.isExtended() ? "-" : "+", x + w - 4 * PADDING, currentY + (h - mc.font.lineHeight) / 2, -1, true); currentY += h + PADDING; @@ -130,7 +130,7 @@ public class SettingsFrame extends Frame>> { sb.setY(currentY); sb.setW(w - PADDING * 4); sb.setH(h - h / 4); - sb.render(ctx, mouseX, mouseY, delta); + sb.render(gui, mouseX, mouseY, delta); if (j < groupButtons.size() - 1) { currentY += (h - h / 4) + PADDING; @@ -148,16 +148,16 @@ public class SettingsFrame extends Frame>> { int firstLineY = descBoxTop + ((descBoxBottom - descBoxTop) - descHeight) / 2; for (int i = 0; i < descLines.size(); i++) { String line = descLines.get(i); - int lineX = centerX - mc.textRenderer.getWidth(line) / 2; - int lineY = firstLineY + i * (mc.textRenderer.fontHeight + lineSpacing); - ctx.drawText(mc.textRenderer, line, lineX, lineY, -1, true); + int lineX = centerX - mc.font.width(line) / 2; + int lineY = firstLineY + i * (mc.font.lineHeight + lineSpacing); + gui.text(mc.font, line, lineX, lineY, -1, true); } } @Override - public void drawTooltips(DrawContext ctx, int mouseX, int mouseY) { + public void drawTooltips(GuiGraphicsExtractor gui, int mouseX, int mouseY) { for (SettingButton sb : visibleButtons) - sb.drawTooltip(ctx, mouseX, mouseY); + sb.drawTooltip(gui, mouseX, mouseY); } @Override @@ -215,9 +215,7 @@ public class SettingsFrame extends Frame>> { @Override public void updateWidth() { // asegurarse de que todos los botones caben en el marco, haciendo que la anchura se ajuste al texto más largo - if (mc.textRenderer == null) return; - - int maxWidth = mc.textRenderer.getWidth(title); + int maxWidth = mc.font.width(title); for (SettingButton button : buttons) { String text = button.getSetting().getName(); @@ -226,15 +224,16 @@ public class SettingsFrame extends Frame>> { case CycleButton cycleButton -> text += ": " + cycleButton.getSetting().getValue(); case BindButton bindButton -> text += ": " + bindButton.getSetting().getKeyName(); case TextButton textButton -> text += ": " + textButton.getSetting().getValue(); + case ColorButton colorButton -> text += colorButton.getSetting().getTooltipText(); default -> {} } - int textWidth = mc.textRenderer.getWidth(text); + int textWidth = mc.font.width(text); maxWidth = Math.max(maxWidth, textWidth); } for (SettingGroup group : settingGroups) { - int groupTextWidth = mc.textRenderer.getWidth("▶ " + group.getName()); + int groupTextWidth = mc.font.width(group.getName() + " +"); maxWidth = Math.max(maxWidth, groupTextWidth); } @@ -251,8 +250,8 @@ public class SettingsFrame extends Frame>> { public int getGroupHeaderY(int groupIndex) { int currentY = renderY + h + PADDING; List descLines = wrapDescription(module.getDescription(), w - 2 * PADDING); - int descHeight = descLines.size() * mc.textRenderer.fontHeight + (descLines.size() - 1) * 2; - currentY += descHeight + 3 * PADDING; // descBoxBottom + padding + int descHeight = descLines.size() * mc.font.lineHeight + (descLines.size() - 1) * 2; + currentY += descHeight + 3 * PADDING; // descBoxBottom + padding // iterar hasta llegar al grupo deseado int currentIndex = 0; @@ -354,14 +353,13 @@ public class SettingsFrame extends Frame>> { private List wrapDescription(String text, int maxWidth) { List lines = new ArrayList<>(); - if (mc.textRenderer == null) return lines; String[] words = text.split(" "); StringBuilder line = new StringBuilder(); for (String word : words) { String testLine = line.isEmpty() ? word : line + " " + word; - if (mc.textRenderer.getWidth(testLine) > maxWidth - 2 * PADDING) { + if (mc.font.width(testLine) > maxWidth - 2 * PADDING) { if (!line.isEmpty()) lines.add(line.toString()); line = new StringBuilder(word); } else { @@ -378,7 +376,7 @@ public class SettingsFrame extends Frame>> { } protected boolean isCloseButtonHovered(double mouseX, double mouseY) { - return mouseX > x + w - mc.textRenderer.getWidth("×") - 3 * PADDING && mouseX < x + w - PADDING + return mouseX > x + w - mc.font.width("×") - 3 * PADDING && mouseX < x + w - PADDING && mouseY > renderY + PADDING && mouseY < renderY + h - PADDING; } diff --git a/src/main/java/me/retucio/sputnik/ui/widgets/frames/settings/ClientSettingsFrame.java b/src/main/java/me/retucio/sputnik/ui/widgets/frames/settings/ClientSettingsFrame.java index 9ee6ffd..87c2ed1 100644 --- a/src/main/java/me/retucio/sputnik/ui/widgets/frames/settings/ClientSettingsFrame.java +++ b/src/main/java/me/retucio/sputnik/ui/widgets/frames/settings/ClientSettingsFrame.java @@ -8,7 +8,7 @@ import me.retucio.sputnik.ui.widgets.frames.SettingsFrame; import me.retucio.sputnik.ui.screen.ClickGUI; import me.retucio.sputnik.ui.widgets.buttons.SettingButton; import me.retucio.sputnik.util.Colors; -import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.GuiGraphicsExtractor; public class ClientSettingsFrame extends SettingsFrame { @@ -21,25 +21,25 @@ public class ClientSettingsFrame extends SettingsFrame { } @Override - public void render(DrawContext ctx, int mouseX, int mouseY, float delta) { + public void render(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) { updateWidth(); // botones, fondo, etc. if (extended) { - super.render(ctx, mouseX, mouseY, delta); + super.render(gui, mouseX, mouseY, delta); } // cabezal - ctx.fill(x, renderY, x + w, renderY + h, Colors.mainColor.getRGB()); + gui.fill(x, renderY, x + w, renderY + h, Colors.mainColor.getRGB()); - ctx.drawText(mc.textRenderer, title, + gui.text(mc.font, title, x + 8, - renderY + (h / 2) - (mc.textRenderer.fontHeight / 2), + renderY + (h / 2) - (mc.font.lineHeight / 2), -1, true); - ctx.drawText(mc.textRenderer, extended ? "-" : "+", - x + w - mc.textRenderer.getWidth("+") - 8, - renderY + (h / 2) - (mc.textRenderer.fontHeight / 2), + gui.text(mc.font, extended ? "-" : "+", + x + w - mc.font.width("+") - 8, + renderY + (h / 2) - (mc.font.lineHeight / 2), -1, true); } @@ -84,8 +84,8 @@ public class ClientSettingsFrame extends SettingsFrame { } @Override - public void drawTooltips(DrawContext ctx, int mouseX, int mouseY) { + public void drawTooltips(GuiGraphicsExtractor gui, int mouseX, int mouseY) { if (!extended) return; - super.drawTooltips(ctx, mouseX, mouseY); + super.drawTooltips(gui, mouseX, mouseY); } } diff --git a/src/main/java/me/retucio/sputnik/ui/widgets/frames/settings/ColorPickerFrame.java b/src/main/java/me/retucio/sputnik/ui/widgets/frames/settings/ColorPickerFrame.java index 52a9e72..9a5001f 100644 --- a/src/main/java/me/retucio/sputnik/ui/widgets/frames/settings/ColorPickerFrame.java +++ b/src/main/java/me/retucio/sputnik/ui/widgets/frames/settings/ColorPickerFrame.java @@ -13,7 +13,7 @@ import me.retucio.sputnik.ui.widgets.frames.SettingsFrame; import me.retucio.sputnik.ui.screen.ClickGUI; import me.retucio.sputnik.util.Colors; import me.retucio.sputnik.util.render.DrawUtil; -import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.GuiGraphicsExtractor; import java.awt.*; @@ -23,12 +23,10 @@ public class ColorPickerFrame extends SettingsFrame { private final ColorSetting colorSetting; private Color currentColor; - // Color picker state private boolean pickingHue = false; private boolean pickingSaturationBrightness = false; private boolean pickingAlpha = false; - // Picker areas private int huePickerX, huePickerY, huePickerWidth, huePickerHeight; private int saturationBrightnessPickerX, saturationBrightnessPickerY, saturationBrightnessPickerWidth, saturationBrightnessPickerHeight; private int alphaPickerX, alphaPickerY, alphaPickerWidth, alphaPickerHeight; @@ -117,14 +115,16 @@ public class ColorPickerFrame extends SettingsFrame { // RENDERIZADO @Override - public void render(DrawContext ctx, int mouseX, int mouseY, float delta) { + public void render(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) { if (colorSetting == null) return; updateWidth(); // al parecer este era el problema :/ - for (Setting setting : dummyModule.getSettings()) - if (setting instanceof NumberSetting ns) ns.setLocked( - pickingAlpha || pickingHue || pickingSaturationBrightness); + for (Setting setting : dummyModule.getSettings()) { + if (setting instanceof NumberSetting ns) { + ns.setLocked(pickingAlpha || pickingHue || pickingSaturationBrightness); + } + } currentColor = colorSetting.getValue(); @@ -133,17 +133,17 @@ public class ColorPickerFrame extends SettingsFrame { // cabezal int centerY = renderY + h / 2; int titleX = x + 8; - int titleY = centerY - mc.textRenderer.fontHeight / 2; + int titleY = centerY - mc.font.lineHeight / 2; String title = colorSetting.getName(); - ctx.fill(x, renderY, x + w, renderY + h, Colors.mainColor.getRGB()); - ctx.drawText(mc.textRenderer, title, titleX, titleY, -1, true); + gui.fill(x, renderY, x + w, renderY + h, Colors.mainColor.getRGB()); + gui.text(mc.font, title, titleX, titleY, -1, true); // botón de cerrar int closeButtonColor = isCloseButtonHovered(mouseX, mouseY) ? Color.RED.getRGB() : -1; - ctx.drawText(mc.textRenderer, "×", x + w - mc.textRenderer.getWidth("×") - 8, titleY, closeButtonColor, true); + gui.text(mc.font, "×", x + w - mc.font.width("×") - 8, titleY, closeButtonColor, true); int previewX = x + padding; @@ -175,9 +175,9 @@ public class ColorPickerFrame extends SettingsFrame { int bgY2 = bgY1 + previewHeight + saturationBrightnessPickerHeight + alphaPickerHeight + buttonAreaHeight + (padding * 6) - 11; - ctx.fill(bgX1, bgY1, bgX2, bgY2, Colors.frameBGColor.getRGB()); + gui.fill(bgX1, bgY1, bgX2, bgY2, Colors.frameBGColor.getRGB()); - DrawUtil.drawBorder(ctx, previewX, previewY, previewWidth, previewHeight, -1); + DrawUtil.drawBorder(gui, previewX, previewY, previewWidth, previewHeight, -1); if (colorSetting.isRainbow()) { float hueStep = 1f / previewWidth; @@ -186,21 +186,21 @@ public class ColorPickerFrame extends SettingsFrame { float hue = i * hueStep; Color rainbowColor = Color.getHSBColor(hue, colorSetting.getSaturation(), colorSetting.getBrightness()); int endX = Math.min(i + stripWidth, previewWidth); - ctx.fill(previewX + i, previewY, previewX + endX, previewY + previewHeight, + gui.fill(previewX + i, previewY, previewX + endX, previewY + previewHeight, (colorSetting.getA() << 24) | (rainbowColor.getRGB() & 0x00FFFFFF)); } } else { - ctx.fill(previewX, previewY, previewX + previewWidth, previewY + previewHeight, currentColor.getRGB()); + gui.fill(previewX, previewY, previewX + previewWidth, previewY + previewHeight, currentColor.getRGB()); } // hex del color actual String hexText = colorSetting.isRainbow() ? "gay." : Colors.ARGBtoHex(colorSetting.getA(), colorSetting.getR(), colorSetting.getG(), colorSetting.getB()); - int hexWidth = mc.textRenderer.getWidth(hexText); - ctx.drawText(mc.textRenderer, hexText, x + w / 2 - hexWidth / 2, previewY + previewHeight / 2 - mc.textRenderer.fontHeight / 2, -1, true); + int hexWidth = mc.font.width(hexText); + gui.text(mc.font, hexText, x + w / 2 - hexWidth / 2, previewY + previewHeight / 2 - mc.font.lineHeight / 2, -1, true); // utilizar un gradiente combinado, para mejorar la optimización - renderSaturationBrightnessGradient(ctx); - DrawUtil.drawBorder(ctx, saturationBrightnessPickerX, saturationBrightnessPickerY, + renderSaturationBrightnessGradient(gui); + DrawUtil.drawBorder(gui, saturationBrightnessPickerX, saturationBrightnessPickerY, saturationBrightnessPickerWidth, saturationBrightnessPickerHeight, -1); float[] hsb1; @@ -214,28 +214,28 @@ public class ColorPickerFrame extends SettingsFrame { int indicatorX = saturationBrightnessPickerX + (int)(hsb1[1] * saturationBrightnessPickerWidth); int indicatorY = saturationBrightnessPickerY + (int)((1 - hsb1[2]) * saturationBrightnessPickerHeight); - DrawUtil.drawCircle(ctx, indicatorX, indicatorY, 3, -1); + DrawUtil.drawCircle(gui, indicatorX, indicatorY, 3, -1); // gradiente del "hue" (no sé cómo se dice en castellano) for (int hy = 0; hy < huePickerHeight; hy += 2) { float hue = 1.0f - (hy / (float) huePickerHeight); Color hueColor = Color.getHSBColor(hue, 1.0f, 1.0f); - ctx.fill(huePickerX, huePickerY + hy, huePickerX + huePickerWidth, + gui.fill(huePickerX, huePickerY + hy, huePickerX + huePickerWidth, huePickerY + Math.min(hy + 2, huePickerHeight), hueColor.getRGB()); } - DrawUtil.drawBorder(ctx, huePickerX, huePickerY, huePickerWidth, huePickerHeight, -1); + DrawUtil.drawBorder(gui, huePickerX, huePickerY, huePickerWidth, huePickerHeight, -1); if (!colorSetting.isRainbow()) { float[] hsb2 = Color.RGBtoHSB(colorSetting.getR(), colorSetting.getG(), colorSetting.getB(), null); int hueIndicatorY = huePickerY + (int)((1 - hsb2[0]) * huePickerHeight); - DrawUtil.drawCircle(ctx, huePickerX + huePickerWidth / 2, hueIndicatorY, 3, -1); + DrawUtil.drawCircle(gui, huePickerX + huePickerWidth / 2, hueIndicatorY, 3, -1); } - renderAlphaGradient(ctx); - DrawUtil.drawBorder(ctx, alphaPickerX, alphaPickerY, alphaPickerWidth, alphaPickerHeight, -1); + renderAlphaGradient(gui); + DrawUtil.drawBorder(gui, alphaPickerX, alphaPickerY, alphaPickerWidth, alphaPickerHeight, -1); int alphaIndicatorX = alphaPickerX + (int)((colorSetting.getA() / 255f) * alphaPickerWidth); - DrawUtil.drawCircle(ctx, alphaIndicatorX, alphaPickerY + alphaPickerHeight / 2, 3, -1); + DrawUtil.drawCircle(gui, alphaIndicatorX, alphaPickerY + alphaPickerHeight / 2, 3, -1); totalHeight = previewHeight + saturationBrightnessPickerHeight + alphaPickerHeight + (padding * 4) + h; @@ -250,14 +250,14 @@ public class ColorPickerFrame extends SettingsFrame { sb.setY(startButtonY); sb.setW(w - 8); sb.setH(h - h / 4); - sb.render(ctx, mouseX, mouseY, delta); + sb.render(gui, mouseX, mouseY, delta); startButtonY += h; } totalHeight += (visibleButtons.size() * h) + padding; } - private void renderSaturationBrightnessGradient(DrawContext ctx) { + private void renderSaturationBrightnessGradient(GuiGraphicsExtractor gui) { float hue; if (colorSetting.isRainbow()) { hue = (System.currentTimeMillis() % (colorSetting.getRainbowSpeed() * 1000L)) @@ -271,7 +271,7 @@ public class ColorPickerFrame extends SettingsFrame { for (int sx = 0; sx < saturationBrightnessPickerWidth; sx++) { float saturation = sx / (float) saturationBrightnessPickerWidth; Color colorAtX = Color.getHSBColor(hue, saturation, 1); - ctx.fill(saturationBrightnessPickerX + sx, saturationBrightnessPickerY, + gui.fill(saturationBrightnessPickerX + sx, saturationBrightnessPickerY, saturationBrightnessPickerX + sx + 1, saturationBrightnessPickerY + saturationBrightnessPickerHeight, colorAtX.getRGB()); } @@ -281,15 +281,15 @@ public class ColorPickerFrame extends SettingsFrame { float brightness = (sy / (float) saturationBrightnessPickerHeight); int alpha = (int)(brightness * 255); Color overlay = new Color(0, 0, 0, alpha); - ctx.fill(saturationBrightnessPickerX, saturationBrightnessPickerY + sy, + gui.fill(saturationBrightnessPickerX, saturationBrightnessPickerY + sy, saturationBrightnessPickerX + saturationBrightnessPickerWidth, saturationBrightnessPickerY + sy + 1, overlay.getRGB()); } } - private void renderAlphaGradient(DrawContext ctx) { + private void renderAlphaGradient(GuiGraphicsExtractor gui) { // dibujar casilleros alternando el tono de gris para el slider de la opacidad - DrawUtil.drawCheckerBoard(ctx, alphaPickerX + 1, alphaPickerY, alphaPickerWidth, alphaPickerHeight, 3, 0xFF333333, 0xFF666666); + DrawUtil.drawCheckerBoard(gui, alphaPickerX + 1, alphaPickerY, alphaPickerWidth, alphaPickerHeight, 3, 0xFF333333, 0xFF666666); if (colorSetting != null) { int alphaWidth = (int)(alphaPickerWidth * (colorSetting.getA() / 255f)); @@ -303,7 +303,7 @@ public class ColorPickerFrame extends SettingsFrame { new Color(255, 255, 255, alphaValue); int stripEndX = Math.min(ax + stripWidth, alphaWidth); - ctx.fill(alphaPickerX + ax, alphaPickerY, + gui.fill(alphaPickerX + ax, alphaPickerY, alphaPickerX + stripEndX, alphaPickerY + alphaPickerHeight, overlayColor.getRGB()); } } diff --git a/src/main/java/me/retucio/sputnik/ui/widgets/misc/ScrollBarWidget.java b/src/main/java/me/retucio/sputnik/ui/widgets/misc/ScrollBarWidget.java index 618d11b..2d843c0 100644 --- a/src/main/java/me/retucio/sputnik/ui/widgets/misc/ScrollBarWidget.java +++ b/src/main/java/me/retucio/sputnik/ui/widgets/misc/ScrollBarWidget.java @@ -4,10 +4,11 @@ import me.retucio.sputnik.ui.screen.ClickGUI; import me.retucio.sputnik.ui.widgets.frames.settings.ClientSettingsFrame; import me.retucio.sputnik.ui.widgets.Widget; import me.retucio.sputnik.util.Colors; -import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.GuiGraphicsExtractor; import java.awt.*; + public class ScrollBarWidget extends Widget { private boolean dragging; @@ -22,13 +23,13 @@ public class ScrollBarWidget extends Widget { } @Override - public void render(DrawContext ctx, int mouseX, int mouseY, float delta) { + public void render(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) { if (contentHeight <= windowHeight || !ClientSettingsFrame.guiSettings.scrollBar.getValue()) return; - int trackX1 = mc.getWindow().getScaledWidth() - 10; + int trackX1 = mc.getWindow().getGuiScaledWidth() - 10; int trackX2 = trackX1 + 10; - ctx.fill(trackX1, 0, trackX2, windowHeight, Colors.buttonColor.getRGB()); + gui.fill(trackX1, 0, trackX2, windowHeight, Colors.buttonColor.getRGB()); int thumbHeight = getThumbHeight(); int thumbY = getThumbY(); @@ -39,7 +40,7 @@ public class ScrollBarWidget extends Widget { if (dragging) thumbColor = Colors.mainColor.darker(); - ctx.fill(trackX1 + 1, thumbY + 1, trackX2 - 1, thumbY + thumbHeight - 1, thumbColor.getRGB()); + gui.fill(trackX1 + 1, thumbY + 1, trackX2 - 1, thumbY + thumbHeight - 1, thumbColor.getRGB()); } @Override @@ -80,7 +81,7 @@ public class ScrollBarWidget extends Widget { private boolean isThumbHovered(double mouseX, double mouseY) { if (!ClickGUI.INSTANCE.canSelect(this)) return false; - int trackX1 = mc.getWindow().getScaledWidth() - 10; + int trackX1 = mc.getWindow().getGuiScaledWidth() - 10; int trackX2 = trackX1 + 10; int thumbY = getThumbY(); int thumbHeight = getThumbHeight(); @@ -91,7 +92,7 @@ public class ScrollBarWidget extends Widget { if (contentHeight <= windowHeight) scrollOffset = 0; else - scrollOffset = Math.max(0, Math.min(contentHeight - windowHeight, scrollOffset)); + scrollOffset = Math.clamp(scrollOffset, 0, contentHeight - windowHeight); } private int getThumbY() { diff --git a/src/main/java/me/retucio/sputnik/ui/widgets/misc/SearchBarWidget.java b/src/main/java/me/retucio/sputnik/ui/widgets/misc/SearchBarWidget.java index 10211a4..6128f84 100644 --- a/src/main/java/me/retucio/sputnik/ui/widgets/misc/SearchBarWidget.java +++ b/src/main/java/me/retucio/sputnik/ui/widgets/misc/SearchBarWidget.java @@ -13,10 +13,10 @@ import me.retucio.sputnik.util.Colors; import me.retucio.sputnik.util.KeyUtil; import me.retucio.sputnik.util.MiscUtil; import me.retucio.sputnik.util.render.Textures; -import net.minecraft.client.gl.RenderPipelines; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.client.renderer.RenderPipelines; +import net.minecraft.network.chat.Component; import org.lwjgl.glfw.GLFW; import java.awt.Color; @@ -56,7 +56,7 @@ public class SearchBarWidget extends Widget { } @Override - public void render(DrawContext ctx, int mouseX, int mouseY, float delta) { + public void render(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) { if (!ClientSettingsFrame.guiSettings.searchBar.getValue()) return; Color textFieldColor = isTextFieldHovered(mouseX, mouseY) @@ -66,14 +66,14 @@ public class SearchBarWidget extends Widget { if (focused) textFieldColor = Colors.buttonColor.darker(); // bordes de la barra, para no obstruir la transparencia del campo de texto - ctx.fill(x, renderY, x + 20, renderY + h, Colors.mainColor.getRGB()); - ctx.fill(x, renderY, x + w, renderY + 2, Colors.mainColor.getRGB()); - ctx.fill(x, renderY + h, x + w, renderY + h - 2, Colors.mainColor.getRGB()); - ctx.fill(x + w - 20, renderY, x + w, renderY + h, Colors.mainColor.getRGB()); + gui.fill(x, renderY, x + 20, renderY + h, Colors.mainColor.getRGB()); + gui.fill(x, renderY, x + w, renderY + 2, Colors.mainColor.getRGB()); + gui.fill(x, renderY + h, x + w, renderY + h - 2, Colors.mainColor.getRGB()); + gui.fill(x + w - 20, renderY, x + w, renderY + h, Colors.mainColor.getRGB()); - ctx.fill(x + 20, renderY + 2, x + w - 20, renderY + h - 2, textFieldColor.getRGB()); + gui.fill(x + 20, renderY + 2, x + w - 20, renderY + h - 2, textFieldColor.getRGB()); - ctx.drawTexture(RenderPipelines.GUI_TEXTURED, Textures.SEARCH_BAR_FILTER, + gui.blit(RenderPipelines.GUI_TEXTURED, Textures.SEARCH_BAR_FILTER, x + w - 35, renderY + h / 2 - 6, 0, 0, 12, 12, 12, 12, isFilterButtonHovered(mouseX, mouseY) @@ -83,21 +83,21 @@ public class SearchBarWidget extends Widget { // dibujar líneas en la parte agarrable, para indicárselo al usuario for (int i = 0; i < 4; i++) { - ctx.drawHorizontalLine(x + 4, x + 16, renderY + 3 * i + 5, Color.LIGHT_GRAY.getRGB()); + gui.horizontalLine(x + 4, x + 16, renderY + 3 * i + 5, Color.LIGHT_GRAY.getRGB()); } // texto - Text label = Text.literal(focused ? buffer + "_" : (buffer.isEmpty() ? Formatting.ITALIC + "\uD83D\uDD0D buscar..." : buffer.toString())); - ctx.drawText(mc.textRenderer, label, - x + 24, renderY + h / 2 - mc.textRenderer.fontHeight / 2, + Component label = Component.literal(focused ? buffer + "_" : (buffer.isEmpty() ? ChatFormatting.ITALIC + "\uD83D\uDD0D buscar..." : buffer.toString())); + gui.text(mc.font, label, + x + 24, renderY + h / 2 - mc.font.lineHeight / 2, (buffer.isEmpty() && !focused) ? Color.LIGHT_GRAY.getRGB() : -1, true); // botón para borrar búsqueda actual - ctx.drawText(mc.textRenderer, "×", x + w - mc.textRenderer.getWidth("×") - 6, renderY + (h / 2) - mc.textRenderer.fontHeight / 2, + gui.text(mc.font, "×", x + w - mc.font.width("×") - 6, renderY + (h / 2) - mc.font.lineHeight / 2, isClearButtonHovered(mouseX, mouseY) ? Color.RED.getRGB() : -1, true); if (isFilterButtonHovered(mouseX, mouseY)) { - ctx.drawTooltip(mc.textRenderer, Text.of("filtrar por categoría"), mouseX + 7, mouseY + 20); + gui.setTooltipForNextFrame(mc.font, Component.literal("filtrar por categoría"), mouseX + 7, mouseY + 20); } } @@ -167,7 +167,7 @@ public class SearchBarWidget extends Widget { public void charTyped(char c) { if (!focused) return; buffer.append(c); - if (mc.textRenderer.getWidth(buffer.toString()) > w - 30) onBackspace(); + if (mc.font.width(buffer.toString()) > w - 30) onBackspace(); } public String getSearchInput() { diff --git a/src/main/java/me/retucio/sputnik/util/ChatUtil.java b/src/main/java/me/retucio/sputnik/util/ChatUtil.java index 2b4e32b..0366bac 100644 --- a/src/main/java/me/retucio/sputnik/util/ChatUtil.java +++ b/src/main/java/me/retucio/sputnik/util/ChatUtil.java @@ -5,14 +5,14 @@ import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.command.CommandManager; import me.retucio.sputnik.event.sputnik.LoadModuleManagerEvent; import me.retucio.sputnik.ui.widgets.frames.settings.ClientSettingsFrame; -import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.network.chat.Component; // cosas útiles relacionadas al chat public class ChatUtil { - private static final MinecraftClient mc = MinecraftClient.getInstance(); + private static final Minecraft mc = Minecraft.getInstance(); private static String prefix = getDefaultPrefix(); public static void onLoadModuleManager(LoadModuleManagerEvent event) { @@ -21,7 +21,7 @@ public class ChatUtil { public static void simulateChatMessage(String message) { if (message.startsWith("/")) { - mc.player.networkHandler.sendChatCommand(message.substring(1)); + mc.player.connection.sendCommand(message.substring(1)); } else if (message.startsWith(CommandManager.INSTANCE.getPrefix())) { try { CommandManager.dispatch(message.substring(CommandManager.INSTANCE.getPrefix().length())); @@ -29,59 +29,50 @@ public class ChatUtil { ChatUtil.error(e.getMessage()); } } else { - mc.player.networkHandler.sendChatMessage(message); + mc.player.connection.sendChat(message); } } public static void addMessage(String text) { - addMessage(Text.of(text)); + addMessage(Component.nullToEmpty(text)); } - public static void addMessage(Text text) { - if (mc.inGameHud == null || !Sputnik.settingsApplied) return; - mc.inGameHud.getChatHud().addMessage(text); + public static void addMessage(Component text) { + if (!Sputnik.settingsApplied) return; + mc.gui.getChat().addClientSystemMessage(text); } public static void addMessageWithPrefix(String text) { - addMessageWithPrefix(Text.of(text)); + addMessageWithPrefix(Component.nullToEmpty(text)); } - public static void addMessageWithPrefix(Text text) { - addMessage(Text.literal(getPrefix() + Formatting.RESET).append(text)); + public static void addMessageWithPrefix(Component text) { + addMessage(Component.literal(getPrefix() + ChatFormatting.RESET).append(text)); } public static void info(String text) { - addMessage(Text.literal(getPrefix() + Formatting.RESET + text)); + addMessage(Component.literal(getPrefix() + ChatFormatting.RESET + text)); } - public static void info(Text text) { - addMessage(Text.literal(getPrefix() + Formatting.RESET).append(text)); + public static void info(Component text) { + addMessage(Component.literal(getPrefix() + ChatFormatting.RESET).append(text)); } public static void warn(String text) { - addMessage(Text.literal(getPrefix() + Formatting.YELLOW + text)); + addMessage(Component.literal(getPrefix() + ChatFormatting.YELLOW + text)); } - public static void warn(Text text) { - addMessage(Text.literal(getPrefix() + Formatting.YELLOW).append(text)); + public static void warn(Component text) { + addMessage(Component.literal(getPrefix() + ChatFormatting.YELLOW).append(text)); } public static void error(String text) { - addMessage(Text.literal(getPrefix() + Formatting.RED + text)); + addMessage(Component.literal(getPrefix() + ChatFormatting.RED + text)); } - public static void error(Text text) { - addMessage(Text.literal(getPrefix() + Formatting.RED).append(text)); - } - - public static void sendServerMessage(String text) { - sendServerMessage(Text.of(text)); - } - - public static void sendServerMessage(Text text) { - if (mc.player == null) return; - mc.player.sendMessage(text, false); + public static void error(Component text) { + addMessage(Component.literal(getPrefix() + ChatFormatting.RED).append(text)); } public static String getPrefix() { diff --git a/src/main/java/me/retucio/sputnik/util/Colors.java b/src/main/java/me/retucio/sputnik/util/Colors.java index a695643..20f03ce 100644 --- a/src/main/java/me/retucio/sputnik/util/Colors.java +++ b/src/main/java/me/retucio/sputnik/util/Colors.java @@ -1,6 +1,6 @@ package me.retucio.sputnik.util; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; import java.awt.Color; @@ -111,18 +111,18 @@ public class Colors { return new Color((int) r, (int) g, (int) b, alpha); } - public static Formatting getFormatting(Color color) { + public static ChatFormatting getFormatting(Color color) { return nearest(color); } - public static Formatting nearest(Color input) { - Formatting nearest = null; + public static ChatFormatting nearest(Color input) { + ChatFormatting nearest = null; double minDistance = Double.MAX_VALUE; - for (Formatting formatting : Formatting.values()) { - if (formatting.getColorValue() == null) continue; // saltarse los modificadores + for (ChatFormatting formatting : ChatFormatting.values()) { + if (formatting.getColor() == null) continue; // saltarse los modificadores - Color candidate = new Color(formatting.getColorValue()); + Color candidate = new Color(formatting.getColor()); double dist = colorDistance(input, candidate); if (dist < minDistance) { diff --git a/src/main/java/me/retucio/sputnik/util/EntityUtil.java b/src/main/java/me/retucio/sputnik/util/EntityUtil.java index d777861..f068a55 100644 --- a/src/main/java/me/retucio/sputnik/util/EntityUtil.java +++ b/src/main/java/me/retucio/sputnik/util/EntityUtil.java @@ -1,42 +1,35 @@ package me.retucio.sputnik.util; -import net.minecraft.entity.Entity; -import net.minecraft.entity.projectile.ProjectileUtil; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; -import net.minecraft.util.hit.EntityHitResult; -import net.minecraft.util.hit.HitResult; -import net.minecraft.util.math.Box; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.RaycastContext; +import net.minecraft.util.Mth; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.projectile.ProjectileUtil; +import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; import org.joml.Vector3d; import static me.retucio.sputnik.Sputnik.mc; public class EntityUtil { - public static Vector3d getEntityVector(Vector3d vector, Entity entity, double tickDelta) { - vector.x = MathHelper.lerp(tickDelta, entity.lastRenderX, entity.getX()); - vector.y = MathHelper.lerp(tickDelta, entity.lastRenderY, entity.getY()); - vector.z = MathHelper.lerp(tickDelta, entity.lastRenderZ, entity.getZ()); - return vector; - } - public static Entity getEntityPlayerIsLookingAt() { - if (mc.player == null || mc.world == null) return null; + if (mc.player == null || mc.level == null) return null; - float reachDistance = (float) mc.player.getEntityInteractionRange(); + float reachDistance = (float) mc.player.entityInteractionRange(); - Vec3d cameraPos = mc.player.getCameraPosVec(1.0F); - Vec3d rotation = mc.player.getRotationVec(1.0F); - Vec3d endPos = cameraPos.add(rotation.x * reachDistance, rotation.y * reachDistance, rotation.z * reachDistance); + Vec3 cameraPos = mc.player.getEyePosition(1.0f); + Vec3 rotation = mc.player.getViewVector(1.0f); + Vec3 endPos = cameraPos.add(rotation.x * reachDistance, rotation.y * reachDistance, rotation.z * reachDistance); - EntityHitResult entityHitResult = ProjectileUtil.raycast( + EntityHitResult entityHitResult = ProjectileUtil.getEntityHitResult( mc.player, cameraPos, endPos, - new Box(cameraPos, endPos), - entity -> !entity.isSpectator() && entity.canHit(), + new AABB(cameraPos, endPos), + entity -> !entity.isSpectator() && entity.isPickable(), reachDistance * reachDistance ); @@ -44,11 +37,11 @@ public class EntityUtil { } public static boolean hasLineOfSight(Entity viewer, Entity target) { - HitResult hitResult = viewer.getEntityWorld().raycast(new RaycastContext( - viewer.getEyePos(), - target.getEyePos(), - RaycastContext.ShapeType.COLLIDER, - RaycastContext.FluidHandling.NONE, + HitResult hitResult = viewer.level().clip(new ClipContext( + viewer.getEyePosition(), + target.getEyePosition(), + ClipContext.Block.COLLIDER, + ClipContext.Fluid.NONE, viewer )); @@ -60,31 +53,31 @@ public class EntityUtil { } public static double getYaw(Entity entity) { - return getYaw(entity.getEntityPos()); + return getYaw(entity.position()); } - public static double getYaw(Vec3d pos) { - return mc.player.getYaw() + MathHelper.wrapDegrees( + public static double getYaw(Vec3 pos) { + return mc.player.getYRot() + Mth.wrapDegrees( (float) Math.toDegrees(Math.atan2( - pos.getZ() - mc.player.getZ(), - pos.getX() - mc.player.getX()) - ) - 90f - mc.player.getYaw()); + pos.z() - mc.player.getZ(), + pos.x() - mc.player.getX()) + ) - 90f - mc.player.getYRot()); } - public static double getPitch(Vec3d pos) { - double diffX = pos.getX() - mc.player.getX(); - double diffY = pos.getY() - (mc.player.getY() + mc.player.getEyeHeight(mc.player.getPose())); - double diffZ = pos.getZ() - mc.player.getZ(); + public static double getPitch(Vec3 pos) { + double diffX = pos.x() - mc.player.getX(); + double diffY = pos.y() - (mc.player.getY() + mc.player.getEyeHeight(mc.player.getPose())); + double diffZ = pos.z() - mc.player.getZ(); double diffXZ = Math.sqrt(diffX * diffX + diffZ * diffZ); - return mc.player.getPitch() + MathHelper.wrapDegrees((float) -Math.toDegrees(Math.atan2(diffY, diffXZ)) - mc.player.getPitch()); + return mc.player.getXRot() + Mth.wrapDegrees((float) -Math.toDegrees(Math.atan2(diffY, diffXZ)) - mc.player.getXRot()); } public static double getPitch(Entity entity, Target target) { double y; if (target == Target.HEAD) y = entity.getEyeY(); - else if (target == Target.BODY) y = entity.getY() + entity.getHeight() / 2; + else if (target == Target.BODY) y = entity.getY() + entity.getBbHeight() / 2; else y = entity.getY(); double diffX = entity.getX() - mc.player.getX(); @@ -93,24 +86,24 @@ public class EntityUtil { double diffXZ = Math.sqrt(diffX * diffX + diffZ * diffZ); - return mc.player.getPitch() + MathHelper.wrapDegrees((float) -Math.toDegrees(Math.atan2(diffY, diffXZ)) - mc.player.getPitch()); + return mc.player.getXRot() + Mth.wrapDegrees((float) -Math.toDegrees(Math.atan2(diffY, diffXZ)) - mc.player.getXRot()); } - public static void lookAt(Vec3d pos) { + public static void lookAt(Vec3 pos) { lookAtClient(pos); lookAtServer(pos); } - public static void lookAtClient(Vec3d pos) { - mc.player.setYaw((float) getYaw(pos)); - mc.player.setPitch((float) getPitch(pos)); + public static void lookAtClient(Vec3 pos) { + mc.player.setYRot((float) getYaw(pos)); + mc.player.setXRot((float) getPitch(pos)); } - public static void lookAtServer(Vec3d pos) { - mc.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.LookAndOnGround( + public static void lookAtServer(Vec3 pos) { + mc.getConnection().send(new ServerboundMovePlayerPacket.Rot( (float) getYaw(pos), (float) getPitch(pos), - mc.player.isOnGround(), + mc.player.onGround(), mc.player.horizontalCollision )); } diff --git a/src/main/java/me/retucio/sputnik/util/InventoryUtil.java b/src/main/java/me/retucio/sputnik/util/InventoryUtil.java index 0fe57b2..f861b99 100644 --- a/src/main/java/me/retucio/sputnik/util/InventoryUtil.java +++ b/src/main/java/me/retucio/sputnik/util/InventoryUtil.java @@ -1,32 +1,27 @@ package me.retucio.sputnik.util; import com.github.retucio.neutrino.EventListener; -import com.google.common.eventbus.Subscribe; import me.retucio.sputnik.event.network.DisconnectEvent; import me.retucio.sputnik.event.interact.OpenScreenEvent; -import net.minecraft.client.gui.screen.ingame.GenericContainerScreen; -import net.minecraft.client.gui.screen.ingame.HandledScreen; -import net.minecraft.component.ComponentType; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.Inventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.registry.tag.TagKey; -import net.minecraft.screen.GenericContainerScreenHandler; -import net.minecraft.screen.PlayerScreenHandler; -import net.minecraft.screen.ScreenHandler; -import net.minecraft.screen.slot.Slot; -import net.minecraft.screen.slot.SlotActionType; -import net.minecraft.text.Text; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.client.gui.screens.inventory.ContainerScreen; +import net.minecraft.network.chat.Component; +import net.minecraft.world.Container; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.*; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; import java.util.ArrayList; import java.util.List; import java.util.function.Predicate; -import static me.retucio.sputnik.Sputnik.mc; public class InventoryUtil { + private static final Minecraft mc = Minecraft.getInstance(); + public static final int HOTBAR_START = 0; public static final int HOTBAR_END = 8; public static final int MAIN_INVENTORY_START = 9; @@ -35,12 +30,12 @@ public class InventoryUtil { public static final int ARMOR_END = 39; public static final int OFFHAND_SLOT = 40; - private static Inventory echestInv; + private static Container echestInv; - public static ItemStack find(Predicate predicate) { + public static ItemStack findStack(Predicate predicate) { if (mc.player == null) return null; - for (int i = 0; i < mc.player.getInventory().size(); i++) { - ItemStack stack = mc.player.getInventory().getStack(i); + for (int i = 0; i < mc.player.getInventory().getContainerSize(); i++) { + ItemStack stack = mc.player.getInventory().getItem(i); if (predicate.test(stack)) { return stack; } @@ -50,8 +45,8 @@ public class InventoryUtil { public static int findSlot(Predicate predicate) { if (mc.player == null) return -1; - for (int i = 0; i < mc.player.getInventory().size(); i++) { - ItemStack stack = mc.player.getInventory().getStack(i); + for (int i = 0; i < mc.player.getInventory().getContainerSize(); i++) { + ItemStack stack = mc.player.getInventory().getItem(i); if (predicate.test(stack)) { return i; } @@ -59,11 +54,11 @@ public class InventoryUtil { return -1; } - public static List findAll(Predicate predicate) { + public static List findAllStacks(Predicate predicate) { List stacks = new ArrayList<>(); if (mc.player == null) return stacks; - for (int i = 0; i < mc.player.getInventory().size(); i++) { - ItemStack stack = mc.player.getInventory().getStack(i); + for (int i = 0; i < mc.player.getInventory().getContainerSize(); i++) { + ItemStack stack = mc.player.getInventory().getItem(i); if (predicate.test(stack)) { stacks.add(stack); } @@ -74,8 +69,8 @@ public class InventoryUtil { public static List findAllSlots(Predicate predicate) { List slots = new ArrayList<>(); if (mc.player == null) return slots; - for (int i = 0; i < mc.player.getInventory().size(); i++) { - ItemStack stack = mc.player.getInventory().getStack(i); + for (int i = 0; i < mc.player.getInventory().getContainerSize(); i++) { + ItemStack stack = mc.player.getInventory().getItem(i); if (predicate.test(stack)) { slots.add(i); } @@ -83,126 +78,101 @@ public class InventoryUtil { return slots; } - - public static List find(TagKey tag) { - if (mc.player == null) return null; - List stacks = new ArrayList<>(); - for (ItemStack stack : mc.player.getInventory()) { - for (TagKey tagkey : stack.streamTags().toList()) { - if (tag.equals(tagkey)) { - stacks.add(stack); - } - } - } - return stacks; - } - - public static List find(ComponentType componentType) { - List stacks = new ArrayList<>(); - if (mc.player == null) return stacks; - for (ItemStack stack : mc.player.getInventory()) { - if (stack.getComponents().getTypes().contains(componentType)) { - stacks.add(stack); - } - } - return stacks; - } - - public static void move(int fromSlot, int toSlot) { - if (mc.player == null || mc.interactionManager == null) return; + if (mc.player == null || mc.gameMode == null) return; - int syncId = mc.player.playerScreenHandler.syncId; + int containerId = mc.player.inventoryMenu.containerId; - mc.interactionManager.clickSlot(syncId, fromSlot, 0, SlotActionType.PICKUP, mc.player); - mc.interactionManager.clickSlot(syncId, toSlot, 0, SlotActionType.PICKUP, mc.player); + mc.gameMode.handleContainerInput(containerId, fromSlot, 0, ContainerInput.PICKUP, mc.player); + mc.gameMode.handleContainerInput(containerId, toSlot, 0, ContainerInput.PICKUP, mc.player); - if (!mc.player.playerScreenHandler.getCursorStack().isEmpty()) { - mc.interactionManager.clickSlot(syncId, fromSlot, 0, SlotActionType.PICKUP, mc.player); + if (!mc.player.inventoryMenu.getCarried().isEmpty()) { + mc.gameMode.handleContainerInput(containerId, fromSlot, 0, ContainerInput.PICKUP, mc.player); } } - public static void swapSlots(int containerSlot1, int containerSlot2, HandledScreen screen) { - swapSlots(containerSlot1, containerSlot2, screen.getScreenHandler()); + public static void swapSlots(int containerSlot1, int containerSlot2, AbstractContainerScreen screen) { + swapSlots(containerSlot1, containerSlot2, screen.getMenu()); } - public static void swapSlots(int containerSlot1, int containerSlot2, ScreenHandler handler) { - if (mc.player == null || mc.interactionManager == null) return; + public static void swapSlots(int containerSlot1, int containerSlot2, AbstractContainerMenu handler) { + if (mc.player == null || mc.gameMode == null) return; - int syncId = handler.syncId; + int containerId = handler.containerId; - mc.interactionManager.clickSlot(syncId, containerSlot1, 0, SlotActionType.PICKUP, mc.player); - mc.interactionManager.clickSlot(syncId, containerSlot2, 0, SlotActionType.PICKUP, mc.player); - mc.interactionManager.clickSlot(syncId, containerSlot1, 0, SlotActionType.PICKUP, mc.player); + mc.gameMode.handleContainerInput(containerId, containerSlot1, 0, ContainerInput.PICKUP, mc.player); + mc.gameMode.handleContainerInput(containerId, containerSlot2, 0, ContainerInput.PICKUP, mc.player); + mc.gameMode.handleContainerInput(containerId, containerSlot1, 0, ContainerInput.PICKUP, mc.player); } public static void swapWithHotbar(int containerSlot, int hotbarSlot) { - swapWithHotbar(containerSlot, hotbarSlot, mc.player.playerScreenHandler); + if (mc.player == null) return; + swapWithHotbar(containerSlot, hotbarSlot, mc.player.inventoryMenu); } - public static void swapWithHotbar(int containerSlot, int hotbarSlot, HandledScreen screen) { - swapWithHotbar(containerSlot, hotbarSlot, screen.getScreenHandler()); + public static void swapWithHotbar(int containerSlot, int hotbarSlot, AbstractContainerScreen screen) { + swapWithHotbar(containerSlot, hotbarSlot, screen.getMenu()); } - public static void swapWithHotbar(int containerSlot, int hotbarSlot, ScreenHandler handler) { - if (mc.player == null || mc.interactionManager == null) return; - mc.interactionManager.clickSlot(handler.syncId, containerSlot, hotbarSlot, SlotActionType.SWAP, mc.player); + public static void swapWithHotbar(int containerSlot, int hotbarSlot, AbstractContainerMenu handler) { + if (mc.player == null || mc.gameMode == null) return; + mc.gameMode.handleContainerInput(handler.containerId, containerSlot, hotbarSlot, ContainerInput.SWAP, mc.player); } - public static void quickMove(int containerSlot, HandledScreen screen) { - if (mc.player == null || mc.interactionManager == null) return; + public static void quickMove(int containerSlot, AbstractContainerScreen screen) { + if (mc.player == null || mc.gameMode == null) return; - ScreenHandler handler = screen.getScreenHandler(); - mc.interactionManager.clickSlot(handler.syncId, containerSlot, 0, SlotActionType.QUICK_MOVE, mc.player); + AbstractContainerMenu handler = screen.getMenu(); + mc.gameMode.handleContainerInput(handler.containerId, containerSlot, 0, ContainerInput.QUICK_MOVE, mc.player); } - public static void dropItem(int containerSlot, boolean dropStack, HandledScreen screen) { - if (mc.player == null || mc.interactionManager == null) return; + public static void dropItem(int containerSlot, boolean dropStack, AbstractContainerScreen screen) { + if (mc.player == null || mc.gameMode == null) return; - ScreenHandler handler = screen.getScreenHandler(); + AbstractContainerMenu handler = screen.getMenu(); int button = dropStack ? 1 : 0; - mc.interactionManager.clickSlot(handler.syncId, containerSlot, button, SlotActionType.THROW, mc.player); + mc.gameMode.handleContainerInput(handler.containerId, containerSlot, button, ContainerInput.THROW, mc.player); } - public static int getContainerSlotByPlayerIndex(ScreenHandler handler, int playerStorageIndex) { + public static int getContainerSlotByPlayerIndex(AbstractContainerMenu handler, int playerStorageIndex) { for (Slot slot : handler.slots) - if (slot.inventory instanceof PlayerInventory && slot.getIndex() == playerStorageIndex) - return slot.id; + if (slot.container instanceof Inventory && slot.getContainerSlot() == playerStorageIndex) + return slot.index; return -1; } - public static int getPlayerIndexFromContainerSlot(ScreenHandler handler, int containerSlot) { + public static int getPlayerIndexFromContainerSlot(AbstractContainerMenu handler, int containerSlot) { if (containerSlot < 0 || containerSlot >= handler.slots.size()) return -1; Slot slot = handler.getSlot(containerSlot); - if (slot.inventory instanceof PlayerInventory) - return slot.getIndex(); + if (slot.container instanceof Inventory) + return slot.getContainerSlot(); return -1; } - public static boolean isPlayerInventorySlot(ScreenHandler handler, int containerSlot) { + public static boolean isPlayerInventorySlot(AbstractContainerMenu handler, int containerSlot) { if (containerSlot < 0 || containerSlot >= handler.slots.size()) return false; Slot slot = handler.getSlot(containerSlot); - return slot.inventory instanceof PlayerInventory; + return slot.container instanceof Inventory; } - public static List getPlayerContainerSlots(ScreenHandler handler) { + public static List getPlayerContainerSlots(AbstractContainerMenu handler) { List playerSlots = new ArrayList<>(); for (Slot slot : handler.slots) - if (slot.inventory instanceof PlayerInventory) - playerSlots.add(slot.id); + if (slot.container instanceof Inventory) + playerSlots.add(slot.index); return playerSlots; } - public static List getSlotsInSameColumn(ScreenHandler handler, int playerStorageIndex) { + public static List getSlotsInSameColumn(AbstractContainerMenu handler, int playerStorageIndex) { List slotsInColumn = new ArrayList<>(); int column = playerStorageIndex % 9; for (Slot slot : handler.slots) { - if (slot.inventory instanceof PlayerInventory) { - int index = slot.getIndex(); + if (slot.container instanceof Inventory) { + int index = slot.getContainerSlot(); if (index >= 0 && index <= 35) { if (index % 9 == column) { - slotsInColumn.add(slot.id); + slotsInColumn.add(slot.index); } } } @@ -217,10 +187,10 @@ public class InventoryUtil { return slotsInColumn; } - public static void moveToOffhand(int containerSlot, HandledScreen screen) { - if (mc.player == null || mc.interactionManager == null) return; + public static void moveToOffhand(int containerSlot, AbstractContainerScreen screen) { + if (mc.player == null || mc.gameMode == null) return; - ScreenHandler handler = screen.getScreenHandler(); + AbstractContainerMenu handler = screen.getMenu(); int offhandContainerSlot = getContainerSlotByPlayerIndex(handler, OFFHAND_SLOT); if (offhandContainerSlot == -1) return; @@ -229,40 +199,40 @@ public class InventoryUtil { public static ItemStack getOffhandItem() { if (mc.player == null) return ItemStack.EMPTY; - return mc.player.getOffHandStack(); + return mc.player.getOffhandItem(); } public static boolean hasEmptyHotbarSlot() { if (mc.player == null) return false; - PlayerInventory inv = mc.player.getInventory(); + Inventory inv = mc.player.getInventory(); for (int i = HOTBAR_START; i <= HOTBAR_END; i++) - if (inv.getStack(i).isEmpty()) + if (inv.getItem(i).isEmpty()) return true; return false; } public static int findEmptyHotbarSlot() { if (mc.player == null) return -1; - PlayerInventory inv = mc.player.getInventory(); + Inventory inv = mc.player.getInventory(); for (int i = HOTBAR_START; i <= HOTBAR_END; i++) - if (inv.getStack(i).isEmpty()) + if (inv.getItem(i).isEmpty()) return i; return -1; } - public static List findMatchingItems(HandledScreen screen, ItemStack reference) { - return findMatchingItems(screen.getScreenHandler(), reference); + public static List findMatchingItems(AbstractContainerScreen screen, ItemStack reference) { + return findMatchingItems(screen.getMenu(), reference); } - public static List findMatchingItems(ScreenHandler handler, ItemStack reference) { + public static List findMatchingItems(AbstractContainerMenu handler, ItemStack reference) { List matchingSlots = new ArrayList<>(); if (reference.isEmpty()) return matchingSlots; for (int i = 0; i < handler.slots.size(); i++) { - ItemStack stack = handler.getSlot(i).getStack(); - if (!stack.isEmpty() && ItemStack.areItemsAndComponentsEqual(reference, stack)) { + ItemStack stack = handler.getSlot(i).getItem(); + if (!stack.isEmpty() && ItemStack.isSameItemSameComponents(reference, stack)) { matchingSlots.add(i); } } @@ -270,42 +240,42 @@ public class InventoryUtil { return matchingSlots; } - public static void quickMoveAll(HandledScreen screen, ItemStack reference) { - if (mc.player == null || mc.interactionManager == null) return; + public static void quickMoveAll(AbstractContainerScreen screen, ItemStack reference) { + if (mc.player == null || mc.gameMode == null) return; List matchingSlots = findMatchingItems(screen, reference); - ScreenHandler handler = screen.getScreenHandler(); + AbstractContainerMenu handler = screen.getMenu(); for (int slot : matchingSlots) { - mc.interactionManager.clickSlot(handler.syncId, slot, 0, SlotActionType.QUICK_MOVE, mc.player); + mc.gameMode.handleContainerInput(handler.containerId, slot, 0, ContainerInput.QUICK_MOVE, mc.player); } } - public static boolean isPlayerScreen(HandledScreen screen) { - return screen.getScreenHandler() instanceof PlayerScreenHandler; + public static boolean isPlayerScreen(AbstractContainerScreen screen) { + return screen.getMenu() instanceof InventoryMenu; } - public static int getRowOffset(HandledScreen screen) { + public static int getRowOffset(AbstractContainerScreen screen) { return isPlayerScreen(screen) ? 0 : 9; } - public static int calculateTargetSlot(HandledScreen screen, int currentContainerSlot, + public static int calculateTargetSlot(AbstractContainerScreen screen, int currentContainerSlot, int hotbarColumn, int rowOffset) { - ScreenHandler handler = screen.getScreenHandler(); + AbstractContainerMenu handler = screen.getMenu(); if (!isPlayerScreen(screen)) { int targetRow = rowOffset / 9; for (Slot slot : handler.slots) { - if (slot.inventory instanceof PlayerInventory) { - int playerIndex = slot.getIndex(); + if (slot.container instanceof Inventory) { + int playerIndex = slot.getContainerSlot(); if (playerIndex >= 0 && playerIndex <= 35) { int playerColumn = playerIndex % 9; int playerRow = playerIndex / 9; if (playerColumn == hotbarColumn && playerRow == targetRow) { - return slot.id; + return slot.index; } } } @@ -327,7 +297,7 @@ public class InventoryUtil { public static int getSlotNumberFromKey(int key) { for (int i = 0; i < 9; i++) { - if (KeyUtil.getKey(mc.options.hotbarKeys[i]) == key) { + if (KeyUtil.getKey(mc.options.keyHotbarSlots[i]) == key) { return i; } } @@ -335,9 +305,10 @@ public class InventoryUtil { } public static boolean hasInHotbar(Item item) { - List stacks = findAll(stack -> stack.isOf(item)); + if (mc.player == null) return false; + List stacks = findAllStacks(stack -> stack.is(item)); for (ItemStack stack : stacks) { - int slot = mc.player.getInventory().getSlotWithStack(stack); + int slot = mc.player.getInventory().findSlotMatchingItem(stack); if (slot < HOTBAR_END || slot == OFFHAND_SLOT) { return true; } @@ -349,12 +320,12 @@ public class InventoryUtil { public static void onOpenScreen(OpenScreenEvent event) { if (mc.player == null || event.getScreen() == null - || !(mc.player.currentScreenHandler instanceof GenericContainerScreenHandler handler)) + || !(mc.player.containerMenu instanceof ChestMenu handler)) return; - if (event.getScreen() instanceof GenericContainerScreen screen - && screen.getTitle().equals(Text.translatable("container.enderchest"))) - echestInv = handler.getInventory(); + if (event.getScreen() instanceof ContainerScreen screen + && screen.getTitle().equals(Component.translatable("container.enderchest"))) + echestInv = handler.getContainer(); } @EventListener @@ -362,7 +333,7 @@ public class InventoryUtil { echestInv = null; } - public static Inventory getEchestInv() { + public static Container getEchestInv() { return echestInv; } } diff --git a/src/main/java/me/retucio/sputnik/util/KeyUtil.java b/src/main/java/me/retucio/sputnik/util/KeyUtil.java index 00da155..c9bf232 100644 --- a/src/main/java/me/retucio/sputnik/util/KeyUtil.java +++ b/src/main/java/me/retucio/sputnik/util/KeyUtil.java @@ -1,12 +1,11 @@ package me.retucio.sputnik.util; import me.retucio.sputnik.mixin.accessors.KeyBindingAccessor; -import net.minecraft.client.input.KeyInput; -import net.minecraft.client.option.KeyBinding; +import net.minecraft.client.KeyMapping; +import net.minecraft.client.input.KeyEvent; import org.lwjgl.glfw.GLFW; import java.awt.*; -import java.awt.event.KeyEvent; import java.awt.im.InputContext; import java.util.Locale; @@ -16,16 +15,16 @@ import static me.retucio.sputnik.Sputnik.mc; public class KeyUtil { public static int getKeyAction(int key) { - return GLFW.glfwGetKey(mc.getWindow().getHandle(), key); + return GLFW.glfwGetKey(mc.getWindow().handle(), key); } - public static boolean isKeyDown(KeyBinding key) { + public static boolean isKeyDown(KeyMapping key) { return isKeyDown(getKey(key)); } public static boolean isKeyDown(int key) { return GLFW.glfwGetKey( - mc.getWindow().getHandle(), + mc.getWindow().handle(), key) != GLFW.GLFW_RELEASE; } @@ -34,12 +33,12 @@ public class KeyUtil { || isKeyDown(GLFW.GLFW_KEY_RIGHT_SHIFT); } - public static int getKey(KeyBinding kb) { - return ((KeyBindingAccessor) kb).getBoundKey().getCode(); + public static int getKey(KeyMapping kb) { + return ((KeyBindingAccessor) kb).getKey().getValue(); } public static boolean isCapsLockOn() throws HeadlessException { - return Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); + return Toolkit.getDefaultToolkit().getLockingKeyState(java.awt.event.KeyEvent.VK_CAPS_LOCK); } public static void pressKey(int key, int action) { @@ -47,10 +46,10 @@ public class KeyUtil { } public static void pressKey(int key, int action, int scancode, int modifiers) { - mc.keyboard.onKey( - mc.getWindow().getHandle(), + mc.keyboardHandler.keyPress( + mc.getWindow().handle(), action, - new KeyInput( + new KeyEvent( key, scancode, modifiers diff --git a/src/main/java/me/retucio/sputnik/util/Lists.java b/src/main/java/me/retucio/sputnik/util/Lists.java index 3a0b145..487a344 100644 --- a/src/main/java/me/retucio/sputnik/util/Lists.java +++ b/src/main/java/me/retucio/sputnik/util/Lists.java @@ -1,13 +1,14 @@ package me.retucio.sputnik.util; -import net.minecraft.block.Block; -import net.minecraft.entity.EntityType; -import net.minecraft.item.Item; -import net.minecraft.particle.ParticleType; -import net.minecraft.registry.Registries; -import net.minecraft.screen.ScreenHandlerType; -import net.minecraft.sound.SoundEvent; -import net.minecraft.text.Text; + +import net.minecraft.core.particles.ParticleType; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.network.chat.Component; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; import java.awt.*; import java.util.*; @@ -17,23 +18,23 @@ import static me.retucio.sputnik.util.Colors.*; public class Lists { - public static final List> entityList = Registries.ENTITY_TYPE.stream().toList(); + public static final List> entityList = BuiltInRegistries.ENTITY_TYPE.stream().toList(); public static Map, String> entityNames; - public static final List> particleList = Registries.PARTICLE_TYPE.stream().toList(); + public static final List> particleList = BuiltInRegistries.PARTICLE_TYPE.stream().toList(); public static Map, String> particleNames; - public static final List itemList = Registries.ITEM.stream().toList(); + public static final List itemList = BuiltInRegistries.ITEM.stream().toList(); public static Map itemNames; - public static final List blockList = Registries.BLOCK.stream().toList(); + public static final List blockList = BuiltInRegistries.BLOCK.stream().toList(); public static Map blockNames; - public static final List soundList = Registries.SOUND_EVENT.stream().toList(); + public static final List soundList = BuiltInRegistries.SOUND_EVENT.stream().toList(); public static Map soundNames; - public static final List> screenList = Registries.SCREEN_HANDLER.stream().toList(); - public static Map, String> screenNames; + public static final List> screenList = BuiltInRegistries.MENU.stream().toList(); + public static Map, String> screenNames; public static final List colorList = new ArrayList<>(); public static final List fontList = new ArrayList<>(); @@ -41,31 +42,31 @@ public class Lists { // intentar traducir nombres y fallar miserablemente public static void init() { entityNames = getMapOfLists(entityList, - entityList.stream().map(entity -> Text.translatable(entity.getTranslationKey()).getString()).toList()); + entityList.stream().map(entity -> Component.translatable(entity.getDescriptionId()).getString()).toList()); particleNames = getMapOfLists(particleList, - particleList.stream().map(particle -> Text.translatable( - Registries.PARTICLE_TYPE.getId(particle).toShortTranslationKey()).getString() - ).toList()); + particleList.stream().map(particle -> Component.translatable( + BuiltInRegistries.PARTICLE_TYPE.getKey(particle).toShortLanguageKey() + ).toString()).toList()); itemNames = getMapOfLists(itemList, - itemList.stream().map(item -> Text.translatable( - item.getTranslationKey()).getString() + itemList.stream().map(item -> Component.translatable( + item.getDescriptionId()).getString() ).toList()); blockNames = getMapOfLists(blockList, - blockList.stream().map(block -> Text.translatable( - block.getTranslationKey()).getString() + blockList.stream().map(block -> Component.translatable( + block.getDescriptionId()).getString() ).toList()); soundNames = getMapOfLists(soundList, - soundList.stream().map(sound -> Text.translatable( - sound.id().toShortTranslationKey()).getString() + soundList.stream().map(sound -> Component.translatable( + sound.location().toShortLanguageKey()).getString() ).toList()); screenNames = getMapOfLists(screenList, - screenList.stream().map(screen -> Text.translatable( - Registries.SCREEN_HANDLER.getId(screen).toShortTranslationKey()).getString() + screenList.stream().map(screen -> Component.translatable( + BuiltInRegistries.MENU.getKey(screen).toShortLanguageKey()).getString() ).toList()); colorList.addAll(Arrays.asList( diff --git a/src/main/java/me/retucio/sputnik/util/MiscUtil.java b/src/main/java/me/retucio/sputnik/util/MiscUtil.java index 550519b..3536b76 100644 --- a/src/main/java/me/retucio/sputnik/util/MiscUtil.java +++ b/src/main/java/me/retucio/sputnik/util/MiscUtil.java @@ -4,8 +4,9 @@ import com.github.retucio.neutrino.EventListener; import me.retucio.sputnik.event.TickEvent; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.client.HUD; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.util.math.Vec3d; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.core.Vec3i; +import net.minecraft.world.phys.Vec3; import org.joml.Vector3d; import org.joml.Vector3f; import org.lwjgl.glfw.GLFW; @@ -18,19 +19,20 @@ import java.util.List; import static me.retucio.sputnik.Sputnik.mc; + public class MiscUtil { public static Screen screen; @EventListener public static void onTick(TickEvent.Post event) { - if (screen != null && mc.currentScreen == null) { + if (screen != null && mc.screen == null) { mc.setScreen(screen); screen = null; } } - public static void copyVector(Vector3d destination, Vec3d source) { + public static void copyVector(Vector3d destination, Vec3 source) { destination.x = source.x; destination.y = source.y; destination.z = source.z; @@ -83,8 +85,8 @@ public class MiscUtil { } public static String getPasteContent(int maxLength) { - if (maxLength == -1) return mc.keyboard.getClipboard(); - return mc.keyboard.getClipboard().substring(0, Math.min(maxLength, mc.keyboard.getClipboard().length())); + if (maxLength == -1) return mc.keyboardHandler.getClipboard(); + return mc.keyboardHandler.getClipboard().substring(0, Math.min(maxLength, mc.keyboardHandler.getClipboard().length())); } public static void backspace(StringBuilder buffer) { @@ -102,11 +104,13 @@ public class MiscUtil { } - public static Vec3d vec3dOf(Vector3f v) { - return new Vec3d(v.x, v.y, v.z); + public static Vec3 vec3dOf(Vector3f v) { + return new Vec3(v.x, v.y, v.z); } - public static Vector3f vec3fOf(Vec3d v) { + public static Vector3f vec3fOf(Vec3 v) { return new Vector3f((float) v.x, (float) v.y, (float) v.z); } + + public static Vec3i vec3iOf(Vec3 v) { return new Vec3i((int) v.x, (int) v.y, (int) v.z); } } diff --git a/src/main/java/me/retucio/sputnik/util/NetworkUtil.java b/src/main/java/me/retucio/sputnik/util/NetworkUtil.java index 95019d4..b8f6c8e 100644 --- a/src/main/java/me/retucio/sputnik/util/NetworkUtil.java +++ b/src/main/java/me/retucio/sputnik/util/NetworkUtil.java @@ -1,35 +1,35 @@ package me.retucio.sputnik.util; +import com.github.retucio.neutrino.EventListener; import me.retucio.sputnik.event.network.PacketEvent; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.ShapeContext; -import net.minecraft.client.MinecraftClient; -import net.minecraft.command.argument.EntityAnchorArgumentType; -import net.minecraft.item.BlockItem; -import net.minecraft.item.ItemStack; -import net.minecraft.network.ClientConnection; -import net.minecraft.network.listener.PacketListener; -import net.minecraft.network.packet.Packet; -import net.minecraft.network.packet.c2s.play.HandSwingC2SPacket; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; -import net.minecraft.network.packet.s2c.play.WorldTimeUpdateS2CPacket; -import net.minecraft.util.ActionResult; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; +import net.minecraft.client.Minecraft; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.network.Connection; +import net.minecraft.network.PacketListener; +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.protocol.game.ClientboundSetTimePacket; +import net.minecraft.network.protocol.game.ServerboundSwingPacket; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.phys.shapes.CollisionContext; import java.util.ArrayList; import java.util.List; + public class NetworkUtil { - private static final MinecraftClient mc = MinecraftClient.getInstance(); + private static final Minecraft mc = Minecraft.getInstance(); // tps private static final List tpsHistory = new ArrayList<>(); @@ -52,9 +52,10 @@ public class NetworkUtil { estimatedTPS = sum / tpsHistory.size(); } + @EventListener public void onReceivePacket(PacketEvent.Receive event) { - if (event.getPacket() instanceof WorldTimeUpdateS2CPacket packet) { - long currentWorldTime = packet.time(); + if (event.getPacket() instanceof ClientboundSetTimePacket packet) { + long currentWorldTime = packet.gameTime(); long currentRealTime = System.currentTimeMillis(); if (lastWorldTime != -1L && lastRealTime != -1L) { @@ -63,7 +64,7 @@ public class NetworkUtil { if (elapsedRealTime > 0) { float tps = (float) elapsedWorldTicks / (elapsedRealTime / 1000.0f); - tps = Math.max(0.1f, Math.min(20.0f, tps)); + tps = Math.clamp(tps, 0.1f, 20.0f); updateTPS(tps); } } @@ -75,40 +76,41 @@ public class NetworkUtil { public static void sendPacketNoEvent(Packet packet) { - mc.getNetworkHandler().getConnection().sendImmediately(packet, null, true); + mc.getConnection().getConnection().sendPacket(packet, null, true); } public static void receivePacketNoEvent(Packet packet) { - receivePacketNoEvent(packet, mc.getNetworkHandler().getConnection().getPacketListener()); + receivePacketNoEvent(packet, mc.getConnection().getConnection().getPacketListener()); } public static void receivePacketNoEvent(Packet packet, PacketListener listener) { - ClientConnection.handlePacket(packet, listener); + Connection.genericsFtw(packet, listener); } - public static void interactBlock(BlockHitResult blockHitResult, Hand hand, boolean swing) { - boolean wasSneaking = mc.player.isSneaking(); - mc.player.setSneaking(false); + public static void interactBlock(BlockHitResult blockHitResult, InteractionHand hand, boolean swing) { + boolean wasSneaking = mc.player.isCrouching(); + mc.player.setShiftKeyDown(false); - ActionResult result = mc.interactionManager.interactBlock(mc.player, hand, blockHitResult); + InteractionResult result = mc.gameMode.useItemOn(mc.player, hand, blockHitResult); - if (result.isAccepted()) { - if (swing) mc.player.swingHand(hand); - else mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(hand)); + if (result.consumesAction()) { + if (swing) mc.player.swing(hand); + else mc.getConnection().send(new ServerboundSwingPacket(hand)); } - mc.player.setSneaking(wasSneaking); + mc.player.setShiftKeyDown(wasSneaking); } - public static boolean placeBlock(BlockPos blockPos, Hand hand, int slot, boolean rotate, boolean swingHand, boolean checkEntities, boolean swapBack) { + public static boolean placeBlock(BlockPos blockPos, InteractionHand hand, int slot, boolean rotate, + boolean swingHand, boolean checkEntities, boolean swapBack) { if (slot < 0 || slot > 8) return false; Block toPlace = Blocks.OBSIDIAN; - ItemStack i = hand == Hand.MAIN_HAND ? mc.player.getInventory().getStack(slot) : mc.player.getOffHandStack(); + ItemStack i = hand == InteractionHand.MAIN_HAND ? mc.player.getInventory().getItem(slot) : mc.player.getOffhandItem(); if (i.getItem() instanceof BlockItem blockItem) toPlace = blockItem.getBlock(); if (!canPlaceBlock(blockPos, checkEntities, toPlace)) return false; - Vec3d hitPos = Vec3d.ofCenter(blockPos); + Vec3 hitPos = Vec3.atCenterOf(blockPos); BlockPos neighbour; Direction side = getClosestSide(blockPos); @@ -117,8 +119,8 @@ public class NetworkUtil { side = Direction.UP; neighbour = blockPos; } else { - neighbour = blockPos.offset(side); - hitPos = hitPos.add(side.getOffsetX() * 0.5, side.getOffsetY() * 0.5, side.getOffsetZ() * 0.5); + neighbour = blockPos.relative(side); + hitPos = hitPos.add(side.getStepX() * 0.5, side.getStepY() * 0.5, side.getStepZ() * 0.5); } BlockHitResult bhr = new BlockHitResult(hitPos, side.getOpposite(), neighbour, false); @@ -141,25 +143,25 @@ public class NetworkUtil { public static boolean canPlaceBlock(BlockPos blockPos, boolean checkEntities, Block block) { if (blockPos == null) return false; - if (!World.isValid(blockPos)) return false; - if (!mc.world.getBlockState(blockPos).isReplaceable()) return false; - return !checkEntities || mc.world.canPlace(block.getDefaultState(), blockPos, ShapeContext.absent()); + if (!Level.isInSpawnableBounds(blockPos)) return false; + if (!mc.level.getBlockState(blockPos).canBeReplaced()) return false; + return !checkEntities || mc.level.isUnobstructed(block.defaultBlockState(), blockPos, CollisionContext.empty()); } public static Direction getClosestSide(BlockPos blockPos) { - Vec3d lookVec = blockPos.toCenterPos().subtract(mc.player.getEyePos()); + Vec3 lookVec = blockPos.getCenter().subtract(mc.player.getEyePosition()); double bestRelevancy = -Double.MAX_VALUE; Direction bestSide = null; for (Direction side : Direction.values()) { - BlockPos neighbor = blockPos.offset(side); - BlockState state = mc.world.getBlockState(neighbor); + BlockPos neighbor = blockPos.relative(side); + BlockState state = mc.level.getBlockState(neighbor); if (state.isAir()) continue; if (!state.getFluidState().isEmpty()) continue; - double relevancy = side.getAxis().choose(lookVec.getX(), lookVec.getY(), lookVec.getZ()) * side.getDirection().offset(); + double relevancy = side.getAxis().choose(lookVec.x(), lookVec.y(), lookVec.z()) * side.getAxisDirection().getStep(); if (relevancy > bestRelevancy) { bestRelevancy = relevancy; bestSide = side; diff --git a/src/main/java/me/retucio/sputnik/util/interfaces/IChatComponent.java b/src/main/java/me/retucio/sputnik/util/interfaces/IChatComponent.java new file mode 100644 index 0000000..9ac220d --- /dev/null +++ b/src/main/java/me/retucio/sputnik/util/interfaces/IChatComponent.java @@ -0,0 +1,13 @@ +package me.retucio.sputnik.util.interfaces; + +import net.minecraft.client.multiplayer.chat.GuiMessage; +import net.minecraft.network.chat.Component; +import java.util.List; + + +public interface IChatComponent { + + void sputnik$add(Component message, int id); + + List sputnik$getVisibleMessages(); +} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/util/interfaces/IChatHud.java b/src/main/java/me/retucio/sputnik/util/interfaces/IChatHud.java deleted file mode 100644 index c46f5ae..0000000 --- a/src/main/java/me/retucio/sputnik/util/interfaces/IChatHud.java +++ /dev/null @@ -1,13 +0,0 @@ -package me.retucio.sputnik.util.interfaces; - -import net.minecraft.client.gui.hud.ChatHudLine; -import net.minecraft.text.Text; - -import java.util.List; - -public interface IChatHud { - - void sputnik$add(Text message, int id); - - List sputnik$getVisibleMessages(); -} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/util/interfaces/IMessageHandler.java b/src/main/java/me/retucio/sputnik/util/interfaces/IChatListener.java similarity index 78% rename from src/main/java/me/retucio/sputnik/util/interfaces/IMessageHandler.java rename to src/main/java/me/retucio/sputnik/util/interfaces/IChatListener.java index ed468d1..dda3b44 100644 --- a/src/main/java/me/retucio/sputnik/util/interfaces/IMessageHandler.java +++ b/src/main/java/me/retucio/sputnik/util/interfaces/IChatListener.java @@ -2,7 +2,7 @@ package me.retucio.sputnik.util.interfaces; import com.mojang.authlib.GameProfile; -public interface IMessageHandler { +public interface IChatListener { GameProfile sputnik$getSender(); } diff --git a/src/main/java/me/retucio/sputnik/util/interfaces/IChatHudLine.java b/src/main/java/me/retucio/sputnik/util/interfaces/IGuiMessage.java similarity index 89% rename from src/main/java/me/retucio/sputnik/util/interfaces/IChatHudLine.java rename to src/main/java/me/retucio/sputnik/util/interfaces/IGuiMessage.java index e4be705..49bbee6 100644 --- a/src/main/java/me/retucio/sputnik/util/interfaces/IChatHudLine.java +++ b/src/main/java/me/retucio/sputnik/util/interfaces/IGuiMessage.java @@ -2,7 +2,7 @@ package me.retucio.sputnik.util.interfaces; import com.mojang.authlib.GameProfile; -public interface IChatHudLine { +public interface IGuiMessage { String sputnik$getText(); diff --git a/src/main/java/me/retucio/sputnik/util/interfaces/IChatHudLineVisible.java b/src/main/java/me/retucio/sputnik/util/interfaces/IGuiMessageLine.java similarity index 69% rename from src/main/java/me/retucio/sputnik/util/interfaces/IChatHudLineVisible.java rename to src/main/java/me/retucio/sputnik/util/interfaces/IGuiMessageLine.java index c60cff2..e165f84 100644 --- a/src/main/java/me/retucio/sputnik/util/interfaces/IChatHudLineVisible.java +++ b/src/main/java/me/retucio/sputnik/util/interfaces/IGuiMessageLine.java @@ -1,6 +1,6 @@ package me.retucio.sputnik.util.interfaces; -public interface IChatHudLineVisible extends IChatHudLine { +public interface IGuiMessageLine extends IGuiMessage { boolean sputnik$isStartOfEntry(); void sputnik$setStartOfEntry(boolean start); diff --git a/src/main/java/me/retucio/sputnik/util/interfaces/IVec3d.java b/src/main/java/me/retucio/sputnik/util/interfaces/IVec3.java similarity index 85% rename from src/main/java/me/retucio/sputnik/util/interfaces/IVec3d.java rename to src/main/java/me/retucio/sputnik/util/interfaces/IVec3.java index 10aad54..cc56a0f 100644 --- a/src/main/java/me/retucio/sputnik/util/interfaces/IVec3d.java +++ b/src/main/java/me/retucio/sputnik/util/interfaces/IVec3.java @@ -1,9 +1,10 @@ package me.retucio.sputnik.util.interfaces; -import net.minecraft.util.math.Vec3i; +import net.minecraft.core.Vec3i; import org.joml.Vector3d; -public interface IVec3d { + +public interface IVec3 { void sputnik$set(double x, double y, double z); default void sputnik$set(Vec3i vec) { sputnik$set(vec.getX(), vec.getY(), vec.getZ()); } diff --git a/src/main/java/me/retucio/sputnik/util/interfaces/TextVisitor.java b/src/main/java/me/retucio/sputnik/util/interfaces/TextVisitor.java index a0731b2..bf734a0 100644 --- a/src/main/java/me/retucio/sputnik/util/interfaces/TextVisitor.java +++ b/src/main/java/me/retucio/sputnik/util/interfaces/TextVisitor.java @@ -2,10 +2,9 @@ package me.retucio.sputnik.util.interfaces; -import net.minecraft.text.PlainTextContent; -import net.minecraft.text.StringVisitable; -import net.minecraft.text.Style; -import net.minecraft.text.Text; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.Style; +import net.minecraft.network.chat.contents.PlainTextContents; import java.util.ArrayDeque; import java.util.Optional; @@ -16,22 +15,22 @@ import java.util.Queue; @FunctionalInterface public interface TextVisitor { - Optional accept(Text text, Style style, String string); + Optional accept(Component text, Style style, String string); - static Optional visit(Text text, TextVisitor visitor, Style baseStyle) { - Queue queue = collectSiblings(text); + static Optional visit(Component text, TextVisitor visitor, Style baseStyle) { + Queue queue = collectSiblings(text); return text.visit((style, string) -> visitor.accept(queue.remove(), style, string), baseStyle); } - static ArrayDeque collectSiblings(Text text) { - ArrayDeque queue = new ArrayDeque<>(); + static ArrayDeque collectSiblings(Component text) { + ArrayDeque queue = new ArrayDeque<>(); collectSiblings(text, queue); return queue; } - private static void collectSiblings(Text text, Queue queue) { - if (!(text.getContent() instanceof PlainTextContent ptc) || !ptc.string().isEmpty()) queue.add(text); - for (Text sibling : text.getSiblings()) { + private static void collectSiblings(Component text, Queue queue) { + if (!(text.getContents() instanceof PlainTextContents ptc) || !ptc.text().isEmpty()) queue.add(text); + for (Component sibling : text.getSiblings()) { collectSiblings(sibling, queue); } } diff --git a/src/main/java/me/retucio/sputnik/util/BlockIterator.java b/src/main/java/me/retucio/sputnik/util/misc/BlockIterator.java similarity index 83% rename from src/main/java/me/retucio/sputnik/util/BlockIterator.java rename to src/main/java/me/retucio/sputnik/util/misc/BlockIterator.java index 445cd62..37c5782 100644 --- a/src/main/java/me/retucio/sputnik/util/BlockIterator.java +++ b/src/main/java/me/retucio/sputnik/util/misc/BlockIterator.java @@ -3,37 +3,39 @@ * Copyright (c) Meteor Development. */ -package me.retucio.sputnik.util; +package me.retucio.sputnik.util.misc; import com.github.retucio.neutrino.EventListener; import it.unimi.dsi.fastutil.objects.ReferenceArrayList; -import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.event.TickEvent; -import net.minecraft.block.BlockState; -import net.minecraft.client.MinecraftClient; -import net.minecraft.util.math.BlockPos; +import net.minecraft.client.Minecraft; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.state.BlockState; import java.util.List; import java.util.function.BiConsumer; + +// lo siento meteor // https://github.com/MeteorDevelopment/meteor-client/blob/master/src/main/java/meteordevelopment/meteorclient/utils/world/BlockIterator.java public class BlockIterator { + private static final Minecraft mc = Minecraft.getInstance(); + private static final Pool callbackPool = new Pool<>(Callback::new); private static final List callbacks = new ReferenceArrayList<>(); private static final List afterCallbacks = new ReferenceArrayList<>(); - private static final BlockPos.Mutable blockPos = new BlockPos.Mutable(); + private static final BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos(); private static int hRadius, vRadius; private static boolean disableCurrent; private BlockIterator() {} - @EventListener() + @EventListener private static void onTick(TickEvent.Pre event) { - MinecraftClient mc = MinecraftClient.getInstance(); if (mc.player == null) return; int px = mc.player.getBlockX(); @@ -42,11 +44,11 @@ public class BlockIterator { for (int x = px - hRadius; x <= px + hRadius; x++) { for (int z = pz - hRadius; z <= pz + hRadius; z++) { - for (int y = Math.max(mc.world.getBottomY(), py - vRadius); y <= py + vRadius; y++) { - if (y > mc.world.getHeight()) break; + for (int y = Math.max(mc.level.getMinY(), py - vRadius); y <= py + vRadius; y++) { + if (y > mc.level.getHeight()) break; blockPos.set(x, y, z); - BlockState blockState = mc.world.getBlockState(blockPos); + BlockState blockState = mc.level.getBlockState(blockPos); int dx = Math.abs(x - px); int dy = Math.abs(y - py); diff --git a/src/main/java/me/retucio/sputnik/util/Pool.java b/src/main/java/me/retucio/sputnik/util/misc/Pool.java similarity index 95% rename from src/main/java/me/retucio/sputnik/util/Pool.java rename to src/main/java/me/retucio/sputnik/util/misc/Pool.java index fe3cf83..a62b2f2 100644 --- a/src/main/java/me/retucio/sputnik/util/Pool.java +++ b/src/main/java/me/retucio/sputnik/util/misc/Pool.java @@ -1,4 +1,4 @@ -package me.retucio.sputnik.util; +package me.retucio.sputnik.util.misc; import java.util.ArrayDeque; import java.util.Collection; diff --git a/src/main/java/me/retucio/sputnik/util/misc/ProjectileInfo.java b/src/main/java/me/retucio/sputnik/util/misc/ProjectileInfo.java index e48d420..c10adfe 100644 --- a/src/main/java/me/retucio/sputnik/util/misc/ProjectileInfo.java +++ b/src/main/java/me/retucio/sputnik/util/misc/ProjectileInfo.java @@ -1,24 +1,24 @@ package me.retucio.sputnik.util.misc; -import net.minecraft.client.MinecraftClient; -import net.minecraft.component.DataComponentTypes; -import net.minecraft.component.type.ChargedProjectilesComponent; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.item.*; -import net.minecraft.registry.Registry; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; +import net.minecraft.client.Minecraft; +import net.minecraft.core.Holder; +import net.minecraft.core.Registry; +import net.minecraft.core.component.DataComponents; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.util.Mth; +import net.minecraft.world.item.*; +import net.minecraft.world.item.component.ChargedProjectiles; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.phys.Vec3; import java.util.ArrayList; import java.util.List; public record ProjectileInfo ( - double gravity, double drag, Vec3d initialVelocity, Vec3d offset, Vec3d position, + double gravity, double drag, Vec3 initialVelocity, Vec3 offset, Vec3 position, double waterDrag, double underwaterGravity, List order ) { @@ -26,16 +26,16 @@ public record ProjectileInfo ( private static final List ORDER_GMD = List.of(2, 0, 1); // gravity-move-drag private static final List ORDER_GDM = List.of(2, 1, 0); // gravity-drag-move - private static final MinecraftClient mc = MinecraftClient.getInstance(); + private static final Minecraft mc = Minecraft.getInstance(); - public ProjectileInfo(double gravity, double drag, Vec3d initialVelocity, Vec3d offset, - Vec3d position, double waterDrag, List order) { + public ProjectileInfo(double gravity, double drag, Vec3 initialVelocity, Vec3 offset, + Vec3 position, double waterDrag, List order) { this(gravity, drag, initialVelocity, offset, position, waterDrag, gravity, order); } public static List getItemsInfo(ItemStack itemStack) { - float tickProgress = mc.getRenderTickCounter().getTickProgress(false); - Vec3d position = mc.player.getCameraPosVec(tickProgress).add(0, -0.1, 0); + float tickProgress = mc.getDeltaTracker().getGameTimeDeltaPartialTick(false); + Vec3 position = mc.player.getEyePosition(tickProgress).add(0, -0.1, 0); Item item = itemStack.getItem(); if (item instanceof BowItem) { @@ -44,7 +44,7 @@ public record ProjectileInfo ( return getCrossbowProjectileInfo(tickProgress, itemStack, position); } else if (item instanceof TridentItem) { return getTridentProjectileInfo(tickProgress, itemStack, position); - } else if (item instanceof SnowballItem || item instanceof EggItem || item instanceof EnderPearlItem) { + } else if (item instanceof SnowballItem || item instanceof EggItem || item instanceof EnderpearlItem) { return getThrowableProjectileInfo(tickProgress, position); } else if (item instanceof WindChargeItem) { return getWindChargeProjectileInfo(tickProgress, position); @@ -52,40 +52,40 @@ public record ProjectileInfo ( return getPotionProjectileInfo(position); } else if (item instanceof ExperienceBottleItem) { return getExperienceBottleProjectileInfo(position); - } else if (item instanceof FishingRodItem && mc.player.fishHook == null) { + } else if (item instanceof FishingRodItem && mc.player.fishing == null) { return getFishingRodProjectileInfo(tickProgress); } return new ArrayList<>(); } - private static List getBowProjectileInfo(float tickProgress, Vec3d position) { + private static List getBowProjectileInfo(float tickProgress, Vec3 position) { List list = new ArrayList<>(); - int useTicks = mc.player.getItemUseTime(); - float pull = BowItem.getPullProgress(useTicks); + int useTicks = mc.player.getTicksUsingItem(); + float pull = BowItem.getPowerForTime(useTicks); if (pull >= 0.1) { - Vec3d velocity = mc.player.getRotationVec(tickProgress).multiply(3 * pull); - Vec3d offset = new Vec3d(0.2, -0.06, 0.2); + Vec3 velocity = mc.player.getViewVector(tickProgress).scale(3 * pull); + Vec3 offset = new Vec3(0.2, -0.06, 0.2); list.add(new ProjectileInfo(0.05, 0.99, velocity, offset, position, 0.6, ORDER_MDG)); } return list; } - private static List getCrossbowProjectileInfo(float tickProgress, ItemStack itemStack, Vec3d position) { + private static List getCrossbowProjectileInfo(float tickProgress, ItemStack itemStack, Vec3 position) { List list = new ArrayList<>(); double gravity = 0.05; double drag = 0.99; double waterDrag = 0.6; - Vec3d velocity = mc.player.getRotationVec(tickProgress).multiply(3.15); - Vec3d offset = new Vec3d(0, -0.06, 0.03); + Vec3 velocity = mc.player.getViewVector(tickProgress).scale(3.15); + Vec3 offset = new Vec3(0, -0.06, 0.03); - ChargedProjectilesComponent projectiles = itemStack.get(DataComponentTypes.CHARGED_PROJECTILES); + ChargedProjectiles projectiles = itemStack.get(DataComponents.CHARGED_PROJECTILES); if (projectiles != null) { - for (ItemStack projectile : projectiles.getProjectiles()) { - if (projectile.isOf(Items.FIREWORK_ROCKET)) { - velocity = mc.player.getRotationVec(tickProgress).multiply(1.6f); + for (ItemStackTemplate projectile : projectiles.items()) { + if (projectile.is(Items.FIREWORK_ROCKET)) { + velocity = mc.player.getViewVector(tickProgress).scale(1.6f); gravity = 0; waterDrag = drag; } @@ -97,8 +97,8 @@ public record ProjectileInfo ( if (hasEnchantment(itemStack, Enchantments.MULTISHOT)) { float angle = 10f; - Vec3d vel1 = velocity.rotateY((float) Math.toRadians(angle)); - Vec3d vel2 = velocity.rotateY((float) Math.toRadians(-angle)); + Vec3 vel1 = velocity.yRot((float) Math.toRadians(angle)); + Vec3 vel2 = velocity.yRot((float) Math.toRadians(-angle)); list.add(new ProjectileInfo(gravity, drag, vel1, offset, position, waterDrag, ORDER_MDG)); list.add(new ProjectileInfo(gravity, drag, vel2, offset, position, waterDrag, ORDER_MDG)); } @@ -106,87 +106,88 @@ public record ProjectileInfo ( return list; } - private static List getTridentProjectileInfo(float tickProgress, ItemStack itemStack, Vec3d position) { + private static List getTridentProjectileInfo(float tickProgress, ItemStack itemStack, Vec3 position) { List list = new ArrayList<>(); - int useTicks = mc.player.getItemUseTime(); + int useTicks = mc.player.getTicksUsingItem(); - if (useTicks >= TridentItem.MIN_DRAW_DURATION && !hasEnchantment(itemStack, Enchantments.RIPTIDE)) { - Vec3d velocity = mc.player.getRotationVec(tickProgress).multiply(TridentItem.THROW_SPEED); - Vec3d offset = new Vec3d(0.2, 0.1, 0.2); + if (useTicks >= TridentItem.THROW_THRESHOLD_TIME && !hasEnchantment(itemStack, Enchantments.RIPTIDE)) { + Vec3 velocity = mc.player.getViewVector(tickProgress).scale(TridentItem.PROJECTILE_SHOOT_POWER); + Vec3 offset = new Vec3(0.2, 0.1, 0.2); list.add(new ProjectileInfo(0.05, 0.99, velocity, offset, position, 0.99, ORDER_MDG)); } return list; } - private static List getThrowableProjectileInfo(float tickProgress, Vec3d position) { - Vec3d velocity = mc.player.getRotationVec(tickProgress).multiply(SnowballItem.POWER); - Vec3d offset = new Vec3d(0.2, -0.06, 0.2); + private static List getThrowableProjectileInfo(float tickProgress, Vec3 position) { + Vec3 velocity = mc.player.getViewVector(tickProgress).scale(SnowballItem.PROJECTILE_SHOOT_POWER); + Vec3 offset = new Vec3(0.2, -0.06, 0.2); return List.of(new ProjectileInfo(0.03, 0.99, velocity, offset, position, 0.8, ORDER_GDM)); } - private static List getWindChargeProjectileInfo(float tickProgress, Vec3d position) { - Vec3d velocity = mc.player.getRotationVec(tickProgress).multiply(1.5f); - Vec3d offset = new Vec3d(0.2, -0.06, 0.2); + private static List getWindChargeProjectileInfo(float tickProgress, Vec3 position) { + Vec3 velocity = mc.player.getViewVector(tickProgress).scale(1.5f); + Vec3 offset = new Vec3(0.2, -0.06, 0.2); return List.of(new ProjectileInfo(0, 1, velocity, offset, position, 1, ORDER_MDG)); } - private static List getPotionProjectileInfo(Vec3d position) { - Vec3d direction = angleFromRotation(mc.player.getYaw(), mc.player.getPitch()); - Vec3d velocity = direction.multiply(ThrowablePotionItem.POWER); - Vec3d offset = new Vec3d(0.2, -0.06, 0.2); + private static List getPotionProjectileInfo(Vec3 position) { + Vec3 direction = angleFromRotation(mc.player.getYRot(), mc.player.getXRot()); + Vec3 velocity = direction.scale(ThrowablePotionItem.PROJECTILE_SHOOT_POWER); + Vec3 offset = new Vec3(0.2, -0.06, 0.2); return List.of(new ProjectileInfo(0.05, 0.99, velocity, offset, position, 0.8, ORDER_GDM)); } - private static List getExperienceBottleProjectileInfo(Vec3d position) { - Vec3d direction = angleFromRotation(mc.player.getYaw(), mc.player.getPitch()).normalize(); - Vec3d velocity = direction.multiply(0.7); - Vec3d offset = new Vec3d(0.2, -0.06, 0.2); + private static List getExperienceBottleProjectileInfo(Vec3 position) { + Vec3 direction = angleFromRotation(mc.player.getYRot(), mc.player.getXRot()).normalize(); + Vec3 velocity = direction.scale(0.7); + Vec3 offset = new Vec3(0.2, -0.06, 0.2); return List.of(new ProjectileInfo(0.07, 0.99, velocity, offset, position, 0.8, ORDER_GDM)); } private static List getFishingRodProjectileInfo(float tickProgress) { - Vec3d cameraPos = mc.player.getCameraPosVec(tickProgress); + Vec3 cameraPos = mc.player.getEyePosition(tickProgress); - float yawRad = (float) Math.toRadians(mc.player.getYaw()); - float pitchRad = (float) Math.toRadians(mc.player.getPitch()); + float yawRad = (float) Math.toRadians(mc.player.getYRot()); + float pitchRad = (float) Math.toRadians(mc.player.getXRot()); - Vec3d position = new Vec3d( - cameraPos.x - MathHelper.sin(-yawRad) * 0.3, + Vec3 position = new Vec3( + cameraPos.x - Mth.sin(-yawRad) * 0.3, cameraPos.y, - cameraPos.z - MathHelper.cos(-yawRad) * 0.3 + cameraPos.z - Mth.cos(-yawRad) * 0.3 ); - float h = MathHelper.cos(-yawRad - MathHelper.PI); - float i = MathHelper.sin(-yawRad - MathHelper.PI); - float j = -MathHelper.cos(-pitchRad); - float k = MathHelper.sin(-pitchRad); + float h = Mth.cos(-yawRad - Mth.PI); + float i = Mth.sin(-yawRad - Mth.PI); + float j = -Mth.cos(-pitchRad); + float k = Mth.sin(-pitchRad); - Vec3d velocity = new Vec3d(-i, MathHelper.clamp(-(k / j), -5f, 5f), -h); + Vec3 velocity = new Vec3(-i, Mth.clamp(-(k / j), -5f, 5f), -h); double length = velocity.length(); - velocity = velocity.multiply(0.6 / length + 0.5); - Vec3d offset = new Vec3d(0.16, -0.06, 0.2); + velocity = velocity.scale(0.6 / length + 0.5); + Vec3 offset = new Vec3(0.16, -0.06, 0.2); return List.of(new ProjectileInfo(0.03, 0.92, velocity, offset, position, 0.92, ORDER_GMD)); } - public static boolean hasEnchantment(ItemStack stack, RegistryKey enchantment) { - Registry registry = mc.player.getEntityWorld().getRegistryManager().getOrThrow(RegistryKeys.ENCHANTMENT); - RegistryEntry entry = registry.getOrThrow(enchantment); - return EnchantmentHelper.getLevel(entry, stack) > 0; + public static boolean hasEnchantment(ItemStack stack, ResourceKey enchantment) { + Registry registry = mc.player.level().registryAccess().lookupOrThrow(Registries.ENCHANTMENT); + Holder entry = registry.getOrThrow(enchantment); + return EnchantmentHelper.getItemEnchantmentLevel(entry, stack) > 0; } - private static Vec3d angleFromRotation(float yaw, float pitch) { + + private static Vec3 angleFromRotation(float yaw, float pitch) { float yawRad = (float) Math.toRadians(yaw); float pitchRad = (float) Math.toRadians(pitch); - float x = -MathHelper.sin(yawRad) * MathHelper.cos(pitchRad); - float y = -MathHelper.sin(Math.toRadians(pitch - 20)); - float z = MathHelper.cos(yawRad) * MathHelper.cos(pitchRad); + float x = -Mth.sin(yawRad) * Mth.cos(pitchRad); + float y = -Mth.sin(Math.toRadians(pitch - 20)); + float z = Mth.cos(yawRad) * Mth.cos(pitchRad); - return new Vec3d(x, y, z).normalize(); + return new Vec3(x, y, z).normalize(); } } \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/util/VersionChecker.java b/src/main/java/me/retucio/sputnik/util/misc/VersionChecker.java similarity index 99% rename from src/main/java/me/retucio/sputnik/util/VersionChecker.java rename to src/main/java/me/retucio/sputnik/util/misc/VersionChecker.java index cf16864..ee513fb 100644 --- a/src/main/java/me/retucio/sputnik/util/VersionChecker.java +++ b/src/main/java/me/retucio/sputnik/util/misc/VersionChecker.java @@ -1,4 +1,4 @@ -package me.retucio.sputnik.util; +package me.retucio.sputnik.util.misc; import me.retucio.sputnik.Sputnik; import net.fabricmc.loader.api.FabricLoader; diff --git a/src/main/java/me/retucio/sputnik/util/render/DrawUtil.java b/src/main/java/me/retucio/sputnik/util/render/DrawUtil.java index 3d76411..997cc7c 100644 --- a/src/main/java/me/retucio/sputnik/util/render/DrawUtil.java +++ b/src/main/java/me/retucio/sputnik/util/render/DrawUtil.java @@ -1,31 +1,32 @@ package me.retucio.sputnik.util.render; -import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.GuiGraphicsExtractor; + public class DrawUtil { - public static void drawBorder(DrawContext ctx, int x, int y, int width, int height, int color) { - ctx.fill(x, y, x + width, y + 1, color); - ctx.fill(x, y + height - 1, x + width, y + height, color); - ctx.fill(x, y, x + 1, y + height, color); - ctx.fill(x + width - 1, y, x + width, y + height, color); + public static void drawBorder(GuiGraphicsExtractor gui, int x, int y, int width, int height, int color) { + gui.fill(x, y, x + width, y + 1, color); + gui.fill(x, y + height - 1, x + width, y + height, color); + gui.fill(x, y, x + 1, y + height, color); + gui.fill(x + width - 1, y, x + width, y + height, color); } - public static void drawCircle(DrawContext ctx, int x, int y, int radius, int color) { + public static void drawCircle(GuiGraphicsExtractor gui, int x, int y, int radius, int color) { for (int i = -radius; i <= radius; i++) for (int j = -radius; j <= radius; j++) if (i * i + j * j <= radius * radius) - ctx.fill(x + i, y + j, x + i + 1, y + j + 1, color); + gui.fill(x + i, y + j, x + i + 1, y + j + 1, color); } - public static void drawCheckerBoard(DrawContext ctx, int x, int y, int width, int height, int checkerSize, int color1, int color2) { + public static void drawCheckerBoard(GuiGraphicsExtractor gui, int x, int y, int width, int height, int checkerSize, int color1, int color2) { for (int ax = 0; ax < width - 4; ax += checkerSize * 2) { for (int ay = 0; ay < height; ay += checkerSize * 2) { - ctx.fill(x + ax, y + ay, + gui.fill(x + ax, y + ay, x + ax + checkerSize, y + ay + checkerSize, color1); if (ax + checkerSize < width - 4 && ay + checkerSize < height) { - ctx.fill(x + ax + checkerSize, y + ay + checkerSize, + gui.fill(x + ax + checkerSize, y + ay + checkerSize, x + ax + checkerSize * 2, y + ay + checkerSize * 2, color1); } } @@ -33,14 +34,14 @@ public class DrawUtil { for (int ax = checkerSize; ax < width - 4; ax += checkerSize * 2) { for (int ay = 0; ay < height; ay += checkerSize * 2) { - ctx.fill(x + ax, y + ay, + gui.fill(x + ax, y + ay, x + ax + checkerSize, y + ay + checkerSize, color2); } } for (int ax = 0; ax < width - 4; ax += checkerSize * 2) { for (int ay = checkerSize; ay < height; ay += checkerSize * 2) { - ctx.fill(x + ax, y + ay, + gui.fill(x + ax, y + ay, x + ax + checkerSize, y + ay + checkerSize, color2); } } diff --git a/src/main/java/me/retucio/sputnik/util/render/GlintRenderLayer.java b/src/main/java/me/retucio/sputnik/util/render/GlintRenderLayer.java deleted file mode 100644 index 96cdf70..0000000 --- a/src/main/java/me/retucio/sputnik/util/render/GlintRenderLayer.java +++ /dev/null @@ -1,107 +0,0 @@ -package me.retucio.sputnik.util.render; - -import com.mojang.blaze3d.pipeline.RenderPipeline; -import com.mojang.blaze3d.vertex.VertexFormat; -import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; -import me.retucio.sputnik.Sputnik; -import me.retucio.sputnik.module.modules.render.GlintPlus; -import net.minecraft.client.gl.RenderPipelines; -import net.minecraft.client.render.*; -import net.minecraft.client.util.BufferAllocator; -import net.minecraft.util.DyeColor; -import net.minecraft.util.Identifier; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.Function; - -/** clase modificada de RenderLayer para modificar el color del destello de encantamientos - * @see GlintPlus - * yoinkeado de: https://github.com/Pepperoni-Jabroni/NoMorePurple/blob/main/src/main/java/pepjebs/no_more_purple/client/GlintRenderLayer.java - * (y actualizado) - */ - -public class GlintRenderLayer extends RenderLayer { - - public static List glintColor = newRenderList(GlintRenderLayer::buildGlintRenderLayer); - public static List entityGlintColor = newRenderList(GlintRenderLayer::buildEntityGlintRenderLayer); - public static List armorEntityGlintColor = newRenderList(GlintRenderLayer::buildArmorEntityGlintRenderLayer); - - public static void addGlintTypes(Object2ObjectLinkedOpenHashMap map) { - addGlintTypes(map, glintColor); - addGlintTypes(map, entityGlintColor); - addGlintTypes(map, armorEntityGlintColor); - } - - public GlintRenderLayer(String name) { - super(name, RenderSetup.builder(RenderPipelines.GLINT).build()); - } - - private static List newRenderList(Function func) { - ArrayList list = new ArrayList<>(DyeColor.values().length); - - for (DyeColor color : DyeColor.values()) - list.add(func.apply(color.name())); - - list.add(func.apply("rainbow")); - list.add(func.apply("none")); - - return list; - } - - public static void addGlintTypes(Object2ObjectLinkedOpenHashMap map, List typeList) { - for(RenderLayer renderType : typeList) - if (!map.containsKey(renderType)) - map.put(renderType, new BufferAllocator(renderType.getExpectedBufferSize())); - } - - private static RenderLayer buildGlintRenderLayer(String name) { - final Identifier res = Identifier.of(Sputnik.MOD_ID, "textures/misc/glint_" + name.toLowerCase() + ".png"); - - return RenderLayer.of("glint_" + name, RenderSetup.builder(RenderPipelines.GLINT) - .texture("Sampler0", res) - .textureTransform(TextureTransform.GLINT_TEXTURING) - .translucent() - .build()); - - } - - private static RenderLayer buildEntityGlintRenderLayer(String name) { - final Identifier res = Identifier.of(Sputnik.MOD_ID, "textures/misc/glint_" + name.toLowerCase() + ".png"); - - return RenderLayer.of("entity_glint_" + name, RenderSetup.builder(RenderPipelines.GLINT) - .texture("Sampler0", res) - .textureTransform(TextureTransform.ENTITY_GLINT_TEXTURING) - .outputTarget(OutputTarget.ITEM_ENTITY_TARGET) - .translucent() - .build()); - } - - - private static RenderLayer buildArmorEntityGlintRenderLayer(String name) { - final Identifier res = Identifier.of(Sputnik.MOD_ID, "textures/misc/glint_" + name.toLowerCase() + ".png"); - - return RenderLayer.of("armor_glint_" + name, RenderSetup.builder(RenderPipelines.GLINT) - .texture("Sampler0", res) - .textureTransform(TextureTransform.ARMOR_ENTITY_GLINT_TEXTURING) - .layeringTransform(LayeringTransform.VIEW_OFFSET_Z_LAYERING) - .translucent() - .build()); - } - - @Override - public void draw(BuiltBuffer buffer) {} - - @Override - public VertexFormat getVertexFormat() { return VertexFormat.builder().build(); } - - @Override - public VertexFormat.DrawMode getDrawMode() { - return null; - } - - @Override - public RenderPipeline getRenderPipeline() { - return null; - } -} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/util/render/GlintRenderType.java b/src/main/java/me/retucio/sputnik/util/render/GlintRenderType.java new file mode 100644 index 0000000..f499d7d --- /dev/null +++ b/src/main/java/me/retucio/sputnik/util/render/GlintRenderType.java @@ -0,0 +1,100 @@ +package me.retucio.sputnik.util.render; + +import com.mojang.blaze3d.pipeline.RenderPipeline; +import com.mojang.blaze3d.vertex.ByteBufferBuilder; +import com.mojang.blaze3d.vertex.MeshData; +import com.mojang.blaze3d.vertex.VertexFormat; +import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; +import me.retucio.sputnik.Sputnik; +import me.retucio.sputnik.module.modules.render.GlintPlus; +import net.minecraft.client.renderer.RenderPipelines; +import net.minecraft.client.renderer.rendertype.*; +import net.minecraft.resources.Identifier; +import net.minecraft.world.item.DyeColor; +import org.jspecify.annotations.NonNull; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Function; + + +/** clase modificada de RenderType para modificar el color del destello de encantamientos + * @see GlintPlus + * yoinkeado de: https://github.com/Pepperoni-Jabroni/NoMorePurple/blob/main/src/main/java/pepjebs/no_more_purple/client/GlintRenderLayer.java + * (y actualizado) + */ + +public class GlintRenderType extends RenderType { + + public static List glintColor = newRenderList(GlintRenderType::buildGlintRenderLayer); + public static List entityGlintColor = newRenderList(GlintRenderType::buildEntityGlintRenderLayer); + public static List armorEntityGlintColor = newRenderList(GlintRenderType::buildArmorEntityGlintRenderLayer); + + public static void addGlintTypes(Object2ObjectLinkedOpenHashMap map) { + addGlintTypes(map, glintColor); + addGlintTypes(map, entityGlintColor); + addGlintTypes(map, armorEntityGlintColor); + } + + public GlintRenderType(String name) { + super(name, RenderSetup.builder(RenderPipelines.GLINT).createRenderSetup()); + } + + private static List newRenderList(Function func) { + ArrayList list = new ArrayList<>(DyeColor.values().length); + + for (DyeColor color : DyeColor.values()) + list.add(func.apply(color.name())); + + list.add(func.apply("rainbow")); + list.add(func.apply("none")); + + return list; + } + + public static void addGlintTypes(Object2ObjectLinkedOpenHashMap map, List typeList) { + for(RenderType renderType : typeList) + if (!map.containsKey(renderType)) + map.put(renderType, new ByteBufferBuilder(renderType.bufferSize())); + } + + private static RenderType buildGlintRenderLayer(String name) { + final Identifier res = Identifier.fromNamespaceAndPath(Sputnik.MOD_ID, "textures/misc/glint_" + name.toLowerCase() + ".png"); + + return RenderType.create("glint_" + name, RenderSetup.builder(RenderPipelines.GLINT) + .withTexture("Sampler0", res) + .setTextureTransform(TextureTransform.GLINT_TEXTURING) + .sortOnUpload() + .createRenderSetup()); + + } + + private static RenderType buildEntityGlintRenderLayer(String name) { + final Identifier res = Identifier.fromNamespaceAndPath(Sputnik.MOD_ID, "textures/misc/glint_" + name.toLowerCase() + ".png"); + + return RenderType.create("entity_glint_" + name, RenderSetup.builder(RenderPipelines.GLINT) + .withTexture("Sampler0", res) + .setTextureTransform(TextureTransform.ENTITY_GLINT_TEXTURING) + .setOutputTarget(OutputTarget.ITEM_ENTITY_TARGET) + .sortOnUpload() + .createRenderSetup()); + } + + + private static RenderType buildArmorEntityGlintRenderLayer(String name) { + final Identifier res = Identifier.fromNamespaceAndPath(Sputnik.MOD_ID, "textures/misc/glint_" + name.toLowerCase() + ".png"); + + return RenderType.create("armor_glint_" + name, RenderSetup.builder(RenderPipelines.GLINT) + .withTexture("Sampler0", res) + .setTextureTransform(TextureTransform.ARMOR_ENTITY_GLINT_TEXTURING) + .setLayeringTransform(LayeringTransform.VIEW_OFFSET_Z_LAYERING) + .sortOnUpload() + .createRenderSetup()); + } + + @Override + public void draw(@NonNull MeshData buffer) {} + + @Override + public @NonNull VertexFormat format() { return VertexFormat.builder().build(); } +} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/util/render/Layers.java b/src/main/java/me/retucio/sputnik/util/render/Layers.java deleted file mode 100644 index a7a3079..0000000 --- a/src/main/java/me/retucio/sputnik/util/render/Layers.java +++ /dev/null @@ -1,50 +0,0 @@ -package me.retucio.sputnik.util.render; - -import me.retucio.sputnik.Sputnik; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.RenderSetup; - -import static me.retucio.sputnik.util.render.Pipelines.*; - -public class Layers { - - private static final RenderLayer LINES; - private static final RenderLayer LINES_CULL; - - private static final RenderLayer QUADS; - private static final RenderLayer QUADS_CULL; - - private static final RenderLayer TEXT; - - - public static RenderLayer lines() { - return LINES; - } - - public static RenderLayer linesCull() { - return LINES_CULL; - } - - public static RenderLayer quads() { - return QUADS; - } - - public static RenderLayer quadsCull() { - return QUADS_CULL; - } - - public static RenderLayer text() { - return TEXT; - } - - static { - LINES = RenderLayer.of(Sputnik.MOD_ID + "_lines", RenderSetup.builder(LINES_PIPELINE).build()); - LINES_CULL = RenderLayer.of(Sputnik.MOD_ID + "_lines_cull", RenderSetup.builder(LINES_CULL_PIPELINE).build()); - - QUADS = RenderLayer.of(Sputnik.MOD_ID + "_quads", RenderSetup.builder(QUADS_PIPELINE).build()); - QUADS_CULL = RenderLayer.of(Sputnik.MOD_ID + "_quads_cull", RenderSetup.builder(QUADS_CULL_PIPELINE).build()); - - TEXT = RenderLayer.of(Sputnik.MOD_ID + "_text", RenderSetup.builder(TEXT_PIPELINE).build()); - } - -} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/util/render/Pipelines.java b/src/main/java/me/retucio/sputnik/util/render/Pipelines.java index cbf23cc..869a1ba 100644 --- a/src/main/java/me/retucio/sputnik/util/render/Pipelines.java +++ b/src/main/java/me/retucio/sputnik/util/render/Pipelines.java @@ -1,20 +1,18 @@ package me.retucio.sputnik.util.render; -import com.mojang.blaze3d.pipeline.BlendFunction; import com.mojang.blaze3d.pipeline.RenderPipeline; -import com.mojang.blaze3d.platform.DepthTestFunction; import com.mojang.blaze3d.systems.GpuDevice; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.VertexFormat; import me.retucio.sputnik.Sputnik; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gl.RenderPipelines; -import net.minecraft.client.render.VertexFormats; -import net.minecraft.resource.Resource; -import net.minecraft.resource.ResourceManager; -import net.minecraft.util.Identifier; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderPipelines; +import net.minecraft.resources.Identifier; +import net.minecraft.server.packs.resources.Resource; +import net.minecraft.server.packs.resources.ResourceManager; import org.apache.commons.io.IOUtils; import java.io.IOException; @@ -28,49 +26,49 @@ public class Pipelines { static List PIPELINES = new ArrayList<>(); - static final RenderPipeline LINES_PIPELINE = add(RenderPipeline.builder(RenderPipelines.RENDERTYPE_LINES_SNIPPET) - .withLocation(Identifier.of(Sputnik.MOD_ID, "pipeline/lines")) - .withVertexFormat(VertexFormats.POSITION_COLOR_NORMAL_LINE_WIDTH, VertexFormat.DrawMode.LINES) - .withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST) - .withDepthWrite(false) + static final RenderPipeline LINES_PIPELINE = add(RenderPipeline.builder(RenderPipelines.LINES_SNIPPET) + .withLocation(Identifier.fromNamespaceAndPath(Sputnik.MOD_ID, "pipeline/lines")) + .withVertexFormat(DefaultVertexFormat.POSITION_COLOR_NORMAL_LINE_WIDTH, VertexFormat.Mode.LINES) +// .withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST) +// .withDepthWrite(false) .withCull(false) .build()); - static final RenderPipeline LINES_CULL_PIPELINE = add(RenderPipeline.builder(RenderPipelines.RENDERTYPE_LINES_SNIPPET) - .withLocation(Identifier.of(Sputnik.MOD_ID, "pipeline/lines_cull")) - .withVertexFormat(VertexFormats.POSITION_COLOR_NORMAL_LINE_WIDTH, VertexFormat.DrawMode.LINES) - .withDepthTestFunction(DepthTestFunction.LEQUAL_DEPTH_TEST) - .withDepthWrite(false) + static final RenderPipeline LINES_CULL_PIPELINE = add(RenderPipeline.builder(RenderPipelines.LINES_SNIPPET) + .withLocation(Identifier.fromNamespaceAndPath(Sputnik.MOD_ID, "pipeline/lines_cull")) + .withVertexFormat(DefaultVertexFormat.POSITION_COLOR_NORMAL_LINE_WIDTH, VertexFormat.Mode.LINES) +// .withDepthTestFunction(DepthTestFunction.LEQUAL_DEPTH_TEST) +// .withDepthWrite(false) .withCull(true) .build()); - static final RenderPipeline QUADS_PIPELINE = add(RenderPipeline.builder(RenderPipelines.POSITION_COLOR_SNIPPET) - .withLocation(Identifier.of(Sputnik.MOD_ID, "pipeline/quads")) - .withVertexFormat(VertexFormats.POSITION_COLOR, VertexFormat.DrawMode.QUADS) - .withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST) - .withBlend(BlendFunction.TRANSLUCENT) - .withDepthWrite(false) + static final RenderPipeline QUADS_PIPELINE = add(RenderPipeline.builder(RenderPipelines.DEBUG_FILLED_SNIPPET) + .withLocation(Identifier.fromNamespaceAndPath(Sputnik.MOD_ID, "pipeline/quads")) + .withVertexFormat(DefaultVertexFormat.POSITION_COLOR, VertexFormat.Mode.QUADS) +// .withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST) +// .withBlend(BlendFunction.TRANSLUCENT) +// .withDepthWrite(false) .withCull(false) .build()); - static final RenderPipeline QUADS_CULL_PIPELINE = add(RenderPipeline.builder(RenderPipelines.POSITION_COLOR_SNIPPET) - .withLocation(Identifier.of(Sputnik.MOD_ID, "pipeline/quads_cull")) - .withVertexFormat(VertexFormats.POSITION_COLOR, VertexFormat.DrawMode.QUADS) - .withDepthTestFunction(DepthTestFunction.LEQUAL_DEPTH_TEST) - .withBlend(BlendFunction.TRANSLUCENT) - .withDepthWrite(false) + static final RenderPipeline QUADS_CULL_PIPELINE = add(RenderPipeline.builder(RenderPipelines.DEBUG_FILLED_SNIPPET) + .withLocation(Identifier.fromNamespaceAndPath(Sputnik.MOD_ID, "pipeline/quads_cull")) + .withVertexFormat(DefaultVertexFormat.POSITION_COLOR, VertexFormat.Mode.QUADS) +// .withDepthTestFunction(DepthTestFunction.LEQUAL_DEPTH_TEST) +// .withBlend(BlendFunction.TRANSLUCENT) +// .withDepthWrite(false) .withCull(false) .build()); - static final RenderPipeline TEXT_PIPELINE = add(RenderPipeline.builder(RenderPipelines.POSITION_TEX_COLOR_SNIPPET) - .withLocation(Identifier.of(Sputnik.MOD_ID, "pipeline/text")) - .withVertexFormat(VertexFormats.POSITION_TEXTURE_COLOR, VertexFormat.DrawMode.TRIANGLES) - .withVertexShader(Identifier.of(Sputnik.MOD_ID, "shaders/text.vert")) - .withFragmentShader(Identifier.of(Sputnik.MOD_ID, "shaders/text.frag")) + static final RenderPipeline TEXT_PIPELINE = add(RenderPipeline.builder(RenderPipelines.GUI_TEXTURED_SNIPPET) + .withLocation(Identifier.fromNamespaceAndPath(Sputnik.MOD_ID, "pipeline/text")) + .withVertexFormat(DefaultVertexFormat.POSITION_TEX_COLOR, VertexFormat.Mode.TRIANGLES) + .withVertexShader(Identifier.fromNamespaceAndPath(Sputnik.MOD_ID, "shaders/text.vert")) + .withFragmentShader(Identifier.fromNamespaceAndPath(Sputnik.MOD_ID, "shaders/text.frag")) .withSampler("u_Texture") - .withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST) - .withDepthWrite(false) - .withBlend(BlendFunction.TRANSLUCENT) +// .withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST) +// .withDepthWrite(false) +// .withBlend(BlendFunction.TRANSLUCENT) .withCull(false) .build()); @@ -87,13 +85,13 @@ public class Pipelines { public static void precompile(RenderPipeline pipeline) { GpuDevice device = RenderSystem.getDevice(); - ResourceManager resources = MinecraftClient.getInstance().getResourceManager(); + ResourceManager resources = Minecraft.getInstance().getResourceManager(); device.precompilePipeline(pipeline, (identifier, shaderType) -> { Resource resource = resources.getResource(identifier).get(); - try (InputStream in = resource.getInputStream()) { - return IOUtils.toString(in, StandardCharsets.UTF_8); + try (InputStream is = resource.open()) { + return IOUtils.toString(is, StandardCharsets.UTF_8); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/src/main/java/me/retucio/sputnik/util/render/RenderUtil.java b/src/main/java/me/retucio/sputnik/util/render/RenderUtil.java index b848ee8..d9877f9 100644 --- a/src/main/java/me/retucio/sputnik/util/render/RenderUtil.java +++ b/src/main/java/me/retucio/sputnik/util/render/RenderUtil.java @@ -1,11 +1,14 @@ package me.retucio.sputnik.util.render; -import com.mojang.blaze3d.vertex.VertexFormat; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.render.*; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.math.*; -import net.minecraft.util.shape.VoxelShape; +import com.mojang.blaze3d.vertex.*; +import com.mojang.math.Axis; +import net.minecraft.client.Camera; +import net.minecraft.client.Minecraft; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.phys.shapes.VoxelShape; import org.joml.Vector3f; import java.awt.*; @@ -13,39 +16,39 @@ import java.awt.*; // literalmente robado de https://github.com/mioclient/oyvey-ported/ (perdón) public class RenderUtil { - private static final MinecraftClient mc = MinecraftClient.getInstance(); - private static final Tessellator tessellator = Tessellator.getInstance(); + private static final Minecraft mc = Minecraft.getInstance(); + private static final Tesselator tessellator = Tesselator.getInstance(); /* líneas */ - public static void drawLine(MatrixStack matrices, Vec3d from, Vec3d to, Color color, float lineWidth) { - BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR_NORMAL_LINE_WIDTH); - Vec3d cam = mc.gameRenderer.getCamera().getCameraPos(); + public static void drawLine(PoseStack matrices, Vec3 from, Vec3 to, Color color, float lineWidth) { + BufferBuilder buffer = tessellator.begin(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR_NORMAL_LINE_WIDTH); + Vec3 cam = mc.gameRenderer.getMainCamera().position(); - buffer.vertex(matrices.peek(), (float) (from.x - cam.x), (float) (from.y - cam.y), (float) (from.z - cam.z)).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), (float) (to.x - cam.x), (float) (to.y - cam.y), (float) (to.z - cam.z)).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), (float) (from.x - cam.x), (float) (from.y - cam.y), (float) (from.z - cam.z)).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), (float) (to.x - cam.x), (float) (to.y - cam.y), (float) (to.z - cam.z)).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - Layers.lines().draw(buffer.end()); + SputnikRenderTypes.lines().draw(buffer.buildOrThrow()); } // https://github.com/TheF1xer/GateClient-1.12.2/blob/main/src/main/java/me/thef1xer/gateclient/util/RenderUtil.java - public static void drawTracer(MatrixStack matrices, Vec3d pos, Color color, float lineWidth) { - BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR_NORMAL_LINE_WIDTH); - Camera cam = mc.gameRenderer.getCamera(); + public static void drawTracer(PoseStack matrices, Vec3 pos, Color color, float lineWidth) { + BufferBuilder buffer = tessellator.begin(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR_NORMAL_LINE_WIDTH); + Camera cam = mc.gameRenderer.getMainCamera(); Vector3f cameraVector = new Vector3f(0, 0, 1) - .rotateX((float) Math.toRadians(cam.getPitch())) - .rotateY((float) -Math.toRadians(cam.getYaw())); + .rotateX((float) Math.toRadians(cam.xRot())) + .rotateY((float) -Math.toRadians(cam.yRot())); - buffer.vertex(matrices.peek(), cameraVector.x, cameraVector.y, cameraVector.z).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), (float) (pos.x - cam.getCameraPos().x), (float) (pos.y - cam.getCameraPos().y), (float) (pos.z - cam.getCameraPos().z)).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - Layers.lines().draw(buffer.end()); + buffer.addVertex(matrices.last(), cameraVector.x, cameraVector.y, cameraVector.z).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), (float) (pos.x - cam.position().x), (float) (pos.y - cam.position().y), (float) (pos.z - cam.position().z)).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + SputnikRenderTypes.lines().draw(buffer.buildOrThrow()); } - public static void drawVector(MatrixStack matrices, Vector3f start, Vec3d direction, Color c, float lineWidth) { - BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR_NORMAL_LINE_WIDTH); - MatrixStack.Entry pose = matrices.peek(); + public static void drawVector(PoseStack matrices, Vector3f start, Vec3 direction, Color c, float lineWidth) { + BufferBuilder buffer = tessellator.begin(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR_NORMAL_LINE_WIDTH); + PoseStack.Pose pose = matrices.last(); int color = c.getRGB(); float a = ((color >> 24) & 0xFF) / 255f; @@ -57,45 +60,45 @@ public class RenderUtil { float endY = start.y() + (float) direction.y; float endZ = start.z() + (float) direction.z; - buffer.vertex(pose.getPositionMatrix(), start.x(), start.y(), start.z()) - .color(r, g, b, a) - .normal(pose, (float) direction.x, (float) direction.y, (float) direction.z) - .lineWidth(lineWidth); + buffer.addVertex(pose.pose(), start.x(), start.y(), start.z()) + .setColor(r, g, b, a) + .setNormal(pose, (float) direction.x, (float) direction.y, (float) direction.z) + .setLineWidth(lineWidth); - buffer.vertex(pose.getPositionMatrix(), endX, endY, endZ) - .color(r, g, b, a) - .normal(pose, (float) direction.x, (float) direction.y, (float) direction.z) - .lineWidth(lineWidth); + buffer.addVertex(pose.pose(), endX, endY, endZ) + .setColor(r, g, b, a) + .setNormal(pose, (float) direction.x, (float) direction.y, (float) direction.z) + .setLineWidth(lineWidth); - Layers.lines().draw(buffer.end()); + SputnikRenderTypes.lines().draw(buffer.buildOrThrow()); } /* caras */ - public static void drawFilledRect(MatrixStack matrices, float x, float y, float width, float height, Color color) { + public static void drawFilledRect(PoseStack matrices, float x, float y, float width, float height, Color color) { float r = color.getRed() / 255f; float g = color.getGreen() / 255f; float b = color.getBlue() / 255f; float a = color.getAlpha() / 255f; - matrices.push(); + matrices.pushPose(); matrices.translate(0, 0, 0); - BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); + BufferBuilder buffer = tessellator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); - buffer.vertex(matrices.peek().getPositionMatrix(), x, y + height, 0).color(r, g, b, a); - buffer.vertex(matrices.peek().getPositionMatrix(), x + width, y + height, 0).color(r, g, b, a); - buffer.vertex(matrices.peek().getPositionMatrix(), x + width, y, 0).color(r, g, b, a); - buffer.vertex(matrices.peek().getPositionMatrix(), x, y, 0).color(r, g, b, a); + buffer.addVertex(matrices.last().pose(), x, y + height, 0).setColor(r, g, b, a); + buffer.addVertex(matrices.last().pose(), x + width, y + height, 0).setColor(r, g, b, a); + buffer.addVertex(matrices.last().pose(), x + width, y, 0).setColor(r, g, b, a); + buffer.addVertex(matrices.last().pose(), x, y, 0).setColor(r, g, b, a); - Layers.quads().draw(buffer.end()); - matrices.pop(); + SputnikRenderTypes.quads().draw(buffer.buildOrThrow()); + matrices.popPose(); } - public static void drawBlockFaceOutlines(MatrixStack matrices, BlockPos pos, Direction face, Color color, float lineWidth, boolean cull) { + public static void drawBlockFaceOutlines(PoseStack matrices, BlockPos pos, Direction face, Color color, float lineWidth, boolean cull) { if (lineWidth <= 0) return; - Vec3d cameraPos = mc.gameRenderer.getCamera().getCameraPos(); + Vec3 cameraPos = mc.gameRenderer.getMainCamera().position(); float minX = (float) (pos.getX() - cameraPos.x); float minY = (float) (pos.getY() - cameraPos.y); @@ -104,107 +107,107 @@ public class RenderUtil { float maxY = minY + 1; float maxZ = minZ + 1; - BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR_NORMAL_LINE_WIDTH); + BufferBuilder buffer = tessellator.begin(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR_NORMAL_LINE_WIDTH); switch (face) { case UP: - buffer.vertex(matrices.peek(), minX, maxY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, maxY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, maxY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, maxY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, maxY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, maxY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, maxY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, maxY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, maxY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, maxY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, maxY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, maxY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, maxY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, maxY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, maxY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, maxY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); break; case DOWN: - buffer.vertex(matrices.peek(), minX, minY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, minY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, minY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, minY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, minY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, minY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, minY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, minY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, minY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, minY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, minY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, minY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, minY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, minY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, minY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, minY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); break; case EAST: - buffer.vertex(matrices.peek(), maxX, minY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, maxY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, minY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, maxY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, maxY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, maxY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, maxY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, maxY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, maxY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, minY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, maxY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, minY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, minY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, minY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, minY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, minY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); break; case WEST: - buffer.vertex(matrices.peek(), minX, minY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, maxY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, minY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, maxY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, maxY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, maxY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, maxY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, maxY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, maxY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, minY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, maxY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, minY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, minY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, minY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, minY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, minY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); break; case NORTH: - buffer.vertex(matrices.peek(), minX, minY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, minY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, minY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, minY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, minY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, maxY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, minY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, maxY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, maxY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, maxY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, maxY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, maxY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, maxY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, minY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, maxY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, minY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); break; case SOUTH: - buffer.vertex(matrices.peek(), minX, minY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, minY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, minY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, minY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, minY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, maxY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, minY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, maxY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, maxY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, maxY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, maxY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, maxY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, maxY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, minY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, maxY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, minY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); break; } - if (cull) Layers.linesCull().draw(buffer.end()); - else Layers.lines().draw(buffer.end()); + if (cull) SputnikRenderTypes.linesCull().draw(buffer.buildOrThrow()); + else SputnikRenderTypes.lines().draw(buffer.buildOrThrow()); } // expand es para evitar z-fighting - public static void drawBlockFaceFilled(MatrixStack matrices, BlockPos pos, Direction face, Color color, float expand, boolean cull) { - Vec3d cameraPos = mc.gameRenderer.getCamera().getCameraPos(); + public static void drawBlockFaceFilled(PoseStack matrices, BlockPos pos, Direction face, Color color, float expand, boolean cull) { + Vec3 cameraPos = mc.gameRenderer.getMainCamera().position(); float minX = (float) (pos.getX() - cameraPos.x); float minY = (float) (pos.getY() - cameraPos.y); @@ -229,75 +232,75 @@ public class RenderUtil { } } - BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); + BufferBuilder buffer = tessellator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); switch (face) { case DOWN: - buffer.vertex(matrices.peek().getPositionMatrix(), minX, minY, minZ).color(r, g, b, a); - buffer.vertex(matrices.peek().getPositionMatrix(), maxX, minY, minZ).color(r, g, b, a); - buffer.vertex(matrices.peek().getPositionMatrix(), maxX, minY, maxZ).color(r, g, b, a); - buffer.vertex(matrices.peek().getPositionMatrix(), minX, minY, maxZ).color(r, g, b, a); + buffer.addVertex(matrices.last().pose(), minX, minY, minZ).setColor(r, g, b, a); + buffer.addVertex(matrices.last().pose(), maxX, minY, minZ).setColor(r, g, b, a); + buffer.addVertex(matrices.last().pose(), maxX, minY, maxZ).setColor(r, g, b, a); + buffer.addVertex(matrices.last().pose(), minX, minY, maxZ).setColor(r, g, b, a); break; case UP: - buffer.vertex(matrices.peek().getPositionMatrix(), minX, maxY, minZ).color(r, g, b, a); - buffer.vertex(matrices.peek().getPositionMatrix(), minX, maxY, maxZ).color(r, g, b, a); - buffer.vertex(matrices.peek().getPositionMatrix(), maxX, maxY, maxZ).color(r, g, b, a); - buffer.vertex(matrices.peek().getPositionMatrix(), maxX, maxY, minZ).color(r, g, b, a); + buffer.addVertex(matrices.last().pose(), minX, maxY, minZ).setColor(r, g, b, a); + buffer.addVertex(matrices.last().pose(), minX, maxY, maxZ).setColor(r, g, b, a); + buffer.addVertex(matrices.last().pose(), maxX, maxY, maxZ).setColor(r, g, b, a); + buffer.addVertex(matrices.last().pose(), maxX, maxY, minZ).setColor(r, g, b, a); break; case NORTH: - buffer.vertex(matrices.peek().getPositionMatrix(), minX, minY, minZ).color(r, g, b, a); - buffer.vertex(matrices.peek().getPositionMatrix(), minX, maxY, minZ).color(r, g, b, a); - buffer.vertex(matrices.peek().getPositionMatrix(), maxX, maxY, minZ).color(r, g, b, a); - buffer.vertex(matrices.peek().getPositionMatrix(), maxX, minY, minZ).color(r, g, b, a); + buffer.addVertex(matrices.last().pose(), minX, minY, minZ).setColor(r, g, b, a); + buffer.addVertex(matrices.last().pose(), minX, maxY, minZ).setColor(r, g, b, a); + buffer.addVertex(matrices.last().pose(), maxX, maxY, minZ).setColor(r, g, b, a); + buffer.addVertex(matrices.last().pose(), maxX, minY, minZ).setColor(r, g, b, a); break; case SOUTH: - buffer.vertex(matrices.peek().getPositionMatrix(), minX, minY, maxZ).color(r, g, b, a); - buffer.vertex(matrices.peek().getPositionMatrix(), maxX, minY, maxZ).color(r, g, b, a); - buffer.vertex(matrices.peek().getPositionMatrix(), maxX, maxY, maxZ).color(r, g, b, a); - buffer.vertex(matrices.peek().getPositionMatrix(), minX, maxY, maxZ).color(r, g, b, a); + buffer.addVertex(matrices.last().pose(), minX, minY, maxZ).setColor(r, g, b, a); + buffer.addVertex(matrices.last().pose(), maxX, minY, maxZ).setColor(r, g, b, a); + buffer.addVertex(matrices.last().pose(), maxX, maxY, maxZ).setColor(r, g, b, a); + buffer.addVertex(matrices.last().pose(), minX, maxY, maxZ).setColor(r, g, b, a); break; case WEST: - buffer.vertex(matrices.peek().getPositionMatrix(), minX, minY, minZ).color(r, g, b, a); - buffer.vertex(matrices.peek().getPositionMatrix(), minX, minY, maxZ).color(r, g, b, a); - buffer.vertex(matrices.peek().getPositionMatrix(), minX, maxY, maxZ).color(r, g, b, a); - buffer.vertex(matrices.peek().getPositionMatrix(), minX, maxY, minZ).color(r, g, b, a); + buffer.addVertex(matrices.last().pose(), minX, minY, minZ).setColor(r, g, b, a); + buffer.addVertex(matrices.last().pose(), minX, minY, maxZ).setColor(r, g, b, a); + buffer.addVertex(matrices.last().pose(), minX, maxY, maxZ).setColor(r, g, b, a); + buffer.addVertex(matrices.last().pose(), minX, maxY, minZ).setColor(r, g, b, a); break; case EAST: - buffer.vertex(matrices.peek().getPositionMatrix(), maxX, minY, minZ).color(r, g, b, a); - buffer.vertex(matrices.peek().getPositionMatrix(), maxX, maxY, minZ).color(r, g, b, a); - buffer.vertex(matrices.peek().getPositionMatrix(), maxX, maxY, maxZ).color(r, g, b, a); - buffer.vertex(matrices.peek().getPositionMatrix(), maxX, minY, maxZ).color(r, g, b, a); + buffer.addVertex(matrices.last().pose(), maxX, minY, minZ).setColor(r, g, b, a); + buffer.addVertex(matrices.last().pose(), maxX, maxY, minZ).setColor(r, g, b, a); + buffer.addVertex(matrices.last().pose(), maxX, maxY, maxZ).setColor(r, g, b, a); + buffer.addVertex(matrices.last().pose(), maxX, minY, maxZ).setColor(r, g, b, a); break; } - if (cull) Layers.quadsCull().draw(buffer.end()); - else Layers.quads().draw(buffer.end()); + if (cull) SputnikRenderTypes.quadsCull().draw(buffer.buildOrThrow()); + else SputnikRenderTypes.quads().draw(buffer.buildOrThrow()); } - public static void drawTriangle(MatrixStack matrices, float x1, float y1, float x2, float y2, float x3, float y3, Color color) { + public static void drawTriangle(PoseStack matrices, float x1, float y1, float x2, float y2, float x3, float y3, Color color) { float r = color.getRed() / 255f; float g = color.getGreen() / 255f; float b = color.getBlue() / 255f; float a = color.getAlpha() / 255f; - BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.TRIANGLES, VertexFormats.POSITION_COLOR); - buffer.vertex(matrices.peek().getPositionMatrix(), x1, y1, 0).color(r, g, b, a); - buffer.vertex(matrices.peek().getPositionMatrix(), x2, y2, 0).color(r, g, b, a); - buffer.vertex(matrices.peek().getPositionMatrix(), x3, y3, 0).color(r, g, b, a); - Layers.quads().draw(buffer.end()); + BufferBuilder buffer = tessellator.begin(VertexFormat.Mode.TRIANGLES, DefaultVertexFormat.POSITION_COLOR); + buffer.addVertex(matrices.last().pose(), x1, y1, 0).setColor(r, g, b, a); + buffer.addVertex(matrices.last().pose(), x2, y2, 0).setColor(r, g, b, a); + buffer.addVertex(matrices.last().pose(), x3, y3, 0).setColor(r, g, b, a); + SputnikRenderTypes.quads().draw(buffer.buildOrThrow()); } // cajas - public static void drawOutlineBox(MatrixStack matrices, Box box, Color color, float lineWidth, boolean cull) { + public static void drawOutlineBox(PoseStack matrices, AABB box, Color color, float lineWidth, boolean cull) { if (lineWidth <= 0) return; - Vec3d cameraPos = mc.gameRenderer.getCamera().getCameraPos(); + Vec3 cameraPos = mc.gameRenderer.getMainCamera().position(); float minX = (float) (box.minX - cameraPos.x); float minY = (float) (box.minY - cameraPos.y); @@ -306,53 +309,53 @@ public class RenderUtil { float maxY = (float) (box.maxY - cameraPos.y); float maxZ = (float) (box.maxZ - cameraPos.z); - BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR_NORMAL_LINE_WIDTH); + BufferBuilder buffer = tessellator.begin(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR_NORMAL_LINE_WIDTH); // parte inferior - buffer.vertex(matrices.peek(), minX, minY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, minY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, minY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, minY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, minY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, minY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, minY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, minY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, minY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, minY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, minY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, minY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, minY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, minY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, minY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, minY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); // parte superior - buffer.vertex(matrices.peek(), minX, maxY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, maxY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, maxY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, maxY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, maxY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, maxY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, maxY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, maxY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, maxY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, maxY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, maxY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, maxY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, maxY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, maxY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, maxY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, maxY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); // líneas verticales - buffer.vertex(matrices.peek(), minX, minY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, maxY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, minY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, maxY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, minY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, maxY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, minY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, maxY, minZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, minY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), maxX, maxY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, minY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), maxX, maxY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, minY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); - buffer.vertex(matrices.peek(), minX, maxY, maxZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, minY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); + buffer.addVertex(matrices.last(), minX, maxY, maxZ).setColor(color.getRGB()).setNormal(-1, -1, -1).setLineWidth(lineWidth); - if (cull) Layers.linesCull().draw(buffer.end()); - else Layers.lines().draw(buffer.end()); + if (cull) SputnikRenderTypes.linesCull().draw(buffer.buildOrThrow()); + else SputnikRenderTypes.lines().draw(buffer.buildOrThrow()); } - public static void drawFilledBox(MatrixStack matrices, Box box, Color color, boolean cull) { - Vec3d cameraPos = mc.gameRenderer.getCamera().getCameraPos(); + public static void drawFilledBox(PoseStack matrices, AABB box, Color color, boolean cull) { + Vec3 cameraPos = mc.gameRenderer.getMainCamera().position(); float minX = (float) (box.minX - cameraPos.x); float minY = (float) (box.minY - cameraPos.y); @@ -361,50 +364,50 @@ public class RenderUtil { float maxY = (float) (box.maxY - cameraPos.y); float maxZ = (float) (box.maxZ - cameraPos.z); - BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); - - buffer.vertex(matrices.peek().getPositionMatrix(), minX, minY, minZ).color(color.getRGB()); - buffer.vertex(matrices.peek().getPositionMatrix(), maxX, minY, minZ).color(color.getRGB()); - buffer.vertex(matrices.peek().getPositionMatrix(), maxX, minY, maxZ).color(color.getRGB()); - buffer.vertex(matrices.peek().getPositionMatrix(), minX, minY, maxZ).color(color.getRGB()); + BufferBuilder buffer = tessellator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); - buffer.vertex(matrices.peek().getPositionMatrix(), minX, maxY, minZ).color(color.getRGB()); - buffer.vertex(matrices.peek().getPositionMatrix(), minX, maxY, maxZ).color(color.getRGB()); - buffer.vertex(matrices.peek().getPositionMatrix(), maxX, maxY, maxZ).color(color.getRGB()); - buffer.vertex(matrices.peek().getPositionMatrix(), maxX, maxY, minZ).color(color.getRGB()); + buffer.addVertex(matrices.last().pose(), minX, minY, minZ).setColor(color.getRGB()); + buffer.addVertex(matrices.last().pose(), maxX, minY, minZ).setColor(color.getRGB()); + buffer.addVertex(matrices.last().pose(), maxX, minY, maxZ).setColor(color.getRGB()); + buffer.addVertex(matrices.last().pose(), minX, minY, maxZ).setColor(color.getRGB()); - buffer.vertex(matrices.peek().getPositionMatrix(), minX, minY, minZ).color(color.getRGB()); - buffer.vertex(matrices.peek().getPositionMatrix(), minX, maxY, minZ).color(color.getRGB()); - buffer.vertex(matrices.peek().getPositionMatrix(), maxX, maxY, minZ).color(color.getRGB()); - buffer.vertex(matrices.peek().getPositionMatrix(), maxX, minY, minZ).color(color.getRGB()); + buffer.addVertex(matrices.last().pose(), minX, maxY, minZ).setColor(color.getRGB()); + buffer.addVertex(matrices.last().pose(), minX, maxY, maxZ).setColor(color.getRGB()); + buffer.addVertex(matrices.last().pose(), maxX, maxY, maxZ).setColor(color.getRGB()); + buffer.addVertex(matrices.last().pose(), maxX, maxY, minZ).setColor(color.getRGB()); - buffer.vertex(matrices.peek().getPositionMatrix(), maxX, minY, minZ).color(color.getRGB()); - buffer.vertex(matrices.peek().getPositionMatrix(), maxX, maxY, minZ).color(color.getRGB()); - buffer.vertex(matrices.peek().getPositionMatrix(), maxX, maxY, maxZ).color(color.getRGB()); - buffer.vertex(matrices.peek().getPositionMatrix(), maxX, minY, maxZ).color(color.getRGB()); + buffer.addVertex(matrices.last().pose(), minX, minY, minZ).setColor(color.getRGB()); + buffer.addVertex(matrices.last().pose(), minX, maxY, minZ).setColor(color.getRGB()); + buffer.addVertex(matrices.last().pose(), maxX, maxY, minZ).setColor(color.getRGB()); + buffer.addVertex(matrices.last().pose(), maxX, minY, minZ).setColor(color.getRGB()); - buffer.vertex(matrices.peek().getPositionMatrix(), minX, minY, maxZ).color(color.getRGB()); - buffer.vertex(matrices.peek().getPositionMatrix(), maxX, minY, maxZ).color(color.getRGB()); - buffer.vertex(matrices.peek().getPositionMatrix(), maxX, maxY, maxZ).color(color.getRGB()); - buffer.vertex(matrices.peek().getPositionMatrix(), minX, maxY, maxZ).color(color.getRGB()); + buffer.addVertex(matrices.last().pose(), maxX, minY, minZ).setColor(color.getRGB()); + buffer.addVertex(matrices.last().pose(), maxX, maxY, minZ).setColor(color.getRGB()); + buffer.addVertex(matrices.last().pose(), maxX, maxY, maxZ).setColor(color.getRGB()); + buffer.addVertex(matrices.last().pose(), maxX, minY, maxZ).setColor(color.getRGB()); - buffer.vertex(matrices.peek().getPositionMatrix(), minX, minY, minZ).color(color.getRGB()); - buffer.vertex(matrices.peek().getPositionMatrix(), minX, minY, maxZ).color(color.getRGB()); - buffer.vertex(matrices.peek().getPositionMatrix(), minX, maxY, maxZ).color(color.getRGB()); - buffer.vertex(matrices.peek().getPositionMatrix(), minX, maxY, minZ).color(color.getRGB()); + buffer.addVertex(matrices.last().pose(), minX, minY, maxZ).setColor(color.getRGB()); + buffer.addVertex(matrices.last().pose(), maxX, minY, maxZ).setColor(color.getRGB()); + buffer.addVertex(matrices.last().pose(), maxX, maxY, maxZ).setColor(color.getRGB()); + buffer.addVertex(matrices.last().pose(), minX, maxY, maxZ).setColor(color.getRGB()); - if (cull) Layers.quadsCull().draw(buffer.end()); - else Layers.quads().draw(buffer.end()); + buffer.addVertex(matrices.last().pose(), minX, minY, minZ).setColor(color.getRGB()); + buffer.addVertex(matrices.last().pose(), minX, minY, maxZ).setColor(color.getRGB()); + buffer.addVertex(matrices.last().pose(), minX, maxY, maxZ).setColor(color.getRGB()); + buffer.addVertex(matrices.last().pose(), minX, maxY, minZ).setColor(color.getRGB()); + + if (cull) SputnikRenderTypes.quadsCull().draw(buffer.buildOrThrow()); + else SputnikRenderTypes.quads().draw(buffer.buildOrThrow()); } // formas custom - public static void drawVoxelShapeOutline(MatrixStack matrices, VoxelShape voxelShape, BlockPos blockPos, Color color, float lineWidth, boolean cull) { + public static void drawVoxelShapeOutline(PoseStack matrices, VoxelShape voxelShape, BlockPos blockPos, Color color, float lineWidth, boolean cull) { if (voxelShape.isEmpty()) return; - voxelShape.forEachBox((minX, minY, minZ, maxX, maxY, maxZ) -> { - Box box = new Box( + voxelShape.forAllBoxes((minX, minY, minZ, maxX, maxY, maxZ) -> { + AABB box = new AABB( blockPos.getX() + minX, blockPos.getY() + minY, blockPos.getZ() + minZ, blockPos.getX() + maxX, blockPos.getY() + maxY, blockPos.getZ() + maxZ ); @@ -413,11 +416,11 @@ public class RenderUtil { }); } - public static void drawVoxelShapeFilled(MatrixStack matrices, VoxelShape voxelShape, BlockPos pos, Color color, boolean cull) { + public static void drawVoxelShapeFilled(PoseStack matrices, VoxelShape voxelShape, BlockPos pos, Color color, boolean cull) { if (voxelShape.isEmpty()) return; - voxelShape.forEachBox((minX, minY, minZ, maxX, maxY, maxZ) -> { - Box box = new Box( + voxelShape.forAllBoxes((minX, minY, minZ, maxX, maxY, maxZ) -> { + AABB box = new AABB( pos.getX() + minX, pos.getY() + minY, pos.getZ() + minZ, pos.getX() + maxX, pos.getY() + maxY, pos.getZ() + maxZ ); @@ -429,14 +432,14 @@ public class RenderUtil { // bloques - public static void drawBlockOutline(MatrixStack matrices, BlockPos pos, Color color, float lineWidth, boolean cull) { - Box box = new Box(pos.getX(), pos.getY(), pos.getZ(), + public static void drawBlockOutline(PoseStack matrices, BlockPos pos, Color color, float lineWidth, boolean cull) { + AABB box = new AABB(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1); drawOutlineBox(matrices, box, color, lineWidth, cull); } - public static void drawBlockFilled(MatrixStack matrices, BlockPos pos, Color color, boolean cull) { - Box box = new Box(pos.getX(), pos.getY(), pos.getZ(), + public static void drawBlockFilled(PoseStack matrices, BlockPos pos, Color color, boolean cull) { + AABB box = new AABB(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1); drawFilledBox(matrices, box, color, cull); } @@ -444,19 +447,19 @@ public class RenderUtil { - public static MatrixStack matrixFrom(Vec3d pos) { - MatrixStack matrices = new MatrixStack(); + public static PoseStack matrixFrom(Vec3 pos) { + PoseStack matrices = new PoseStack(); - Camera camera = mc.gameRenderer.getCamera(); - Vec3d camPos = camera.getCameraPos(); + Camera camera = mc.gameRenderer.getMainCamera(); + Vec3 camPos = camera.position(); - matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(camera.getYaw())); - matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(camera.getPitch() + 180.0F)); + matrices.mulPose(Axis.XP.rotationDegrees(camera.yRot())); + matrices.mulPose(Axis.YP.rotationDegrees(camera.xRot() + 180.0f)); matrices.translate( - pos.getX() - camPos.getX(), - pos.getY() - camPos.getY(), - pos.getZ() - camPos.getZ() + pos.x() - camPos.x(), + pos.y() - camPos.y(), + pos.z() - camPos.z() ); return matrices; diff --git a/src/main/java/me/retucio/sputnik/util/render/SputnikRenderTypes.java b/src/main/java/me/retucio/sputnik/util/render/SputnikRenderTypes.java new file mode 100644 index 0000000..85e38e8 --- /dev/null +++ b/src/main/java/me/retucio/sputnik/util/render/SputnikRenderTypes.java @@ -0,0 +1,51 @@ +package me.retucio.sputnik.util.render; + +import me.retucio.sputnik.Sputnik; +import net.minecraft.client.renderer.rendertype.RenderSetup; +import net.minecraft.client.renderer.rendertype.RenderType; + +import static me.retucio.sputnik.util.render.Pipelines.*; + + +public class SputnikRenderTypes { + + private static final RenderType LINES; + private static final RenderType LINES_CULL; + + private static final RenderType QUADS; + private static final RenderType QUADS_CULL; + + private static final RenderType TEXT; + + + public static RenderType lines() { + return LINES; + } + + public static RenderType linesCull() { + return LINES_CULL; + } + + public static RenderType quads() { + return QUADS; + } + + public static RenderType quadsCull() { + return QUADS_CULL; + } + + public static RenderType text() { + return TEXT; + } + + static { + LINES = RenderType.create(Sputnik.MOD_ID + "_lines", RenderSetup.builder(LINES_PIPELINE).createRenderSetup()); + LINES_CULL = RenderType.create(Sputnik.MOD_ID + "_lines_cull", RenderSetup.builder(LINES_CULL_PIPELINE).createRenderSetup()); + + QUADS = RenderType.create(Sputnik.MOD_ID + "_quads", RenderSetup.builder(QUADS_PIPELINE).createRenderSetup()); + QUADS_CULL = RenderType.create(Sputnik.MOD_ID + "_quads_cull", RenderSetup.builder(QUADS_CULL_PIPELINE).createRenderSetup()); + + TEXT = RenderType.create(Sputnik.MOD_ID + "_text", RenderSetup.builder(TEXT_PIPELINE).createRenderSetup()); + } + +} \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/util/render/Textures.java b/src/main/java/me/retucio/sputnik/util/render/Textures.java index 8a9629e..db9f9bb 100644 --- a/src/main/java/me/retucio/sputnik/util/render/Textures.java +++ b/src/main/java/me/retucio/sputnik/util/render/Textures.java @@ -1,44 +1,42 @@ package me.retucio.sputnik.util.render; +import com.mojang.blaze3d.platform.NativeImage; import me.retucio.sputnik.Sputnik; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.texture.NativeImage; -import net.minecraft.client.texture.NativeImageBackedTexture; -import net.minecraft.resource.Resource; -import net.minecraft.util.Identifier; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.resources.Identifier; +import net.minecraft.server.packs.resources.Resource; import java.util.ArrayList; import java.util.List; + public class Textures { - public static final MinecraftClient mc = MinecraftClient.getInstance(); + public static final Minecraft mc = Minecraft.getInstance(); public static final List textures = new ArrayList<>(); public static final Identifier SEARCH_BAR_FILTER = texture("gui/filter_icon"); public static Identifier texture(String path) { - Identifier id = Identifier.of(Sputnik.MOD_ID, "textures/" + path + ".png"); + Identifier id = Identifier.fromNamespaceAndPath(Sputnik.MOD_ID, "textures/" + path + ".png"); textures.add(id); return id; } public static boolean register(Identifier id) { if (!textures.contains(id)) textures.add(id); - if (mc.getTextureManager() != null) { - try { - Resource resource = mc.getResourceManager().getResource(id).orElseThrow(); - NativeImage image = NativeImage.read(resource.getInputStream()); - NativeImageBackedTexture texture = new NativeImageBackedTexture(null, image); - mc.getTextureManager().registerTexture(id, texture); - return true; - } catch (Exception e) { - Sputnik.LOGGER.error("Failed to load texture: {}", id, e); - return false; - } + try { + Resource resource = mc.getResourceManager().getResource(id).orElseThrow(); + NativeImage image = NativeImage.read(resource.open()); + DynamicTexture texture = new DynamicTexture(null, image); + mc.getTextureManager().register(id, texture); + return true; + } catch (Exception e) { + Sputnik.LOGGER.error("Failed to load texture: {}", id, e); + return false; } - return false; } public static void init() { diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 6443b8f..71b6ea2 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -25,9 +25,9 @@ ], "accessWidener": "sputnik.accesswidener", "depends": { - "fabricloader": ">=0.17.3", - "minecraft": "~1.21.10", - "java": ">=21", + "fabricloader": ">=0.19.2", + "minecraft": "~26.1.2", + "java": ">=25", "fabric-api": "*" }, "suggests": {} diff --git a/src/main/resources/sputnik.accesswidener b/src/main/resources/sputnik.accesswidener index df6ab95..ba19298 100644 --- a/src/main/resources/sputnik.accesswidener +++ b/src/main/resources/sputnik.accesswidener @@ -1,60 +1,41 @@ -accessWidener v2 named +accessWidener v2 official # red -accessible field net/minecraft/client/network/DataQueryHandler expectedTransactionId I -accessible field net/minecraft/network/ClientConnection queuedTasks Ljava/util/Queue; -accessible method net/minecraft/network/ClientConnection handleQueuedTasks ()V -accessible method net/minecraft/network/ClientConnection sendImmediately (Lnet/minecraft/network/packet/Packet;Lio/netty/channel/ChannelFutureListener;Z)V -accessible method net/minecraft/network/ClientConnection handlePacket (Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/listener/PacketListener;)V -accessible method net/minecraft/client/world/ClientWorld getPendingUpdateManager ()Lnet/minecraft/client/network/PendingUpdateManager; -accessible method net/minecraft/client/network/ClientPlayerInteractionManager sendSequencedPacket (Lnet/minecraft/client/world/ClientWorld;Lnet/minecraft/client/network/SequencedPacketCreator;)V -accessible class net/minecraft/client/network/ClientCommonNetworkHandler$ConfirmServerResourcePackScreen -accessible class net/minecraft/client/network/ClientCommonNetworkHandler$ConfirmServerResourcePackScreen$Pack +accessible method net/minecraft/network/Connection genericsFtw (Lnet/minecraft/network/protocol/Packet;Lnet/minecraft/network/PacketListener;)V +accessible method net/minecraft/network/Connection sendPacket (Lnet/minecraft/network/protocol/Packet;Lio/netty/channel/ChannelFutureListener;Z)V +accessible method net/minecraft/client/gui/screens/ConnectScreen connect (Lnet/minecraft/client/Minecraft;Lnet/minecraft/client/multiplayer/resolver/ServerAddress;Lnet/minecraft/client/multiplayer/ServerData;Lnet/minecraft/client/multiplayer/TransferState;)V +accessible method net/minecraft/client/multiplayer/MultiPlayerGameMode startPrediction (Lnet/minecraft/client/multiplayer/ClientLevel;Lnet/minecraft/client/multiplayer/prediction/PredictiveAction;)V + +accessible class net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl$PackConfirmScreen +accessible class net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl$PackConfirmScreen$PendingRequest # texto -accessible method net/minecraft/client/font/FontManager getStorageInternal (Lnet/minecraft/util/Identifier;)Lnet/minecraft/client/font/FontStorage; -accessible class net/minecraft/client/font/TextRenderer$Drawer -accessible field net/minecraft/client/font/TextHandler widthRetriever Lnet/minecraft/client/font/TextHandler$WidthRetriever; +accessible class net/minecraft/client/gui/Font$PreparedTextBuilder +accessible field net/minecraft/client/StringSplitter widthProvider Lnet/minecraft/client/StringSplitter$WidthProvider; # chat -accessible class net/minecraft/client/gui/hud/ChatHud$Interactable -accessible class net/minecraft/client/gui/hud/ChatHud$LineConsumer +accessible class net/minecraft/client/gui/components/ChatComponent$DrawingFocusedGraphicsAccess +accessible method net/minecraft/client/gui/components/ChatComponent addMessage (Lnet/minecraft/network/chat/Component;Lnet/minecraft/network/chat/MessageSignature;Lnet/minecraft/client/multiplayer/chat/GuiMessageSource;Lnet/minecraft/client/multiplayer/chat/GuiMessageTag;)V # entidad -accessible field net/minecraft/entity/LivingEntity jumpingCooldown I -accessible method net/minecraft/entity/Entity setFlag (IZ)V -accessible method net/minecraft/entity/player/PlayerEntity canGlide ()Z -accessible method net/minecraft/entity/LivingEntity calcGlidingVelocity (Lnet/minecraft/util/math/Vec3d;)Lnet/minecraft/util/math/Vec3d; +accessible method net/minecraft/client/multiplayer/ClientLevel getEntities ()Lnet/minecraft/world/level/entity/LevelEntityGetter; +accessible method net/minecraft/world/entity/EntityReference resolve (Lnet/minecraft/world/level/entity/UniquelyIdentifyable;Ljava/lang/Class;)Lnet/minecraft/world/level/entity/UniquelyIdentifyable; +accessible field net/minecraft/world/entity/LivingEntity noJumpDelay I +accessible method net/minecraft/world/entity/LivingEntity updateFallFlyingMovement (Lnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3; # partícula -accessible field net/minecraft/client/particle/BillboardParticle alpha F -accessible field net/minecraft/client/particle/Particle velocityMultiplier F -accessible field net/minecraft/client/particle/BillboardParticle scale F -accessible field net/minecraft/client/particle/Particle gravityStrength F -accessible field net/minecraft/client/particle/Particle collidesWithWorld Z -accessible class net/minecraft/client/particle/ParticleSpriteManager$SpriteAwareFactory -accessible class net/minecraft/client/particle/ParticleSpriteManager$SimpleSpriteProvider +accessible field net/minecraft/client/particle/SingleQuadParticle alpha F +accessible field net/minecraft/client/particle/SingleQuadParticle quadSize F +accessible field net/minecraft/client/particle/Particle friction F +accessible field net/minecraft/client/particle/Particle gravity F +accessible field net/minecraft/client/particle/Particle hasPhysics Z # renderizado 3d -accessible field net/minecraft/client/render/WorldRenderer worldRenderState Lnet/minecraft/client/render/state/WorldRenderState; -accessible method net/minecraft/client/render/RenderLayer (Ljava/lang/String;Lnet/minecraft/client/render/RenderSetup;)V -accessible method net/minecraft/client/render/GameRenderer getProjectionMatrix (F)Lorg/joml/Matrix4f; -accessible method com/mojang/blaze3d/pipeline/RenderPipeline$Builder withSnippet (Lcom/mojang/blaze3d/pipeline/RenderPipeline$Snippet;)V +accessible method net/minecraft/client/renderer/rendertype/RenderType (Ljava/lang/String;Lnet/minecraft/client/renderer/rendertype/RenderSetup;)V # misc. -accessible field net/minecraft/client/MinecraftClient resourceManager Lnet/minecraft/resource/ReloadableResourceManagerImpl; -accessible field net/minecraft/client/texture/TextureManager textures Ljava/util/Map; -accessible method net/minecraft/client/MinecraftClient doItemUse ()V - -accessible class net/minecraft/entity/projectile/FishingBobberEntity$State - -accessible method net/minecraft/screen/ScreenHandlerType register (Ljava/lang/String;Lnet/minecraft/screen/ScreenHandlerType$Factory;)Lnet/minecraft/screen/ScreenHandlerType; -accessible method net/minecraft/client/gui/screen/ingame/HandledScreen handleHotbarKeyPressed (Lnet/minecraft/client/input/KeyInput;)Z - -accessible method net/minecraft/client/Keyboard onKey (JILnet/minecraft/client/input/KeyInput;)V -accessible class net/minecraft/client/MinecraftClient$LoadingContext - -accessible field net/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket type Lnet/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket$InteractTypeHandler; -accessible field net/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket entityId I -accessible class net/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket$InteractType -accessible method net/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket$InteractTypeHandler getType ()Lnet/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket$InteractType; +accessible class net/minecraft/world/entity/projectile/FishingHook$FishHookState +accessible method net/minecraft/client/Minecraft startUseItem ()V +accessible method net/minecraft/client/KeyboardHandler keyPress (JILnet/minecraft/client/input/KeyEvent;)V +accessible method net/minecraft/client/renderer/entity/layers/WingsLayer getPlayerElytraTexture (Lnet/minecraft/client/renderer/entity/state/HumanoidRenderState;)Lnet/minecraft/resources/Identifier; +accessible method net/minecraft/world/inventory/MenuType register (Ljava/lang/String;Lnet/minecraft/world/inventory/MenuType$MenuSupplier;)Lnet/minecraft/world/inventory/MenuType; \ No newline at end of file diff --git a/src/main/resources/sputnik.mixins.json b/src/main/resources/sputnik.mixins.json index 1c74d7f..8919370 100644 --- a/src/main/resources/sputnik.mixins.json +++ b/src/main/resources/sputnik.mixins.json @@ -1,33 +1,33 @@ { "required": true, "package": "me.retucio.sputnik.mixin", - "compatibilityLevel": "JAVA_21", + "compatibilityLevel": "JAVA_25", "mixins": [ - "accessors.AbstractBlockAccessor", - "accessors.ConfirmServerResourcePackScreenAccessor", - "accessors.EntityVelocityUpdateS2CPacketAccessor", - "accessors.ExplosionS2CPacketAccessor", - "accessors.FishingBobberEntityAccessor", - "accessors.PackAccessor", - "accessors.StatusEffectInstanceAccessor", - "mixins.entity.AbstractBoatEntityMixin", + "accessors.BlockBehaviourAccessor", + "accessors.ClientboundExplodePacketAccessor", + "accessors.ClientboundSetEntityMotionPacketAccessor", + "accessors.FishingHookAccessor", + "accessors.MobEffectInstanceAccessor", + "accessors.PackConfirmScreenAccessor", + "accessors.PendingRequestAccessor", + "mixins.entity.AbstractBoatMixin", "mixins.entity.EntityMixin", "mixins.entity.ItemEntityMixin", "mixins.entity.LivingEntityMixin", - "mixins.io.KeyInputMixin", + "mixins.io.KeyboardInputMixin", "mixins.item.ItemMixin", "mixins.item.ItemStackMixin", "mixins.item.TridentItemMixin", - "mixins.misc.StringHelperMixin", - "mixins.misc.Vec3dMixin", - "mixins.network.ClientConnectionMixin", - "mixins.network.HandshakeC2SPacketMixin", + "mixins.misc.StringUtilMixin", + "mixins.misc.Vec3Mixin", + "mixins.network.ClientIntentionPacketMixin", + "mixins.network.ConnectionMixin", "mixins.network.ServerConnectorMixin", "mixins.network.YggdrasilUserApiServiceMixin", - "mixins.player.PlayerEntityMixin", - "mixins.player.PlayerInputMixin", + "mixins.player.PlayerMixin", + "mixins.player.InputMixin", "mixins.player.PlayerInventoryMixin", - "mixins.world.BlockCollisionSpliteratorMixin" + "mixins.world.BlockCollisionsMixin" ], "injectors": { "defaultRequire": 1 @@ -36,71 +36,71 @@ "requireAnnotations": true }, "client": [ + "accessors.AbstractContainerScreenAccessor", "accessors.AbstractSignEditScreenAccessor", "accessors.AnvilScreenAccessor", - "accessors.ClientPlayNetworkHandlerAccessor", - "accessors.HandledScreenAccessor", + "accessors.ClientPacketListenerAccessor", "accessors.KeyBindingAccessor", "accessors.OverlayTextureAccessor", "mixins.entity.EntityRendererMixin", "mixins.hud.BossBarHudMixin", - "mixins.hud.ChatHudInteractableMixin", - "mixins.hud.ChatHudLineConsumerMixin", - "mixins.hud.ChatHudLineMixin", - "mixins.hud.ChatHudLineVisibleMixin", - "mixins.hud.ChatHudMixin", + "mixins.hud.ChatComponentLineConsumerMixin", + "mixins.hud.ChatComponentMixin", + "mixins.hud.DrawingFocusedGraphicsAccessMixin", + "mixins.hud.GuiMessageLineMixin", + "mixins.hud.GuiMessageMixin", "mixins.hud.InGameHudMixin", - "mixins.io.KeyboardMixin", - "mixins.io.MouseMixin", - "mixins.io.ScreenshotRecorderMixin", + "mixins.io.KeyboardHandlerMixin", + "mixins.io.MouseHandlerMixin", + "mixins.io.ScreenshotMixin", "mixins.misc.FontManagerMixin", - "mixins.misc.GameOptionsMixin", - "mixins.misc.MinecraftClientMixin", - "mixins.network.ChatInputSuggestorMixin", - "mixins.network.ClientCommonNetworkHandlerMixin", - "mixins.network.ClientPlayNetworkHandlerMixin", - "mixins.network.MessageHandlerMixin", - "mixins.network.ResourcePackPolicyMixin", - "mixins.network.ServerInfoMixin", - "mixins.network.TelemetryManagerMixin", - "mixins.player.ClientPlayerEntityMixin", - "mixins.player.ClientPlayerInteractionManagerMixin", - "mixins.render.BufferStorageMixin", + "mixins.misc.MinecraftMixin", + "mixins.misc.OptionsMixin", + "mixins.network.ClientCommonPacketListenerImplMixin", + "mixins.network.ClientPacketListenerMixin", + "mixins.network.ClientTelemetryManagerMixin", + "mixins.network.CommandSuggestionsMixin", + "mixins.network.ChatListenerMixin", + "mixins.network.ServerDataMixin", + "mixins.network.ServerPackStatusMixin", + "mixins.player.LocalPlayerMixin", + "mixins.player.MultiPlayerGameModeMixin", + "mixins.render.ArrowLayerMixin", "mixins.render.CameraMixin", - "mixins.render.CapeFeatureRendererMixin", - "mixins.render.ChunkBorderDebugRendererMixin", - "mixins.render.ElytraFeatureRendererMixin", + "mixins.render.CapeLayerMixin", + "mixins.render.ChunkBorderRendererMixin", "mixins.render.EntityHitboxDebugRendererMixin", - "mixins.render.EquipmentRendererMixin", + "mixins.render.EquipmentLayerRendererMixin", "mixins.render.FogRendererMixin", + "mixins.render.FontMixin", "mixins.render.GameRendererMixin", - "mixins.render.HeldItemRendererMixin", - "mixins.render.InGameOverlayRendererMixin", - "mixins.render.ItemRendererMixin", + "mixins.render.ItemFeatureRendererMixin", + "mixins.render.ItemInHandRendererMixin", + "mixins.render.LevelRendererMixin", "mixins.render.LightmapTextureManagerMixin", "mixins.render.LivingEntityRendererMixin", + "mixins.render.MobEffectFogEnvironmentMixin", "mixins.render.OverlayTextureMixin", - "mixins.render.ShaderLoaderMixin", + "mixins.render.PreparedTextBuilderMixin", + "mixins.render.RenderBuffersMixin", + "mixins.render.ScreenEffectRendererMixin", + "mixins.render.ShaderManagerMixin", "mixins.render.SkyRendererMixin", - "mixins.render.StatusEffectFogModifierMixin", - "mixins.render.StuckArrowsFeatureRendererMixin", - "mixins.render.TextRendererDrawerMixin", - "mixins.render.TextRendererMixin", - "mixins.render.WeatherRenderingMixin", - "mixins.render.WorldRendererMixin", + "mixins.render.WeatherEffectRendererMixin", + "mixins.render.WingsLayerMixin", "mixins.screen.ChatScreenMixin", "mixins.screen.ConfirmScreenMixin", - "mixins.screen.CreativeInventoryScreenMixin", + "mixins.screen.CreativeModeInventoryScreenMixin", "mixins.screen.DisconnectedScreenMixin", "mixins.screen.ScreenMixin", - "mixins.world.ChunkOcclusionDataBuilderMixin", - "mixins.world.ClientWorldMixin", - "mixins.world.ClientWorldPropertiesMixin", - "mixins.world.DamageParticleFactoryMixin", - "mixins.world.DamageParticleMixin", - "mixins.world.EmitterParticleMixin", - "mixins.world.ParticleManagerMixin", - "mixins.world.RenderTickCounterDynamicMixin", - "mixins.world.TotemParticleMixin" + "mixins.world.ClientLevelDataMixin", + "mixins.world.ClientLevelMixin", + "mixins.world.CritParticleMixin", + "mixins.world.CritParticleProviderMixin", + "mixins.world.DeltaTrackerTimerMixin", + "mixins.world.ParticleEngineMixin", + "mixins.world.TotemParticleMixin", + "mixins.world.TrackingEmitterMixin", + "mixins.world.VisGraphMixin" ] } \ No newline at end of file