Search in sources :

Example 1 with EnumRitualReaderState

use of WayofTime.bloodmagic.ritual.EnumRitualReaderState in project BloodMagic by WayofTime.

the class ItemRitualReader method addInformation.

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag tooltipFlag) {
    if (!stack.hasTagCompound())
        return;
    EnumRitualReaderState state = this.getState(stack);
    tooltip.add(TextHelper.localizeEffect(tooltipBase + "currentState", TextHelper.localizeEffect(tooltipBase + state.toString().toLowerCase())));
    tooltip.add("");
    boolean sneaking = Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT);
    if (sneaking) {
        tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect(tooltipBase + "desc." + state.toString().toLowerCase()))));
    } else {
        tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.extraInfo"));
    }
    super.addInformation(stack, world, tooltip, tooltipFlag);
}
Also used : EnumRitualReaderState(WayofTime.bloodmagic.ritual.EnumRitualReaderState) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with EnumRitualReaderState

use of WayofTime.bloodmagic.ritual.EnumRitualReaderState in project BloodMagic by WayofTime.

the class ItemRitualReader method cycleReader.

public void cycleReader(ItemStack stack, EntityPlayer player) {
    EnumRitualReaderState prevState = getState(stack);
    int val = prevState.ordinal();
    int nextVal = val + 1 >= EnumRitualReaderState.values().length ? 0 : val + 1;
    EnumRitualReaderState nextState = EnumRitualReaderState.values()[nextVal];
    setState(stack, nextState);
    notifyPlayerOfStateChange(nextState, player);
}
Also used : EnumRitualReaderState(WayofTime.bloodmagic.ritual.EnumRitualReaderState)

Example 3 with EnumRitualReaderState

use of WayofTime.bloodmagic.ritual.EnumRitualReaderState in project BloodMagic by WayofTime.

the class ItemRitualReader method onItemUse.

@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack stack = player.getHeldItem(hand);
    if (!world.isRemote) {
        EnumRitualReaderState state = this.getState(stack);
        TileEntity tile = world.getTileEntity(pos);
        if (tile instanceof IMasterRitualStone) {
            IMasterRitualStone master = (IMasterRitualStone) tile;
            this.setMasterBlockPos(stack, pos);
            this.setBlockPos(stack, BlockPos.ORIGIN);
            switch(state) {
                case INFORMATION:
                    master.provideInformationOfRitualToPlayer(player);
                    break;
                case SET_AREA:
                    String range = this.getCurrentBlockRange(stack);
                    if (player.isSneaking()) {
                        String newRange = master.getNextBlockRange(range);
                        range = newRange;
                        this.setCurrentBlockRange(stack, newRange);
                    }
                    master.provideInformationOfRangeToPlayer(player, range);
                    break;
                case SET_WILL_TYPES:
                    List<EnumDemonWillType> typeList = new ArrayList<>();
                    NonNullList<ItemStack> inv = player.inventory.mainInventory;
                    for (int i = 0; i < 9; i++) {
                        ItemStack testStack = inv.get(i);
                        if (testStack.isEmpty()) {
                            continue;
                        }
                        if (testStack.getItem() instanceof IDiscreteDemonWill) {
                            EnumDemonWillType type = ((IDiscreteDemonWill) testStack.getItem()).getType(testStack);
                            if (!typeList.contains(type)) {
                                typeList.add(type);
                            }
                        }
                    }
                    master.setActiveWillConfig(player, typeList);
                    master.provideInformationOfWillConfigToPlayer(player, typeList);
                    break;
            }
            return EnumActionResult.FAIL;
        } else {
            if (state == EnumRitualReaderState.SET_AREA) {
                BlockPos masterPos = this.getMasterBlockPos(stack);
                if (!masterPos.equals(BlockPos.ORIGIN)) {
                    BlockPos containedPos = getBlockPos(stack);
                    if (containedPos.equals(BlockPos.ORIGIN)) {
                        this.setBlockPos(stack, pos.subtract(masterPos));
                        player.sendStatusMessage(new TextComponentTranslation("ritual.bloodmagic.blockRange.firstBlock"), true);
                    // TODO: Notify player.
                    } else {
                        tile = world.getTileEntity(masterPos);
                        if (tile instanceof IMasterRitualStone) {
                            IMasterRitualStone master = (IMasterRitualStone) tile;
                            master.setBlockRangeByBounds(player, this.getCurrentBlockRange(stack), containedPos, pos.subtract(masterPos));
                        }
                        this.setBlockPos(stack, BlockPos.ORIGIN);
                    }
                }
            }
        }
    }
    return super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) IDiscreteDemonWill(WayofTime.bloodmagic.soul.IDiscreteDemonWill) EnumRitualReaderState(WayofTime.bloodmagic.ritual.EnumRitualReaderState) ArrayList(java.util.ArrayList) TileEntity(net.minecraft.tileentity.TileEntity) IMasterRitualStone(WayofTime.bloodmagic.ritual.IMasterRitualStone) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType)

Aggregations

EnumRitualReaderState (WayofTime.bloodmagic.ritual.EnumRitualReaderState)3 IMasterRitualStone (WayofTime.bloodmagic.ritual.IMasterRitualStone)1 EnumDemonWillType (WayofTime.bloodmagic.soul.EnumDemonWillType)1 IDiscreteDemonWill (WayofTime.bloodmagic.soul.IDiscreteDemonWill)1 ArrayList (java.util.ArrayList)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1