use of WayofTime.bloodmagic.ritual.imperfect.ImperfectRitual in project BloodMagic by WayofTime.
the class DataProviderRitualController method getNBTData.
@Nonnull
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te instanceof TileMasterRitualStone) {
TileMasterRitualStone mrs = (TileMasterRitualStone) te;
tag.setBoolean("master", true);
if (mrs.getCurrentRitual() != null) {
tag.setString("ritual", mrs.getCurrentRitual().getUnlocalizedName());
tag.setBoolean("active", mrs.isActive());
if (mrs.getOwner() != null)
tag.setString("owner", PlayerHelper.getUsernameFromUUID(mrs.getOwner()));
tag.setBoolean("enabled", RitualRegistry.ritualEnabled(mrs.getCurrentRitual()));
}
} else {
tag.setBoolean("master", false);
ImperfectRitual ritual = ImperfectRitualRegistry.getRitualForBlock(world.getBlockState(pos.up()));
if (ritual != null) {
tag.setString("ritual", ritual.getUnlocalizedName());
tag.setBoolean("enabled", ImperfectRitualRegistry.ritualEnabled(ritual));
}
}
return tag;
}
use of WayofTime.bloodmagic.ritual.imperfect.ImperfectRitual 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