Search in sources :

Example 1 with TileMasterRitualStone

use of WayofTime.bloodmagic.tile.TileMasterRitualStone 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;
}
Also used : TileMasterRitualStone(WayofTime.bloodmagic.tile.TileMasterRitualStone) ImperfectRitual(WayofTime.bloodmagic.ritual.imperfect.ImperfectRitual) Nonnull(javax.annotation.Nonnull)

Example 2 with TileMasterRitualStone

use of WayofTime.bloodmagic.tile.TileMasterRitualStone in project BloodMagic by WayofTime.

the class ItemRitualDiviner method addRuneToRitual.

/**
 * Adds a single rune to the ritual.
 *
 * @param stack  - The Ritual Diviner stack
 * @param world  - The World
 * @param pos    - Block Position of the MRS.
 * @param player - The Player attempting to place the ritual
 * @return - True if a rune was successfully added
 */
public boolean addRuneToRitual(ItemStack stack, World world, BlockPos pos, EntityPlayer player) {
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileMasterRitualStone) {
        Ritual ritual = RitualRegistry.getRitualForId(this.getCurrentRitual(stack));
        if (ritual != null) {
            EnumFacing direction = getDirection(stack);
            List<RitualComponent> components = Lists.newArrayList();
            ritual.gatherComponents(components::add);
            for (RitualComponent component : components) {
                if (!canPlaceRitualStone(component.getRuneType(), stack)) {
                    return false;
                }
                BlockPos offset = component.getOffset(direction);
                BlockPos newPos = pos.add(offset);
                IBlockState state = world.getBlockState(newPos);
                Block block = state.getBlock();
                if (RitualHelper.isRune(world, newPos)) {
                    if (RitualHelper.isRuneType(world, newPos, component.getRuneType())) {
                        if (world.isRemote) {
                            undisplayHologram();
                        }
                    } else {
                        // Replace existing ritual stone
                        RitualHelper.setRuneType(world, newPos, component.getRuneType());
                        return true;
                    }
                } else if (block.isAir(state, world, newPos) || block.isReplaceable(world, newPos)) {
                    if (!consumeStone(stack, world, player)) {
                        return false;
                    }
                    int meta = component.getRuneType().ordinal();
                    IBlockState newState = RegistrarBloodMagicBlocks.RITUAL_STONE.getStateFromMeta(meta);
                    world.setBlockState(newPos, newState);
                    return true;
                } else {
                    // TODO: Possibly replace the block with a
                    return false;
                // ritual stone
                }
            }
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) TileMasterRitualStone(WayofTime.bloodmagic.tile.TileMasterRitualStone) Ritual(WayofTime.bloodmagic.ritual.Ritual) RitualComponent(WayofTime.bloodmagic.ritual.RitualComponent) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) BlockPos(net.minecraft.util.math.BlockPos)

Example 3 with TileMasterRitualStone

use of WayofTime.bloodmagic.tile.TileMasterRitualStone in project BloodMagic by WayofTime.

the class ItemRitualDiviner method trySetDisplayedRitual.

@SideOnly(Side.CLIENT)
public void trySetDisplayedRitual(ItemStack itemStack, World world, BlockPos pos) {
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileMasterRitualStone) {
        Ritual ritual = RitualRegistry.getRitualForId(this.getCurrentRitual(itemStack));
        TileMasterRitualStone masterRitualStone = (TileMasterRitualStone) tile;
        if (ritual != null) {
            EnumFacing direction = getDirection(itemStack);
            ClientHandler.setRitualHolo(masterRitualStone, ritual, direction, true);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileMasterRitualStone(WayofTime.bloodmagic.tile.TileMasterRitualStone) Ritual(WayofTime.bloodmagic.ritual.Ritual) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 4 with TileMasterRitualStone

use of WayofTime.bloodmagic.tile.TileMasterRitualStone 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;
}
Also used : RitualEvent(WayofTime.bloodmagic.event.RitualEvent) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) IBlockState(net.minecraft.block.state.IBlockState) TileMasterRitualStone(WayofTime.bloodmagic.tile.TileMasterRitualStone) EnumFacing(net.minecraft.util.EnumFacing) IImperfectRitualStone(WayofTime.bloodmagic.ritual.imperfect.IImperfectRitualStone) TileEntity(net.minecraft.tileentity.TileEntity) TileImperfectRitualStone(WayofTime.bloodmagic.tile.TileImperfectRitualStone) ImperfectRitual(WayofTime.bloodmagic.ritual.imperfect.ImperfectRitual) ItemStack(net.minecraft.item.ItemStack)

Example 5 with TileMasterRitualStone

use of WayofTime.bloodmagic.tile.TileMasterRitualStone in project BloodMagic by WayofTime.

the class ClientHandler method render.

@SubscribeEvent
public static void render(RenderWorldLastEvent event) {
    EntityPlayerSP player = minecraft.player;
    World world = player.getEntityWorld();
    if (mrsHoloTile != null) {
        if (world.getTileEntity(mrsHoloTile.getPos()) instanceof TileMasterRitualStone) {
            if (mrsHoloDisplay)
                renderRitualStones(mrsHoloTile, event.getPartialTicks());
            else
                ClientHandler.setRitualHoloToNull();
        } else {
            ClientHandler.setRitualHoloToNull();
        }
    }
    if (minecraft.objectMouseOver == null || minecraft.objectMouseOver.typeOfHit != RayTraceResult.Type.BLOCK)
        return;
    TileEntity tileEntity = world.getTileEntity(minecraft.objectMouseOver.getBlockPos());
    if (tileEntity instanceof TileMasterRitualStone && !player.getHeldItemMainhand().isEmpty() && player.getHeldItemMainhand().getItem() instanceof ItemRitualDiviner)
        renderRitualStones(player, event.getPartialTicks());
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileMasterRitualStone(WayofTime.bloodmagic.tile.TileMasterRitualStone) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) World(net.minecraft.world.World) ItemRitualDiviner(WayofTime.bloodmagic.item.ItemRitualDiviner) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

TileMasterRitualStone (WayofTime.bloodmagic.tile.TileMasterRitualStone)5 TileEntity (net.minecraft.tileentity.TileEntity)4 Ritual (WayofTime.bloodmagic.ritual.Ritual)2 ImperfectRitual (WayofTime.bloodmagic.ritual.imperfect.ImperfectRitual)2 IBlockState (net.minecraft.block.state.IBlockState)2 RitualEvent (WayofTime.bloodmagic.event.RitualEvent)1 ItemRitualDiviner (WayofTime.bloodmagic.item.ItemRitualDiviner)1 RitualComponent (WayofTime.bloodmagic.ritual.RitualComponent)1 IImperfectRitualStone (WayofTime.bloodmagic.ritual.imperfect.IImperfectRitualStone)1 TileImperfectRitualStone (WayofTime.bloodmagic.tile.TileImperfectRitualStone)1 Nonnull (javax.annotation.Nonnull)1 Block (net.minecraft.block.Block)1 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)1 ItemBlock (net.minecraft.item.ItemBlock)1 ItemStack (net.minecraft.item.ItemStack)1 EnumFacing (net.minecraft.util.EnumFacing)1 BlockPos (net.minecraft.util.math.BlockPos)1 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)1 World (net.minecraft.world.World)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1