Add client bootstrap and packet handlers; refine sanity/insanity clamping logic
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
package net.fretux.mindmotion.client;
|
||||
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
|
||||
public final class ClientBootstrap {
|
||||
private ClientBootstrap() {
|
||||
}
|
||||
|
||||
public static void init(IEventBus modEventBus) {
|
||||
modEventBus.addListener(Keybinds::register);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package net.fretux.mindmotion.client;
|
||||
|
||||
import net.fretux.mindmotion.client.shader.VentShaderHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public final class ClientPacketHandlers {
|
||||
private ClientPacketHandlers() {
|
||||
}
|
||||
|
||||
public static void handleVentEffect() {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
if (mc.player == null) {
|
||||
return;
|
||||
}
|
||||
mc.player.swingTime = 10;
|
||||
VentShaderHandler.triggerVentShockwave();
|
||||
}
|
||||
}
|
||||
@@ -155,10 +155,6 @@ public class PlayerTickHandler {
|
||||
if (isInsane) {
|
||||
if (delta > 0) {
|
||||
sanity.setInsanity(Math.max(0, insanity - delta));
|
||||
insanity = sanity.getInsanity();
|
||||
if (insanity <= 0) {
|
||||
sanity.setSanity(Math.min(sanity.getMaxSanity(), value + delta));
|
||||
}
|
||||
return;
|
||||
}
|
||||
float newValue = value + delta;
|
||||
|
||||
@@ -14,7 +14,11 @@ public class SanityCapability implements ISanity {
|
||||
@Override
|
||||
public void setSanity(float sanity) {
|
||||
float max = getMaxSanity();
|
||||
this.sanity = Math.max(0, Math.min(max, sanity));
|
||||
float clampedSanity = Math.max(0, Math.min(max, sanity));
|
||||
if (clampedSanity > this.sanity && this.insanity > 0f) {
|
||||
return;
|
||||
}
|
||||
this.sanity = clampedSanity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -25,7 +29,11 @@ public class SanityCapability implements ISanity {
|
||||
@Override
|
||||
public void setInsanity(float insanity) {
|
||||
float max = getMaxSanity();
|
||||
this.insanity = Math.max(0, Math.min(max, insanity));
|
||||
float clampedInsanity = Math.max(0, Math.min(max, insanity));
|
||||
if (clampedInsanity > this.insanity && this.sanity > 0f) {
|
||||
return;
|
||||
}
|
||||
this.insanity = clampedInsanity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,4 +72,4 @@ public class SanityCapability implements ISanity {
|
||||
public float getBonusMaxSanity() {
|
||||
return bonusMaxSanity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user