Java Code Examples for net.minecraft.world.World#immediateBlockTick()

The following examples show how to use net.minecraft.world.World#immediateBlockTick() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
@Override
public boolean run(@NotNull World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
	BlockPos targetPos = spell.getTargetPos();
	Entity targetEntity = spell.getVictim(world);
	Entity caster = spell.getCaster(world);
	Vec3d pos = spell.getTarget(world);

	if (pos == null) return true;

	if (targetEntity instanceof EntityLivingBase) {
		double potency = spellRing.getAttributeValue(world, AttributeRegistry.POTENCY, spell) / 2;

		if (!spellRing.taxCaster(world, spell, true)) return false;

		((EntityLivingBase) targetEntity).heal((float) potency);
		world.playSound(null, new BlockPos(pos), ModSounds.HEAL, SoundCategory.NEUTRAL, 1, 1);
	}

	if (targetPos != null) {
		BlockPos otherTargetPos = spell.getTargetPos().add(0, 1, 0); // beam missed crops and targets farmland

		if (world.getBlockState(targetPos).getBlock() instanceof IGrowable || world.getBlockState(otherTargetPos).getBlock() instanceof IGrowable) {
			if (!spellRing.taxCaster(world, spell, true)) return false;
			if (!(caster instanceof EntityPlayerMP) || BlockUtils.hasEditPermission(targetPos, (EntityPlayerMP) caster)) {
				ItemDye.applyBonemeal(new ItemStack(Items.DYE), world, targetPos);
				ItemDye.applyBonemeal(new ItemStack(Items.DYE), world, otherTargetPos);

				PacketThriveBlock ptb = new PacketThriveBlock(targetPos);
				PacketHandler.NETWORK.sendToAllAround(ptb, new NetworkRegistry.TargetPoint(world.provider.getDimension(), targetPos.getX(), targetPos.getY(), targetPos.getZ(), 100));

				if (!world.isRemote) {
					world.playEvent(2005, targetPos, 0);
					world.playEvent(2005, otherTargetPos, 0);
				}
			}
		} else if (world.getBlockState(targetPos).getBlock() instanceof IPlantable || world.getBlockState(otherTargetPos).getBlock() instanceof IPlantable) {
			IBlockState state = world.getBlockState(targetPos);
			Block block = state.getBlock();
			if (!spellRing.taxCaster(world, spell, true)) return false;
			if (caster == null || (caster instanceof EntityPlayer && BlockUtils.hasEditPermission(targetPos, (EntityPlayerMP) caster))) {
				while (world.getBlockState(targetPos.up()).getBlock() == block) {
					targetPos = targetPos.up();
					state = world.getBlockState(targetPos);
					block = state.getBlock();
				}
				world.immediateBlockTick(targetPos, state, RandUtil.random);
				world.playSound(null, new BlockPos(pos), ModSounds.HEAL, SoundCategory.NEUTRAL, 1, 1);
			}

			state = world.getBlockState(otherTargetPos);
			block = state.getBlock();

			if (caster == null || (caster instanceof EntityPlayer && BlockUtils.hasEditPermission(otherTargetPos, (EntityPlayerMP) caster))) {
				while (world.getBlockState(otherTargetPos.up()).getBlock() == block) {
					otherTargetPos = otherTargetPos.up();
					state = world.getBlockState(otherTargetPos);
					block = state.getBlock();
				}
				world.immediateBlockTick(otherTargetPos, state, RandUtil.random);
				world.playSound(null, new BlockPos(pos), ModSounds.HEAL, SoundCategory.NEUTRAL, 1, 1);
			}
		}
	}

	return true;
}