From 4422398fdbe176e41a7ebfdb2c96c4fd1b62f309 Mon Sep 17 00:00:00 2001 From: Ted Senft Date: Wed, 7 Feb 2024 22:31:25 -0500 Subject: [PATCH] Shuffle around a lot of constants. Categorize. --- README.md | 8 +++ .../compactmods/machines/api/CMBlocks.java | 17 ----- .../machines/api/CompactMachinesAddon.java | 9 --- .../machines/api/{core => }/Constants.java | 2 +- .../machines/api/ICompactMachinesAddon.java | 12 ---- .../machines/api/{core => }/Messages.java | 2 +- .../machines/api/{core => }/Tooltips.java | 2 +- .../{core => advancement}/Advancements.java | 3 +- .../machines/api}/codec/CodecExtensions.java | 2 +- .../api}/codec/DoubleStreamExtensions.java | 2 +- .../machines/api}/codec/NbtListCollector.java | 2 +- .../api/{core => command}/CMCommands.java | 4 +- .../compactmods/machines/api/core/CMTags.java | 41 ----------- .../api/dimension/CompactDimension.java | 4 +- .../api/location/GlobalPosWithRotation.java | 40 +++++++++++ .../api/location/IDimensionalPosition.java | 20 ------ ...eBlockEntity.java => IColoredMachine.java} | 2 +- .../api/machine/MachineConstants.java | 36 ++++++++++ .../api/machine/MachineEntityNbt.java | 8 --- .../machines/api/machine/MachineIds.java | 17 ----- .../machines/api/machine/MachineNbt.java | 11 --- .../machines/api/machine/MachineTags.java | 16 ----- .../machines/api/room/WallConstants.java | 25 +++++++ .../machines/api/shrinking/PSDTags.java | 3 +- .../machines/api/util/KeyHelper.java | 30 ++++++++ .../dev/compactmods/machines/LoggingUtil.java | 2 +- .../machines/client/Resources.java | 2 +- .../machines/command/Commands.java | 2 +- .../machines/compat/jei}/JeiInfo.java | 3 +- .../location/PreciseDimensionalPosition.java | 70 ------------------- .../machine/LegacySizedTemplates.java | 2 +- .../machine/client/MachineColors.java | 10 +-- .../graph/node/CompactMachineNode.java | 3 - .../machine/item/ICompactMachineItem.java | 1 - .../machines/room/RoomRegistrar.java | 2 +- .../room/graph/node/RoomChunkNode.java | 2 +- .../room/history/PlayerRoomHistoryItem.java | 14 ---- .../machines/room/spawn/RoomSpawn.java | 2 +- .../machines/room/spawn/SpawnManager.java | 2 +- .../compactmods/machines/util/MathUtil.java | 7 +- .../compactmods/machines/util/NbtUtil.java | 2 +- .../compactmods/machines/util/PlayerUtil.java | 4 -- .../machines/wall/ItemBlockWall.java | 6 +- .../api/room/CompactRoomGenerator.java | 5 +- .../api/room/IPlayerRoomMetadata.java | 13 ---- .../api/room/IPlayerRoomMetadataProvider.java | 13 ---- .../api/room/RoomTemplate.java | 4 +- .../history/IPlayerRoomEntryPointManager.java | 11 +++ .../api/room/history/IRoomHistory.java | 11 --- .../api/room/history/IRoomHistoryItem.java | 11 --- .../api/room/history/RoomEntryPoint.java | 19 +++++ .../api/room/upgrade/RoomUpgrade.java | 2 +- 52 files changed, 207 insertions(+), 336 deletions(-) delete mode 100644 core-api/src/main/java/dev/compactmods/machines/api/CMBlocks.java delete mode 100644 core-api/src/main/java/dev/compactmods/machines/api/CompactMachinesAddon.java rename core-api/src/main/java/dev/compactmods/machines/api/{core => }/Constants.java (62%) delete mode 100644 core-api/src/main/java/dev/compactmods/machines/api/ICompactMachinesAddon.java rename core-api/src/main/java/dev/compactmods/machines/api/{core => }/Messages.java (98%) rename core-api/src/main/java/dev/compactmods/machines/api/{core => }/Tooltips.java (97%) rename core-api/src/main/java/dev/compactmods/machines/api/{core => advancement}/Advancements.java (96%) rename {core/src/main/java/dev/compactmods/machines => core-api/src/main/java/dev/compactmods/machines/api}/codec/CodecExtensions.java (97%) rename {core/src/main/java/dev/compactmods/machines => core-api/src/main/java/dev/compactmods/machines/api}/codec/DoubleStreamExtensions.java (97%) rename {core/src/main/java/dev/compactmods/machines => core-api/src/main/java/dev/compactmods/machines/api}/codec/NbtListCollector.java (96%) rename core-api/src/main/java/dev/compactmods/machines/api/{core => command}/CMCommands.java (94%) delete mode 100644 core-api/src/main/java/dev/compactmods/machines/api/core/CMTags.java create mode 100644 core-api/src/main/java/dev/compactmods/machines/api/location/GlobalPosWithRotation.java delete mode 100644 core-api/src/main/java/dev/compactmods/machines/api/location/IDimensionalPosition.java rename core-api/src/main/java/dev/compactmods/machines/api/machine/{IMachineBlockEntity.java => IColoredMachine.java} (63%) create mode 100644 core-api/src/main/java/dev/compactmods/machines/api/machine/MachineConstants.java delete mode 100644 core-api/src/main/java/dev/compactmods/machines/api/machine/MachineEntityNbt.java delete mode 100644 core-api/src/main/java/dev/compactmods/machines/api/machine/MachineIds.java delete mode 100644 core-api/src/main/java/dev/compactmods/machines/api/machine/MachineNbt.java delete mode 100644 core-api/src/main/java/dev/compactmods/machines/api/machine/MachineTags.java create mode 100644 core-api/src/main/java/dev/compactmods/machines/api/room/WallConstants.java create mode 100644 core-api/src/main/java/dev/compactmods/machines/api/util/KeyHelper.java rename {core-api/src/main/java/dev/compactmods/machines/api/core => core/src/main/java/dev/compactmods/machines/compat/jei}/JeiInfo.java (74%) delete mode 100644 core/src/main/java/dev/compactmods/machines/room/history/PlayerRoomHistoryItem.java delete mode 100644 room-api/src/main/java/dev/compactmods/compactmachines/api/room/IPlayerRoomMetadata.java delete mode 100644 room-api/src/main/java/dev/compactmods/compactmachines/api/room/IPlayerRoomMetadataProvider.java create mode 100644 room-api/src/main/java/dev/compactmods/compactmachines/api/room/history/IPlayerRoomEntryPointManager.java delete mode 100644 room-api/src/main/java/dev/compactmods/compactmachines/api/room/history/IRoomHistory.java delete mode 100644 room-api/src/main/java/dev/compactmods/compactmachines/api/room/history/IRoomHistoryItem.java create mode 100644 room-api/src/main/java/dev/compactmods/compactmachines/api/room/history/RoomEntryPoint.java diff --git a/README.md b/README.md index 5ed1ac0..b6912e5 100644 --- a/README.md +++ b/README.md @@ -12,4 +12,12 @@ like the dimension/registry keys, location-related classes, and block/item tags. ## Common Main (core) Contains core mod code such as structure generation, math, advancements, and data classes. +## Room API (room-api) +Contains classes and systems for working with machine rooms. +- Player Room History Management +- Room Owner Management +- Room Registration Systems +- Room Spawn Management + +## Room Upgrade API (room-upgrade-api) diff --git a/core-api/src/main/java/dev/compactmods/machines/api/CMBlocks.java b/core-api/src/main/java/dev/compactmods/machines/api/CMBlocks.java deleted file mode 100644 index 680991b..0000000 --- a/core-api/src/main/java/dev/compactmods/machines/api/CMBlocks.java +++ /dev/null @@ -1,17 +0,0 @@ -package dev.compactmods.machines.api; - -import dev.compactmods.machines.api.core.Constants; -import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.Block; - -public interface CMBlocks { - - ResourceKey BREAKABLE_WALL = blockKey("wall"); - ResourceKey SOLID_WALL = blockKey("solid_wall"); - - private static ResourceKey blockKey(String id) { - return ResourceKey.create(Registries.BLOCK, new ResourceLocation(Constants.MOD_ID, id)); - } -} diff --git a/core-api/src/main/java/dev/compactmods/machines/api/CompactMachinesAddon.java b/core-api/src/main/java/dev/compactmods/machines/api/CompactMachinesAddon.java deleted file mode 100644 index db09c3b..0000000 --- a/core-api/src/main/java/dev/compactmods/machines/api/CompactMachinesAddon.java +++ /dev/null @@ -1,9 +0,0 @@ -package dev.compactmods.machines.api; - -/** - * Registers an instance of {@link ICompactMachinesAddon} for use in getting api interfaces. - */ -public @interface CompactMachinesAddon { - - int major() default 2; -} diff --git a/core-api/src/main/java/dev/compactmods/machines/api/core/Constants.java b/core-api/src/main/java/dev/compactmods/machines/api/Constants.java similarity index 62% rename from core-api/src/main/java/dev/compactmods/machines/api/core/Constants.java rename to core-api/src/main/java/dev/compactmods/machines/api/Constants.java index 6857891..f0125d9 100644 --- a/core-api/src/main/java/dev/compactmods/machines/api/core/Constants.java +++ b/core-api/src/main/java/dev/compactmods/machines/api/Constants.java @@ -1,4 +1,4 @@ -package dev.compactmods.machines.api.core; +package dev.compactmods.machines.api; public interface Constants { String MOD_ID = "compactmachines"; diff --git a/core-api/src/main/java/dev/compactmods/machines/api/ICompactMachinesAddon.java b/core-api/src/main/java/dev/compactmods/machines/api/ICompactMachinesAddon.java deleted file mode 100644 index 9422d82..0000000 --- a/core-api/src/main/java/dev/compactmods/machines/api/ICompactMachinesAddon.java +++ /dev/null @@ -1,12 +0,0 @@ -package dev.compactmods.machines.api; - -public interface ICompactMachinesAddon { - - default void prepare() { - // no-op - } - - default void afterRegistration() { - // no-op - } -} diff --git a/core-api/src/main/java/dev/compactmods/machines/api/core/Messages.java b/core-api/src/main/java/dev/compactmods/machines/api/Messages.java similarity index 98% rename from core-api/src/main/java/dev/compactmods/machines/api/core/Messages.java rename to core-api/src/main/java/dev/compactmods/machines/api/Messages.java index 80612fd..1c8973c 100644 --- a/core-api/src/main/java/dev/compactmods/machines/api/core/Messages.java +++ b/core-api/src/main/java/dev/compactmods/machines/api/Messages.java @@ -1,4 +1,4 @@ -package dev.compactmods.machines.api.core; +package dev.compactmods.machines.api; import net.minecraft.resources.ResourceLocation; diff --git a/core-api/src/main/java/dev/compactmods/machines/api/core/Tooltips.java b/core-api/src/main/java/dev/compactmods/machines/api/Tooltips.java similarity index 97% rename from core-api/src/main/java/dev/compactmods/machines/api/core/Tooltips.java rename to core-api/src/main/java/dev/compactmods/machines/api/Tooltips.java index 85d5e40..899fa3f 100644 --- a/core-api/src/main/java/dev/compactmods/machines/api/core/Tooltips.java +++ b/core-api/src/main/java/dev/compactmods/machines/api/Tooltips.java @@ -1,4 +1,4 @@ -package dev.compactmods.machines.api.core; +package dev.compactmods.machines.api; import net.minecraft.resources.ResourceLocation; diff --git a/core-api/src/main/java/dev/compactmods/machines/api/core/Advancements.java b/core-api/src/main/java/dev/compactmods/machines/api/advancement/Advancements.java similarity index 96% rename from core-api/src/main/java/dev/compactmods/machines/api/core/Advancements.java rename to core-api/src/main/java/dev/compactmods/machines/api/advancement/Advancements.java index 3d670dc..1d25f2b 100644 --- a/core-api/src/main/java/dev/compactmods/machines/api/core/Advancements.java +++ b/core-api/src/main/java/dev/compactmods/machines/api/advancement/Advancements.java @@ -1,5 +1,6 @@ -package dev.compactmods.machines.api.core; +package dev.compactmods.machines.api.advancement; +import dev.compactmods.machines.api.Constants; import net.minecraft.resources.ResourceLocation; /** diff --git a/core/src/main/java/dev/compactmods/machines/codec/CodecExtensions.java b/core-api/src/main/java/dev/compactmods/machines/api/codec/CodecExtensions.java similarity index 97% rename from core/src/main/java/dev/compactmods/machines/codec/CodecExtensions.java rename to core-api/src/main/java/dev/compactmods/machines/api/codec/CodecExtensions.java index f60a451..be318c6 100644 --- a/core/src/main/java/dev/compactmods/machines/codec/CodecExtensions.java +++ b/core-api/src/main/java/dev/compactmods/machines/api/codec/CodecExtensions.java @@ -1,4 +1,4 @@ -package dev.compactmods.machines.codec; +package dev.compactmods.machines.api.codec; import com.mojang.serialization.Codec; import net.minecraft.Util; diff --git a/core/src/main/java/dev/compactmods/machines/codec/DoubleStreamExtensions.java b/core-api/src/main/java/dev/compactmods/machines/api/codec/DoubleStreamExtensions.java similarity index 97% rename from core/src/main/java/dev/compactmods/machines/codec/DoubleStreamExtensions.java rename to core-api/src/main/java/dev/compactmods/machines/api/codec/DoubleStreamExtensions.java index b3c106f..b651d66 100644 --- a/core/src/main/java/dev/compactmods/machines/codec/DoubleStreamExtensions.java +++ b/core-api/src/main/java/dev/compactmods/machines/api/codec/DoubleStreamExtensions.java @@ -1,4 +1,4 @@ -package dev.compactmods.machines.codec; +package dev.compactmods.machines.api.codec; import com.mojang.serialization.DataResult; import com.mojang.serialization.DynamicOps; diff --git a/core/src/main/java/dev/compactmods/machines/codec/NbtListCollector.java b/core-api/src/main/java/dev/compactmods/machines/api/codec/NbtListCollector.java similarity index 96% rename from core/src/main/java/dev/compactmods/machines/codec/NbtListCollector.java rename to core-api/src/main/java/dev/compactmods/machines/api/codec/NbtListCollector.java index 44640c0..078a40b 100644 --- a/core/src/main/java/dev/compactmods/machines/codec/NbtListCollector.java +++ b/core-api/src/main/java/dev/compactmods/machines/api/codec/NbtListCollector.java @@ -1,4 +1,4 @@ -package dev.compactmods.machines.codec; +package dev.compactmods.machines.api.codec; import com.google.common.collect.ImmutableSet; import net.minecraft.nbt.Tag; diff --git a/core-api/src/main/java/dev/compactmods/machines/api/core/CMCommands.java b/core-api/src/main/java/dev/compactmods/machines/api/command/CMCommands.java similarity index 94% rename from core-api/src/main/java/dev/compactmods/machines/api/core/CMCommands.java rename to core-api/src/main/java/dev/compactmods/machines/api/command/CMCommands.java index 9dbab4e..5cd52bb 100644 --- a/core-api/src/main/java/dev/compactmods/machines/api/core/CMCommands.java +++ b/core-api/src/main/java/dev/compactmods/machines/api/command/CMCommands.java @@ -1,8 +1,8 @@ -package dev.compactmods.machines.api.core; +package dev.compactmods.machines.api.command; import net.minecraft.resources.ResourceLocation; -import static dev.compactmods.machines.api.core.Constants.MOD_ID; +import static dev.compactmods.machines.api.Constants.MOD_ID; public interface CMCommands { ResourceLocation LEVEL_REGISTERED = new ResourceLocation(MOD_ID, "level_registered"); diff --git a/core-api/src/main/java/dev/compactmods/machines/api/core/CMTags.java b/core-api/src/main/java/dev/compactmods/machines/api/core/CMTags.java deleted file mode 100644 index d31755b..0000000 --- a/core-api/src/main/java/dev/compactmods/machines/api/core/CMTags.java +++ /dev/null @@ -1,41 +0,0 @@ -package dev.compactmods.machines.api.core; - -import net.minecraft.core.Registry; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.TagKey; -import net.minecraft.world.item.Item; -import net.minecraft.world.level.block.Block; - -public interface CMTags { - /** - * Marks an item as a room upgrade. Not yet used by the main mod. - */ - TagKey ROOM_UPGRADE_ITEM = TagKey.create(Registries.ITEM, new ResourceLocation(Constants.MOD_ID, "room_upgrade")); - - /** - * Marks an item as a Compact Machine item. - */ - TagKey MACHINE_ITEM = TagKey.create(Registries.ITEM, new ResourceLocation(Constants.MOD_ID, "machine")); - - /** - * Marks a block as a Compact Machine block. - */ - TagKey MACHINE_BLOCK = TagKey.create(Registries.BLOCK, new ResourceLocation(Constants.MOD_ID, "machine")); - - /** - * Marks a block as an unbound Compact Machine; applied only to machines that are not yet bound to a room. - */ - TagKey UNBOUND_MACHINE_BLOCK = TagKey.create(Registries.BLOCK, new ResourceLocation(Constants.MOD_ID, "new_machine")); - - /** - * Applied to solid wall items. - */ - TagKey SOLID_WALL_ITEMS = TagKey.create(Registries.ITEM, new ResourceLocation(Constants.MOD_ID, "solid_walls")); - - /** - * Applied to solid walls and tunnel blocks. - */ - TagKey SOLID_WALL_BLOCKS = TagKey.create(Registries.BLOCK, new ResourceLocation(Constants.MOD_ID, "solid_walls")); -} diff --git a/core-api/src/main/java/dev/compactmods/machines/api/dimension/CompactDimension.java b/core-api/src/main/java/dev/compactmods/machines/api/dimension/CompactDimension.java index 2637be0..6a6e0ac 100644 --- a/core-api/src/main/java/dev/compactmods/machines/api/dimension/CompactDimension.java +++ b/core-api/src/main/java/dev/compactmods/machines/api/dimension/CompactDimension.java @@ -1,6 +1,5 @@ package dev.compactmods.machines.api.dimension; -import net.minecraft.core.Registry; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; @@ -13,7 +12,7 @@ import net.minecraft.world.level.storage.LevelStorageSource; import org.jetbrains.annotations.NotNull; -import static dev.compactmods.machines.api.core.Constants.MOD_ID; +import static dev.compactmods.machines.api.Constants.MOD_ID; public abstract class CompactDimension { public static final ResourceKey LEVEL_KEY = ResourceKey @@ -40,7 +39,6 @@ public static DimensionDataStorage getDataStorage(@NotNull LevelStorageSource.Le return new DimensionDataStorage(dimPath.resolve("data").toFile(), fixer); } - @NotNull public static boolean isLevelCompact(Level level) { return level.dimension().equals(LEVEL_KEY); } diff --git a/core-api/src/main/java/dev/compactmods/machines/api/location/GlobalPosWithRotation.java b/core-api/src/main/java/dev/compactmods/machines/api/location/GlobalPosWithRotation.java new file mode 100644 index 0000000..f2d0b8e --- /dev/null +++ b/core-api/src/main/java/dev/compactmods/machines/api/location/GlobalPosWithRotation.java @@ -0,0 +1,40 @@ +package dev.compactmods.machines.api.location; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import dev.compactmods.machines.api.codec.CodecExtensions; +import net.minecraft.core.BlockPos; +import net.minecraft.core.GlobalPos; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec2; +import net.minecraft.world.phys.Vec3; + +public record GlobalPosWithRotation(ResourceKey dimension, Vec3 position, Vec2 rotation) { + + /* + * BlockPos also technically supported here, since pos matches GlobalPos.CODEC#pos - only difference + * here is that BlockPos uses an INT stream, while VEC3D uses a double stream. + */ + public static final Codec CODEC = RecordCodecBuilder.create(i -> i.group( + ResourceKey.codec(Registries.DIMENSION).fieldOf("dimension").forGetter(GlobalPosWithRotation::dimension), + CodecExtensions.VECTOR3D.fieldOf("pos").forGetter(GlobalPosWithRotation::position), + CodecExtensions.VEC2.optionalFieldOf("rot", Vec2.ZERO).forGetter(x -> x.rotation) + ).apply(i, GlobalPosWithRotation::new)); + + public static final GlobalPosWithRotation INVALID = new GlobalPosWithRotation(GlobalPos.of(Level.OVERWORLD, BlockPos.ZERO), Vec2.ZERO); + + public GlobalPosWithRotation(GlobalPos pos, Vec2 rotation) { + this(pos.dimension(), Vec3.atBottomCenterOf(pos.pos()), rotation); + } + + public GlobalPosWithRotation(ResourceKey dimension, BlockPos position, Vec2 rotation) { + this(dimension, Vec3.atBottomCenterOf(position), rotation); + } + + public static GlobalPosWithRotation fromPlayer(Player player) { + return new GlobalPosWithRotation(player.level().dimension(), player.position(), new Vec2(player.xRotO, player.yRotO)); + } +} diff --git a/core-api/src/main/java/dev/compactmods/machines/api/location/IDimensionalPosition.java b/core-api/src/main/java/dev/compactmods/machines/api/location/IDimensionalPosition.java deleted file mode 100644 index 0eafb42..0000000 --- a/core-api/src/main/java/dev/compactmods/machines/api/location/IDimensionalPosition.java +++ /dev/null @@ -1,20 +0,0 @@ -package dev.compactmods.machines.api.location; - -import net.minecraft.resources.ResourceKey; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.level.ChunkPos; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; - -public interface IDimensionalPosition { - - Vec3 position(); - - ResourceKey dimension(); - ServerLevel level(MinecraftServer server); - - boolean isLoaded(MinecraftServer serv); - - ChunkPos chunkPos(); -} diff --git a/core-api/src/main/java/dev/compactmods/machines/api/machine/IMachineBlockEntity.java b/core-api/src/main/java/dev/compactmods/machines/api/machine/IColoredMachine.java similarity index 63% rename from core-api/src/main/java/dev/compactmods/machines/api/machine/IMachineBlockEntity.java rename to core-api/src/main/java/dev/compactmods/machines/api/machine/IColoredMachine.java index e19964c..39d00cb 100644 --- a/core-api/src/main/java/dev/compactmods/machines/api/machine/IMachineBlockEntity.java +++ b/core-api/src/main/java/dev/compactmods/machines/api/machine/IColoredMachine.java @@ -1,5 +1,5 @@ package dev.compactmods.machines.api.machine; -public interface IMachineBlockEntity { +public interface IColoredMachine { int getColor(); } diff --git a/core-api/src/main/java/dev/compactmods/machines/api/machine/MachineConstants.java b/core-api/src/main/java/dev/compactmods/machines/api/machine/MachineConstants.java new file mode 100644 index 0000000..ec9ced9 --- /dev/null +++ b/core-api/src/main/java/dev/compactmods/machines/api/machine/MachineConstants.java @@ -0,0 +1,36 @@ +package dev.compactmods.machines.api.machine; + +import dev.compactmods.machines.api.Constants; +import dev.compactmods.machines.api.util.KeyHelper; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.TagKey; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; + +public interface MachineConstants { + + ResourceLocation BOUND_MACHINE_BLOCK_ID = new ResourceLocation(Constants.MOD_ID, "machine"); + ResourceLocation BOUND_MACHINE_ENTITY = new ResourceLocation(Constants.MOD_ID, "machine"); + + ResourceLocation UNBOUND_MACHINE_BLOCK_ID = new ResourceLocation(Constants.MOD_ID, "new_machine"); + ResourceLocation UNBOUND_MACHINE_ITEM_ID = new ResourceLocation(Constants.MOD_ID, "new_machine"); + ResourceLocation UNBOUND_MACHINE_ENTITY = new ResourceLocation(Constants.MOD_ID, "new_machine"); + + ResourceKey UNBOUND_MACHINE_BLOCK_RESKEY = KeyHelper.blockResKey("new_machine"); + ResourceKey UNBOUND_MACHINE_ITEM_RESKEY = KeyHelper.itemResKey("new_machine"); + + /** + * Marks a block as an unbound Compact Machine; applied only to machines that are not yet bound to a room. + */ + TagKey UNBOUND_MACHINE_BLOCK = KeyHelper.blockTag("new_machine"); + + /** + * Marks a block as a bound Compact Machine; applied only to machines that are bound to a room. + */ + TagKey BOUND_MACHINE_BLOCK = KeyHelper.blockTag("bound_machine"); + + TagKey MACHINE_BLOCK = KeyHelper.blockTag("machine"); + TagKey MACHINE_ITEM = KeyHelper.itemTagKey("machine"); + +} diff --git a/core-api/src/main/java/dev/compactmods/machines/api/machine/MachineEntityNbt.java b/core-api/src/main/java/dev/compactmods/machines/api/machine/MachineEntityNbt.java deleted file mode 100644 index 2a3616e..0000000 --- a/core-api/src/main/java/dev/compactmods/machines/api/machine/MachineEntityNbt.java +++ /dev/null @@ -1,8 +0,0 @@ -package dev.compactmods.machines.api.machine; - -public interface MachineEntityNbt { - String NBT_ROOM_CODE = "room_code"; - String NBT_CUSTOM_COLOR = "machine_color"; - String NBT_TEMPLATE_ID = "template_id"; - String NBT_ROOM_COLOR = "room_color"; -} diff --git a/core-api/src/main/java/dev/compactmods/machines/api/machine/MachineIds.java b/core-api/src/main/java/dev/compactmods/machines/api/machine/MachineIds.java deleted file mode 100644 index a9e0583..0000000 --- a/core-api/src/main/java/dev/compactmods/machines/api/machine/MachineIds.java +++ /dev/null @@ -1,17 +0,0 @@ -package dev.compactmods.machines.api.machine; - -import dev.compactmods.machines.api.core.Constants; -import net.minecraft.core.Registry; -import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.Item; - -public interface MachineIds { - - ResourceLocation BOUND_MACHINE_ENTITY = new ResourceLocation(Constants.MOD_ID, "machine"); - - ResourceLocation UNBOUND_MACHINE_ENTITY = new ResourceLocation(Constants.MOD_ID, "new_machine"); - ResourceLocation UNBOUND_MACHINE_ITEM_ID = new ResourceLocation(Constants.MOD_ID, "new_machine"); - ResourceKey UNBOUND_MACHINE_ITEM_KEY = ResourceKey.create(Registries.ITEM, UNBOUND_MACHINE_ITEM_ID); -} diff --git a/core-api/src/main/java/dev/compactmods/machines/api/machine/MachineNbt.java b/core-api/src/main/java/dev/compactmods/machines/api/machine/MachineNbt.java deleted file mode 100644 index 2b0e20a..0000000 --- a/core-api/src/main/java/dev/compactmods/machines/api/machine/MachineNbt.java +++ /dev/null @@ -1,11 +0,0 @@ -package dev.compactmods.machines.api.machine; - -public abstract class MachineNbt { - public static final String OWNER = "owner"; - public static final String ID = "machine_id"; - - public static final String NBT_TEMPLATE_ID = "template_id"; - public static final String NBT_COLOR = "machine_color"; - - public static final String NBT_CUSTOM_NAME = "custom_name"; -} diff --git a/core-api/src/main/java/dev/compactmods/machines/api/machine/MachineTags.java b/core-api/src/main/java/dev/compactmods/machines/api/machine/MachineTags.java deleted file mode 100644 index a8e3a3b..0000000 --- a/core-api/src/main/java/dev/compactmods/machines/api/machine/MachineTags.java +++ /dev/null @@ -1,16 +0,0 @@ -package dev.compactmods.machines.api.machine; - -import dev.compactmods.machines.api.core.Constants; -import net.minecraft.core.Registry; -import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.TagKey; -import net.minecraft.world.item.Item; -import net.minecraft.world.level.block.Block; - -public interface MachineTags { - - TagKey BLOCK = TagKey.create(Registries.BLOCK, new ResourceLocation(Constants.MOD_ID, "machine")); - TagKey ITEM = TagKey.create(Registries.ITEM, new ResourceLocation(Constants.MOD_ID, "machine")); - -} diff --git a/core-api/src/main/java/dev/compactmods/machines/api/room/WallConstants.java b/core-api/src/main/java/dev/compactmods/machines/api/room/WallConstants.java new file mode 100644 index 0000000..983a292 --- /dev/null +++ b/core-api/src/main/java/dev/compactmods/machines/api/room/WallConstants.java @@ -0,0 +1,25 @@ +package dev.compactmods.machines.api.room; + +import dev.compactmods.machines.api.util.KeyHelper; +import net.minecraft.resources.ResourceKey; +import net.minecraft.tags.TagKey; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; + +public interface WallConstants { + + ResourceKey BREAKABLE_WALL = KeyHelper.blockResKey("wall"); + ResourceKey SOLID_WALL = KeyHelper.blockResKey("solid_wall"); + + /** + * Applied to solid wall items. + */ + TagKey TAG_SOLID_WALL_ITEMS = KeyHelper.itemTagKey("solid_walls"); + + /** + * Applied to solid walls and tunnel blocks. + */ + TagKey TAG_SOLID_WALL_BLOCKS = KeyHelper.blockTag("solid_walls"); + + +} diff --git a/core-api/src/main/java/dev/compactmods/machines/api/shrinking/PSDTags.java b/core-api/src/main/java/dev/compactmods/machines/api/shrinking/PSDTags.java index 5954353..2d1bd4b 100644 --- a/core-api/src/main/java/dev/compactmods/machines/api/shrinking/PSDTags.java +++ b/core-api/src/main/java/dev/compactmods/machines/api/shrinking/PSDTags.java @@ -1,7 +1,6 @@ package dev.compactmods.machines.api.shrinking; -import dev.compactmods.machines.api.core.Constants; -import net.minecraft.core.Registry; +import dev.compactmods.machines.api.Constants; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; diff --git a/core-api/src/main/java/dev/compactmods/machines/api/util/KeyHelper.java b/core-api/src/main/java/dev/compactmods/machines/api/util/KeyHelper.java new file mode 100644 index 0000000..0242af4 --- /dev/null +++ b/core-api/src/main/java/dev/compactmods/machines/api/util/KeyHelper.java @@ -0,0 +1,30 @@ +package dev.compactmods.machines.api.util; + +import dev.compactmods.machines.api.Constants; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.TagKey; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; +import org.jetbrains.annotations.NotNull; + +public class KeyHelper { + + public static ResourceKey blockResKey(String id) { + return ResourceKey.create(Registries.BLOCK, new ResourceLocation(Constants.MOD_ID, id)); + } + + @NotNull + public static TagKey itemTagKey(String id) { + return TagKey.create(Registries.ITEM, new ResourceLocation(Constants.MOD_ID, id)); + } + + public static TagKey blockTag(String id) { + return TagKey.create(Registries.BLOCK, new ResourceLocation(Constants.MOD_ID, id)); + } + + public static ResourceKey itemResKey(String id) { + return ResourceKey.create(Registries.ITEM, new ResourceLocation(Constants.MOD_ID, id)); + } +} diff --git a/core/src/main/java/dev/compactmods/machines/LoggingUtil.java b/core/src/main/java/dev/compactmods/machines/LoggingUtil.java index 6de675d..70cf0f0 100644 --- a/core/src/main/java/dev/compactmods/machines/LoggingUtil.java +++ b/core/src/main/java/dev/compactmods/machines/LoggingUtil.java @@ -1,6 +1,6 @@ package dev.compactmods.machines; -import dev.compactmods.machines.api.core.Constants; +import dev.compactmods.machines.api.Constants; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/core/src/main/java/dev/compactmods/machines/client/Resources.java b/core/src/main/java/dev/compactmods/machines/client/Resources.java index 149d77d..0bbcccd 100644 --- a/core/src/main/java/dev/compactmods/machines/client/Resources.java +++ b/core/src/main/java/dev/compactmods/machines/client/Resources.java @@ -1,6 +1,6 @@ package dev.compactmods.machines.client; -import dev.compactmods.machines.api.core.Constants; +import dev.compactmods.machines.api.Constants; import net.minecraft.resources.ResourceLocation; public class Resources { diff --git a/core/src/main/java/dev/compactmods/machines/command/Commands.java b/core/src/main/java/dev/compactmods/machines/command/Commands.java index ee53ed3..ec079b5 100644 --- a/core/src/main/java/dev/compactmods/machines/command/Commands.java +++ b/core/src/main/java/dev/compactmods/machines/command/Commands.java @@ -1,7 +1,7 @@ package dev.compactmods.machines.command; import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import dev.compactmods.machines.api.core.Constants; +import dev.compactmods.machines.api.Constants; import net.minecraft.commands.CommandSourceStack; diff --git a/core-api/src/main/java/dev/compactmods/machines/api/core/JeiInfo.java b/core/src/main/java/dev/compactmods/machines/compat/jei/JeiInfo.java similarity index 74% rename from core-api/src/main/java/dev/compactmods/machines/api/core/JeiInfo.java rename to core/src/main/java/dev/compactmods/machines/compat/jei/JeiInfo.java index 3a2b998..fc788d9 100644 --- a/core-api/src/main/java/dev/compactmods/machines/api/core/JeiInfo.java +++ b/core/src/main/java/dev/compactmods/machines/compat/jei/JeiInfo.java @@ -1,5 +1,6 @@ -package dev.compactmods.machines.api.core; +package dev.compactmods.machines.compat.jei; +import dev.compactmods.machines.api.Constants; import net.minecraft.resources.ResourceLocation; public interface JeiInfo { diff --git a/core/src/main/java/dev/compactmods/machines/location/PreciseDimensionalPosition.java b/core/src/main/java/dev/compactmods/machines/location/PreciseDimensionalPosition.java index 847ce59..e69de29 100644 --- a/core/src/main/java/dev/compactmods/machines/location/PreciseDimensionalPosition.java +++ b/core/src/main/java/dev/compactmods/machines/location/PreciseDimensionalPosition.java @@ -1,70 +0,0 @@ -package dev.compactmods.machines.location; - -import com.mojang.serialization.Codec; -import com.mojang.serialization.codecs.RecordCodecBuilder; -import dev.compactmods.machines.api.location.IDimensionalPosition; -import dev.compactmods.machines.codec.CodecExtensions; -import dev.compactmods.machines.util.MathUtil; -import net.minecraft.core.BlockPos; -import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceKey; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.ChunkPos; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec2; -import net.minecraft.world.phys.Vec3; - -import java.util.Objects; - -public record PreciseDimensionalPosition(ResourceKey dimension, Vec3 position, Vec2 rotation) - implements IDimensionalPosition { - - public static final Codec CODEC = RecordCodecBuilder.create(i -> i.group( - ResourceKey.codec(Registries.DIMENSION).fieldOf("dim").forGetter(PreciseDimensionalPosition::dimension), - CodecExtensions.VECTOR3D.fieldOf("pos").forGetter(PreciseDimensionalPosition::position), - CodecExtensions.VEC2.optionalFieldOf("rot", Vec2.ZERO).forGetter(x -> x.rotation) - ).apply(i, PreciseDimensionalPosition::new)); - - public static PreciseDimensionalPosition fromPlayer(Player player) { - return new PreciseDimensionalPosition(player.level().dimension(), player.position(), new Vec2(player.xRotO, player.yRotO)); - } - - @Override - public ServerLevel level(MinecraftServer server) { - return server.getLevel(dimension); - } - - @Override - public boolean isLoaded(MinecraftServer serv) { - return level(serv).isLoaded(BlockPos.containing(position)); - } - - @Override - public ChunkPos chunkPos() { - return MathUtil.getChunkPos(this.position); - } - - @Override - public boolean equals(Object obj) { - if (obj == this) return true; - if (obj == null || obj.getClass() != this.getClass()) return false; - var that = (PreciseDimensionalPosition) obj; - return Objects.equals(this.dimension, that.dimension) && - Objects.equals(this.position, that.position); - } - - @Override - public int hashCode() { - return Objects.hash(dimension, position); - } - - @Override - public String toString() { - return "PreciseDimensionalPosition[" + - "dimension=" + dimension + ", " + - "position=" + position + ']'; - } - -} diff --git a/core/src/main/java/dev/compactmods/machines/machine/LegacySizedTemplates.java b/core/src/main/java/dev/compactmods/machines/machine/LegacySizedTemplates.java index 2063216..c0a1c47 100644 --- a/core/src/main/java/dev/compactmods/machines/machine/LegacySizedTemplates.java +++ b/core/src/main/java/dev/compactmods/machines/machine/LegacySizedTemplates.java @@ -1,7 +1,7 @@ package dev.compactmods.machines.machine; import dev.compactmods.compactmachines.api.room.RoomTemplate; -import dev.compactmods.machines.api.core.Constants; +import dev.compactmods.machines.api.Constants; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.FastColor; diff --git a/core/src/main/java/dev/compactmods/machines/machine/client/MachineColors.java b/core/src/main/java/dev/compactmods/machines/machine/client/MachineColors.java index 4272720..fedb766 100644 --- a/core/src/main/java/dev/compactmods/machines/machine/client/MachineColors.java +++ b/core/src/main/java/dev/compactmods/machines/machine/client/MachineColors.java @@ -1,7 +1,7 @@ package dev.compactmods.machines.machine.client; -import dev.compactmods.machines.api.core.CMTags; -import dev.compactmods.machines.api.machine.IMachineBlockEntity; +import dev.compactmods.machines.api.machine.IColoredMachine; +import dev.compactmods.machines.api.machine.MachineConstants; import dev.compactmods.machines.machine.item.ICompactMachineItem; import net.minecraft.client.color.block.BlockColor; import net.minecraft.client.color.item.ItemColor; @@ -9,15 +9,15 @@ public class MachineColors { public static final ItemColor ITEM = (stack, pTintIndex) -> { - if(!stack.is(CMTags.MACHINE_ITEM)) return 0xFFFFFFFF; + if(!stack.is(MachineConstants.MACHINE_ITEM)) return 0xFFFFFFFF; return pTintIndex == 0 ? ICompactMachineItem.getMachineColor(stack) : 0xFFFFFFFF; }; public static final BlockColor BLOCK = (state, level, pos, tintIndex) -> { - if(!state.is(CMTags.MACHINE_BLOCK) || level == null || pos == null) + if(!state.is(MachineConstants.MACHINE_BLOCK) || level == null || pos == null) return 0xFFFFFFFF; - if(!(level.getBlockEntity(pos) instanceof IMachineBlockEntity machineData)) + if(!(level.getBlockEntity(pos) instanceof IColoredMachine machineData)) return 0xFFFFFFFF; return tintIndex == 0 ? machineData.getColor() : 0xFFFFFFFF; diff --git a/core/src/main/java/dev/compactmods/machines/machine/graph/node/CompactMachineNode.java b/core/src/main/java/dev/compactmods/machines/machine/graph/node/CompactMachineNode.java index c10ea3e..a5927d7 100644 --- a/core/src/main/java/dev/compactmods/machines/machine/graph/node/CompactMachineNode.java +++ b/core/src/main/java/dev/compactmods/machines/machine/graph/node/CompactMachineNode.java @@ -3,13 +3,10 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import dev.compactmods.feather.node.Node; -import dev.compactmods.machines.api.core.Constants; import net.minecraft.core.BlockPos; import net.minecraft.core.GlobalPos; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; import java.util.UUID; diff --git a/core/src/main/java/dev/compactmods/machines/machine/item/ICompactMachineItem.java b/core/src/main/java/dev/compactmods/machines/machine/item/ICompactMachineItem.java index 0a87405..10cfa97 100644 --- a/core/src/main/java/dev/compactmods/machines/machine/item/ICompactMachineItem.java +++ b/core/src/main/java/dev/compactmods/machines/machine/item/ICompactMachineItem.java @@ -1,6 +1,5 @@ package dev.compactmods.machines.machine.item; -import dev.compactmods.machines.api.machine.MachineNbt; import net.minecraft.world.item.ItemStack; public interface ICompactMachineItem { diff --git a/core/src/main/java/dev/compactmods/machines/room/RoomRegistrar.java b/core/src/main/java/dev/compactmods/machines/room/RoomRegistrar.java index 63bfa9f..7081cd5 100644 --- a/core/src/main/java/dev/compactmods/machines/room/RoomRegistrar.java +++ b/core/src/main/java/dev/compactmods/machines/room/RoomRegistrar.java @@ -5,7 +5,7 @@ import dev.compactmods.compactmachines.api.room.RoomInstance; import dev.compactmods.compactmachines.api.room.registration.IRoomBuilder; import dev.compactmods.feather.MemoryGraph; -import dev.compactmods.machines.api.core.Constants; +import dev.compactmods.machines.api.Constants; import dev.compactmods.machines.api.dimension.CompactDimension; import dev.compactmods.machines.api.dimension.MissingDimensionException; import dev.compactmods.machines.room.graph.node.RoomRegistrationNode; diff --git a/core/src/main/java/dev/compactmods/machines/room/graph/node/RoomChunkNode.java b/core/src/main/java/dev/compactmods/machines/room/graph/node/RoomChunkNode.java index c071f20..e97b7aa 100644 --- a/core/src/main/java/dev/compactmods/machines/room/graph/node/RoomChunkNode.java +++ b/core/src/main/java/dev/compactmods/machines/room/graph/node/RoomChunkNode.java @@ -3,7 +3,7 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import dev.compactmods.feather.node.Node; -import dev.compactmods.machines.codec.CodecExtensions; +import dev.compactmods.machines.api.codec.CodecExtensions; import net.minecraft.world.level.ChunkPos; import java.util.UUID; diff --git a/core/src/main/java/dev/compactmods/machines/room/history/PlayerRoomHistoryItem.java b/core/src/main/java/dev/compactmods/machines/room/history/PlayerRoomHistoryItem.java deleted file mode 100644 index 81db4c1..0000000 --- a/core/src/main/java/dev/compactmods/machines/room/history/PlayerRoomHistoryItem.java +++ /dev/null @@ -1,14 +0,0 @@ -package dev.compactmods.machines.room.history; - -import com.mojang.serialization.Codec; -import com.mojang.serialization.codecs.RecordCodecBuilder; -import dev.compactmods.machines.location.PreciseDimensionalPosition; -import net.minecraft.core.GlobalPos; - -public record PlayerRoomHistoryItem(PreciseDimensionalPosition entry, GlobalPos machine) { - - public static final Codec CODEC = RecordCodecBuilder.create(i -> i.group( - PreciseDimensionalPosition.CODEC.fieldOf("position").forGetter(PlayerRoomHistoryItem::entry), - GlobalPos.CODEC.fieldOf("machine").forGetter(PlayerRoomHistoryItem::machine) - ).apply(i, PlayerRoomHistoryItem::new)); -} diff --git a/core/src/main/java/dev/compactmods/machines/room/spawn/RoomSpawn.java b/core/src/main/java/dev/compactmods/machines/room/spawn/RoomSpawn.java index 7cf46ea..3486813 100644 --- a/core/src/main/java/dev/compactmods/machines/room/spawn/RoomSpawn.java +++ b/core/src/main/java/dev/compactmods/machines/room/spawn/RoomSpawn.java @@ -3,7 +3,7 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import dev.compactmods.compactmachines.api.room.spawn.IRoomSpawn; -import dev.compactmods.machines.codec.CodecExtensions; +import dev.compactmods.machines.api.codec.CodecExtensions; import net.minecraft.world.phys.Vec2; import net.minecraft.world.phys.Vec3; diff --git a/core/src/main/java/dev/compactmods/machines/room/spawn/SpawnManager.java b/core/src/main/java/dev/compactmods/machines/room/spawn/SpawnManager.java index 9b635fb..4f59e33 100644 --- a/core/src/main/java/dev/compactmods/machines/room/spawn/SpawnManager.java +++ b/core/src/main/java/dev/compactmods/machines/room/spawn/SpawnManager.java @@ -4,7 +4,7 @@ import dev.compactmods.compactmachines.api.room.spawn.IRoomSpawn; import dev.compactmods.compactmachines.api.room.spawn.IRoomSpawnManager; import dev.compactmods.compactmachines.api.room.spawn.IRoomSpawns; -import dev.compactmods.machines.api.core.Constants; +import dev.compactmods.machines.api.Constants; import dev.compactmods.machines.api.dimension.CompactDimension; import dev.compactmods.machines.api.dimension.MissingDimensionException; import net.minecraft.nbt.CompoundTag; diff --git a/core/src/main/java/dev/compactmods/machines/util/MathUtil.java b/core/src/main/java/dev/compactmods/machines/util/MathUtil.java index 090009d..9f4f922 100644 --- a/core/src/main/java/dev/compactmods/machines/util/MathUtil.java +++ b/core/src/main/java/dev/compactmods/machines/util/MathUtil.java @@ -10,16 +10,11 @@ import java.util.stream.Stream; public class MathUtil { - public static ChunkPos getChunkPos(Vec3 precise) { - final var x = SectionPos.blockToSectionCoord(precise.x); - final var z = SectionPos.blockToSectionCoord(precise.z); - return new ChunkPos(x, z); - } public static Stream getChunksFromAABB(AABB bounds) { ChunkPos min = new ChunkPos(BlockPos.containing(bounds.minX, bounds.minY, bounds.minZ)); ChunkPos max = new ChunkPos(BlockPos.containing(bounds.maxX, bounds.maxY, bounds.maxZ)); - + return ChunkPos.rangeClosed(min, max); } diff --git a/core/src/main/java/dev/compactmods/machines/util/NbtUtil.java b/core/src/main/java/dev/compactmods/machines/util/NbtUtil.java index 117fcb8..d271982 100644 --- a/core/src/main/java/dev/compactmods/machines/util/NbtUtil.java +++ b/core/src/main/java/dev/compactmods/machines/util/NbtUtil.java @@ -1,6 +1,6 @@ package dev.compactmods.machines.util; -import dev.compactmods.machines.codec.CodecExtensions; +import dev.compactmods.machines.api.codec.CodecExtensions; import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.Tag; import net.minecraft.world.level.ChunkPos; diff --git a/core/src/main/java/dev/compactmods/machines/util/PlayerUtil.java b/core/src/main/java/dev/compactmods/machines/util/PlayerUtil.java index 6cb7044..42d286c 100644 --- a/core/src/main/java/dev/compactmods/machines/util/PlayerUtil.java +++ b/core/src/main/java/dev/compactmods/machines/util/PlayerUtil.java @@ -1,14 +1,10 @@ package dev.compactmods.machines.util; import com.mojang.authlib.GameProfile; -import dev.compactmods.machines.api.core.Messages; -import dev.compactmods.machines.i18n.TranslationUtil; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.phys.Vec2; -import org.jetbrains.annotations.NotNull; import java.util.Optional; import java.util.UUID; diff --git a/core/src/main/java/dev/compactmods/machines/wall/ItemBlockWall.java b/core/src/main/java/dev/compactmods/machines/wall/ItemBlockWall.java index f967ba8..841cd9b 100644 --- a/core/src/main/java/dev/compactmods/machines/wall/ItemBlockWall.java +++ b/core/src/main/java/dev/compactmods/machines/wall/ItemBlockWall.java @@ -1,7 +1,7 @@ package dev.compactmods.machines.wall; -import dev.compactmods.machines.api.core.CMTags; -import dev.compactmods.machines.api.core.Tooltips; +import dev.compactmods.machines.api.Tooltips; +import dev.compactmods.machines.api.room.WallConstants; import dev.compactmods.machines.i18n.TranslationUtil; import net.minecraft.ChatFormatting; import net.minecraft.client.gui.screens.Screen; @@ -26,7 +26,7 @@ public ItemBlockWall(Block blockIn, Properties builder) { public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List tooltip, TooltipFlag flagIn) { super.appendHoverText(stack, worldIn, tooltip, flagIn); - if (stack.is(CMTags.SOLID_WALL_ITEMS)) { + if (stack.is(WallConstants.TAG_SOLID_WALL_ITEMS)) { MutableComponent text; if (Screen.hasShiftDown()) { text = TranslationUtil.tooltip(Tooltips.Details.SOLID_WALL) diff --git a/room-api/src/main/java/dev/compactmods/compactmachines/api/room/CompactRoomGenerator.java b/room-api/src/main/java/dev/compactmods/compactmachines/api/room/CompactRoomGenerator.java index 0c327fc..7df99a7 100644 --- a/room-api/src/main/java/dev/compactmods/compactmachines/api/room/CompactRoomGenerator.java +++ b/room-api/src/main/java/dev/compactmods/compactmachines/api/room/CompactRoomGenerator.java @@ -1,6 +1,6 @@ package dev.compactmods.compactmachines.api.room; -import dev.compactmods.machines.api.CMBlocks; +import dev.compactmods.machines.api.room.WallConstants; import dev.compactmods.machines.api.util.BlockSpaceUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -12,7 +12,6 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.levelgen.structure.BoundingBox; import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; @@ -53,7 +52,7 @@ public static void generateRoom(ServerLevel level, RoomTemplate template, Vec3 r * @param outerBounds Outer dimensions of the room. */ public static void generateRoom(LevelAccessor world, AABB outerBounds) { - final var block = BuiltInRegistries.BLOCK.get(CMBlocks.SOLID_WALL); + final var block = BuiltInRegistries.BLOCK.get(WallConstants.SOLID_WALL); if (block != null) { final var solidWall = block.defaultBlockState(); generateRoom(world, outerBounds, solidWall); diff --git a/room-api/src/main/java/dev/compactmods/compactmachines/api/room/IPlayerRoomMetadata.java b/room-api/src/main/java/dev/compactmods/compactmachines/api/room/IPlayerRoomMetadata.java deleted file mode 100644 index f27532c..0000000 --- a/room-api/src/main/java/dev/compactmods/compactmachines/api/room/IPlayerRoomMetadata.java +++ /dev/null @@ -1,13 +0,0 @@ -package dev.compactmods.compactmachines.api.room; - -import org.jetbrains.annotations.NotNull; - -import java.util.UUID; - -public interface IPlayerRoomMetadata { - @NotNull - String roomCode(); - - @NotNull - UUID owner(); -} diff --git a/room-api/src/main/java/dev/compactmods/compactmachines/api/room/IPlayerRoomMetadataProvider.java b/room-api/src/main/java/dev/compactmods/compactmachines/api/room/IPlayerRoomMetadataProvider.java deleted file mode 100644 index 77475de..0000000 --- a/room-api/src/main/java/dev/compactmods/compactmachines/api/room/IPlayerRoomMetadataProvider.java +++ /dev/null @@ -1,13 +0,0 @@ -package dev.compactmods.compactmachines.api.room; - -import java.util.Optional; -import java.util.UUID; - -// capability stuff, maybe redo in 1.20 -public interface IPlayerRoomMetadataProvider { - Optional currentRoom(); - Optional roomCode(); - Optional owner(); - void clearCurrent(); - void setCurrent(IPlayerRoomMetadata current); -} diff --git a/room-api/src/main/java/dev/compactmods/compactmachines/api/room/RoomTemplate.java b/room-api/src/main/java/dev/compactmods/compactmachines/api/room/RoomTemplate.java index 20f0d44..5373723 100644 --- a/room-api/src/main/java/dev/compactmods/compactmachines/api/room/RoomTemplate.java +++ b/room-api/src/main/java/dev/compactmods/compactmachines/api/room/RoomTemplate.java @@ -2,7 +2,7 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import dev.compactmods.machines.api.core.Constants; +import dev.compactmods.machines.api.Constants; import net.minecraft.core.Registry; import net.minecraft.core.Vec3i; import net.minecraft.resources.ResourceKey; @@ -10,7 +10,7 @@ import java.util.Objects; -import static dev.compactmods.machines.api.core.Constants.MOD_ID; +import static dev.compactmods.machines.api.Constants.MOD_ID; /** * Template structure for creating a new Compact Machine room. These can be added and removed from the registry diff --git a/room-api/src/main/java/dev/compactmods/compactmachines/api/room/history/IPlayerRoomEntryPointManager.java b/room-api/src/main/java/dev/compactmods/compactmachines/api/room/history/IPlayerRoomEntryPointManager.java new file mode 100644 index 0000000..d94c742 --- /dev/null +++ b/room-api/src/main/java/dev/compactmods/compactmachines/api/room/history/IPlayerRoomEntryPointManager.java @@ -0,0 +1,11 @@ +package dev.compactmods.compactmachines.api.room.history; + +public interface IPlayerRoomEntryPointManager { + + void clear(); + boolean hasHistory(); + + RoomEntryPoint pop(); + + void addHistory(RoomEntryPoint item); +} diff --git a/room-api/src/main/java/dev/compactmods/compactmachines/api/room/history/IRoomHistory.java b/room-api/src/main/java/dev/compactmods/compactmachines/api/room/history/IRoomHistory.java deleted file mode 100644 index 3add634..0000000 --- a/room-api/src/main/java/dev/compactmods/compactmachines/api/room/history/IRoomHistory.java +++ /dev/null @@ -1,11 +0,0 @@ -package dev.compactmods.compactmachines.api.room.history; - -public interface IRoomHistory { - - void clear(); - boolean hasHistory(); - T peek(); - T pop(); - - void addHistory(T item); -} diff --git a/room-api/src/main/java/dev/compactmods/compactmachines/api/room/history/IRoomHistoryItem.java b/room-api/src/main/java/dev/compactmods/compactmachines/api/room/history/IRoomHistoryItem.java deleted file mode 100644 index ea82f6a..0000000 --- a/room-api/src/main/java/dev/compactmods/compactmachines/api/room/history/IRoomHistoryItem.java +++ /dev/null @@ -1,11 +0,0 @@ -package dev.compactmods.compactmachines.api.room.history; - -import dev.compactmods.machines.api.location.IDimensionalPosition; -import net.minecraft.core.GlobalPos; - -public interface IRoomHistoryItem { - - IDimensionalPosition getEntryLocation(); - - GlobalPos getMachine(); -} diff --git a/room-api/src/main/java/dev/compactmods/compactmachines/api/room/history/RoomEntryPoint.java b/room-api/src/main/java/dev/compactmods/compactmachines/api/room/history/RoomEntryPoint.java new file mode 100644 index 0000000..510d32f --- /dev/null +++ b/room-api/src/main/java/dev/compactmods/compactmachines/api/room/history/RoomEntryPoint.java @@ -0,0 +1,19 @@ +package dev.compactmods.compactmachines.api.room.history; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import dev.compactmods.machines.api.location.GlobalPosWithRotation; +import net.minecraft.world.entity.player.Player; + +public record RoomEntryPoint(GlobalPosWithRotation entryLocation) { + + public static final RoomEntryPoint INVALID = new RoomEntryPoint(GlobalPosWithRotation.INVALID); + + public static final Codec CODEC = RecordCodecBuilder.create(i -> i.group( + GlobalPosWithRotation.CODEC.fieldOf("entry_location").forGetter(RoomEntryPoint::entryLocation) + ).apply(i, RoomEntryPoint::new)); + + public static RoomEntryPoint fromPlayer(Player player) { + return new RoomEntryPoint(GlobalPosWithRotation.fromPlayer(player)); + } +} \ No newline at end of file diff --git a/room-upgrade-api/src/main/java/dev/compactmods/machines/api/room/upgrade/RoomUpgrade.java b/room-upgrade-api/src/main/java/dev/compactmods/machines/api/room/upgrade/RoomUpgrade.java index 07ae968..aa084de 100644 --- a/room-upgrade-api/src/main/java/dev/compactmods/machines/api/room/upgrade/RoomUpgrade.java +++ b/room-upgrade-api/src/main/java/dev/compactmods/machines/api/room/upgrade/RoomUpgrade.java @@ -5,7 +5,7 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; -import static dev.compactmods.machines.api.core.Constants.MOD_ID; +import static dev.compactmods.machines.api.Constants.MOD_ID; public interface RoomUpgrade {