Search in sources :

Example 6 with BlockRooty

use of com.ferreusveritas.dynamictrees.blocks.BlockRooty in project DynamicTrees by DynamicTreesTeam.

the class SubstanceMega method apply.

@Override
public Result apply(World world, BlockPos rootPos, BlockPos hitPos) {
    IBlockState blockState = world.getBlockState(rootPos);
    BlockRooty dirt = TreeHelper.getRooty(blockState);
    Species species = dirt.getSpecies(blockState, world, rootPos);
    Species megaSpecies = species.getMegaSpecies();
    if (megaSpecies.isValid()) {
        int life = dirt.getSoilLife(blockState, world, rootPos);
        megaSpecies.placeRootyDirtBlock(world, rootPos, life);
        blockState = world.getBlockState(rootPos);
        dirt = TreeHelper.getRooty(blockState);
        if (dirt.getSpecies(blockState, world, rootPos) == megaSpecies) {
            TreeHelper.treeParticles(world, rootPos, EnumParticleTypes.DRAGON_BREATH, 8);
            WailaOther.invalidateWailaPosition();
            return Result.successful();
        }
    }
    return Result.failure("substance.dynamictrees.mega.error.no_mega_species", species.getLocalizedName());
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockRooty(com.ferreusveritas.dynamictrees.blocks.BlockRooty) Species(com.ferreusveritas.dynamictrees.trees.Species)

Example 7 with BlockRooty

use of com.ferreusveritas.dynamictrees.blocks.BlockRooty in project DynamicTrees by DynamicTreesTeam.

the class SubstanceTransform method apply.

@Override
public Result apply(World world, BlockPos rootPos, BlockPos hitPos) {
    IBlockState rootyState = world.getBlockState(rootPos);
    BlockRooty dirt = TreeHelper.getRooty(rootyState);
    if (this.toSpecies == null) {
        return Result.failure("substance.dynamictrees.transform.error.not_brewed");
    }
    if (dirt == null) {
        return Result.failure();
    }
    final Species fromSpecies = dirt.getSpecies(rootyState, world, rootPos);
    if (!fromSpecies.isTransformable()) {
        return Result.failure("substance.dynamictrees.transform.error.not_transformable", fromSpecies.getLocalizedName());
    }
    if (fromSpecies == toSpecies) {
        return Result.failure("substance.dynamictrees.transform.error.already_transformed", fromSpecies.getLocalizedName());
    }
    if (world.isRemote) {
        TreeHelper.treeParticles(world, rootPos, EnumParticleTypes.FIREWORKS_SPARK, 8);
        WailaOther.invalidateWailaPosition();
    } else {
        dirt.startAnalysis(world, rootPos, new MapSignal(new NodeTransform(fromSpecies, toSpecies)));
        if (dirt.getSpecies(rootyState, world, rootPos) != toSpecies) {
            toSpecies.placeRootyDirtBlock(world, rootPos, dirt.getSoilLife(rootyState, world, rootPos));
        }
    }
    return Result.successful();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) NodeTransform(com.ferreusveritas.dynamictrees.systems.nodemappers.NodeTransform) BlockRooty(com.ferreusveritas.dynamictrees.blocks.BlockRooty) Species(com.ferreusveritas.dynamictrees.trees.Species) MapSignal(com.ferreusveritas.dynamictrees.api.network.MapSignal)

Aggregations

BlockRooty (com.ferreusveritas.dynamictrees.blocks.BlockRooty)7 IBlockState (net.minecraft.block.state.IBlockState)7 MapSignal (com.ferreusveritas.dynamictrees.api.network.MapSignal)4 Species (com.ferreusveritas.dynamictrees.trees.Species)4 BlockPos (net.minecraft.util.math.BlockPos)3 NodeTransform (com.ferreusveritas.dynamictrees.systems.nodemappers.NodeTransform)2 BlockBranch (com.ferreusveritas.dynamictrees.blocks.BlockBranch)1 NodeCollector (com.ferreusveritas.dynamictrees.systems.nodemappers.NodeCollector)1 NodeFreezer (com.ferreusveritas.dynamictrees.systems.nodemappers.NodeFreezer)1 HashSet (java.util.HashSet)1 CommandException (net.minecraft.command.CommandException)1 WrongUsageException (net.minecraft.command.WrongUsageException)1 EnumFacing (net.minecraft.util.EnumFacing)1 MutableBlockPos (net.minecraft.util.math.BlockPos.MutableBlockPos)1