Search in sources :

Example 1 with EventExplosionVelocity

use of me.dustin.jex.event.player.EventExplosionVelocity in project JexClient by DustinRepo.

the class MixinClientPlayNetworkHandler method onExplosion.

@Inject(method = "onExplosion", at = @At("HEAD"), cancellable = true)
public void onExplosion(ExplosionS2CPacket packet, CallbackInfo ci) {
    if (isBotHandler())
        return;
    NetworkThreadUtils.forceMainThread(packet, (ClientPlayNetworkHandler) (Object) this, Wrapper.INSTANCE.getMinecraft());
    Explosion explosion = new Explosion(Wrapper.INSTANCE.getMinecraft().world, (Entity) null, packet.getX(), packet.getY(), packet.getZ(), packet.getRadius(), packet.getAffectedBlocks());
    explosion.affectWorld(true);
    EventExplosionVelocity eventExplosionVelocity = new EventExplosionVelocity().run();
    if (!eventExplosionVelocity.isCancelled())
        Wrapper.INSTANCE.getLocalPlayer().setVelocity(Wrapper.INSTANCE.getLocalPlayer().getVelocity().add((double) packet.getPlayerVelocityX() * eventExplosionVelocity.getMultX(), (double) packet.getPlayerVelocityY() * eventExplosionVelocity.getMultY(), (double) packet.getPlayerVelocityZ() * eventExplosionVelocity.getMultZ()));
    ci.cancel();
}
Also used : EventExplosionVelocity(me.dustin.jex.event.player.EventExplosionVelocity) Explosion(net.minecraft.world.explosion.Explosion) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

EventExplosionVelocity (me.dustin.jex.event.player.EventExplosionVelocity)1 Explosion (net.minecraft.world.explosion.Explosion)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1