This commit is contained in:
Andrey Nikitin 2023-02-01 17:37:01 +03:00
parent 7f2d295ba8
commit 914bde6c19
3 changed files with 69 additions and 7 deletions

3
examples/.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,3 @@
{
"Lua.runtime.version": "Lua 5.4"
}

29
examples/nav_dash.lua Normal file
View file

@ -0,0 +1,29 @@
local tardim = peripheral.find("digital_tardim_interface")
local screen = peripheral.find("monitor")
screen.clear()
screen.setCursorBlink(false)
screen.setTextScale(0.5)
-- 15x24
--[[
~ Current pos
X
Y
Z
Dimension
Facing
~ Destination
X
Y
Z
Dimension
Facing
~Fuel
Remaining
Required
TARDIM NAV| 11
]]

View file

@ -51,26 +51,48 @@ public class DigitalInterfacePeripheral implements IPeripheral {
/** /**
* @param tileEntity the tile entity of this peripheral * @param tileEntity the tile entity of this peripheral
* @hidden
*/ */
public DigitalInterfacePeripheral(DigitalInterfaceTileEntity tileEntity) { public DigitalInterfacePeripheral(DigitalInterfaceTileEntity tileEntity) {
this.tileEntity = tileEntity; this.tileEntity = tileEntity;
} }
// Setting name for the peripheral. A computer will see it as "digital_tardim_interface_n" /** Setting name for the peripheral. A computer will see it as "digital_tardim_interface_n"
* @hidden
*/
@Nonnull @Nonnull
@Override @Override
public String getType() { return "digital_tardim_interface"; } public String getType() { return "digital_tardim_interface"; }
// Apparently CC uses this to check if the peripheral in front of a modem is this one /** Apparently CC uses this to check if the peripheral in front of a modem is this one
* @hidden
* @param iPeripheral The peripheral to compare against. This may be {@code null}.
* @return {@code true} if the peripheral is the same as this one.
*/
@Override @Override
public boolean equals(@Nullable IPeripheral iPeripheral) { return this == iPeripheral; } public boolean equals(@Nullable IPeripheral iPeripheral) { return this == iPeripheral; }
// Called when a computer connects/disconnects from the peripheral /** Called when a computer disconnects from the peripheral
* @hidden
* @param computer The interface to the computer that is being detached. Remember that multiple computers can be
* attached to a peripheral at once.
*/
@Override @Override
public void detach(@Nonnull IComputerAccess computer) { connectedComputers.remove(computer); } public void detach(@Nonnull IComputerAccess computer) { connectedComputers.remove(computer); }
/** Called when a computer connects to the peripheral
* @hidden
* @param computer The interface to the computer that is being attached. Remember that multiple computers can be
* attached to a peripheral at once.
*/
@Override @Override
public void attach(@Nonnull IComputerAccess computer) { connectedComputers.add(computer); } public void attach(@Nonnull IComputerAccess computer) { connectedComputers.add(computer); }
/**
* I *think* I use this to get peripheral's world position
* @hidden
* @return
*/
public DigitalInterfaceTileEntity getTileEntity() { public DigitalInterfaceTileEntity getTileEntity() {
return tileEntity; return tileEntity;
} }
@ -90,7 +112,8 @@ public class DigitalInterfacePeripheral implements IPeripheral {
* *
* @return TardimData of the TARDIM that the peripheral is in * @return TardimData of the TARDIM that the peripheral is in
* @throws LuaException if the peripheral is not in a TARDIM * @throws LuaException if the peripheral is not in a TARDIM
* */ * @hidden
*/
public TardimData getTardimData() throws LuaException { public TardimData getTardimData() throws LuaException {
int X = getTileEntity().getPos().getX(), Z = getTileEntity().getPos().getZ(); int X = getTileEntity().getPos().getX(), Z = getTileEntity().getPos().getZ();
@ -672,6 +695,16 @@ public class DigitalInterfacePeripheral implements IPeripheral {
} }
} }
/**
* Helper method to find a biome
* @param level ServerLevel to search
* @param biome Biome to find
* @param pos BlockPos to start from
* @param i Idk what this is, likely a radius
* @param j No idea about this either
* @return BlockPos of the biome
* @hidden
*/
public BlockPos findNearestBiome(ServerLevel level, Biome biome, BlockPos pos, int i, int j) { public BlockPos findNearestBiome(ServerLevel level, Biome biome, BlockPos pos, int i, int j) {
Pair<BlockPos, Holder<Biome>> bb = level.getChunkSource() Pair<BlockPos, Holder<Biome>> bb = level.getChunkSource()
.getGenerator() .getGenerator()
@ -689,7 +722,4 @@ public class DigitalInterfacePeripheral implements IPeripheral {
); );
return bb != null && bb.getFirst() != null ? (BlockPos)bb.getFirst() : null; return bb != null && bb.getFirst() != null ? (BlockPos)bb.getFirst() : null;
} }
// I would love to add this, but the methods are very hard so I will slowly remove the backlog
// TODO: demat, remat
} }