Precondition the rest of the new API
This commit is contained in:
parent
c00affa4aa
commit
36ce215b6b
2 changed files with 24 additions and 0 deletions
|
@ -2,6 +2,7 @@ package WayofTime.bloodmagic.api_impl;
|
||||||
|
|
||||||
import WayofTime.bloodmagic.api.altar.EnumAltarComponent;
|
import WayofTime.bloodmagic.api.altar.EnumAltarComponent;
|
||||||
import WayofTime.bloodmagic.apiv2.IBloodMagicAPI;
|
import WayofTime.bloodmagic.apiv2.IBloodMagicAPI;
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.collect.ArrayListMultimap;
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
@ -43,11 +44,17 @@ public class BloodMagicAPI implements IBloodMagicAPI {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSacrificialValue(@Nonnull ResourceLocation entityId, @Nonnegative int value) {
|
public void setSacrificialValue(@Nonnull ResourceLocation entityId, @Nonnegative int value) {
|
||||||
|
Preconditions.checkNotNull(entityId, "entityId cannot be null.");
|
||||||
|
Preconditions.checkArgument(value >= 0, "value cannot be negative.");
|
||||||
|
|
||||||
sacrificialValues.put(entityId, value);
|
sacrificialValues.put(entityId, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerAltarComponent(@Nonnull IBlockState state, @Nonnull String componentType) {
|
public void registerAltarComponent(@Nonnull IBlockState state, @Nonnull String componentType) {
|
||||||
|
Preconditions.checkNotNull(state, "state cannot be null.");
|
||||||
|
Preconditions.checkNotNull(componentType, "componentType cannot be null.");
|
||||||
|
|
||||||
EnumAltarComponent component = EnumAltarComponent.NOTAIR;
|
EnumAltarComponent component = EnumAltarComponent.NOTAIR;
|
||||||
for (EnumAltarComponent type : EnumAltarComponent.VALUES) {
|
for (EnumAltarComponent type : EnumAltarComponent.VALUES) {
|
||||||
if (type.name().equalsIgnoreCase(componentType)) {
|
if (type.name().equalsIgnoreCase(componentType)) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package WayofTime.bloodmagic.api_impl;
|
package WayofTime.bloodmagic.api_impl;
|
||||||
|
|
||||||
import WayofTime.bloodmagic.apiv2.IBloodMagicBlacklist;
|
import WayofTime.bloodmagic.apiv2.IBloodMagicBlacklist;
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -28,48 +29,64 @@ public class BloodMagicBlacklist implements IBloodMagicBlacklist {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTeleposer(@Nonnull IBlockState state) {
|
public void addTeleposer(@Nonnull IBlockState state) {
|
||||||
|
Preconditions.checkNotNull(state, "state cannot be null.");
|
||||||
|
|
||||||
if (!teleposer.contains(state))
|
if (!teleposer.contains(state))
|
||||||
teleposer.add(state);
|
teleposer.add(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTeleposer(@Nonnull Block block) {
|
public void addTeleposer(@Nonnull Block block) {
|
||||||
|
Preconditions.checkNotNull(block, "block cannot be null.");
|
||||||
|
|
||||||
for (IBlockState state : block.getBlockState().getValidStates())
|
for (IBlockState state : block.getBlockState().getValidStates())
|
||||||
addTeleposer(state);
|
addTeleposer(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTeleposer(@Nonnull ResourceLocation entityId) {
|
public void addTeleposer(@Nonnull ResourceLocation entityId) {
|
||||||
|
Preconditions.checkNotNull(entityId, "entityId cannot be null.");
|
||||||
|
|
||||||
if (!teleposerEntities.contains(entityId))
|
if (!teleposerEntities.contains(entityId))
|
||||||
teleposerEntities.add(entityId);
|
teleposerEntities.add(entityId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTransposition(@Nonnull IBlockState state) {
|
public void addTransposition(@Nonnull IBlockState state) {
|
||||||
|
Preconditions.checkNotNull(state, "state cannot be null.");
|
||||||
|
|
||||||
if (!transposition.contains(state))
|
if (!transposition.contains(state))
|
||||||
transposition.add(state);
|
transposition.add(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTransposition(@Nonnull Block block) {
|
public void addTransposition(@Nonnull Block block) {
|
||||||
|
Preconditions.checkNotNull(block, "block cannot be null.");
|
||||||
|
|
||||||
for (IBlockState state : block.getBlockState().getValidStates())
|
for (IBlockState state : block.getBlockState().getValidStates())
|
||||||
addTransposition(state);
|
addTransposition(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addGreenGrove(@Nonnull IBlockState state) {
|
public void addGreenGrove(@Nonnull IBlockState state) {
|
||||||
|
Preconditions.checkNotNull(state, "state cannot be null.");
|
||||||
|
|
||||||
if (!greenGrove.contains(state))
|
if (!greenGrove.contains(state))
|
||||||
greenGrove.add(state);
|
greenGrove.add(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addGreenGrove(@Nonnull Block block) {
|
public void addGreenGrove(@Nonnull Block block) {
|
||||||
|
Preconditions.checkNotNull(block, "block cannot be null.");
|
||||||
|
|
||||||
for (IBlockState state : block.getBlockState().getValidStates())
|
for (IBlockState state : block.getBlockState().getValidStates())
|
||||||
addGreenGrove(state);
|
addGreenGrove(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addWellOfSuffering(@Nonnull ResourceLocation entityId) {
|
public void addWellOfSuffering(@Nonnull ResourceLocation entityId) {
|
||||||
|
Preconditions.checkNotNull(entityId, "entityId cannot be null.");
|
||||||
|
|
||||||
if (!sacrifice.contains(entityId))
|
if (!sacrifice.contains(entityId))
|
||||||
sacrifice.add(entityId);
|
sacrifice.add(entityId);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue