And the shepherd's boy says...

This commit is contained in:
Andrew-71 2023-06-12 21:52:50 +03:00
parent ed5f002edc
commit faa15aee6b
12 changed files with 329 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 B

View file

@ -0,0 +1,54 @@
package su.a71.tardim_ic.tardim_ic.command;
import com.swdteam.tardim.common.command.tardim.CommandTardimBase;
import com.swdteam.tardim.common.command.tardim.ICommand;
import com.swdteam.tardim.tardim.TardimData;
import com.swdteam.tardim.tardim.TardimManager;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.biome.Biome;
public class CommandListBiomes implements ICommand{
@Override
public void execute(String[] args, Player player, BlockPos pos, CommandTardimBase.CommandSource source) {
;
if (args.length == 1 || args.length == 0) {
TardimData data = TardimManager.getFromPos(pos);
if (data != null) {
if (data.hasPermission(player)) {
Registry<Biome> biomeRegistry = player.getLevel().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY);
biomeRegistry.keySet().forEach(
(ResourceLocation res) -> {
String out = res.toString();
if (args.length == 0 || (args[0].equals(out.split(":")[0]))) {
CommandTardimBase.sendResponse(player, out, CommandTardimBase.ResponseType.INFO, source);
}
}
);
} else {
CommandTardimBase.sendResponse(player, "You do not have permission", CommandTardimBase.ResponseType.FAIL, source);
}
}
} else {
CommandTardimBase.sendResponse(player, this.getUsage(), CommandTardimBase.ResponseType.FAIL, source);
}
}
@Override
public String getCommandName() {
return "list-biomes";
}
@Override
public String getUsage() {
return "/list-biomes";
}
@Override
public CommandTardimBase.CommandSource allowedSource() {
return CommandTardimBase.CommandSource.BOTH;
}
}

View file

@ -0,0 +1,45 @@
package su.a71.tardim_ic.tardim_ic.command;
import com.swdteam.tardim.common.command.tardim.CommandTardimBase;
import com.swdteam.tardim.common.command.tardim.ICommand;
import com.swdteam.tardim.tardim.TardimData;
import com.swdteam.tardim.tardim.TardimManager;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.player.Player;
public class CommandListDimensions implements ICommand{
@Override
public void execute(String[] args, Player player, BlockPos pos, CommandTardimBase.CommandSource source) {
if (args.length == 0) {
TardimData data = TardimManager.getFromPos(pos);
if (data != null) {
if (data.hasPermission(player)) {
// TODO: Does this really work?
for (ServerLevel serverLevel : player.getLevel().getServer().getAllLevels()) {
CommandTardimBase.sendResponse(player, serverLevel.dimension().location().toString(), CommandTardimBase.ResponseType.INFO, source);
}
} else {
CommandTardimBase.sendResponse(player, "You do not have permission", CommandTardimBase.ResponseType.FAIL, source);
}
}
} else {
CommandTardimBase.sendResponse(player, this.getUsage(), CommandTardimBase.ResponseType.FAIL, source);
}
}
@Override
public String getCommandName() {
return "list-dimensions";
}
@Override
public String getUsage() {
return "/list-dimensions";
}
@Override
public CommandTardimBase.CommandSource allowedSource() {
return CommandTardimBase.CommandSource.BOTH;
}
}

View file

@ -868,4 +868,40 @@ public class DigitalInterfacePeripheral implements IPeripheral {
throw new LuaException("There was an error trying to play the sound");
}
}
/**
* Get a table with all registered biomes' names.
* Useful for creating advanced navigation systems.
* @return ObjectLuaTable with all biomes' technical names
*/
@LuaFunction(mainThread = true)
public final ObjectLuaTable getBiomes() throws LuaException {
Map<Integer, String> biomes = new HashMap<>();
Registry<Biome> biomeRegistry = tileEntity.getLevel().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY);
Iterator<ResourceLocation> biome_it = biomeRegistry.keySet().iterator();
int i = 0;
while (biome_it.hasNext()) {
biomes.put(i + 1, biome_it.next().toString());
i++;
}
return new ObjectLuaTable(biomes);
}
/**
* Get a table with all registered dimensions' names.
* Useful for creating advanced navigation systems.
* @return ObjectLuaTable with all dimensions' technical names
*/
@LuaFunction(mainThread = true)
public final ObjectLuaTable getDimensions() throws LuaException {
Iterator<ServerLevel> dim_it = this.tileEntity.getLevel().getServer().getAllLevels().iterator(); // TODO: Does this really work?
Map<Integer, String> dimensions = new HashMap<>();
int i = 0;
while (dim_it.hasNext()) {
dimensions.put(i + 1, dim_it.next().dimension().location().toString());
i++;
}
return new ObjectLuaTable(dimensions);
}
}

View file

@ -4,9 +4,11 @@ package su.a71.tardim_ic.tardim_ic.registration;
import com.swdteam.tardim.common.init.CommandManager;
import su.a71.tardim_ic.tardim_ic.command.CommandCloisterBell;
import su.a71.tardim_ic.tardim_ic.command.CommandListBiomes;
public class CommandInit {
public static void init() {
CommandManager.register(new CommandListBiomes());
CommandManager.register(new CommandCloisterBell());
}
}

View file

@ -22,6 +22,7 @@
]
},
"mixins": [
"mixins.tardim_ic.json"
],
"depends": {

View file

@ -4,7 +4,6 @@
"compatibilityLevel": "JAVA_17",
"refmap": "refmap.tardim_ic.json",
"mixins": [
"JammerMixin"
],
"client": [
],

View file

@ -0,0 +1,54 @@
package su.a71.tardim_ic.tardim_ic.command;
import com.swdteam.common.command.tardim.CommandTardimBase;
import com.swdteam.common.command.tardim.ICommand;
import com.swdteam.tardim.TardimData;
import com.swdteam.tardim.TardimManager;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.biome.Biome;
public class CommandListBiomes implements ICommand{
@Override
public void execute(String[] args, Player player, BlockPos pos, CommandTardimBase.CommandSource source) {
;
if (args.length == 1 || args.length == 0) {
TardimData data = TardimManager.getFromPos(pos);
if (data != null) {
if (data.hasPermission(player)) {
Registry<Biome> biomeRegistry = player.getLevel().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY);
biomeRegistry.keySet().forEach(
(ResourceLocation res) -> {
String out = res.toString();
if (args.length == 0 || (args[0].equals(out.split(":")[0]))) {
CommandTardimBase.sendResponse(player, out, CommandTardimBase.ResponseType.INFO, source);
}
}
);
} else {
CommandTardimBase.sendResponse(player, "You do not have permission", CommandTardimBase.ResponseType.FAIL, source);
}
}
} else {
CommandTardimBase.sendResponse(player, this.getUsage(), CommandTardimBase.ResponseType.FAIL, source);
}
}
@Override
public String getCommandName() {
return "list-biomes";
}
@Override
public String getUsage() {
return "/list-biomes";
}
@Override
public CommandTardimBase.CommandSource allowedSource() {
return CommandTardimBase.CommandSource.BOTH;
}
}

View file

@ -0,0 +1,47 @@
package su.a71.tardim_ic.tardim_ic.command;
import com.swdteam.common.command.tardim.CommandTardimBase;
import com.swdteam.common.command.tardim.ICommand;
import com.swdteam.tardim.TardimData;
import com.swdteam.tardim.TardimManager;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.player.Player;
public class CommandListDimensions implements ICommand{
@Override
public void execute(String[] args, Player player, BlockPos pos, CommandTardimBase.CommandSource source) {
if (args.length == 0) {
TardimData data = TardimManager.getFromPos(pos);
if (data != null) {
if (data.hasPermission(player)) {
// TODO: Does this really work?
for (ServerLevel serverLevel : player.getLevel().getServer().getAllLevels()) {
CommandTardimBase.sendResponse(player, serverLevel.dimension().location().toString(), CommandTardimBase.ResponseType.INFO, source);
}
} else {
CommandTardimBase.sendResponse(player, "You do not have permission", CommandTardimBase.ResponseType.FAIL, source);
}
}
} else {
CommandTardimBase.sendResponse(player, this.getUsage(), CommandTardimBase.ResponseType.FAIL, source);
}
}
@Override
public String getCommandName() {
return "list-dimensions";
}
@Override
public String getUsage() {
return "/list-dimensions";
}
@Override
public CommandTardimBase.CommandSource allowedSource() {
return CommandTardimBase.CommandSource.BOTH;
}
}

View file

@ -33,9 +33,12 @@ import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.client.DimensionSpecialEffectsManager;
import su.a71.tardim_ic.tardim_ic.Registration;
import su.a71.tardim_ic.tardim_ic.utils.FakePlayer;
import net.minecraftforge.registries.ForgeRegistries;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.*;
@ -93,7 +96,6 @@ public class DigitalInterfacePeripheral implements IPeripheral {
return tileEntity;
}
/**
* Get TARDIM's data, which we need for *every* function
* <p>
@ -846,4 +848,40 @@ public class DigitalInterfacePeripheral implements IPeripheral {
throw new LuaException("There was an error trying to play the sound");
}
}
/**
* Get a table with all registered biomes' names.
* Useful for creating advanced navigation systems.
* @return ObjectLuaTable with all biomes' technical names
*/
@LuaFunction(mainThread = true)
public final ObjectLuaTable getBiomes() throws LuaException {
Map<Integer, String> biomes = new HashMap<>();
Registry<Biome> biomeRegistry = tileEntity.getLevel().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY);
Iterator<ResourceLocation> biome_it = biomeRegistry.keySet().iterator();
int i = 0;
while (biome_it.hasNext()) {
biomes.put(i + 1, biome_it.next().toString());
i++;
}
return new ObjectLuaTable(biomes);
}
/**
* Get a table with all registered dimensions' names.
* Useful for creating advanced navigation systems.
* @return ObjectLuaTable with all dimensions' technical names
*/
@LuaFunction(mainThread = true)
public final ObjectLuaTable getDimensions() throws LuaException {
Iterator<ServerLevel> dim_it = this.tileEntity.getLevel().getServer().getAllLevels().iterator(); // TODO: Does this really work?
Map<Integer, String> dimensions = new HashMap<>();
int i = 0;
while (dim_it.hasNext()) {
dimensions.put(i + 1, dim_it.next().dimension().location().toString());
i++;
}
return new ObjectLuaTable(dimensions);
}
}

View file

@ -1,6 +1,8 @@
package su.a71.tardim_ic.tardim_ic.registration;
import su.a71.tardim_ic.tardim_ic.command.CommandListBiomes;
import su.a71.tardim_ic.tardim_ic.command.CommandListDimensions;
import su.a71.tardim_ic.tardim_ic.command.CommandModemTransmit;
import su.a71.tardim_ic.tardim_ic.command.CommandCloisterBell;
import com.swdteam.common.init.CommandManager;
@ -9,5 +11,7 @@ public class CommandInit {
public static void init() {
CommandManager.register(new CommandModemTransmit());
CommandManager.register(new CommandCloisterBell());
CommandManager.register(new CommandListBiomes());
CommandManager.register(new CommandListDimensions());
}
}

47
TODO.txt Normal file
View file

@ -0,0 +1,47 @@
TODO for 1.2 and beyond
Blocks:
Food Dispenser - one button iterates over food types, another dispenses it at cost of some fuel
Cartridge Loader - one button to write to the cartridge, another to load information from it (Right now just location, in the future maybe other too)
Dock Station - lets you get into locations you often visit better, good tool for shop keepers as well. On RP servers could prevent liftoff.
Roundels? - Both normal and storage.
Items:
Personal Location Jammer - when worn, prevents others from locating you. Possibly add some kind of power mechanic to make it less OP
Location Cartridge - a cartridge that stores a location to later visit it with a TARDIM. Can be locked like map. Potentially add a way to write in the field.
Commands:
Quick return - set destination to previous materialisation point.
Compat:
CC - add more meaningful peripherals to things like fuel tank
Create - Port to 0.5.1, add display sources to more things. Also look into mechanical TARDIM power-up
Mixins:
Location jammer working
Better fuel tank (More fuel sources, do not eat buckets)
Into demat for quick return mixin
Fuel tank should give off comparator output based on how full it is, and time rotor based on whether we are in flight
Potentially let name change appearance of TARDIM Controls?
Code:
Make better and coherent file structure. Unify Forge and Fabric where possible. Prepare for if SWDTeam ever unify more things.
Achievements/Advancements:
"Nobody needs soup more than me"
Get soup from TARDIM's food machine
"Power of the Redstone"
Activate a redstone input
"From Russia with love"
Set exterior to Soviet Chronobox (or any other potential USSR-themed exteriors)
"Cyber-Upgrade"
Craft a digital interface
"???"
Register a dock
"I prefer jelly"
Put on a location jammer
"I will always remember..."
Save (or maybe lock like a map?) a location cartridge