forked from Clones/Controlify
remove deprecated api in rumble mixins
This commit is contained in:
@ -16,7 +16,7 @@ public record GamepadDrivers(BasicGamepadInputDriver basicGamepadInputDriver, Gy
|
||||
|
||||
public void printDrivers() {
|
||||
if (DebugProperties.PRINT_DRIVER) {
|
||||
Controlify.LOGGER.info("Drivers in use: Basic Input = {}, Gyro = {}, Rumble = {}",
|
||||
Controlify.LOGGER.info("Drivers in use: Basic Input = '{}', Gyro = '{}', Rumble = '{}'",
|
||||
basicGamepadInputDriver.getBasicGamepadDetails(),
|
||||
gyroDriver.getGyroDetails(),
|
||||
rumbleDriver.getRumbleDetails()
|
||||
|
@ -64,7 +64,8 @@ public class MultiPlayerGameModeMixin {
|
||||
.build();
|
||||
|
||||
blockBreakRumble = effect;
|
||||
ControlifyApi.get().currentController().rumbleManager().play(RumbleSource.BLOCK_DESTROY, effect);
|
||||
ControlifyApi.get().getCurrentController()
|
||||
.ifPresent(controller -> controller.rumbleManager().play(RumbleSource.BLOCK_DESTROY, effect));
|
||||
}
|
||||
|
||||
private void stopRumble() {
|
||||
|
@ -34,11 +34,10 @@ public abstract class LocalPlayerMixin extends AbstractClientPlayer {
|
||||
float maxDamage = 15; // the damage that results in magnitude 1.0f
|
||||
|
||||
float magnitude = (Mth.clamp(damageTaken, smallestDamage, maxDamage) - smallestDamage) / (maxDamage - smallestDamage) * (1 - minMagnitude) + minMagnitude;
|
||||
System.out.println(magnitude);
|
||||
ControlifyApi.get().currentController().rumbleManager().play(
|
||||
ControlifyApi.get().getCurrentController().ifPresent(controller -> controller.rumbleManager().play(
|
||||
RumbleSource.DAMAGE,
|
||||
BasicRumbleEffect.constant(magnitude, 0f, magnitude >= 0.75f ? 8 : 5)
|
||||
);
|
||||
));
|
||||
}
|
||||
// skip first tick from spawn
|
||||
skipTick = false;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package dev.isxander.controlify.mixins.feature.rumble.explosion;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import dev.isxander.controlify.api.ControlifyApi;
|
||||
import dev.isxander.controlify.rumble.BasicRumbleEffect;
|
||||
import dev.isxander.controlify.rumble.RumbleSource;
|
||||
@ -9,7 +8,6 @@ import dev.isxander.controlify.utils.Easings;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.network.protocol.game.ClientboundExplodePacket;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -25,7 +23,7 @@ public class ClientPacketListenerMixin {
|
||||
private void onClientExplosion(ClientboundExplodePacket packet, CallbackInfo ci) {
|
||||
float initialMagnitude = calculateMagnitude(packet);
|
||||
|
||||
ControlifyApi.get().currentController().rumbleManager().play(
|
||||
ControlifyApi.get().getCurrentController().ifPresent(controller -> controller.rumbleManager().play(
|
||||
RumbleSource.EXPLOSION,
|
||||
BasicRumbleEffect.join(
|
||||
BasicRumbleEffect.constant(initialMagnitude, initialMagnitude, 4), // initial boom
|
||||
@ -34,7 +32,7 @@ public class ClientPacketListenerMixin {
|
||||
return new RumbleState(0f, magnitude - t * magnitude);
|
||||
}, 20) // explosion
|
||||
)
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
private float calculateMagnitude(ClientboundExplodePacket packet) {
|
||||
|
@ -14,13 +14,13 @@ public class LightningBoltMixin {
|
||||
@ModifyExpressionValue(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;isClientSide()Z"))
|
||||
private boolean onLightningStrike(boolean client) {
|
||||
if (client) {
|
||||
ControlifyApi.get().currentController().rumbleManager().play(
|
||||
ControlifyApi.get().getCurrentController().ifPresent(controller -> controller.rumbleManager().play(
|
||||
RumbleSource.EXPLOSION,
|
||||
BasicRumbleEffect.join(
|
||||
BasicRumbleEffect.constant(1f, 0.2f, 6), // initial boom
|
||||
BasicRumbleEffect.byTime(t -> new RumbleState(0f, 1 - t*0.2f), 10) // explosion
|
||||
)
|
||||
);
|
||||
));
|
||||
}
|
||||
return client;
|
||||
}
|
||||
|
@ -27,10 +27,13 @@ public class FishingHookMixin {
|
||||
var biting = (boolean) bitingObj;
|
||||
if (isLocalPlayerHook) {
|
||||
if (biting && !this.biting) {
|
||||
bitingRumble = ContinuousRumbleEffect.builder()
|
||||
.constant(0f, 0.05f)
|
||||
.build();
|
||||
ControlifyApi.get().currentController().rumbleManager().play(RumbleSource.MISC, bitingRumble);
|
||||
ControlifyApi.get().getCurrentController().ifPresent(controller -> {
|
||||
bitingRumble = ContinuousRumbleEffect.builder()
|
||||
.constant(0f, 0.05f)
|
||||
.build();
|
||||
|
||||
controller.rumbleManager().play(RumbleSource.MISC, bitingRumble);
|
||||
});
|
||||
} else if (!biting && this.biting) {
|
||||
stopBitingRumble();
|
||||
}
|
||||
|
@ -14,9 +14,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
public class LocalPlayerMixin extends LivingEntityMixin {
|
||||
@Override
|
||||
protected void onBreakItemParticles(ItemStack stack, CallbackInfo ci) {
|
||||
ControlifyApi.get().currentController().rumbleManager().play(
|
||||
ControlifyApi.get().getCurrentController().ifPresent(controller -> controller.rumbleManager().play(
|
||||
RumbleSource.ITEM_BREAK,
|
||||
BasicRumbleEffect.byTick(tick -> new RumbleState(tick <= 4 ? 1f : 0f, 1f), 10)
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,6 @@ public class LevelRendererMixin {
|
||||
}
|
||||
|
||||
private void rumble(RumbleSource source, RumbleEffect effect) {
|
||||
ControlifyApi.get().currentController().rumbleManager().play(source, effect);
|
||||
ControlifyApi.get().getCurrentController().ifPresent(controller -> controller.rumbleManager().play(source, effect));
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,9 @@ public abstract class LocalPlayerMixin extends LivingEntityMixin {
|
||||
}
|
||||
|
||||
private void startRumble(ContinuousRumbleEffect effect) {
|
||||
ControlifyApi.get().currentController().rumbleManager().play(RumbleSource.USE_ITEM, effect);
|
||||
useItemRumble = effect;
|
||||
ControlifyApi.get().getCurrentController().ifPresent(controller -> {
|
||||
controller.rumbleManager().play(RumbleSource.USE_ITEM, effect);
|
||||
useItemRumble = effect;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user