Search in sources :

Example 1 with BlockBranch

use of com.ferreusveritas.dynamictrees.blocks.BlockBranch in project firmalife by eerussianguy.

the class DTRegistry method registerNutRecipes.

@Override
public void registerNutRecipes(IForgeRegistry<NutRecipe> r) {
    ModTrees.tfcTrees.forEach(tree -> {
        String treeName = tree.getName().getPath();
        BlockBranch log = tree.getDynamicBranch();
        Block leaves = ModBlocks.leafMap.get(treeName).getDynamicLeavesState().getBlock();
        if (treeName.contains("chestnut")) {
            r.register(new NutRecipe(log, leaves, new ItemStack(ItemsFL.getFood(FoodFL.CHESTNUTS))).setRegistryName("dt_chestnut"));
        } else if (treeName.contains("pine")) {
            r.register(new NutRecipe(log, leaves, new ItemStack(ItemsFL.getFood(FoodFL.PINE_NUTS))).setRegistryName("dt_pine"));
        } else if (treeName.contains("oak")) {
            r.register(new NutRecipe(log, leaves, new ItemStack(ItemsFL.getFood(FoodFL.ACORNS))).setRegistryName("dt_oak"));
        } else if (treeName.contains("hickory")) {
            r.register(new NutRecipe(log, leaves, new ItemStack(ItemsFL.getFood(FoodFL.PECAN_NUTS))).setRegistryName("dt_hickory"));
        } else if (treeName.contains("palm")) {
            r.register(new NutRecipe(log, leaves, new ItemStack(ItemsFL.getFood(FoodFL.COCONUT))).setRegistryName("dt_palm"));
        }
    });
}
Also used : Block(net.minecraft.block.Block) NutRecipe(com.eerussianguy.firmalife.recipe.NutRecipe) ItemStack(net.minecraft.item.ItemStack) BlockBranch(com.ferreusveritas.dynamictrees.blocks.BlockBranch)

Example 2 with BlockBranch

use of com.ferreusveritas.dynamictrees.blocks.BlockBranch in project Bewitchment by Um-Mitternacht.

the class DropCreatorFruit method getVoluntaryDrop.

public List<ItemStack> getVoluntaryDrop(World world, Species species, BlockPos rootPos, Random random, List<ItemStack> dropList, int soilLife) {
    BlockPos treePos = rootPos.up();
    IBlockState trunk = world.getBlockState(treePos);
    BlockBranch branch = TreeHelper.getBranch(trunk);
    if (branch != null && branch.getRadius(trunk) >= 8 && 0.33F > random.nextFloat()) {
        dropList.add(new ItemStack(this.fruit, 1, 0));
    }
    return dropList;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) BlockBranch(com.ferreusveritas.dynamictrees.blocks.BlockBranch)

Example 3 with BlockBranch

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

the class AnimationHandlerFallover method handleMotion.

