From d8cd235aeb283627708a7c376003281fd35d4bb1 Mon Sep 17 00:00:00 2001 From: enjarai Date: Mon, 16 Sep 2024 23:17:12 +0200 Subject: [PATCH] Cool stuff tho!! --- .../minitardis/component/FlightWave.java | 50 +++++++++++++++++ .../enjarai/minitardis/component/Tardis.java | 12 +++++ .../minitardis/component/TardisControl.java | 2 +- .../minitardis/component/TardisHolder.java | 5 ++ ...dState.java => BeingInterdictedState.java} | 15 +++--- .../component/flight/FlightState.java | 10 ++-- .../component/flight/FlyingState.java | 12 +++-- ...nterceptState.java => InterdictState.java} | 10 ++-- ...ptingState.java => InterdictingState.java} | 16 +++--- .../flight/SuspendedFlightState.java | 7 ++- .../component/screen/app/InterdictorApp.java | 51 ++++++++++++++++++ .../component/screen/app/ScreenAppTypes.java | 1 + .../component/screen/app/StatusApp.java | 18 +++---- .../screen/canvas/patbox/DrawableCanvas.java | 31 +++++++++++ .../assets/mini_tardis/lang/en_us.json | 5 +- .../textures/map/interdictor_background.png | Bin 0 -> 1000 bytes 16 files changed, 203 insertions(+), 42 deletions(-) create mode 100644 src/main/java/dev/enjarai/minitardis/component/FlightWave.java rename src/main/java/dev/enjarai/minitardis/component/flight/{BeingInterceptedState.java => BeingInterdictedState.java} (87%) rename src/main/java/dev/enjarai/minitardis/component/flight/{InterceptState.java => InterdictState.java} (94%) rename src/main/java/dev/enjarai/minitardis/component/flight/{InterceptingState.java => InterdictingState.java} (84%) create mode 100644 src/main/java/dev/enjarai/minitardis/component/screen/app/InterdictorApp.java create mode 100644 src/main/resources/data/mini_tardis/textures/map/interdictor_background.png diff --git a/src/main/java/dev/enjarai/minitardis/component/FlightWave.java b/src/main/java/dev/enjarai/minitardis/component/FlightWave.java new file mode 100644 index 0000000..88d14d0 --- /dev/null +++ b/src/main/java/dev/enjarai/minitardis/component/FlightWave.java @@ -0,0 +1,50 @@ +package dev.enjarai.minitardis.component; + +import net.minecraft.util.math.random.Random; + +public class FlightWave { + private double magnitude; + private double period; + private double offset; + + public FlightWave(double magnitude, double period, double offset) { + this.magnitude = magnitude; + this.period = period; + this.offset = offset; + } + + public FlightWave(Random random) { + this(0, 0, 0); + shuffle(random); + } + + public void shuffle(Random random) { + magnitude = 0.2 + random.nextDouble() * 0.8; + period = 0.2 + random.nextDouble() * 0.8; + offset = random.nextDouble(); + } + + public double getMagnitude() { + return magnitude; + } + + public double getPeriod() { + return period; + } + + public double getOffset() { + return offset; + } + + public void setMagnitude(double magnitude) { + this.magnitude = magnitude; + } + + public void setPeriod(double period) { + this.period = period; + } + + public void setOffset(double offset) { + this.offset = offset; + } +} diff --git a/src/main/java/dev/enjarai/minitardis/component/Tardis.java b/src/main/java/dev/enjarai/minitardis/component/Tardis.java index b689e9e..e195f6f 100644 --- a/src/main/java/dev/enjarai/minitardis/component/Tardis.java +++ b/src/main/java/dev/enjarai/minitardis/component/Tardis.java @@ -82,6 +82,7 @@ public class Tardis { private int stability; private int fuel; private boolean doorOpen; + private FlightWave flightWave; private Tardis(UUID uuid, boolean interiorPlaced, Identifier interior, Either currentLocation, Optional destination, BlockPos interiorDoorPosition, TardisControl controls, FlightState state, int stability, int fuel, boolean doorOpen) { this.uuid = uuid; @@ -143,6 +144,10 @@ public void tick() { world.getChunkManager().addTicket(INTERIOR_TICKET_TYPE, new ChunkPos(interiorDoorPosition), 1, interiorDoorPosition); } + if (flightWave == null) { + flightWave = new FlightWave(getRandom()); + } + var newState = state.tick(this); var shake = state.getScreenShakeIntensity(this); applyScreenShake(shake, shake > 0 ? 1 : 0); @@ -496,6 +501,13 @@ public boolean setDoorOpen(boolean open, boolean force) { return true; } + public FlightWave getFlightWave() { + if (flightWave == null) { + return new FlightWave(0, 0, 0); + } + return flightWave; + } + public void createInteriorSparks(boolean damage) { findSparkPos().ifPresent(pos -> { var world = getInteriorWorld(); diff --git a/src/main/java/dev/enjarai/minitardis/component/TardisControl.java b/src/main/java/dev/enjarai/minitardis/component/TardisControl.java index 7ae5cb5..4f386fc 100644 --- a/src/main/java/dev/enjarai/minitardis/component/TardisControl.java +++ b/src/main/java/dev/enjarai/minitardis/component/TardisControl.java @@ -136,7 +136,7 @@ public boolean rotateDestination(Direction direction) { public boolean handbrake(boolean state) { if (!state && tardis.getState() instanceof FlyingState && !isDestinationLocked()) { return tardis.getDestinationTardis() - .map(otherTardis -> tardis.suggestStateTransition(new InterceptingState(otherTardis.uuid()))) + .map(otherTardis -> tardis.suggestStateTransition(new InterdictingState(otherTardis.uuid()))) .orElseGet(() -> tardis.suggestStateTransition(new DriftingState())); } else if (tardis.getState() instanceof RespondsToFlyLever respondingState) { return respondingState.toggleFlyLever(tardis, state) || tardis.suggestStateTransition(new FlyingState(tardis.getRandom().nextInt())); diff --git a/src/main/java/dev/enjarai/minitardis/component/TardisHolder.java b/src/main/java/dev/enjarai/minitardis/component/TardisHolder.java index 3eb85c7..d1d085c 100644 --- a/src/main/java/dev/enjarai/minitardis/component/TardisHolder.java +++ b/src/main/java/dev/enjarai/minitardis/component/TardisHolder.java @@ -13,6 +13,7 @@ import xyz.nucleoid.fantasy.Fantasy; import java.util.*; +import java.util.stream.Collectors; public class TardisHolder implements ServerTickingComponent { private MinecraftServer server; @@ -54,6 +55,10 @@ public Set getAllTardii() { return ImmutableSet.copyOf(tardii.values()); } + public Set getInterdictableTardii() { + return tardii.values().stream().filter(t -> t.getState().canBeInterdicted(t)).collect(Collectors.toSet()); + } + @Override public void serverTick() { tardii.values().forEach(Tardis::tick); diff --git a/src/main/java/dev/enjarai/minitardis/component/flight/BeingInterceptedState.java b/src/main/java/dev/enjarai/minitardis/component/flight/BeingInterdictedState.java similarity index 87% rename from src/main/java/dev/enjarai/minitardis/component/flight/BeingInterceptedState.java rename to src/main/java/dev/enjarai/minitardis/component/flight/BeingInterdictedState.java index ccdc4f3..2158a8d 100644 --- a/src/main/java/dev/enjarai/minitardis/component/flight/BeingInterceptedState.java +++ b/src/main/java/dev/enjarai/minitardis/component/flight/BeingInterdictedState.java @@ -5,7 +5,6 @@ import com.mojang.serialization.codecs.RecordCodecBuilder; import dev.enjarai.minitardis.MiniTardis; import dev.enjarai.minitardis.ModSounds; -import dev.enjarai.minitardis.component.PartialTardisLocation; import dev.enjarai.minitardis.component.Tardis; import net.minecraft.sound.SoundCategory; import net.minecraft.util.Identifier; @@ -13,8 +12,8 @@ import java.util.UUID; -public class BeingInterceptedState extends InterceptState { - public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( +public class BeingInterdictedState extends InterdictState { + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( Uuids.CODEC.fieldOf("other_tardis").forGetter(s -> s.otherTardis), Codec.INT.fieldOf("flying_ticks").forGetter(s -> s.flyingTicks), Codec.INT.fieldOf("phases_complete").forGetter(s -> s.phasesComplete), @@ -23,19 +22,19 @@ public class BeingInterceptedState extends InterceptState { Codec.INT.fieldOf("offset_y").forGetter(s -> s.offsetY), Codec.INT.fieldOf("target_x").forGetter(s -> s.targetX), Codec.INT.fieldOf("target_y").forGetter(s -> s.targetY) - ).apply(instance, BeingInterceptedState::new)); - public static final Identifier ID = MiniTardis.id("being_intercepted"); + ).apply(instance, BeingInterdictedState::new)); + public static final Identifier ID = MiniTardis.id("being_interdicted"); private int targetX; private int targetY; - protected BeingInterceptedState(UUID otherTardis, int flyingTicks, int phasesComplete, int phaseTicks, int offsetX, int offsetY, int targetX, int targetY) { + protected BeingInterdictedState(UUID otherTardis, int flyingTicks, int phasesComplete, int phaseTicks, int offsetX, int offsetY, int targetX, int targetY) { super(otherTardis, flyingTicks, phasesComplete, phaseTicks, offsetX, offsetY); this.targetX = targetX; this.targetY = targetY; } - public BeingInterceptedState(UUID otherTardis) { + public BeingInterdictedState(UUID otherTardis) { super(otherTardis); } @@ -58,7 +57,7 @@ public FlightState tick(Tardis tardis) { } var other = tardis.getHolder().getTardis(otherTardis); - if (other.flatMap(t -> t.getState(InterceptState.class)).isEmpty()) { + if (other.flatMap(t -> t.getState(InterdictState.class)).isEmpty()) { tardis.getControls().moderateMalfunction(); return new FlyingState(tardis.getRandom().nextInt()); } diff --git a/src/main/java/dev/enjarai/minitardis/component/flight/FlightState.java b/src/main/java/dev/enjarai/minitardis/component/flight/FlightState.java index 81cde1b..8e9ae13 100644 --- a/src/main/java/dev/enjarai/minitardis/component/flight/FlightState.java +++ b/src/main/java/dev/enjarai/minitardis/component/flight/FlightState.java @@ -2,12 +2,10 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.MapCodec; -import dev.enjarai.minitardis.ModCCAComponents; import dev.enjarai.minitardis.block.console.ScreenBlockEntity; import dev.enjarai.minitardis.component.Tardis; import dev.enjarai.minitardis.component.TardisControl; import dev.enjarai.minitardis.component.screen.canvas.patbox.DrawableCanvas; -import net.minecraft.network.packet.s2c.play.PositionFlag; import net.minecraft.network.packet.s2c.play.StopSoundS2CPacket; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvent; @@ -31,8 +29,8 @@ public interface FlightState { Map.entry(BootingUpState.ID, BootingUpState.CODEC), Map.entry(CrashedState.ID, CrashedState.CODEC), Map.entry(SuspendedFlightState.ID, SuspendedFlightState.CODEC), - Map.entry(InterceptingState.ID, InterceptingState.CODEC), - Map.entry(BeingInterceptedState.ID, BeingInterceptedState.CODEC) + Map.entry(InterdictingState.ID, InterdictingState.CODEC), + Map.entry(BeingInterdictedState.ID, BeingInterdictedState.CODEC) ); Map> CONSTRUCTORS = Map.of( LandedState.ID, LandedState::new, @@ -98,6 +96,10 @@ default boolean overrideScreenImage(Tardis tardis) { return false; } + default boolean canBeInterdicted(Tardis tardis) { + return false; + } + /** * The function that will be used to draw the custom screen image if `overrideScreenImage` returns true. */ diff --git a/src/main/java/dev/enjarai/minitardis/component/flight/FlyingState.java b/src/main/java/dev/enjarai/minitardis/component/flight/FlyingState.java index f476f45..7d652f3 100644 --- a/src/main/java/dev/enjarai/minitardis/component/flight/FlyingState.java +++ b/src/main/java/dev/enjarai/minitardis/component/flight/FlyingState.java @@ -5,7 +5,6 @@ import com.mojang.serialization.codecs.RecordCodecBuilder; import dev.enjarai.minitardis.MiniTardis; import dev.enjarai.minitardis.ModSounds; -import dev.enjarai.minitardis.component.PartialTardisLocation; import dev.enjarai.minitardis.component.Tardis; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; @@ -119,10 +118,10 @@ public boolean suggestTransition(Tardis tardis, FlightState newState) { } else if (newState instanceof DriftingState driftingState) { driftingState.flyingTicks = flyingTicks; return true; - } else if (newState instanceof InterceptingState interceptingState) { - interceptingState.flyingTicks = flyingTicks; + } else if (newState instanceof InterdictingState interdictingState) { + interdictingState.flyingTicks = flyingTicks; return true; - } else if (newState instanceof BeingInterceptedState interceptedState) { + } else if (newState instanceof BeingInterdictedState interceptedState) { interceptedState.flyingTicks = flyingTicks; return true; } else if (newState instanceof SuspendedFlightState suspendedFlightState) { @@ -175,6 +174,11 @@ public boolean isSolid(Tardis tardis) { return false; } + @Override + public boolean canBeInterdicted(Tardis tardis) { + return true; + } + @Override public boolean isInteriorLightEnabled(int order) { return spinnyLighting(order, flyingTicks); diff --git a/src/main/java/dev/enjarai/minitardis/component/flight/InterceptState.java b/src/main/java/dev/enjarai/minitardis/component/flight/InterdictState.java similarity index 94% rename from src/main/java/dev/enjarai/minitardis/component/flight/InterceptState.java rename to src/main/java/dev/enjarai/minitardis/component/flight/InterdictState.java index 50a0260..4e1635c 100644 --- a/src/main/java/dev/enjarai/minitardis/component/flight/InterceptState.java +++ b/src/main/java/dev/enjarai/minitardis/component/flight/InterdictState.java @@ -11,7 +11,7 @@ import static dev.enjarai.minitardis.component.flight.FlyingState.SOUND_LOOP_LENGTH; -public abstract class InterceptState implements FlightState, RespondsToFlyLever, RespondsToNudging { +public abstract class InterdictState implements FlightState, RespondsToFlyLever, RespondsToNudging { public static final int PHASES = 6; public static final int MAX_X_OFFSET = 4; public static final int MAX_Y_OFFSET = 2; @@ -23,7 +23,7 @@ public abstract class InterceptState implements FlightState, RespondsToFlyLever, protected int offsetX; protected int offsetY; - protected InterceptState(UUID otherTardis, int flyingTicks, int phasesComplete, int phaseTicks, int offsetX, int offsetY) { + protected InterdictState(UUID otherTardis, int flyingTicks, int phasesComplete, int phaseTicks, int offsetX, int offsetY) { this.otherTardis = otherTardis; this.flyingTicks = flyingTicks; this.phasesComplete = phasesComplete; @@ -32,7 +32,7 @@ protected InterceptState(UUID otherTardis, int flyingTicks, int phasesComplete, this.offsetY = offsetY; } - public InterceptState(UUID otherTardis) { + public InterdictState(UUID otherTardis) { this(otherTardis, 0, 0, 0, 0, 0); } @@ -134,8 +134,8 @@ public int getPhasesComplete() { return phasesComplete; } - public Optional getLinkedState(Tardis tardis) { - return tardis.getHolder().getTardis(otherTardis).flatMap(t -> t.getState(InterceptState.class)); + public Optional getLinkedState(Tardis tardis) { + return tardis.getHolder().getTardis(otherTardis).flatMap(t -> t.getState(InterdictState.class)); } @Override diff --git a/src/main/java/dev/enjarai/minitardis/component/flight/InterceptingState.java b/src/main/java/dev/enjarai/minitardis/component/flight/InterdictingState.java similarity index 84% rename from src/main/java/dev/enjarai/minitardis/component/flight/InterceptingState.java rename to src/main/java/dev/enjarai/minitardis/component/flight/InterdictingState.java index a58070e..333c951 100644 --- a/src/main/java/dev/enjarai/minitardis/component/flight/InterceptingState.java +++ b/src/main/java/dev/enjarai/minitardis/component/flight/InterdictingState.java @@ -11,22 +11,22 @@ import java.util.UUID; -public class InterceptingState extends InterceptState { - public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( +public class InterdictingState extends InterdictState { + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( Uuids.CODEC.fieldOf("other_tardis").forGetter(s -> s.otherTardis), Codec.INT.fieldOf("flying_ticks").forGetter(s -> s.flyingTicks), Codec.INT.fieldOf("phases_complete").forGetter(s -> s.phasesComplete), Codec.INT.fieldOf("phase_ticks").forGetter(s -> s.phaseTicks), Codec.INT.fieldOf("offset_x").forGetter(s -> s.offsetX), Codec.INT.fieldOf("offset_y").forGetter(s -> s.offsetY) - ).apply(instance, InterceptingState::new)); - public static final Identifier ID = MiniTardis.id("intercepting"); + ).apply(instance, InterdictingState::new)); + public static final Identifier ID = MiniTardis.id("interdicting"); - protected InterceptingState(UUID otherTardis, int flyingTicks, int phasesComplete, int phaseTicks, int offsetX, int offsetY) { + protected InterdictingState(UUID otherTardis, int flyingTicks, int phasesComplete, int phaseTicks, int offsetX, int offsetY) { super(otherTardis, flyingTicks, phasesComplete, phaseTicks, offsetX, offsetY); } - public InterceptingState(UUID otherTardis) { + public InterdictingState(UUID otherTardis) { super(otherTardis); } @@ -38,8 +38,8 @@ public FlightState tick(Tardis tardis) { return new SearchingForLandingState(true, tardis.getRandom().nextInt()); } - if (other.get().getState(BeingInterceptedState.class).isEmpty()) { - if (!other.get().suggestStateTransition(new BeingInterceptedState(tardis.uuid()))) { + if (other.get().getState(BeingInterdictedState.class).isEmpty()) { + if (!other.get().suggestStateTransition(new BeingInterdictedState(tardis.uuid()))) { tardis.getControls().moderateMalfunction(); return new FlyingState(tardis.getRandom().nextInt()); } diff --git a/src/main/java/dev/enjarai/minitardis/component/flight/SuspendedFlightState.java b/src/main/java/dev/enjarai/minitardis/component/flight/SuspendedFlightState.java index 78f64d8..e30814c 100644 --- a/src/main/java/dev/enjarai/minitardis/component/flight/SuspendedFlightState.java +++ b/src/main/java/dev/enjarai/minitardis/component/flight/SuspendedFlightState.java @@ -85,7 +85,7 @@ public boolean suggestTransition(Tardis tardis, FlightState newState) { } else if (newState instanceof DriftingState driftingState) { driftingState.flyingTicks = flyingTicks; return true; - } else if (newState instanceof BeingInterceptedState interceptedState) { + } else if (newState instanceof BeingInterdictedState interceptedState) { interceptedState.flyingTicks = flyingTicks; return true; } else if (newState instanceof TakingOffState) { @@ -100,6 +100,11 @@ public boolean isSolid(Tardis tardis) { return false; } + @Override + public boolean canBeInterdicted(Tardis tardis) { + return true; + } + @Override public boolean isInteriorLightEnabled(int order) { return FlyingState.spinnyLighting(order, flyingTicks); diff --git a/src/main/java/dev/enjarai/minitardis/component/screen/app/InterdictorApp.java b/src/main/java/dev/enjarai/minitardis/component/screen/app/InterdictorApp.java new file mode 100644 index 0000000..cefa662 --- /dev/null +++ b/src/main/java/dev/enjarai/minitardis/component/screen/app/InterdictorApp.java @@ -0,0 +1,51 @@ +package dev.enjarai.minitardis.component.screen.app; + +import com.mojang.serialization.Codec; +import dev.enjarai.minitardis.block.console.ScreenBlockEntity; +import dev.enjarai.minitardis.canvas.TardisCanvasUtils; +import dev.enjarai.minitardis.component.FlightWave; +import dev.enjarai.minitardis.component.TardisControl; +import dev.enjarai.minitardis.component.screen.canvas.patbox.DrawableCanvas; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.util.ClickType; + +public class InterdictorApp implements ScreenApp { + public static final Codec CODEC = Codec.unit(InterdictorApp::new); + + @Override + public AppView getView(TardisControl controls) { + return new AppView() { + FlightWave selectedWave = new FlightWave(controls.getTardis().getRandom()); + + @Override + public void draw(ScreenBlockEntity blockEntity, DrawableCanvas canvas) { + var timeyTimey = controls.getTardis().getInteriorWorld().getTime() * 2; + + drawWave(canvas, selectedWave, timeyTimey, (short) 0xf383); + } + + void drawWave(DrawableCanvas canvas, FlightWave wave, double offset, short color) { + for (int x = 3; x < 126; x++) { + int y1 = 55 + (int) (Math.sin((x + offset + wave.getOffset() * 35.0 - 1) * wave.getPeriod() * 0.2) * 35.0 * wave.getMagnitude()); + int y2 = 55 + (int) (Math.sin((x + offset + wave.getOffset() * 35.0) * wave.getPeriod() * 0.2) * 35.0 * wave.getMagnitude()); + canvas.bresenhamLine(x - 1, y1, x, y2, color); + } + } + + @Override + public void drawBackground(ScreenBlockEntity blockEntity, DrawableCanvas canvas) { + canvas.draw(0, 0, TardisCanvasUtils.getSprite("interdictor_background")); + } + + @Override + public boolean onClick(ScreenBlockEntity blockEntity, ServerPlayerEntity player, ClickType type, int x, int y) { + return false; + } + }; + } + + @Override + public ScreenAppType getType() { + return ScreenAppTypes.INTERDICTOR; + } +} diff --git a/src/main/java/dev/enjarai/minitardis/component/screen/app/ScreenAppTypes.java b/src/main/java/dev/enjarai/minitardis/component/screen/app/ScreenAppTypes.java index a37e7d5..f70201a 100644 --- a/src/main/java/dev/enjarai/minitardis/component/screen/app/ScreenAppTypes.java +++ b/src/main/java/dev/enjarai/minitardis/component/screen/app/ScreenAppTypes.java @@ -20,6 +20,7 @@ public class ScreenAppTypes { public static final ScreenAppType WAYPOINTS = register("waypoints", WaypointsApp.CODEC, WaypointsApp::new, true); public static final ScreenAppType LOOK_AND_FEEL = register("look_and_feel", LookAndFeelApp.CODEC, LookAndFeelApp::new, true); public static final ScreenAppType FLOPPY_BIRD = register("floppy_bird", FloppyBirdApp.CODEC, FloppyBirdApp::new, true); + public static final ScreenAppType INTERDICTOR = register("interdictor", InterdictorApp.CODEC, InterdictorApp::new, true); private static ScreenAppType register(String name, Codec codec, Supplier constructor, boolean spawnsAsDungeonLoot) { return Registry.register(ScreenAppType.REGISTRY, MiniTardis.id(name), new ScreenAppType<>(MapCodec.assumeMapUnsafe(codec), constructor, spawnsAsDungeonLoot)); diff --git a/src/main/java/dev/enjarai/minitardis/component/screen/app/StatusApp.java b/src/main/java/dev/enjarai/minitardis/component/screen/app/StatusApp.java index ac084fe..2d44d2b 100644 --- a/src/main/java/dev/enjarai/minitardis/component/screen/app/StatusApp.java +++ b/src/main/java/dev/enjarai/minitardis/component/screen/app/StatusApp.java @@ -6,7 +6,7 @@ import dev.enjarai.minitardis.component.TardisControl; import dev.enjarai.minitardis.component.flight.DriftingState; import dev.enjarai.minitardis.component.flight.FlyingState; -import dev.enjarai.minitardis.component.flight.InterceptState; +import dev.enjarai.minitardis.component.flight.InterdictState; import dev.enjarai.minitardis.component.flight.RefuelingState; import dev.enjarai.minitardis.component.screen.canvas.CanvasColors; import dev.enjarai.minitardis.component.screen.canvas.patbox.CanvasImage; @@ -102,19 +102,19 @@ public void draw(ScreenBlockEntity blockEntity, DrawableCanvas canvas) { var stutterOffsetFuel = isSolid || (state instanceof RefuelingState && tardis.getFuel() < 1000) ? 0 : random.nextBetween(-1, 1); drawVerticalBar(canvas, tardis.getFuel() * 480 / 10000 + stutterOffsetFuel, 72, 16, TardisCanvasUtils.getSprite("vertical_bar_blue"), "ART"); - tardis.getState(InterceptState.class).ifPresentOrElse(interceptState -> { + tardis.getState(InterdictState.class).ifPresentOrElse(interdictState -> { canvas.draw(0, 16, TardisCanvasUtils.getSprite("intercept_radar")); - var targetX = interceptState.getTargetX(); - var targetY = interceptState.getTargetY(); - var currentX = interceptState.getOffsetX(); - var currentY = interceptState.getOffsetY(); + var targetX = interdictState.getTargetX(); + var targetY = interdictState.getTargetY(); + var currentX = interdictState.getOffsetX(); + var currentY = interdictState.getOffsetY(); canvas.draw(35 + targetX * 6, 16 + 23 + targetY * 6, TardisCanvasUtils.getSprite("intercept_target")); canvas.draw(35 + currentX * 6, 16 + 23 + currentY * 6, TardisCanvasUtils.getSprite("intercept_current")); - int phase = interceptState.getPhasesComplete(); - int otherPhase = interceptState.getLinkedState(tardis).map(InterceptState::getPhasesComplete).orElse(0); - for (int i = 0; i < InterceptState.PHASES; i++) { + int phase = interdictState.getPhasesComplete(); + int otherPhase = interdictState.getLinkedState(tardis).map(InterdictState::getPhasesComplete).orElse(0); + for (int i = 0; i < InterdictState.PHASES; i++) { canvas.draw(8 + i * 8, 68, TardisCanvasUtils.getSprite(i < phase ? "intercept_phase_complete" : "intercept_phase")); canvas.draw(8 + i * 8, 76, TardisCanvasUtils.getSprite(i < otherPhase ? "intercept_phase_other_complete" : "intercept_phase_other")); } diff --git a/src/main/java/dev/enjarai/minitardis/component/screen/canvas/patbox/DrawableCanvas.java b/src/main/java/dev/enjarai/minitardis/component/screen/canvas/patbox/DrawableCanvas.java index 0fb5ddc..cf2619b 100644 --- a/src/main/java/dev/enjarai/minitardis/component/screen/canvas/patbox/DrawableCanvas.java +++ b/src/main/java/dev/enjarai/minitardis/component/screen/canvas/patbox/DrawableCanvas.java @@ -113,4 +113,35 @@ default void draw(int x, int y, int width, int height, DrawableCanvas source) { } } } + + default void bresenhamLine(int x0, int y0, int x1, int y1, short color) { + + int dx = Math.abs(x1 - x0); + int dy = Math.abs(y1 - y0); + + int sx = x0 < x1 ? 1 : -1; + int sy = y0 < y1 ? 1 : -1; + + int err = dx - dy; + int e2; + + while (true) { + + setRaw(x0, y0, color); + + if (x0 == x1 && y0 == y1) break; + + e2 = 2 * err; + + if (e2 > -dy) { + err = err - dy; + x0 = x0 + sx; + } + + if (e2 < dx) { + err = err + dx; + y0 = y0 + sy; + } + } + } } diff --git a/src/main/resources/assets/mini_tardis/lang/en_us.json b/src/main/resources/assets/mini_tardis/lang/en_us.json index da66010..dcecda2 100644 --- a/src/main/resources/assets/mini_tardis/lang/en_us.json +++ b/src/main/resources/assets/mini_tardis/lang/en_us.json @@ -81,8 +81,8 @@ "mini_tardis.state.mini_tardis.drifting": "CAUTION: Drifting", "mini_tardis.state.mini_tardis.disabled": "Powered Off", "mini_tardis.state.mini_tardis.suspended_flight": "Suspended Flight", - "mini_tardis.state.mini_tardis.intercepting": "Intercepting", - "mini_tardis.state.mini_tardis.being_intercepted": "Being Intercepted!", + "mini_tardis.state.mini_tardis.interdicting": "Interdicting", + "mini_tardis.state.mini_tardis.being_interdicted": "Being Interdicted!", "mini_tardis.app.mini_tardis.dummy": "Deleted App", "mini_tardis.app.mini_tardis.bad_apple": "Bad Apple", @@ -100,6 +100,7 @@ "mini_tardis.app.mini_tardis.waypoints.tooltip": "%d locations stored", "mini_tardis.app.mini_tardis.floppy_bird": "Floppy Bird", "mini_tardis.app.mini_tardis.floppy_bird.tooltip": "%d high scores stored", + "mini_tardis.app.mini_tardis.interdictor": "Interdictor", "dimension.minecraft.overworld": "Overworld", "dimension.minecraft.the_nether": "The Nether", diff --git a/src/main/resources/data/mini_tardis/textures/map/interdictor_background.png b/src/main/resources/data/mini_tardis/textures/map/interdictor_background.png new file mode 100644 index 0000000000000000000000000000000000000000..fcd2c74fc7aba3e55aa9361a93dc97231110a22e GIT binary patch literal 1000 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7uRSjKx9jP7LeL$-HD>U|!_u;uumf z=k4A7S<;RI$3Jd-?A6*W(j?F#%5mdhYQU6hD}$GIoRt2-7_wUEh2kFuMa`h6iZUVG zOHOfW@@U2^@kpQYs%1jyukE|dH=Ez*m*{bS6jr|f_T@hQmkAf-&#~mmc6RirE59w= zQCfE`@a}*2qx$pr*I5ThwMmx_T(`XL@7Dd=5x=G6wc0<<=3}@748N6Z4%J;YwzbQ4)xN#1FC@XhJ$FqhFeJ(x z%sMyz-^pUJJzRc)$Goqle?A|+UQ`+zb#GPO#ogX!`)1U(Je6zoV6A0%{rbo1*XEwD zul?q@`JHh>+%?7vb(5Fv{VTDFkKqt3es-??&9Hix-|laW)1v3!UN`yly_};F&zG*dNq2 z)cj@uDtpK7@U4kyL)NX0DqnnOeKoH%{I>rU&xTjK!d2fgulf7SHG*{qFrgUBGH?f{ zbjTb#|D0JO@_2sm^UsW0aqZdbAK$IFW4Pok)o`Vj>1}q-tGD47(-YYW{7f0HrFU4( zc{qE=JjN~hiefwX7=G+y*r&hXN9%j;75nrKeP?x$WGnzitd7oPrzZw=ml++ZBH0~& z^IX1H#}moU@X+TAW75^>zd1Fpee6!(yY>41?ARk7@(N+V^dfid;}^zj9DCiaKa|?< zxt6)%Yz+H>!;