I had a duty of updating
This commit is contained in:
parent
c43331624e
commit
64be11775f
8 changed files with 212 additions and 3 deletions
|
@ -22,6 +22,7 @@ import su.a71.tardim_ic.tardim_ic.redstone_input.RedstoneInputBlock;
|
|||
import su.a71.tardim_ic.tardim_ic.redstone_input.RedstoneInputTileEntity;
|
||||
|
||||
import su.a71.tardim_ic.tardim_ic.Constants;
|
||||
import su.a71.tardim_ic.tardim_ic.registration.CommandInit;
|
||||
|
||||
public class Registration {
|
||||
// Blocks
|
||||
|
@ -58,5 +59,6 @@ public class Registration {
|
|||
Registry.register(Registry.ITEM, new ResourceLocation(Constants.MOD_ID, "digital_tardim_interface"), new BlockItem(DIGITAL_TARDIM_INTERFACE, new FabricItemSettings().tab(TARDIM_IC_TAB)));
|
||||
|
||||
ComputerCraftAPI.registerPeripheralProvider(new DigitalInterfacePeripheralProvider());
|
||||
CommandInit.init();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
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.world.entity.player.Player;
|
||||
|
||||
//import static com.swdteam.common.command.tardim.CommandTardimBase.sendResponse;
|
||||
|
||||
public class CommandCloisterBell 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)) {
|
||||
try {
|
||||
CommandTardimBase.sendResponse(player, "<Insert Cloister bell>", CommandTardimBase.ResponseType.COMPLETE, source);
|
||||
} catch (Exception var9) {
|
||||
CommandTardimBase.sendResponse(player, "There was an error", CommandTardimBase.ResponseType.FAIL, 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 "cloister-bell";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage() {
|
||||
return "cloister-bell";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandTardimBase.CommandSource allowedSource() {
|
||||
return CommandTardimBase.CommandSource.BOTH;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package su.a71.tardim_ic.tardim_ic.command;
|
||||
|
||||
// This will be added whenever I manage to convince TARDIM devs to make CommandManager.register public
|
||||
// 13.04.23 ITS ALIVE
|
||||
|
||||
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 dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.network.Packet;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
public class CommandModemTransmit implements ICommand {
|
||||
@Override
|
||||
public void execute(String[] args, Player player, BlockPos pos, CommandTardimBase.CommandSource source) {
|
||||
if (args.length == 3) { // TODO: 3 or 4???
|
||||
TardimData data = TardimManager.getFromPos(pos);
|
||||
if (data != null) {
|
||||
if (data.hasPermission(player)) {
|
||||
try {
|
||||
int sendChannel = Integer.parseInt(args[0]);
|
||||
int replyChannel = Integer.parseInt(args[1]);
|
||||
String message = args[2];
|
||||
boolean allDimensions = Boolean.parseBoolean(args[3]) || args[3].equals("true");
|
||||
|
||||
if (data.getTravelLocation() == null) {
|
||||
data.setTravelLocation(new TardimData.Location(data.getCurrentLocation()));
|
||||
}
|
||||
|
||||
if (allDimensions)
|
||||
{
|
||||
ComputerCraftAPI.getWirelessNetwork().transmitInterdimensional(new Packet(sendChannel, replyChannel, message, new CommandSender(player, data.getTravelLocation().getPos())));
|
||||
}
|
||||
else {
|
||||
ComputerCraftAPI.getWirelessNetwork().transmitSameDimension(new Packet(sendChannel, replyChannel, message,
|
||||
new CommandSender(player, data.getTravelLocation().getPos())), 300);
|
||||
}
|
||||
CommandTardimBase.sendResponse(player, "Sent modem message", CommandTardimBase.ResponseType.COMPLETE, source);
|
||||
} catch (Exception var9) {
|
||||
CommandTardimBase.sendResponse(player, "Invalid coordinates", CommandTardimBase.ResponseType.FAIL, 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 "cc-modem-transmit";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage() {
|
||||
return "/cc-modem-transmit <Chnl> <replyChnl> <msg> <ender: bool>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandTardimBase.CommandSource allowedSource() {
|
||||
return CommandTardimBase.CommandSource.BOTH;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package su.a71.tardim_ic.tardim_ic.command;
|
||||
|
||||
import dan200.computercraft.api.network.IPacketSender;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CommandSender implements IPacketSender {
|
||||
|
||||
private final Player player;
|
||||
private final Level level;
|
||||
private final BlockPos pos;
|
||||
|
||||
CommandSender(Player player, BlockPos pos) {
|
||||
this.player = player;
|
||||
this.level = player.level;
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Level getLevel() {
|
||||
return this.level;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Vec3 getPosition() {
|
||||
return new Vec3(this.pos.getX(), this.pos.getY(), this.pos.getZ());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getSenderID() {
|
||||
return this.player.getName().getString();
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package su.a71.tardim_ic.tardim_ic.digital_interface;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.swdteam.tardim.common.command.tardim.CommandTardimBase;
|
||||
import com.swdteam.tardim.common.command.tardim.CommandTravel;
|
||||
import com.swdteam.tardim.common.data.DimensionMapReloadListener;
|
||||
import com.swdteam.tardim.common.init.TRDSounds;
|
||||
|
@ -756,4 +757,41 @@ public class DigitalInterfacePeripheral implements IPeripheral {
|
|||
);
|
||||
return bb != null && bb.getFirst() != null ? (BlockPos)bb.getFirst() : null;
|
||||
}
|
||||
|
||||
@LuaFunction(mainThread = true)
|
||||
public final void setSkin(String skin) throws LuaException {
|
||||
if (this.tileEntity.getLevel().isClientSide()) {
|
||||
return;
|
||||
}
|
||||
|
||||
TardimData data = getTardimData();
|
||||
|
||||
ResourceLocation skinToApply = null;
|
||||
Iterator var13 = TardimRegistry.getRegistry().keySet().iterator();
|
||||
|
||||
label39: {
|
||||
ResourceLocation builder;
|
||||
TardimRegistry.TardimBuilder b;
|
||||
do {
|
||||
if (!var13.hasNext()) {
|
||||
break label39;
|
||||
}
|
||||
|
||||
builder = (ResourceLocation)var13.next();
|
||||
b = TardimRegistry.getTardimBuilder(builder);
|
||||
} while(!b.getDisplayName().equalsIgnoreCase(skin) && !builder.toString().equalsIgnoreCase(skin));
|
||||
|
||||
skinToApply = builder;
|
||||
}
|
||||
|
||||
if (skinToApply == null) {
|
||||
throw new LuaException("Skin" + skin + "' not found");
|
||||
}
|
||||
|
||||
TardimData.Location loc = data.getCurrentLocation();
|
||||
ServerLevel level = this.tileEntity.getLevel().getServer().getLevel(loc.getLevel());
|
||||
data.setIdentifier(skinToApply);
|
||||
|
||||
//TardimRegistry.getTardimBuilder(skinToApply).changeTardimSkin(data, level, loc.getPos(), loc.getFacing(), player);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
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.CommandModemTransmit;
|
||||
|
||||
public class CommandInit {
|
||||
public static void init() {
|
||||
CommandManager.register(new CommandModemTransmit());
|
||||
//CommandManager.register(new CommandCloisterBell());
|
||||
}
|
||||
}
|
|
@ -54,12 +54,12 @@ public class CommandModemTransmit implements ICommand {
|
|||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "ccModemTransmit";
|
||||
return "cc-modem-transmit";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage() {
|
||||
return "ccModemTransmit <channel: int> <replyChannel: int> <message: string> <all_dimension: true/false>";
|
||||
return "/cc-modem-transmit <Chnl> <replyChnl> <msg> <ender: bool>";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,6 +8,6 @@ import com.swdteam.common.init.CommandManager;
|
|||
public class CommandInit {
|
||||
public static void init() {
|
||||
CommandManager.register(new CommandModemTransmit());
|
||||
CommandManager.register(new CommandCloisterBell());
|
||||
//CommandManager.register(new CommandCloisterBell());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue