My reward.
This commit is contained in:
parent
37c181fa21
commit
9f8b8235dd
5 changed files with 144 additions and 9 deletions
|
@ -29,13 +29,12 @@ public class Registration {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Blocks
|
// Blocks
|
||||||
public static final RegistryObject<Block> DIGITAL_TARDIM_INTERFACE = register("digital_tardim_interface", DigitalInterfaceBlock::new);
|
|
||||||
|
|
||||||
private static <T extends Block> RegistryObject<T> register(String name, Supplier<T> block) {
|
private static <T extends Block> RegistryObject<T> register(String name, Supplier<T> block) {
|
||||||
RegistryObject<T> registryObject = BLOCKS.register(name, block);
|
RegistryObject<T> registryObject = BLOCKS.register(name, block);
|
||||||
ITEMS.register(name, () -> new BlockItem(registryObject.get(), new Item.Properties().tab(TARDIM_IC_TAB)));
|
ITEMS.register(name, () -> new BlockItem(registryObject.get(), new Item.Properties().tab(TARDIM_IC_TAB)));
|
||||||
return registryObject;
|
return registryObject;
|
||||||
}
|
}
|
||||||
|
public static final RegistryObject<Block> DIGITAL_TARDIM_INTERFACE = register("digital_tardim_interface", DigitalInterfaceBlock::new);
|
||||||
|
|
||||||
// Tile Entities
|
// Tile Entities
|
||||||
public static final RegistryObject<BlockEntityType<DigitalInterfaceTileEntity>> DIGITAL_TARDIM_INTERFACE_TILEENTITY = Registration.BLOCK_ENTITIES.register("digital_tardim_interface", () -> new BlockEntityType<>(DigitalInterfaceTileEntity::new, Sets.newHashSet(DIGITAL_TARDIM_INTERFACE.get()), null));
|
public static final RegistryObject<BlockEntityType<DigitalInterfaceTileEntity>> DIGITAL_TARDIM_INTERFACE_TILEENTITY = Registration.BLOCK_ENTITIES.register("digital_tardim_interface", () -> new BlockEntityType<>(DigitalInterfaceTileEntity::new, Sets.newHashSet(DIGITAL_TARDIM_INTERFACE.get()), null));
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package su.a71.tardim_ic.tardim_ic.sonic;
|
||||||
|
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
|
||||||
|
import com.swdteam.tardim.TardimData;
|
||||||
|
import com.swdteam.tardim.TardimManager;
|
||||||
|
|
||||||
|
import com.swdteam.client.gui.GuiCommandScreen;
|
||||||
|
|
||||||
|
public class SonicProbe extends Item {
|
||||||
|
private TardimData tardim;
|
||||||
|
public SonicProbe(Properties properties) {
|
||||||
|
super(properties.stacksTo(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTardim(TardimData tardim) {
|
||||||
|
this.tardim = tardim;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add tile entity
|
||||||
|
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"type": "minecraft:crafting_shaped",
|
"type": "minecraft:crafting_shaped",
|
||||||
"pattern": [
|
"pattern": [
|
||||||
"GGG",
|
"DDD",
|
||||||
"R0R",
|
"R0R",
|
||||||
"GRG"
|
"GRG"
|
||||||
],
|
],
|
||||||
|
@ -17,6 +17,10 @@
|
||||||
"0": {
|
"0": {
|
||||||
"item": "minecraft:ender_eye",
|
"item": "minecraft:ender_eye",
|
||||||
"count": 1
|
"count": 1
|
||||||
|
},
|
||||||
|
"D": {
|
||||||
|
"item": "minecraft:polished_deepslate",
|
||||||
|
"count": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"result": {
|
"result": {
|
||||||
|
|
Loading…
Add table
Reference in a new issue