Search in sources :

Example 16 with Species

use of com.ferreusveritas.dynamictrees.trees.Species in project DynamicTrees by DynamicTreesTeam.

the class CommandSetTree method execute.

@Override
public void execute(World world, ICommandSender sender, String[] args) throws CommandException {
    BlockPos pos = BlockPos.ORIGIN;
    Species species = null;
    String joCode = "";
    int turns = 0;
    if (args.length < 5) {
        throw new WrongUsageException("commands.dynamictrees.setree.usage");
    }
    for (int arg = 0; arg < args.length; arg++) {
        switch(arg) {
            case 3:
                pos = CommandBase.parseBlockPos(sender, args, 1, false);
                break;
            case 4:
                species = TreeRegistry.findSpeciesSloppy(args[4]);
                if (species == Species.NULLSPECIES) {
                    throw new WrongUsageException("commands.dynamictrees.setree.specieserror", args[4]);
                }
                break;
            case 5:
                joCode = args[5];
                break;
            case 6:
                try {
                    turns = Integer.parseInt(args[6]);
                } catch (NumberFormatException e) {
                    throw new WrongUsageException("commands.dynamictrees.rotatejocode.turnserror", args[6]);
                }
                break;
        }
    }
    if (joCode.isEmpty()) {
        joCode = DEFAULTJOCODE;
    }
    turns = (3 - (turns % 4)) + 3;
    species.getJoCode(joCode).rotate(EnumFacing.getHorizontal(turns)).setCareful(true).generate(world, species, pos, world.getBiome(pos), EnumFacing.SOUTH, 8, SafeChunkBounds.ANY);
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) BlockPos(net.minecraft.util.math.BlockPos) Species(com.ferreusveritas.dynamictrees.trees.Species)

Example 17 with Species

use of com.ferreusveritas.dynamictrees.trees.Species in project DynamicTrees by DynamicTreesTeam.

the class DendroPotion method addInformation.

@Override
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag tooltipFlag) {
    super.addInformation(stack, world, tooltip, tooltipFlag);
    DendroPotionType potionType = getPotionType(stack);
    if (potionType == DendroPotionType.TRANSFORM) {
        Species species = getTargetSpecies(stack);
        if (species == null) {
            tooltip.add(getPotionType(stack).getLore());
        } else {
            tooltip.add(getTranslationText("potion.transform.description", species.getLocalizedName()));
        }
    } else {
        tooltip.add(getPotionType(stack).getLore());
    }
}
Also used : Species(com.ferreusveritas.dynamictrees.trees.Species)

Example 18 with Species

use of com.ferreusveritas.dynamictrees.trees.Species in project DynamicTrees by DynamicTreesTeam.

the class Seed method doPlanting.

public boolean doPlanting(World world, BlockPos pos, EntityPlayer planter, ItemStack seedStack) {
    Species species = getSpecies(seedStack);
    final Species speciesForLocation = species.getFamily().getSpeciesForLocation(world, pos);
    // If the species is the common species and the location override is not the common species, do location override.
    if (species.equals(species.getFamily().getCommonSpecies()) && !speciesForLocation.equals(species.getFamily().getCommonSpecies())) {
        species = speciesForLocation;
    }
    if (species.plantSapling(world, pos)) {
        // Do the planting
        String joCode = getCode(seedStack);
        if (!joCode.isEmpty()) {
            // Remove the newly created dynamic sapling
            world.setBlockToAir(pos);
            species.getJoCode(joCode).setCareful(true).generate(world, species, pos.down(), world.getBiome(pos), planter != null ? planter.getHorizontalFacing() : EnumFacing.NORTH, 8, SafeChunkBounds.ANY);
        }
        return true;
    }
    return false;
}
Also used : Species(com.ferreusveritas.dynamictrees.trees.Species)

Example 19 with Species

use of com.ferreusveritas.dynamictrees.trees.Species in project DynamicTrees by DynamicTreesTeam.

the class Staff method getSpecies.

