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

@ -15,7 +15,7 @@ import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import WayofTime.bloodmagic.entity.projectile.EntityBloodLight;
import WayofTime.bloodmagic.registry.RegistrarBloodMagicBlocks;
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
public class ItemSigilBloodLight extends ItemSigilBase
{

View file

@ -1,19 +1,18 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import net.minecraft.block.Block;
import WayofTime.bloodmagic.api_impl.BloodMagicAPI;
import net.minecraft.block.IGrowable;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.BonemealEvent;
import net.minecraftforge.fml.common.eventhandler.Event.Result;
import WayofTime.bloodmagic.api.BloodMagicAPI;
public class ItemSigilGreenGrove extends ItemSigilToggleableBase
{
@ -28,7 +27,7 @@ public class ItemSigilGreenGrove extends ItemSigilToggleableBase
if (PlayerHelper.isFakePlayer(player))
return false;
if (applyBonemeal(world, blockPos, player))
if (applyBonemeal(world, blockPos, player, stack))
{
if (!world.isRemote)
{
@ -59,16 +58,16 @@ public class ItemSigilGreenGrove extends ItemSigilToggleableBase
for (int iy = posY - verticalRange; iy <= posY + verticalRange; iy++)
{
BlockPos blockPos = new BlockPos(ix, iy, iz);
Block block = worldIn.getBlockState(blockPos).getBlock();
IBlockState state = worldIn.getBlockState(blockPos);
if (!BloodMagicAPI.greenGroveBlacklist.contains(block))
if (!BloodMagicAPI.INSTANCE.getBlacklist().getGreenGrove().contains(state))
{
if (block instanceof IPlantable || block instanceof IGrowable)
if (state.getBlock() instanceof IGrowable)
{
if (worldIn.rand.nextInt(50) == 0)
{
IBlockState preBlockState = worldIn.getBlockState(blockPos);
block.updateTick(worldIn, blockPos, worldIn.getBlockState(blockPos), worldIn.rand);
state.getBlock().updateTick(worldIn, blockPos, state, worldIn.rand);
IBlockState newState = worldIn.getBlockState(blockPos);
if (!newState.equals(preBlockState) && !worldIn.isRemote)
@ -81,11 +80,11 @@ public class ItemSigilGreenGrove extends ItemSigilToggleableBase
}
}
private boolean applyBonemeal(World worldIn, BlockPos target, EntityPlayer player)
private boolean applyBonemeal(World worldIn, BlockPos target, EntityPlayer player, ItemStack sigilStack)
{
IBlockState iblockstate = worldIn.getBlockState(target);
BonemealEvent event = new BonemealEvent(player, worldIn, target, iblockstate);
BonemealEvent event = new BonemealEvent(player, worldIn, target, iblockstate, EnumHand.MAIN_HAND, sigilStack);
if (MinecraftForge.EVENT_BUS.post(event))
return false;
else if (event.getResult() == Result.ALLOW)

View file

@ -11,7 +11,7 @@ import net.minecraft.world.World;
import org.apache.commons.lang3.tuple.Pair;
import WayofTime.bloodmagic.registry.RegistrarBloodMagicBlocks;
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
public class ItemSigilPhantomBridge extends ItemSigilToggleableBase
{