@Override
public void handleMotion(EntityFallingTree entity) {
    float fallSpeed = getData(entity).fallSpeed;
    if (entity.onGround) {
        float height = (float) entity.getMassCenter().y * 2;
        fallSpeed += (0.2 / height);
        addRotation(entity, fallSpeed);
    }
    entity.motionY -= AnimationConstants.TREE_GRAVITY;
    entity.posY += entity.motionY;
    {
        // Handle entire entity falling and collisions with it's base and the ground
        World world = entity.world;
        int radius = 8;
        IBlockState state = entity.getDestroyData().getBranchBlockState(0);
        if (TreeHelper.isBranch(state)) {
            radius = ((BlockBranch) state.getBlock()).getRadius(state);
        }
        AxisAlignedBB fallBox = new AxisAlignedBB(entity.posX - radius, entity.posY, entity.posZ - radius, entity.posX + radius, entity.posY + 1.0, entity.posZ + radius);
        BlockPos pos = new BlockPos(entity.posX, entity.posY, entity.posZ);
        IBlockState collState = world.getBlockState(pos);
        AxisAlignedBB collBox = collState.getCollisionBoundingBox(world, pos);
        if (collBox != null) {
            collBox = collBox.offset(pos);
            if (fallBox.intersects(collBox)) {
                entity.motionY = 0;
                entity.posY = collBox.maxY;
                entity.prevPosY = entity.posY;
                entity.onGround = true;
            }
        }
    }
    if (fallSpeed > 0 && testCollision(entity)) {
        // pull back to before the collision
        addRotation(entity, -fallSpeed);
        getData(entity).bounces++;
        // bounce with elasticity
        fallSpeed *= -AnimationConstants.TREE_ELASTICITY;
        // The entity has landed if after a bounce it has little velocity
        entity.landed = Math.abs(fallSpeed) < 0.02f;
    }
    // Crush living things with clumsy dead trees
    World world = entity.world;
    if (ModConfigs.enableFallingTreeDamage && !world.isRemote) {
        List<EntityLivingBase> elist = testEntityCollision(entity);
        for (EntityLivingBase living : elist) {
            if (!getData(entity).entitiesHit.contains(living)) {
                getData(entity).entitiesHit.add(living);
                float damage = entity.getDestroyData().woodVolume * Math.abs(fallSpeed) * 3f;
                if (getData(entity).bounces == 0 && damage > 2) {
                    // System.out.println("damage: " + damage);
                    living.motionX += world.rand.nextFloat() * entity.getDestroyData().toolDir.getOpposite().getFrontOffsetX() * damage * 0.2f;
                    living.motionX += world.rand.nextFloat() - 0.5;
                    living.motionY += world.rand.nextFloat() * fallSpeed * 0.25f;
                    living.motionZ += world.rand.nextFloat() * entity.getDestroyData().toolDir.getOpposite().getFrontOffsetZ() * damage * 0.2f;
                    living.motionZ += world.rand.nextFloat() - 0.5;
                    damage *= ModConfigs.fallingTreeDamageMultiplier;
                    // System.out.println("Tree Falling Damage: " + damage + "/" + living.getHealth());
                    living.attackEntityFrom(AnimationConstants.TREE_DAMAGE, damage);
                }
            }
        }
    }
    getData(entity).fallSpeed = fallSpeed;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) IBlockState(net.minecraft.block.state.IBlockState) EntityLivingBase(net.minecraft.entity.EntityLivingBase) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) BlockBranch(com.ferreusveritas.dynamictrees.blocks.BlockBranch)

Example 4 with BlockBranch

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

the class BlockBreakAnimationClientHandler method drawBlockDamageTexture.

private void drawBlockDamageTexture(Minecraft mc, TextureManager renderEngine, Tessellator tessellatorIn, BufferBuilder bufferBuilderIn, Entity entityIn, float partialTicks) {
    double posX = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double) partialTicks;
    double posY = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double) partialTicks;
    double posZ = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double) partialTicks;
    if (!BlockBreakAnimationClientHandler.damagedBranches.isEmpty()) {
        renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
        preRenderDamagedBlocks();
        bufferBuilderIn.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
        bufferBuilderIn.setTranslation(-posX, -posY, -posZ);
        bufferBuilderIn.noColor();
        Iterator<Entry<Integer, DestroyBlockProgress>> iter = BlockBreakAnimationClientHandler.damagedBranches.entrySet().iterator();
        while (iter.hasNext()) {
            Entry<Integer, DestroyBlockProgress> entry = iter.next();
            DestroyBlockProgress destroyblockprogress = entry.getValue();
            BlockPos pos = destroyblockprogress.getPosition();
            double delX = (double) pos.getX() - posX;
            double delY = (double) pos.getY() - posY;
            double delZ = (double) pos.getZ() - posZ;
            if (delX * delX + delY * delY + delZ * delZ > 4096) {
                iter.remove();
            } else {
                IBlockState state = mc.world.getBlockState(pos);
                if (state.getBlock() instanceof BlockBranch) {
                    int k1 = destroyblockprogress.getPartialBlockDamage();
                    TextureAtlasSprite textureatlassprite = this.destroyBlockIcons[k1];
                    BlockRendererDispatcher blockrendererdispatcher = mc.getBlockRendererDispatcher();
                    if (state.getRenderType() == EnumBlockRenderType.MODEL) {
                        state = state.getActualState(mc.world, pos);
                        IBakedModel baseModel = blockrendererdispatcher.getBlockModelShapes().getModelForState(state);
                        IBakedModel damageModel = getDamageModel(baseModel, textureatlassprite, state, mc.world, pos);
                        blockrendererdispatcher.getBlockModelRenderer().renderModel(mc.world, damageModel, state, pos, bufferBuilderIn, true);
                    }
                } else {
                    iter.remove();
                }
            }
        }
        tessellatorIn.draw();
        bufferBuilderIn.setTranslation(0.0, 0.0, 0.0);
        postRenderDamagedBlocks();
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) BlockBranch(com.ferreusveritas.dynamictrees.blocks.BlockBranch) Entry(java.util.Map.Entry) BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel)

