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);
}
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);
}
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);
}
Aggregations