diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f03191..1533b1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog], and this project adheres to [Semantic Versioning]. +## [0.4.0] - 2023-11-10 + +### Added +- added `EnderIOEvents.conduits` event to allow adding custom energy conduits + ## [0.3.1] - 2023-09-22 ### Changed diff --git a/src/main/java/com/almostreliable/kubeio/kube/event/ConduitRegistryEvent.java b/src/main/java/com/almostreliable/kubeio/kube/event/ConduitRegistryEvent.java index d9edfcb..11d7dc7 100644 --- a/src/main/java/com/almostreliable/kubeio/kube/event/ConduitRegistryEvent.java +++ b/src/main/java/com/almostreliable/kubeio/kube/event/ConduitRegistryEvent.java @@ -5,6 +5,7 @@ import com.enderio.EnderIO; import com.enderio.api.conduit.ConduitItemFactory; import com.enderio.api.conduit.ConduitTypes; +import com.google.common.base.Preconditions; import dev.latvian.mods.kubejs.event.EventJS; import dev.latvian.mods.rhino.util.HideFromJS; import net.minecraft.world.item.Item; @@ -19,6 +20,13 @@ public class ConduitRegistryEvent extends EventJS { public static final Set CONDUITS = new HashSet<>(); public void registerEnergyConduit(String id, String name, int transferRate) { + Preconditions.checkArgument(!id.contains(":"), "id must not contain a colon (:)"); + Preconditions.checkArgument(!id.contains(" "), "id must not contain a space"); + Preconditions.checkArgument( + CONDUITS.stream().anyMatch(conduit -> conduit.id().equals(id)), + "id must be unique" + ); + var type = ConduitTypes.CONDUIT_TYPES.register(id, () -> new CustomEnergyConduitType( EnderIO.loc("block/conduit/" + id), transferRate