Example 5 with BlockBranch

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

the class WailaBranchHandler method getTreeVolume.

private float getTreeVolume(World world, BlockPos pos) {
    IBlockState state = world.getBlockState(pos);
    Block block = state.getBlock();
    // Dereference proxy trunk shell block
    if (block instanceof BlockTrunkShell) {
        ShellMuse muse = ((BlockTrunkShell) block).getMuse(world, pos);
        if (muse != null) {
            state = muse.state;
            block = state.getBlock();
            pos = muse.pos;
        }
    }
    if (block instanceof BlockBranch) {
        BlockBranch branch = (BlockBranch) block;
        // Analyze only part of the tree beyond the break point and calculate it's volume, then destroy the branches
        NodeNetVolume volumeSum = new NodeNetVolume();
        branch.analyse(state, world, pos, null, new MapSignal(volumeSum));
        return volumeSum.getVolume() * ModConfigs.treeHarvestMultiplier;
    }
    return 0;
}
Also used : NodeNetVolume(com.ferreusveritas.dynamictrees.systems.nodemappers.NodeNetVolume) IBlockState(net.minecraft.block.state.IBlockState) BlockTrunkShell(com.ferreusveritas.dynamictrees.blocks.BlockTrunkShell) Block(net.minecraft.block.Block) ShellMuse(com.ferreusveritas.dynamictrees.blocks.BlockTrunkShell.ShellMuse) BlockBranch(com.ferreusveritas.dynamictrees.blocks.BlockBranch) MapSignal(com.ferreusveritas.dynamictrees.api.network.MapSignal)

Aggregations

BlockBranch (com.ferreusveritas.dynamictrees.blocks.BlockBranch)18 IBlockState (net.minecraft.block.state.IBlockState)14 BlockPos (net.minecraft.util.math.BlockPos)12 MapSignal (com.ferreusveritas.dynamictrees.api.network.MapSignal)6 EnumFacing (net.minecraft.util.EnumFacing)6 Block (net.minecraft.block.Block)5 MutableBlockPos (net.minecraft.util.math.BlockPos.MutableBlockPos)4 NodeFindEnds (com.ferreusveritas.dynamictrees.systems.nodemappers.NodeFindEnds)3 SimpleVoxmap (com.ferreusveritas.dynamictrees.util.SimpleVoxmap)3 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)3 ILeavesProperties (com.ferreusveritas.dynamictrees.api.treedata.ILeavesProperties)2 NodeCollector (com.ferreusveritas.dynamictrees.systems.nodemappers.NodeCollector)2 Species (com.ferreusveritas.dynamictrees.trees.Species)2 Cell (com.ferreusveritas.dynamictrees.util.SimpleVoxmap.Cell)2 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)2 ItemStack (net.minecraft.item.ItemStack)2 NutRecipe (com.eerussianguy.firmalife.recipe.NutRecipe)1 INodeInspector (com.ferreusveritas.dynamictrees.api.network.INodeInspector)1 ITreePart (com.ferreusveritas.dynamictrees.api.treedata.ITreePart)1 BlockBranchThick (com.ferreusveritas.dynamictrees.blocks.BlockBranchThick)1