Move commonly used API systems to a plugin based system

Create a class that implements IBloodMagicPlugin and annotate it with
`@BloodMagicPlugin`. The `register` method will be called during init.

Currently implemented systems:
- Blacklisting
  - Teleposer
  - Teleposer (entity)
  - Transposition
  - Well of Suffering
  - Green Grove
- Setting sacrificial values
- Adding altar components
This commit is contained in:
Nicholas Ignoffo 2017-08-15 18:14:28 -07:00
parent 5fcdd978d7
commit 554c9852e6
86 changed files with 528 additions and 496 deletions

View file

@ -0,0 +1,56 @@
package WayofTime.bloodmagic.api_impl;
import WayofTime.bloodmagic.api.altar.EnumAltarComponent;
import WayofTime.bloodmagic.apiv2.IBloodMagicAPI;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.ResourceLocation;
import java.util.Map;
public class BloodMagicAPI implements IBloodMagicAPI {
public static final BloodMagicAPI INSTANCE = new BloodMagicAPI();
private final BloodMagicBlacklist blacklist;
private final Map<ResourceLocation, Integer> sacrificialValues;
private final Map<IBlockState, EnumAltarComponent> altarComponents;
public BloodMagicAPI() {
this.blacklist = new BloodMagicBlacklist();
this.sacrificialValues = Maps.newHashMap();
this.altarComponents = Maps.newHashMap();
}
@Override
public BloodMagicBlacklist getBlacklist() {
return blacklist;
}
@Override
public void setSacrificialValue(ResourceLocation entityId, int value) {
sacrificialValues.put(entityId, value);
}
@Override
public void registerAltarComponent(IBlockState state, String componentType) {
EnumAltarComponent component = EnumAltarComponent.NOTAIR;
for (EnumAltarComponent type : EnumAltarComponent.VALUES) {
if (type.name().equalsIgnoreCase(componentType)) {
component = type;
break;
}
}
altarComponents.put(state, component);
}
public Map<ResourceLocation, Integer> getSacrificialValues() {
return ImmutableMap.copyOf(sacrificialValues);
}
public Map<IBlockState, EnumAltarComponent> getAltarComponents() {
return ImmutableMap.copyOf(altarComponents);
}
}