| 1 | /*
|
| 2 | * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
|
| 3 | * Copyright (c) Meteor Development.
|
| 4 | */
|
| 5 |
|
| 6 | package meteordevelopment.meteorclient.mixin;
|
| 7 |
|
| 8 | import meteordevelopment.meteorclient.mixininterface.IClientboundExplodePacket;
|
| 9 | import net.minecraft.network.protocol.game.ClientboundExplodePacket;
|
| 10 | import net.minecraft.world.phys.Vec3;
|
| 11 | import org.spongepowered.asm.mixin.Final;
|
| 12 | import org.spongepowered.asm.mixin.Mixin;
|
| 13 | import org.spongepowered.asm.mixin.Mutable;
|
| 14 | import org.spongepowered.asm.mixin.Shadow;
|
| 15 |
|
| 16 | import java.util.Optional;
|
| 17 |
|
| 18 | @Mixin(ClientboundExplodePacket.class)
|
| 19 | public abstract class ClientboundExplodePacketMixin implements IClientboundExplodePacket {
|
| 20 | @Shadow
|
| 21 | @Final
|
| 22 | @Mutable
|
| 23 | private Optional<Vec3> playerKnockback;
|
| 24 |
|
| 25 | @Override
|
| 26 | public void meteor$setVelocityX(float velocity) {
|
| 27 | if (playerKnockback.isPresent()) {
|
| 28 | Vec3 kb = playerKnockback.get();
|
| 29 | playerKnockback = Optional.of(new Vec3(velocity, kb.y, kb.z));
|
| 30 | } else {
|
| 31 | playerKnockback = Optional.of(new Vec3(velocity, 0, 0));
|
| 32 | }
|
| 33 | }
|
| 34 |
|
| 35 | @Override
|
| 36 | public void meteor$setVelocityY(float velocity) {
|
| 37 | if (playerKnockback.isPresent()) {
|
| 38 | Vec3 kb = playerKnockback.get();
|
| 39 | playerKnockback = Optional.of(new Vec3(kb.x, velocity, kb.z));
|
| 40 | } else {
|
| 41 | playerKnockback = Optional.of(new Vec3(0, velocity, 0));
|
| 42 | }
|
| 43 | }
|
| 44 |
|
| 45 | @Override
|
| 46 | public void meteor$setVelocityZ(float velocity) {
|
| 47 | if (playerKnockback.isPresent()) {
|
| 48 | Vec3 kb = playerKnockback.get();
|
| 49 | playerKnockback = Optional.of(new Vec3(kb.x, kb.y, velocity));
|
| 50 | } else {
|
| 51 | playerKnockback = Optional.of(new Vec3(0, 0, velocity));
|
| 52 | }
|
| 53 | }
|
| 54 | }
|
| 55 |
|