-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
203 additions
and
42 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
src/main/java/dev/enjarai/minitardis/component/FlightWave.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/dev/enjarai/minitardis/component/screen/app/InterdictorApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<InterdictorApp> 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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.