From 259b631f7d3cd08825b07fcf1fdeae77235adc60 Mon Sep 17 00:00:00 2001 From: TeamDman Date: Wed, 5 Dec 2018 15:47:30 -0500 Subject: [PATCH] added unregisterAltarComponent method --- .../bloodmagic/api/IBloodMagicAPI.java | 20 +++++++++++++++++++ .../bloodmagic/api/impl/BloodMagicAPI.java | 16 +++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/api/java/WayofTime/bloodmagic/api/IBloodMagicAPI.java b/src/api/java/WayofTime/bloodmagic/api/IBloodMagicAPI.java index 11ce4bce..99ab8b7b 100644 --- a/src/api/java/WayofTime/bloodmagic/api/IBloodMagicAPI.java +++ b/src/api/java/WayofTime/bloodmagic/api/IBloodMagicAPI.java @@ -54,4 +54,24 @@ public interface IBloodMagicAPI { * @param componentType The type of Blood Altar component to register as. */ void registerAltarComponent(@Nonnull IBlockState state, @Nonnull String componentType); + + /** + * Removes an {@link IBlockState} from the component mappings + *

+ * Valid component types: + *

+ * + * @param state The state to register + * @param componentType The type of Blood Altar component to unregister from. + */ + void unregisterAltarComponent(@Nonnull IBlockState state, @Nonnull String componentType); + + } diff --git a/src/main/java/WayofTime/bloodmagic/api/impl/BloodMagicAPI.java b/src/main/java/WayofTime/bloodmagic/api/impl/BloodMagicAPI.java index a779da4b..528f99ab 100644 --- a/src/main/java/WayofTime/bloodmagic/api/impl/BloodMagicAPI.java +++ b/src/main/java/WayofTime/bloodmagic/api/impl/BloodMagicAPI.java @@ -60,6 +60,22 @@ public class BloodMagicAPI implements IBloodMagicAPI { } else BMLog.API.warn("Invalid Altar component type: {}.", componentType); } + @Override + public void unregisterAltarComponent(@Nonnull IBlockState state, @Nonnull String componentType) { + ComponentType component = null; + for (ComponentType type : ComponentType.VALUES) { + if (type.name().equalsIgnoreCase(componentType)) { + component = type; + break; + } + } + + if (component != null) { + BMLog.API_VERBOSE.info("Unregistered {} from being a {} altar component.", state, componentType); + altarComponents.remove(component, state); + } else BMLog.API.warn("Invalid Altar component type: {}.", componentType); + } + @Nonnull public List getComponentStates(ComponentType component) { return (List) altarComponents.get(component);