use of WayofTime.bloodmagic.ritual.imperfect.IImperfectRitualStone in project BloodMagic by WayofTime.
the class BlockRitualController method onBlockActivated.
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack heldItem = player.getHeldItem(hand);
TileEntity tile = world.getTileEntity(pos);
if (state.getValue(getProperty()) != EnumRitualController.IMPERFECT && tile instanceof TileMasterRitualStone) {
if (heldItem.getItem() == RegistrarBloodMagicItems.ACTIVATION_CRYSTAL) {
if (((IBindable) heldItem.getItem()).getBinding(heldItem) == null)
return false;
String key = RitualHelper.getValidRitual(world, pos);
EnumFacing direction = RitualHelper.getDirectionOfRitual(world, pos, key);
// TODO: Give a message stating that this ritual is not a valid ritual.
if (!key.isEmpty() && direction != null && RitualHelper.checkValidRitual(world, pos, key, direction)) {
if (((TileMasterRitualStone) tile).activateRitual(heldItem, player, RitualRegistry.getRitualForId(key))) {
((TileMasterRitualStone) tile).setDirection(direction);
if (state.getValue(getProperty()) == EnumRitualController.INVERTED)
((TileMasterRitualStone) tile).setInverted(true);
}
} else {
player.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.ritual.notValid"), true);
}
}
} else if (state.getValue(getProperty()) == EnumRitualController.IMPERFECT && tile instanceof TileImperfectRitualStone) {
IBlockState ritualBlock = world.getBlockState(pos.up());
ImperfectRitual ritual = ImperfectRitualRegistry.getRitualForBlock(ritualBlock);
if (ritual == null)
return false;
RitualEvent.ImperfectRitualActivatedEvent event = new RitualEvent.ImperfectRitualActivatedEvent((IImperfectRitualStone) tile, player, ritual);
return !MinecraftForge.EVENT_BUS.post(event) && ((TileImperfectRitualStone) tile).performRitual(world, pos, ritual, player);
}
return false;
}
Aggregations