-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'next/4.4.0' into compactmods/1.18.x
- Loading branch information
Showing
58 changed files
with
1,334 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/api/java/dev/compactmods/machines/api/core/CMTags.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package dev.compactmods.machines.api.core; | ||
|
||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.tags.ItemTags; | ||
import net.minecraft.tags.TagKey; | ||
import net.minecraft.world.item.Item; | ||
|
||
public class CMTags { | ||
|
||
public static final TagKey<Item> ROOM_UPGRADE_ITEM = ItemTags.create(new ResourceLocation(Constants.MOD_ID, "room_upgrade")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/api/java/dev/compactmods/machines/api/room/upgrade/ILevelLoadedUpgradeListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package dev.compactmods.machines.api.room.upgrade; | ||
|
||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.world.level.ChunkPos; | ||
|
||
public interface ILevelLoadedUpgradeListener extends RoomUpgrade { | ||
|
||
/** | ||
* Called when a level is loaded, typically when the server first boots up. | ||
*/ | ||
default void onLevelLoaded(ServerLevel level, ChunkPos room) {} | ||
|
||
/** | ||
* Called when a level is unloaded. | ||
*/ | ||
default void onLevelUnloaded(ServerLevel level, ChunkPos room) {} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
src/api/java/dev/compactmods/machines/api/room/upgrade/RoomUpgrade.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package dev.compactmods.machines.api.room.upgrade; | ||
|
||
import com.mojang.serialization.Codec; | ||
import dev.compactmods.machines.api.core.Constants; | ||
import net.minecraft.core.Registry; | ||
import net.minecraft.resources.ResourceKey; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.level.ChunkPos; | ||
import net.minecraftforge.registries.IForgeRegistryEntry; | ||
|
||
import static dev.compactmods.machines.api.core.Constants.MOD_ID; | ||
|
||
public interface RoomUpgrade extends IForgeRegistryEntry<RoomUpgrade> { | ||
|
||
ResourceKey<Registry<RoomUpgrade>> REG_KEY = ResourceKey.createRegistryKey(new ResourceLocation(MOD_ID, "room_upgrade")); | ||
|
||
String UNNAMED_TRANS_KEY = "item." + MOD_ID + ".upgrades.unnamed"; | ||
|
||
default String getTranslationKey() { | ||
final var rid = this.getRegistryName(); | ||
return "item." + rid.getNamespace() + ".upgrades." + rid.getPath().replace('/', '.'); | ||
} | ||
|
||
default String getTranslationKey(ItemStack stack) { | ||
final var rid = this.getRegistryName(); | ||
return "item." + rid.getNamespace() + ".upgrades." + rid.getPath().replace('/', '.'); | ||
} | ||
|
||
/** | ||
* Called when an upgrade is first applied to a room. | ||
*/ | ||
default void onAdded(ServerLevel level, ChunkPos room) {} | ||
|
||
/** | ||
* Called when an update is removed from a room. | ||
*/ | ||
default void onRemoved(ServerLevel level, ChunkPos room) {} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/api/java/dev/compactmods/machines/api/room/upgrade/RoomUpgradeInstance.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package dev.compactmods.machines.api.room.upgrade; | ||
|
||
import net.minecraft.world.level.ChunkPos; | ||
|
||
public record RoomUpgradeInstance<T extends RoomUpgrade>(T upgrade, ChunkPos room) { | ||
} |
25 changes: 25 additions & 0 deletions
25
src/api/java/dev/compactmods/machines/api/upgrade/RoomUpgradeHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package dev.compactmods.machines.api.upgrade; | ||
|
||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.ItemStack; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Optional; | ||
|
||
public abstract class RoomUpgradeHelper { | ||
|
||
public static final String NBT_UPGRADE_NODE = "upgrade_info"; | ||
public static final String NBT_UPDATE_ID = "key"; | ||
|
||
public static Optional<ResourceLocation> getTypeFrom(@NotNull ItemStack stack) { | ||
if(!stack.hasTag()) return Optional.empty(); | ||
final var tag = stack.getTag(); | ||
if(!tag.contains(NBT_UPGRADE_NODE)) return Optional.empty(); | ||
|
||
final var upg = tag.getCompound(NBT_UPGRADE_NODE); | ||
if(!upg.contains(NBT_UPDATE_ID)) return Optional.empty(); | ||
|
||
final var upg2 = new ResourceLocation(upg.getString(NBT_UPDATE_ID)); | ||
return Optional.of(upg2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.