Search in sources :

Example 31 with Species

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

the class DendroPotion method registerRecipes.

public DendroPotion registerRecipes(IForgeRegistry<IRecipe> registry) {
    ItemStack awkwardStack = PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionType.REGISTRY.getObject(new ResourceLocation("awkward")));
    DendroPotionType.BIOCHAR.ifActive(type -> this.addRecipe(awkwardStack, // Ingredient: charcoal
    new ItemStack(Items.COAL, 1, 1), this.getPotionStack(type)));
    DendroPotionType.DEPLETION.ifActive(type -> this.addRecipe(Items.SLIME_BALL, type));
    DendroPotionType.GIGAS.ifActive(type -> this.addRecipe(Items.PUMPKIN_SEEDS, type));
    DendroPotionType.BURGEONING.ifActive(type -> this.addRecipe(Items.GHAST_TEAR, type));
    DendroPotionType.FERTILITY.ifActive(type -> this.addRecipe(Items.FISH, type));
    // Ingredient: blue orchid.
    DendroPotionType.PERSISTANCE.ifActive(type -> this.addRecipe(Blocks.RED_FLOWER, 1, type));
    DendroPotionType.TRANSFORM.ifActive(type -> {
        this.addRecipe(Items.PRISMARINE_CRYSTALS, type);
        for (Species species : TreeRegistry.getPotionTransformableSpecies()) {
            ItemStack outputStack = setTargetSpecies(new ItemStack(this, 1, type.getIndex()), species);
            this.addRecipe(this.getPotionStack(type), species.getSeedStack(1), outputStack);
        }
    });
    return this;
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) ItemStack(net.minecraft.item.ItemStack) Species(com.ferreusveritas.dynamictrees.trees.Species)

Example 32 with Species

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

the class Seed method onItemUseFlowerPot.

public EnumActionResult onItemUseFlowerPot(EntityPlayer player, World world, BlockPos pos, EnumHand hand, ItemStack seedStack, EnumFacing facing, float hitX, float hitY, float hitZ) {
    // Handle Flower Pot interaction
    IBlockState emptyPotState = world.getBlockState(pos);
    if (emptyPotState.getBlock() instanceof BlockFlowerPot && (emptyPotState == emptyPotState.getBlock().getDefaultState())) {
        // Empty Flower Pot of some kind
        Species species = getSpecies(seedStack);
        BlockBonsaiPot bonzaiPot = species.getBonzaiPot();
        world.setBlockState(pos, bonzaiPot.getDefaultState());
        if (bonzaiPot.setSpecies(world, species, pos) && bonzaiPot.setPotState(world, emptyPotState, pos)) {
            seedStack.shrink(1);
            return EnumActionResult.SUCCESS;
        }
    }
    return EnumActionResult.PASS;
}
Also used : BlockFlowerPot(net.minecraft.block.BlockFlowerPot) IBlockState(net.minecraft.block.state.IBlockState) BlockBonsaiPot(com.ferreusveritas.dynamictrees.blocks.BlockBonsaiPot) Species(com.ferreusveritas.dynamictrees.trees.Species)

Example 33 with Species

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

the class Staff method onItemUse.

@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack heldStack = player.getHeldItem(hand);
    IBlockState clickedBlockState = world.getBlockState(pos);
    if (!isReadOnly(heldStack)) {
        Species species = TreeHelper.getBestGuessSpecies(world, pos);
        if (species.isValid()) {
            setSpecies(heldStack, species);
            if (!player.isSneaking()) {
                EnumFacing playerFacing = player.getHorizontalFacing();
                Optional<JoCode> joCode = TreeHelper.getJoCode(world, pos, playerFacing, species);
                if (joCode.isPresent()) {
                    String code = joCode.get().toString();
                    setCode(heldStack, code);
                    if (world.isRemote) {
                        // Make sure this doesn't run on the server
                        // Put the code in the system clipboard to annoy everyone.
                        GuiScreen.setClipboardString(code);
                    }
                }
            }
            return EnumActionResult.SUCCESS;
        }
    }
    // Create a tree from right clicking on soil
    Species species = getSpecies(heldStack);
    if (species.isValid() && species.isAcceptableSoil(world, pos, clickedBlockState)) {
        species.getJoCode(getCode(heldStack)).setCareful(true).generate(world, species, pos, world.getBiome(pos), player.getHorizontalFacing(), 8, SafeChunkBounds.ANY);
        if (!player.isCreative()) {
            if (hasMaxUses(heldStack)) {
                if (decUses(heldStack)) {
                    // If the player is in creative this will have no effect.
                    heldStack.shrink(1);
                }
            } else {
                // If the player is in creative this will have no effect.
                heldStack.shrink(1);
            }
        }
        return EnumActionResult.SUCCESS;
    }
    return EnumActionResult.FAIL;
}
Also used : JoCode(com.ferreusveritas.dynamictrees.worldgen.JoCode) IBlockState(net.minecraft.block.state.IBlockState) EnumFacing(net.minecraft.util.EnumFacing) ItemStack(net.minecraft.item.ItemStack) Species(com.ferreusveritas.dynamictrees.trees.Species)

Example 34 with Species

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

the class Staff method addInformation.

@Override
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flagIn) {
    Species species = getSpecies(stack);
    tooltip.add(getTranslationText("tooltip.woodland_staff.tree") + " " + ((species != null) ? "§a" + species.getLocalizedName() : getTranslationText("tooltip.woodland_staff.tree_not_set")));
    tooltip.add("JoCode: §6" + getCode(stack));
}
Also used : Species(com.ferreusveritas.dynamictrees.trees.Species)

Example 35 with Species

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

the class BakedModelBlockBonsaiPot method getQuads.

@Override
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
    List<BakedQuad> quads = new ArrayList<BakedQuad>();
    if (side != null) {
        return quads;
    }
    Species species = Species.NULLSPECIES;
    IBlockState potState = null;
    if (state != null && state.getBlock() instanceof BlockBonsaiPot && state instanceof IExtendedBlockState) {
        species = ((IExtendedBlockState) state).getValue(SpeciesProperty.SPECIES);
        potState = ((IExtendedBlockState) state).getValue(BlockBonsaiPot.POT);
    }
    if (species == null || species == Species.NULLSPECIES || !(potState.getBlock() instanceof BlockFlowerPot)) {
        return quads;
    }
    BlockRendererDispatcher dispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
    IBakedModel potModel = dispatcher.getModelForState(potState);
    IBakedModel saplingModel = BakedModelSapling.getModelForSapling(species);
    quads.addAll(potModel.getQuads(potState, side, rand));
    quads.addAll(cachedSaplingQuads.computeIfAbsent(species, s -> QuadManipulator.getQuads(saplingModel, ModBlocks.blockDynamicSapling.getDefaultState(), new Vec3d(0, 0.25, 0), rand)));
    return quads;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) BlockBonsaiPot(com.ferreusveritas.dynamictrees.blocks.BlockBonsaiPot) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) SpeciesProperty(com.ferreusveritas.dynamictrees.blocks.SpeciesProperty) EnumFacing(net.minecraft.util.EnumFacing) HashMap(java.util.HashMap) Species(com.ferreusveritas.dynamictrees.trees.Species) BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) ItemOverrideList(net.minecraft.client.renderer.block.model.ItemOverrideList) QuadManipulator(com.ferreusveritas.dynamictrees.client.QuadManipulator) ArrayList(java.util.ArrayList) BlockFlowerPot(net.minecraft.block.BlockFlowerPot) IBlockState(net.minecraft.block.state.IBlockState) List(java.util.List) Vec3d(net.minecraft.util.math.Vec3d) ModBlocks(com.ferreusveritas.dynamictrees.ModBlocks) Minecraft(net.minecraft.client.Minecraft) Side(net.minecraftforge.fml.relauncher.Side) Map(java.util.Map) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) BlockFlowerPot(net.minecraft.block.BlockFlowerPot) IBlockState(net.minecraft.block.state.IBlockState) BlockBonsaiPot(com.ferreusveritas.dynamictrees.blocks.BlockBonsaiPot) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) ArrayList(java.util.ArrayList) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) Species(com.ferreusveritas.dynamictrees.trees.Species) Vec3d(net.minecraft.util.math.Vec3d) 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