Skip to content

Commit e5c21ec

Browse files
committed
WIP commands and positional changes
1 parent 857a6d2 commit e5c21ec

File tree

49 files changed

+645
-319
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+645
-319
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package dev.compactmods.machines.api.location;
2+
3+
import net.minecraft.server.MinecraftServer;
4+
import net.minecraft.world.level.block.state.BlockState;
5+
6+
public interface IDimensionalBlockPosition extends IDimensionalPosition {
7+
BlockState state(MinecraftServer server);
8+
}
Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
package dev.compactmods.machines.api.location;
22

33
import java.util.Optional;
4+
5+
import com.mojang.serialization.Codec;
46
import net.minecraft.core.Direction;
7+
import net.minecraft.resources.ResourceKey;
58
import net.minecraft.server.MinecraftServer;
69
import net.minecraft.core.BlockPos;
710
import net.minecraft.server.level.ServerLevel;
8-
import net.minecraft.world.level.block.state.BlockState;
11+
import net.minecraft.world.level.Level;
12+
import net.minecraft.world.phys.Vec3;
913

1014
public interface IDimensionalPosition {
15+
1116
IDimensionalPosition relative(Direction direction, float amount);
1217

1318
BlockPos getBlockPosition();
19+
Vec3 getExactPosition();
1420

15-
Optional<ServerLevel> level(MinecraftServer server);
16-
17-
Optional<BlockState> state(MinecraftServer server);
21+
ResourceKey<Level> dimensionKey();
22+
ServerLevel level(MinecraftServer server);
1823

1924
IDimensionalPosition relative(Direction direction);
25+
26+
Optional<Vec3> getRotation();
2027
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package dev.compactmods.machines.api.room;
2+
3+
import dev.compactmods.machines.api.room.history.IRoomHistoryItem;
4+
import net.minecraft.nbt.ListTag;
5+
import net.minecraftforge.common.util.INBTSerializable;
6+
7+
public interface IRoomHistory<T extends IRoomHistoryItem> extends INBTSerializable<ListTag> {
8+
9+
void clear();
10+
boolean hasHistory();
11+
T peek();
12+
T pop();
13+
14+
void addHistory(T item);
15+
}

src/api/java/dev/compactmods/machines/api/room/IMachineRoom.java renamed to src/api/java/dev/compactmods/machines/api/room/IRoomInformation.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
import javax.annotation.Nonnull;
77

8-
public interface IMachineRoom {
8+
public interface IRoomInformation {
99

1010
@Nonnull
11-
ChunkPos getChunk();
11+
ChunkPos chunk();
1212

1313
@Nonnull
14-
ServerLevel getLevel();
14+
ServerLevel level();
1515
}

src/api/java/dev/compactmods/machines/api/room/MachineRoomConnections.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public interface MachineRoomConnections {
1717
void registerRoom(ChunkPos roomChunk);
1818

1919
void connectMachineToRoom(int machine, ChunkPos room);
20+
void changeMachineLink(int machine, ChunkPos newRoom);
2021

2122
void disconnect(int machine);
2223

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package dev.compactmods.machines.api.room.history;
2+
3+
import dev.compactmods.machines.api.location.IDimensionalPosition;
4+
5+
public interface IRoomHistoryItem {
6+
7+
IDimensionalPosition getEntryLocation();
8+
9+
int getMachine();
10+
}

src/main/java/dev/compactmods/machines/command/CMCommandRoot.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
import com.mojang.brigadier.CommandDispatcher;
44
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
55
import dev.compactmods.machines.CompactMachines;
6+
import dev.compactmods.machines.command.subcommand.*;
67
import net.minecraft.commands.CommandSourceStack;
78

89
public class CMCommandRoot {
910

1011
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
1112
final LiteralArgumentBuilder<CommandSourceStack> root = LiteralArgumentBuilder.literal(CompactMachines.MOD_ID);
12-
root.then(CMEjectSubcommand.register());
13-
root.then(CMSummarySubcommand.register());
14-
root.then(ReaddDimensionCommand.register());
13+
root.then(CMEjectSubcommand.make());
14+
root.then(CMSummarySubcommand.make());
15+
root.then(CMRebindSubcommand.make());
16+
root.then(CMReaddDimensionSubcommand.make());
17+
root.then(CMRoomsSubcommand.make());
1518
dispatcher.register(root);
1619
}
1720
}

src/main/java/dev/compactmods/machines/command/CMDataCommand.java renamed to src/main/java/dev/compactmods/machines/command/data/CMDataCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package dev.compactmods.machines.command;
1+
package dev.compactmods.machines.command.data;
22

33
import com.mojang.brigadier.CommandDispatcher;
44
import com.mojang.brigadier.builder.LiteralArgumentBuilder;

src/main/java/dev/compactmods/machines/command/CMMachineDataExportCommand.java renamed to src/main/java/dev/compactmods/machines/command/data/CMMachineDataExportCommand.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
package dev.compactmods.machines.command;
1+
package dev.compactmods.machines.command.data;
22

33
import com.mojang.brigadier.builder.ArgumentBuilder;
44
import com.mojang.brigadier.context.CommandContext;
55
import dev.compactmods.machines.CompactMachines;
6-
import dev.compactmods.machines.api.core.Messages;
6+
import dev.compactmods.machines.api.core.CMCommands;
77
import dev.compactmods.machines.api.room.MachineRoomConnections;
88
import dev.compactmods.machines.core.MissingDimensionException;
99
import dev.compactmods.machines.i18n.TranslationUtil;
@@ -31,10 +31,11 @@ private static int execAll(CommandContext<CommandSourceStack> ctx) {
3131
var src = ctx.getSource();
3232
var serv = src.getServer();
3333

34-
final var connections = MachineToRoomConnections.get(serv);
3534
final CompactMachineData machines;
35+
final MachineRoomConnections connections;
3636
try {
3737
machines = CompactMachineData.get(serv);
38+
connections = MachineToRoomConnections.get(serv);
3839
} catch (MissingDimensionException e) {
3940
CompactMachines.LOGGER.fatal(e);
4041
return -1;
@@ -56,7 +57,7 @@ private static int execAll(CommandContext<CommandSourceStack> ctx) {
5657
writer.close();
5758
} catch (IOException e) {
5859
CompactMachines.LOGGER.error(e);
59-
src.sendFailure(TranslationUtil.message(Messages.FAILED_CMD_FILE_ERROR));
60+
src.sendFailure(TranslationUtil.command(CMCommands.FAILED_CMD_FILE_ERROR));
6061
return -1;
6162
}
6263

src/main/java/dev/compactmods/machines/command/CMRoomDataExportCommand.java renamed to src/main/java/dev/compactmods/machines/command/data/CMRoomDataExportCommand.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
package dev.compactmods.machines.command;
1+
package dev.compactmods.machines.command.data;
22

33
import com.mojang.brigadier.builder.ArgumentBuilder;
44
import com.mojang.brigadier.context.CommandContext;
55
import dev.compactmods.machines.CompactMachines;
6-
import dev.compactmods.machines.api.core.Messages;
6+
import dev.compactmods.machines.api.core.CMCommands;
77
import dev.compactmods.machines.core.MissingDimensionException;
88
import dev.compactmods.machines.core.Registration;
99
import dev.compactmods.machines.i18n.TranslationUtil;
@@ -57,7 +57,7 @@ private static int execAll(CommandContext<CommandSourceStack> ctx) {
5757
writer.close();
5858
} catch (IOException e) {
5959
CompactMachines.LOGGER.error(e);
60-
src.sendFailure(TranslationUtil.message(Messages.FAILED_CMD_FILE_ERROR));
60+
src.sendFailure(TranslationUtil.command(CMCommands.FAILED_CMD_FILE_ERROR));
6161
return -1;
6262
}
6363

0 commit comments

Comments
 (0)