Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Commit

Permalink
Revert naming of RoomUpgradeAction to RoomUpgrade, add docs around re…
Browse files Browse the repository at this point in the history
…gkeys
  • Loading branch information
robotgryphon committed Feb 24, 2023
1 parent cc06f85 commit 01ff01f
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.compactmods.machines.api.core;

import dev.compactmods.machines.api.upgrade.RoomUpgradeAction;
import dev.compactmods.machines.api.room.RoomTemplate;
import dev.compactmods.machines.api.upgrade.RoomUpgrade;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -9,5 +10,13 @@

public interface CMRegistryKeys {

ResourceKey<Registry<RoomUpgradeAction>> UPGRADE_ACTIONS = ResourceKey.createRegistryKey(new ResourceLocation(MOD_ID, "upgrade_actions"));
/**
* Used to store upgrade definitions for rooms (such as chunkloading)
*/
ResourceKey<Registry<RoomUpgrade>> ROOM_UPGRADES = ResourceKey.createRegistryKey(new ResourceLocation(MOD_ID, "room_upgrades"));

/**
* Used to look up and store definitions for room templates.
*/
ResourceKey<Registry<RoomTemplate>> ROOM_TEMPLATES = ResourceKey.createRegistryKey(new ResourceLocation(MOD_ID, "room_templates"));
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,28 @@
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<Item> ROOM_UPGRADE_ITEM = TagKey.create(Registry.ITEM_REGISTRY, new ResourceLocation(Constants.MOD_ID, "room_upgrade"));

/**
* Marks an item as a Compact Machine item.
*/
TagKey<Item> MACHINE_ITEM = TagKey.create(Registry.ITEM_REGISTRY, new ResourceLocation(Constants.MOD_ID, "machine"));

/**
* Marks a block as a Compact Machine; applied to both legacy sized machines and the new machine blocks.
*/
TagKey<Block> MACHINE_BLOCK = TagKey.create(Registry.BLOCK_REGISTRY, new ResourceLocation(Constants.MOD_ID, "machine"));

/**
* Applied to solid wall items.
*/
TagKey<Item> SOLID_WALL_ITEMS = TagKey.create(Registry.ITEM_REGISTRY, new ResourceLocation(Constants.MOD_ID, "solid_walls"));

/**
* Applied to solid walls and tunnel blocks.
*/
TagKey<Block> SOLID_WALL_BLOCKS = TagKey.create(Registry.BLOCK_REGISTRY, new ResourceLocation(Constants.MOD_ID, "solid_walls"));
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.compactmods.machines.api.room;

import dev.compactmods.machines.api.upgrade.RoomUpgradeAction;
import dev.compactmods.machines.api.core.CMRegistryKeys;
import dev.compactmods.machines.api.upgrade.RoomUpgrade;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -10,12 +11,14 @@

public class Rooms {

public static final ResourceKey<Registry<RoomTemplate>> TEMPLATE_REG_KEY = ResourceKey.createRegistryKey(new ResourceLocation(MOD_ID, "room_templates"));
@Deprecated(forRemoval = true)
public static final ResourceKey<Registry<RoomTemplate>> TEMPLATE_REG_KEY = CMRegistryKeys.ROOM_TEMPLATES;

public static final ResourceKey<Registry<RoomUpgradeAction>> ROOM_UPGRADES_REG_KEY = ResourceKey.createRegistryKey(new ResourceLocation(MOD_ID, "room_upgrades"));
@Deprecated(forRemoval = true)
public static final ResourceKey<Registry<RoomUpgrade>> ROOM_UPGRADES_REG_KEY = CMRegistryKeys.ROOM_UPGRADES;

public static Registry<RoomTemplate> getTemplates(MinecraftServer server) {
final var regAccess = server.registryAccess();
return regAccess.registryOrThrow(TEMPLATE_REG_KEY);
return regAccess.registryOrThrow(CMRegistryKeys.ROOM_TEMPLATES);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import dev.compactmods.machines.api.room.registration.IRoomRegistration;
import net.minecraft.server.level.ServerLevel;

public interface ILevelLoadedUpgradeListener extends RoomUpgradeAction {
public interface ILevelLoadedUpgradeListener extends RoomUpgrade {

/**
* Called when a level is loaded, typically when the server first boots up.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import dev.compactmods.machines.api.room.registration.IRoomRegistration;
import net.minecraft.server.level.ServerLevel;

public interface IUpgradeAppliedListener extends RoomUpgradeAction {
public interface IUpgradeAppliedListener extends RoomUpgrade {

/**
* Called when an upgrade is first applied to a room.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import dev.compactmods.machines.api.room.registration.IRoomRegistration;
import net.minecraft.server.level.ServerLevel;

public interface IUpgradeRemovedListener extends RoomUpgradeAction {
public interface IUpgradeRemovedListener extends RoomUpgrade {

/**
* Called when an update is removed from a room.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

import static dev.compactmods.machines.api.core.Constants.MOD_ID;

public interface RoomUpgradeAction {
public interface RoomUpgrade {

ResourceKey<Registry<RoomUpgradeAction>> REG_KEY = ResourceKey.createRegistryKey(new ResourceLocation(MOD_ID, "upgrade_actions"));
ResourceKey<Registry<RoomUpgrade>> REG_KEY = ResourceKey.createRegistryKey(new ResourceLocation(MOD_ID, "upgrade_actions"));

Codec<? extends RoomUpgradeAction> codec();
Codec<? extends RoomUpgrade> codec();
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package dev.compactmods.machines.api.upgrade;

public record RoomUpgradeInstance<T extends RoomUpgradeAction>(T upgrade, String room) {}
public record RoomUpgradeInstance<T extends RoomUpgrade>(T upgrade, String room) {}

0 comments on commit 01ff01f

Please sign in to comment.