Search in sources :

Example 1 with Species

use of com.ferreusveritas.dynamictrees.trees.Species in project Bewitchment by Um-Mitternacht.

the class ItemFoodSeed method onItemUseFlowerPot.

@Optional.Method(modid = "dynamictrees")
public EnumActionResult onItemUseFlowerPot(EntityPlayer player, World world, BlockPos pos, EnumHand hand, ItemStack seedStack, EnumFacing facing, float hitX, float hitY, float hitZ) {
    IBlockState emptyPotState = world.getBlockState(pos);
    if (emptyPotState.getBlock() instanceof BlockFlowerPot && emptyPotState == emptyPotState.getBlock().getDefaultState()) {
        Species species = getSpecies();
        if (species != null) {
            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 2 with Species

use of com.ferreusveritas.dynamictrees.trees.Species in project Bewitchment by Um-Mitternacht.

the class SaplingReplacer method onPlaceSaplingEvent.

@SubscribeEvent
public void onPlaceSaplingEvent(BlockEvent.PlaceEvent event) {
    IBlockState state = event.getPlacedBlock();
    Species species = null;
    if (state.getBlock() == ModObjects.cypress_sapling) {
        species = TreeRegistry.findSpecies(new ResourceLocation(Bewitchment.MODID, "cypress"));
    } else if (state.getBlock() == ModObjects.dragons_blood_sapling) {
        species = TreeRegistry.findSpecies(new ResourceLocation(Bewitchment.MODID, "dragonsblood"));
    } else if (state.getBlock() == ModObjects.elder_sapling) {
        species = TreeRegistry.findSpecies(new ResourceLocation(Bewitchment.MODID, "elder"));
    } else if (state.getBlock() == ModObjects.juniper_sapling) {
        species = TreeRegistry.findSpecies(new ResourceLocation(Bewitchment.MODID, "juniper"));
    }
    if (species != null) {
        event.getWorld().setBlockToAir(event.getPos());
        if (!species.plantSapling(event.getWorld(), event.getPos())) {
            double x = (double) event.getPos().getX() + 0.5D;
            double y = (double) event.getPos().getY() + 0.5D;
            double z = (double) event.getPos().getZ() + 0.5D;
            EntityItem itemEntity = new EntityItem(event.getWorld(), x, y, z, species.getSeedStack(1));
            event.getWorld().spawnEntity(itemEntity);
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) ResourceLocation(net.minecraft.util.ResourceLocation) Species(com.ferreusveritas.dynamictrees.trees.Species) EntityItem(net.minecraft.entity.item.EntityItem) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 3 with Species

use of com.ferreusveritas.dynamictrees.trees.Species in project Bewitchment by Um-Mitternacht.

the class ModRecipes method addOvenRecipes.

protected static void addOvenRecipes() {
    ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "oak_spirit"), new ItemStack(Blocks.SAPLING, 1), new ItemStack(ModObjects.wood_ash, 1), new ItemStack(ModObjects.oak_spirit), 0.75f, true));
    ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "oak_spirit_alt"), new ItemStack(Blocks.SAPLING, 1, 5), new ItemStack(ModObjects.wood_ash, 1), new ItemStack(ModObjects.oak_spirit), 0.75f, true));
    ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "spruce_heart"), new ItemStack(Blocks.SAPLING, 1, 1), new ItemStack(ModObjects.wood_ash, 1), new ItemStack(ModObjects.spruce_heart), 0.75f, true));
    ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "birch_soul"), new ItemStack(Blocks.SAPLING, 1, 2), new ItemStack(ModObjects.wood_ash, 1), new ItemStack(ModObjects.birch_soul), 0.75f, true));
    ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "cloudy_oil"), new ItemStack(Blocks.SAPLING, 1, 3), new ItemStack(ModObjects.wood_ash, 1), new ItemStack(ModObjects.cloudy_oil), 0.75f, true));
    ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "acacia_resin"), new ItemStack(Blocks.SAPLING, 1, 4), new ItemStack(ModObjects.wood_ash, 1), new ItemStack(ModObjects.acacia_resin), 0.75f, true));
    ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "ebb_of_death"), new ItemStack(ModObjects.cypress_sapling), new ItemStack(ModObjects.wood_ash, 1), new ItemStack(ModObjects.ebb_of_death), 0.75f, true));
    ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "droplet_of_wisdom"), new ItemStack(ModObjects.elder_sapling), new ItemStack(ModObjects.wood_ash, 1), new ItemStack(ModObjects.droplet_of_wisdom), 0.75f, true));
    ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "liquid_witchcraft"), new ItemStack(ModObjects.mandrake_root), new ItemStack(ModObjects.wood_ash, 1), new ItemStack(ModObjects.liquid_witchcraft), 0.75f, true));
    ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "essence_of_vitality"), new ItemStack(ModObjects.juniper_sapling), new ItemStack(ModObjects.wood_ash, 1), new ItemStack(ModObjects.essence_of_vitality), 0.75f, true));
    if (Loader.isModLoaded("dynamictrees")) {
        for (TreeFamilyVanilla family : ModTrees.baseFamilies) {
            Species species = family.getCommonSpecies();
            String name = species.getSaplingName().toString().toLowerCase();
            name = name.substring(name.indexOf(":") + 1);
            ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, name), species.getSeedStack(1), new ItemStack(ModObjects.wood_ash, 1), new ItemStack(name.contains("oak") ? ModObjects.oak_spirit : name.contains("spruce") ? ModObjects.spruce_heart : name.contains("birch") ? ModObjects.birch_soul : name.contains("acacia") ? ModObjects.acacia_resin : ModObjects.cloudy_oil), 0.75f, true));
        }
        ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "cypress_seed"), DynamicTreesCompat.cypressTree.getCommonSpecies().getSeedStack(1), new ItemStack(ModObjects.wood_ash, 1), new ItemStack(ModObjects.ebb_of_death), 0.75f, true));
        ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "elder_seed"), new ItemStack(ModObjects.elderberries), new ItemStack(ModObjects.wood_ash, 1), new ItemStack(ModObjects.droplet_of_wisdom), 0.75f, true));
        ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "juniper_seed"), new ItemStack(ModObjects.juniper_berries), new ItemStack(ModObjects.wood_ash, 1), new ItemStack(ModObjects.essence_of_vitality), 0.75f, true));
    }
    ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "cloudy_oil_alt0"), new ItemStack(Blocks.CACTUS), new ItemStack(Items.DYE, 1, 2), new ItemStack(ModObjects.cloudy_oil), 0.55f, true));
    ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "ectoplasm"), new ItemStack(Items.ROTTEN_FLESH), new ItemStack(Items.LEATHER), new ItemStack(ModObjects.ectoplasm, 3), 0.65f, false));
    ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "ectoplasm_alt"), new ItemStack(Items.BONE), new ItemStack(Items.DYE, 1, 15), new ItemStack(ModObjects.ectoplasm), 0.65f, false));
    ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "dimensional_sand"), new ItemStack(Items.ENDER_EYE), new ItemStack(Items.BLAZE_POWDER, 1, 0), new ItemStack(ModObjects.dimensional_sand, 2), 0.8f, false));
    ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "dimensional_sand_alt0"), new ItemStack(Items.SHULKER_SHELL), new ItemStack(Items.CHORUS_FRUIT_POPPED, 1, 0), new ItemStack(ModObjects.dimensional_sand, 4), 1, false));
    ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "dimensional_sand_alt1"), new ItemStack(Items.CHORUS_FRUIT), new ItemStack(Items.CHORUS_FRUIT_POPPED), new ItemStack(ModObjects.dimensional_sand, 2), 0.75f, false));
    ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "witches_can_cook"), new ItemStack(Items.BEEF, 1), new ItemStack(Items.COOKED_BEEF), new ItemStack(ModObjects.tallow), 0.35f, false));
    ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "witches_can_cook_2"), new ItemStack(Items.PORKCHOP, 1), new ItemStack(Items.COOKED_PORKCHOP), new ItemStack(ModObjects.tallow), 0.35f, false));
    ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "witches_can_cook_3"), new ItemStack(Items.MUTTON, 1), new ItemStack(Items.COOKED_MUTTON), new ItemStack(ModObjects.tallow), 0.35f, false));
    ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "witches_can_cook_6"), new ItemStack(Items.CHICKEN, 1), new ItemStack(Items.COOKED_CHICKEN), new ItemStack(ModObjects.tallow), 0.35f, false));
    ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "witches_can_cook_4"), new ItemStack(Items.FISH, 1), new ItemStack(Items.COOKED_FISH), new ItemStack(ModObjects.cloudy_oil), 0.35f, true));
    ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "witches_can_cook_5"), new ItemStack(Items.FISH, 1, 1), new ItemStack(Items.COOKED_FISH, 1, 1), new ItemStack(ModObjects.cloudy_oil), 0.35f, true));
    ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "witches_can_cook_7"), new ItemStack(Items.RABBIT, 1), new ItemStack(Items.COOKED_RABBIT), new ItemStack(ModObjects.tallow), 0.35f, false));
    ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "bread_from_oven"), new ItemStack(Items.WHEAT, 1), new ItemStack(Items.BREAD), new ItemStack(ModObjects.cloudy_oil), 0.35f, true));
    ovenRecipes.add(new OvenRecipe(new ResourceLocation(Bewitchment.MODID, "witches_can_cook_8"), new ItemStack(ModObjects.garlic, 1), new ItemStack(ModObjects.garlic_grilled), new ItemStack(ModObjects.cloudy_oil), 0.35f, true));
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) TreeFamilyVanilla(com.ferreusveritas.dynamictrees.trees.TreeFamilyVanilla) ItemStack(net.minecraft.item.ItemStack) Species(com.ferreusveritas.dynamictrees.trees.Species)

