use of WayofTime.bloodmagic.ritual.IMasterRitualStone 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