Fabric?! IMPOSSIBLE

This commit is contained in:
Andrew-71 2023-04-14 17:52:30 +03:00
parent c3a67bb2e6
commit f4ad251895
16 changed files with 195 additions and 44 deletions

View file

@ -3,8 +3,6 @@ package su.a71.tardim_ic.tardim_ic;
import net.minecraftforge.common.MinecraftForge;
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
@ -12,7 +10,7 @@ import su.a71.tardim_ic.tardim_ic.registration.CommandInit;
public class TardimInControl {
// Our mod id
public static final String MODID = "tardim_ic";
public static final String MODID = Constants.MOD_ID;
public TardimInControl() {
Registration.register();

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.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource;
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 "cloisterBell";
}
@Override
public String getUsage() {
return "cloisterBell";
}
@Override
public CommandTardimBase.CommandSource allowedSource() {
return CommandTardimBase.CommandSource.BOTH;
}
}

View file

@ -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.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;
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 "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;
}
}

View file

@ -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();
}
}

View file

@ -1,7 +1,6 @@
package su.a71.tardim_ic.tardim_ic.redsone_input;
import com.swdteam.common.block.BlockBaseTardimPanel;
import com.swdteam.common.init.TRDDimensions;
import com.swdteam.common.init.TRDSounds;
import com.swdteam.network.NetworkHandler;
@ -29,14 +28,15 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.common.util.FakePlayerFactory; // TODO: ???
import net.minecraftforge.server.ServerLifecycleHooks;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
import su.a71.tardim_ic.tardim_ic.Registration;
import javax.annotation.Nullable;
public class RedstoneInputBlock extends BlockBaseTardimPanel implements EntityBlock {
private boolean isPowered = false;
public RedstoneInputBlock() {

View file

@ -0,0 +1,13 @@
package su.a71.tardim_ic.tardim_ic.registration;
import su.a71.tardim_ic.tardim_ic.command.CommandModemTransmit;
import su.a71.tardim_ic.tardim_ic.command.CommandCloisterBell;
import com.swdteam.common.init.CommandManager;
public class CommandInit {
public static void init() {
CommandManager.register(new CommandModemTransmit());
CommandManager.register(new CommandCloisterBell());
}
}