Example 4 with Species

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

the class ZelkovaLogic method getLowestBranchHeight.

@Override
public int getLowestBranchHeight(GrowthLogicKitConfiguration configuration, PositionalSpeciesContext context) {
    Species species = context.species();
    BlockPos pos = context.pos();
    long day = context.world().getGameTime() / 24000L;
    // Change the hashs every in-game month
    int month = (int) day / 30;
    return (int) (super.getLowestBranchHeight(configuration, context) * species.biomeSuitability(context.world(), pos) + // Vary the height energy by a psuedorandom hash function
    (CoordUtils.coordHashCode(pos.above(month), 2) % configuration.get(VariateHeightLogic.LOWEST_BRANCH_VARIATION)));
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) Species(com.ferreusveritas.dynamictrees.trees.Species)

Example 5 with Species

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

the class DiagonalPalmLogic method populateDirectionProbabilityMap.

@Override
public int[] populateDirectionProbabilityMap(GrowthLogicKitConfiguration configuration, DirectionManipulationContext context) {
    final Species species = context.species();
    final World world = context.world();
    final GrowSignal signal = context.signal();
    final int[] probMap = context.probMap();
    final BlockPos pos = context.pos();
    Direction originDir = signal.dir.getOpposite();
    // Alter probability map for direction change
    // Down is always disallowed for palm
    probMap[0] = 0;
    probMap[1] = species.getUpProbability();
    // Start by disabling probability on the sides
    probMap[2] = probMap[3] = probMap[4] = probMap[5] = 0;
    int diverge = (int) (4 / configuration.get(CHANCE_TO_DIVERGE));
    int split = (int) (1 / configuration.get(CHANCE_TO_SPLIT));
    int randCoordCode = Math.abs(CoordUtils.coordHashCode(pos, 2));
    int directionSelection = randCoordCode % diverge;
    int splitSelection = randCoordCode % split;
    if (directionSelection < 4 && signal.energy > 1) {
        Direction selectedDir = Direction.values()[2 + directionSelection];
        // only do branching if it just grew up (to avoid long sideways branches)
        if (originDir == Direction.DOWN) {
            probMap[selectedDir.ordinal()] = 10;
            // if the chance to split is met, the clockwise direction is also enabled
            if (splitSelection == 0 && signal.energy > species.getEnergy(world, signal.rootPos) * Math.max(0, Math.min(1, 1 - configuration.get(SPLIT_MAX_ENERGY_FACTOR)))) {
                probMap[selectedDir.getClockWise().ordinal()] = 10;
            }
            probMap[1] = 0;
        }
    }
    // Disable the direction we came from
    probMap[originDir.ordinal()] = 0;
    return probMap;
}
Also used : GrowSignal(com.ferreusveritas.dynamictrees.systems.GrowSignal) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) Species(com.ferreusveritas.dynamictrees.trees.Species) Direction(net.minecraft.util.Direction)

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