License, commands, AND STILL NOT GINGER
This commit is contained in:
parent
dcd820a10f
commit
c3a67bb2e6
11 changed files with 119 additions and 8 deletions
|
@ -1,6 +1,7 @@
|
|||
package su.a71.tardim_ic.tardim_ic;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.swdteam.common.command.tardim.ICommand;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
|
|
@ -5,6 +5,8 @@ import net.minecraftforge.fml.common.Mod;
|
|||
|
||||
import su.a71.tardim_ic.tardim_ic.Constants;
|
||||
|
||||
import su.a71.tardim_ic.tardim_ic.registration.CommandInit;
|
||||
|
||||
// The value here should match an entry in the META-INF/mods.toml file
|
||||
@Mod(Constants.MOD_ID)
|
||||
public class TardimInControl {
|
||||
|
@ -14,6 +16,8 @@ public class TardimInControl {
|
|||
|
||||
public TardimInControl() {
|
||||
Registration.register();
|
||||
CommandInit.init(); // Register commands
|
||||
|
||||
// Register ourselves for server and other game events we are interested in. Currently, we do not use any events
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
package su.a71.tardim_ic.tardim_ic.command;
|
||||
|
||||
// This will be added whenever I manage to convince TARDIM devs to make CommandManager.register public
|
||||
|
||||
import com.mojang.brigadier.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.world.entity.player.Player;
|
||||
|
||||
import dan200.computercraft.api.network.Packet;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
|
||||
import static com.swdteam.common.command.tardim.CommandTardimBase.sendResponse;
|
||||
|
||||
public class CommandModemTransmit implements ICommand {
|
||||
@Override
|
||||
public void execute(String[] args, Player player, BlockPos pos, CommandTardimBase.CommandSource source) {
|
||||
if (args.length == 3) {
|
||||
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);
|
||||
}
|
||||
sendResponse(player, "Sent modem message", CommandTardimBase.ResponseType.COMPLETE, source);
|
||||
} catch (Exception var9) {
|
||||
sendResponse(player, "Invalid coordinates", CommandTardimBase.ResponseType.FAIL, source);
|
||||
}
|
||||
} else {
|
||||
sendResponse(player, "You do not have permission", CommandTardimBase.ResponseType.FAIL, source);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sendResponse(player, this.getUsage(), CommandTardimBase.ResponseType.FAIL, source);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "ccModemTransmit";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage() {
|
||||
return "ccModemTransmit <channel: int> <replyChannel: int> <message: string> <all_dimension: true/false>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandTardimBase.CommandSource allowedSource() {
|
||||
return CommandTardimBase.CommandSource.BOTH;
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package su.a71.tardim_ic.tardim_ic.command;
|
||||
|
||||
import dan200.computercraft.api.network.IPacketSender;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
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,7 +1,7 @@
|
|||
|
||||
modLoader = "javafml" #mandatory
|
||||
loaderVersion="[43,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
||||
license = "All rights reserved"
|
||||
license = "MIT"
|
||||
[[mods]] #mandatory
|
||||
# The modid of the mod
|
||||
modId = "tardim_ic" #mandatory
|
||||
|
@ -12,6 +12,8 @@ displayName = "TARDIM: In Control" #mandatory
|
|||
description = '''
|
||||
All of time and space, now automated. Control your TARDIM using ComputerCraft: Tweaked.
|
||||
'''
|
||||
logoFile = "icon.png"
|
||||
authors = "Andrew_7_1"
|
||||
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
||||
[[dependencies.tardim_ic]] #optional
|
||||
# the modid of the dependency
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue