And the shepherd's boy says...
This commit is contained in:
parent
ed5f002edc
commit
faa15aee6b
12 changed files with 329 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue