Allow mods to blacklist their blocks from Green Grove

This commit is contained in:
Nick 2016-01-23 00:32:10 -08:00
parent f7682e5c29
commit 50bd8514ee
4 changed files with 31 additions and 10 deletions
changelog.txt
src/main/java/WayofTime/bloodmagic

View file

@ -6,6 +6,7 @@ Version 2.0.0-7
- Allow configuration of entity sacrificial values
- [API] Allow setting of entity sacrificial values via API. Takes precedence over config values.
- [API] Method to easily get instances of Items and Blocks
- [API] Allow mods to blacklist their blocks from the Green Grove ritual/sigil
------------------------------------------------------
Version 2.0.0-6

View file

@ -20,9 +20,10 @@ public class BloodMagicAPI
{
@Getter
private static final List<BlockStack> teleposerBlacklist = new ArrayList<BlockStack>();
@Getter
private static final Map<String, Integer> entitySacrificeValues = new HashMap<String, Integer>();
@Getter
private static final ArrayList<Block> greenGroveBlacklist = new ArrayList<Block>();
@Getter
@Setter
@ -159,4 +160,14 @@ public class BloodMagicAPI
if (!entitySacrificeValues.containsKey(entityClassName))
entitySacrificeValues.put(entityClassName, sacrificeValue);
}
/**
* Blacklists a block from the Green Grove Ritual and Sigil.
*
* @param block - Block to blacklist
*/
public static void blacklistFromGreenGrove(Block block) {
if (!greenGroveBlacklist.contains(block))
greenGroveBlacklist.add(block);
}
}

View file

@ -1,5 +1,6 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.api.BloodMagicAPI;
import WayofTime.bloodmagic.api.Constants;
import net.minecraft.block.Block;
import net.minecraft.block.IGrowable;
@ -49,15 +50,18 @@ public class ItemSigilGreenGrove extends ItemSigilToggleable
BlockPos blockPos = new BlockPos(ix, iy, iz);
Block block = worldIn.getBlockState(blockPos).getBlock();
if (block instanceof IPlantable || block instanceof IGrowable)
if (!BloodMagicAPI.getGreenGroveBlacklist().contains(block))
{
if (worldIn.rand.nextInt(50) == 0)
if (block instanceof IPlantable || block instanceof IGrowable)
{
IBlockState preBlockState = worldIn.getBlockState(blockPos);
block.updateTick(worldIn, blockPos, worldIn.getBlockState(blockPos), worldIn.rand);
if (worldIn.rand.nextInt(50) == 0)
{
IBlockState preBlockState = worldIn.getBlockState(blockPos);
block.updateTick(worldIn, blockPos, worldIn.getBlockState(blockPos), worldIn.rand);
if (!worldIn.getBlockState(blockPos).equals(preBlockState))
worldIn.playAuxSFX(2005, blockPos, 0);
if (!worldIn.getBlockState(blockPos).equals(preBlockState))
worldIn.playAuxSFX(2005, blockPos, 0);
}
}
}
}

View file

@ -3,6 +3,7 @@ package WayofTime.bloodmagic.ritual;
import java.util.ArrayList;
import java.util.Random;
import WayofTime.bloodmagic.api.BloodMagicAPI;
import net.minecraft.block.Block;
import net.minecraft.block.IGrowable;
import net.minecraft.block.state.IBlockState;
@ -50,10 +51,14 @@ public class RitualGreenGrove extends Ritual
{
IBlockState state = world.getBlockState(newPos);
Block block = state.getBlock();
if (block instanceof IPlantable || block instanceof IGrowable)
if (BloodMagicAPI.getGreenGroveBlacklist().contains(block))
{
block.updateTick(world, newPos, state, new Random());
totalGrowths++;
if (block instanceof IPlantable || block instanceof IGrowable)
{
block.updateTick(world, newPos, state, new Random());
totalGrowths++;
}
}
if (totalGrowths >= maxGrowths)