|
12 | 12 | import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; |
13 | 13 | import com.llamalad7.mixinextras.sugar.Local; |
14 | 14 | import meteordevelopment.meteorclient.MeteorClient; |
| 15 | +import meteordevelopment.meteorclient.events.entity.player.DoItemUseEvent; |
15 | 16 | import meteordevelopment.meteorclient.events.entity.player.ItemUseCrosshairTargetEvent; |
16 | 17 | import meteordevelopment.meteorclient.events.game.GameLeftEvent; |
17 | 18 | import meteordevelopment.meteorclient.events.game.OpenScreenEvent; |
|
44 | 45 | import net.minecraft.entity.Entity; |
45 | 46 | import net.minecraft.entity.player.PlayerEntity; |
46 | 47 | import net.minecraft.item.ItemStack; |
47 | | -import net.minecraft.resource.ReloadableResourceManagerImpl; |
48 | 48 | import net.minecraft.util.hit.HitResult; |
49 | 49 | import net.minecraft.util.profiler.Profilers; |
50 | 50 | import org.jetbrains.annotations.Nullable; |
@@ -84,10 +84,6 @@ public abstract class MinecraftClientMixin implements IMinecraftClient { |
84 | 84 | @Nullable |
85 | 85 | public ClientPlayerEntity player; |
86 | 86 |
|
87 | | - @Shadow |
88 | | - @Final |
89 | | - private ReloadableResourceManagerImpl resourceManager; |
90 | | - |
91 | 87 | @Shadow |
92 | 88 | @Final |
93 | 89 | @Mutable |
@@ -182,6 +178,11 @@ private void onDoItemUseHand(CallbackInfo ci, @Local ItemStack itemStack) { |
182 | 178 | } |
183 | 179 | } |
184 | 180 |
|
| 181 | + @Inject(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Hand;values()[Lnet/minecraft/util/Hand;"), cancellable = true) |
| 182 | + private void onDoItemUseBeforeHands(CallbackInfo ci) { |
| 183 | + if (MeteorClient.EVENT_BUS.post(DoItemUseEvent.get()).isCancelled()) ci.cancel(); |
| 184 | + } |
| 185 | + |
185 | 186 | @ModifyExpressionValue(method = "doItemUse", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;crosshairTarget:Lnet/minecraft/util/hit/HitResult;", ordinal = 1)) |
186 | 187 | private HitResult doItemUseMinecraftClientCrosshairTargetProxy(HitResult original) { |
187 | 188 | return MeteorClient.EVENT_BUS.post(ItemUseCrosshairTargetEvent.get(original)).target; |
@@ -260,6 +261,7 @@ private boolean handleInputEventsModifyIsUsingItem(boolean original) { |
260 | 261 | private void handleInputEventsInjectStopUsingItem(CallbackInfo info) { |
261 | 262 | if (Modules.get().get(Multitask.class).attackingEntities() && player.isUsingItem()) { |
262 | 263 | if (!options.useKey.isPressed() && HB$stopUsingItem()) interactionManager.stopUsingItem(player); |
| 264 | + //noinspection StatementWithEmptyBody |
263 | 265 | while (options.useKey.wasPressed()); |
264 | 266 | } |
265 | 267 | } |
|
0 commit comments