add hint to speed meter
This commit is contained in:
2 files changed
+15
-5
No files matched your search
@@ -11,7 +11,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(PlayerEntity.class)
|
||||
public abstract class PlayerEntityMixin {
|
||||
private static final int THRESHLD_OF_ELYTRA_FLY = 2;
|
||||
@Unique
|
||||
private long flyTime;
|
||||
|
||||
@@ -19,10 +18,7 @@ public abstract class PlayerEntityMixin {
|
||||
public void tickMovement(CallbackInfo ci) {
|
||||
var eb = ((EntityBridge) $this());
|
||||
if (eb.sfcraft$getFlag(EntityBridge.sfcraft$getFlyingFlagIndex())) {
|
||||
flyTime++;
|
||||
if (flyTime > 20 * THRESHLD_OF_ELYTRA_FLY) { // todo config
|
||||
SFCallbacks.PLAYER_FLYING.invoker().onFlyingTick($this(), flyTime - 20*THRESHLD_OF_ELYTRA_FLY, true);
|
||||
}
|
||||
SFCallbacks.PLAYER_FLYING.invoker().onFlyingTick($this(), flyTime++, true);
|
||||
} else {
|
||||
if (flyTime != 0) {
|
||||
SFCallbacks.PLAYER_FLYING.invoker().onFlyingTick($this(), flyTime, false);
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Colors;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
import java.awt.*;
|
||||
import java.text.DecimalFormat;
|
||||
@@ -21,8 +22,10 @@ import java.text.DecimalFormat;
|
||||
public class ElytraSpeedMeterModule extends ServerModule {
|
||||
private static final int BAR_LEN = 20;
|
||||
private static final int MAX_NORMAL_SPEED = 6;
|
||||
private static final int THRESHLD_OF_ELYTRA_FLY = 8;
|
||||
private static final Color BAR_LEFT = new Color(85, 85, 255);
|
||||
private static final Color BAR_RIGHT = new Color(255, 87, 51);
|
||||
private static final Text KEEP_FLYING = Text.literal("... 保持飞行以启动仪表盘 ...").withColor(Colors.LIGHT_GRAY);
|
||||
private static final Text[] ELYTRA_DURABILITY = new Text[100];
|
||||
private static final Text[] PROGRESS_BARS = new Text[BAR_LEN];
|
||||
private static final Text[] Y_METER = new Text[256];
|
||||
@@ -57,6 +60,12 @@ public class ElytraSpeedMeterModule extends ServerModule {
|
||||
}
|
||||
|
||||
private void onFlying(PlayerEntity player, long f, boolean b) {
|
||||
if (f < THRESHLD_OF_ELYTRA_FLY * 20) {
|
||||
if (f > THRESHLD_OF_ELYTRA_FLY * 15) {
|
||||
player.sendMessage(KEEP_FLYING,true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (b) {
|
||||
var text = Text.literal("");
|
||||
text.append(generateYMeter(f, player));
|
||||
@@ -65,6 +74,11 @@ public class ElytraSpeedMeterModule extends ServerModule {
|
||||
player.sendMessage(text, true);
|
||||
} else {
|
||||
clean((ServerPlayerEntity) player);
|
||||
if (f > THRESHLD_OF_ELYTRA_FLY * 20) {
|
||||
player.sendMessage(Text.literal("!! LANDED !!").withColor(Colors.GREEN), true);
|
||||
}else{
|
||||
player.sendMessage(Text.empty(),true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user