public Species getSpecies(ItemStack itemStack) {
    NBTTagCompound nbt = getNBT(itemStack);
    if (nbt.hasKey(TREE)) {
        return TreeRegistry.findSpecies(new ResourceLocation(nbt.getString(TREE)));
    } else {
        Species species = TreeRegistry.findSpeciesSloppy("oak");
        setSpecies(itemStack, species);
        return species;
    }
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Species(com.ferreusveritas.dynamictrees.trees.Species)

Example 20 with Species

use of com.ferreusveritas.dynamictrees.trees.Species in project DynamicTrees by DynamicTreesTeam.

the class ModelEntityFallingTree method generateTreeQuads.

public List<TreeQuadData> generateTreeQuads(EntityFallingTree entity, World world) {
    final BlockRendererDispatcher dispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
    final BranchDestructionData destructionData = entity.getDestroyData();
    final Species species = destructionData.species;
    final BlockPos cutPos = destructionData.cutPos;
    final EnumFacing cutDir = destructionData.cutDir;
    final ArrayList<TreeQuadData> treeQuads = new ArrayList<>();
    if (destructionData.getNumBranches() <= 0) {
        return treeQuads;
    }
    // Draw the ring texture cap on the cut block
    IExtendedBlockState exState = destructionData.getBranchBlockState(0);
    if (exState == null) {
        return treeQuads;
    }
    for (EnumFacing face : EnumFacing.VALUES) {
        exState = exState.withProperty(BlockBranch.CONNECTIONS[face.getIndex()], face == cutDir.getOpposite() ? 8 : 0);
    }
    int radius = ((BlockBranch) exState.getBlock()).getRadius(exState);
    float offset = (8 - Math.min(radius, BlockBranch.RADMAX_NORMAL)) / 16f;
    // Since we source the blockState from the destruction data it will always be the same
    IBakedModel branchModel = dispatcher.getModelForState(exState.getClean());
    treeQuads.addAll(toTreeQuadData(QuadManipulator.getQuads(branchModel, exState, new Vec3d(BlockPos.ORIGIN.offset(cutDir)).scale(offset), new EnumFacing[] { cutDir }), 0xFFFFFFFF, exState.getClean()));
    // Draw the rest of the tree/branch
    for (int index = 0; index < destructionData.getNumBranches(); index++) {
        Block previousBranch = exState.getBlock();
        exState = destructionData.getBranchBlockState(index);
        if (// Update the branch model only if the block is different
        !previousBranch.equals(exState.getBlock())) {
            branchModel = dispatcher.getModelForState(exState.getClean());
        }
        BlockPos relPos = destructionData.getBranchRelPos(index);
        treeQuads.addAll(toTreeQuadData(QuadManipulator.getQuads(branchModel, exState, new Vec3d(relPos)), 0xFFFFFFFF, exState.getClean()));
    }
    // Draw the leaves
    HashMap<BlockPos, IBlockState> leavesClusters = species.getFamily().getFellingLeavesClusters(destructionData);
    if (leavesClusters != null) {
        for (Entry<BlockPos, IBlockState> leafLoc : leavesClusters.entrySet()) {
            IBlockState leafState = leafLoc.getValue();
            if (leafState instanceof IExtendedBlockState) {
                leafState = ((IExtendedBlockState) leafState).getClean();
            }
            treeQuads.addAll(toTreeQuadData(QuadManipulator.getQuads(dispatcher.getModelForState(leafState), leafLoc.getValue(), new Vec3d(leafLoc.getKey())), species.getLeavesProperties().foliageColorMultiplier(leafState, world, cutPos), leafState));
        }
    } else {
        for (int index = 0; index < destructionData.getNumLeaves(); index++) {
            BlockPos relPos = destructionData.getLeavesRelPos(index);
            IBlockState state = destructionData.getLeavesBlockState(index);
            IBakedModel leavesModel = dispatcher.getModelForState(state);
            treeQuads.addAll(toTreeQuadData(QuadManipulator.getQuads(leavesModel, state, new Vec3d(relPos)), destructionData.getLeavesProperties(index).foliageColorMultiplier(state, world, cutPos.add(relPos)), state));
        }
    }
    return treeQuads;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) EnumFacing(net.minecraft.util.EnumFacing) ArrayList(java.util.ArrayList) BlockBranch(com.ferreusveritas.dynamictrees.blocks.BlockBranch) Vec3d(net.minecraft.util.math.Vec3d) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) BranchDestructionData(com.ferreusveritas.dynamictrees.util.BranchDestructionData) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) Species(com.ferreusveritas.dynamictrees.trees.Species) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Aggregations

Species (com.ferreusveritas.dynamictrees.trees.Species)56 BlockPos (net.minecraft.util.math.BlockPos)24 IBlockState (net.minecraft.block.state.IBlockState)19 ItemStack (net.minecraft.item.ItemStack)12 GrowSignal (com.ferreusveritas.dynamictrees.systems.GrowSignal)9 Direction (net.minecraft.util.Direction)9 ResourceLocation (net.minecraft.util.ResourceLocation)8 World (net.minecraft.world.World)8 TileEntitySpecies (com.ferreusveritas.dynamictrees.tileentity.TileEntitySpecies)6 EnumFacing (net.minecraft.util.EnumFacing)6 MapSignal (com.ferreusveritas.dynamictrees.api.network.MapSignal)5 BlockRooty (com.ferreusveritas.dynamictrees.blocks.BlockRooty)4 ArrayList (java.util.ArrayList)4 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)4 WrongUsageException (net.minecraft.command.WrongUsageException)4 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)4 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)4 ITreePart (com.ferreusveritas.dynamictrees.api.treedata.ITreePart)3 BlockBonsaiPot (com.ferreusveritas.dynamictrees.blocks.BlockBonsaiPot)3 TreeFamily (com.ferreusveritas.dynamictrees.trees.TreeFamily)3