BloodMagic/src/main/java/WayofTime/bloodmagic/api/impl/BloodMagicAPI.java

84 lines
2.7 KiB
Java
Raw Normal View History

package WayofTime.bloodmagic.api.impl;
import WayofTime.bloodmagic.api.IBloodMagicAPI;
2018-03-10 02:00:04 +00:00
import WayofTime.bloodmagic.altar.ComponentType;
2018-02-17 07:48:28 +00:00
import WayofTime.bloodmagic.util.BMLog;
2017-08-17 00:29:24 +00:00
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import net.minecraft.block.state.IBlockState;
2018-02-07 03:18:29 +00:00
import javax.annotation.Nonnull;
2018-02-15 07:38:57 +00:00
import java.util.List;
public class BloodMagicAPI implements IBloodMagicAPI {
public static final BloodMagicAPI INSTANCE = new BloodMagicAPI();
private final BloodMagicBlacklist blacklist;
2018-02-07 03:18:29 +00:00
private final BloodMagicRecipeRegistrar recipeRegistrar;
private final BloodMagicValueManager valueManager;
2018-03-10 02:00:04 +00:00
private final Multimap<ComponentType, IBlockState> altarComponents;
public BloodMagicAPI() {
this.blacklist = new BloodMagicBlacklist();
2018-02-07 03:18:29 +00:00
this.recipeRegistrar = new BloodMagicRecipeRegistrar();
this.valueManager = new BloodMagicValueManager();
2017-08-17 00:29:24 +00:00
this.altarComponents = ArrayListMultimap.create();
}
2018-02-07 03:18:29 +00:00
@Nonnull
@Override
public BloodMagicBlacklist getBlacklist() {
return blacklist;
}
2018-02-07 03:18:29 +00:00
@Nonnull
@Override
2018-02-07 03:18:29 +00:00
public BloodMagicRecipeRegistrar getRecipeRegistrar() {
return recipeRegistrar;
}
@Nonnull
2018-02-07 03:18:29 +00:00
@Override
public BloodMagicValueManager getValueManager() {
return valueManager;
}
@Override
2018-02-07 03:18:29 +00:00
public void registerAltarComponent(@Nonnull IBlockState state, @Nonnull String componentType) {
2018-03-10 02:00:04 +00:00
ComponentType component = null;
for (ComponentType type : ComponentType.VALUES) {
if (type.name().equalsIgnoreCase(componentType)) {
component = type;
break;
}
}
2018-02-17 07:48:28 +00:00
if (component != null) {
BMLog.API_VERBOSE.info("Registered {} as a {} altar component.", state, componentType);
2018-02-17 07:48:28 +00:00
altarComponents.put(component, state);
} else BMLog.API.warn("Invalid Altar component type: {}.", componentType);
}
2018-12-05 20:47:30 +00:00
@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);
}
2018-02-07 03:18:29 +00:00
@Nonnull
2018-03-10 02:00:04 +00:00
public List<IBlockState> getComponentStates(ComponentType component) {
2017-08-17 00:29:24 +00:00
return (List<IBlockState>) altarComponents.get(component);
}
}