net.minecraft.block.BlockDoublePlant Java Examples

The following examples show how to use net.minecraft.block.BlockDoublePlant. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VanillaMetaResolver.java    From GardenCollection with MIT License 5 votes vote down vote up
@Override
public int getPlantHeight (Block block, int meta) {
    if (block instanceof BlockDoublePlant)
        return 2;

    // Default: Use for BlockFlower, BlockTallGrass, BlockMushroom
    return 1;
}
 
Example #2
Source File: VanillaMetaResolver.java    From GardenCollection with MIT License 5 votes vote down vote up
@Override
public int getPlantSectionMeta (Block block, int meta, int section) {
    if (block instanceof BlockDoublePlant) {
        switch (section) {
            case 1: return meta & 0x7;
            case 2: return meta | 0x8;
        }
    }

    // Default: Use for BlockFlower, BlockTallGrass, BlockMushroom
    return meta;
}
 
Example #3
Source File: MaterialCache.java    From litematica with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Nullable
protected ItemStack getStateToItemOverride(IBlockState state)
{
    Block block = state.getBlock();

    if (block == Blocks.PISTON_HEAD ||
        block == Blocks.PISTON_EXTENSION ||
        block == Blocks.PORTAL ||
        block == Blocks.END_PORTAL ||
        block == Blocks.END_GATEWAY)
    {
        return ItemStack.EMPTY;
    }
    else if (block == Blocks.FARMLAND)
    {
        return new ItemStack(Blocks.DIRT);
    }
    else if (block == Blocks.GRASS_PATH)
    {
        return new ItemStack(Blocks.GRASS);
    }
    else if (block == Blocks.BROWN_MUSHROOM_BLOCK)
    {
        return new ItemStack(Blocks.BROWN_MUSHROOM_BLOCK);
    }
    else if (block == Blocks.RED_MUSHROOM_BLOCK)
    {
        return new ItemStack(Blocks.RED_MUSHROOM_BLOCK);
    }
    else if (block == Blocks.LAVA)
    {
        if (state.getValue(BlockLiquid.LEVEL) == 0)
        {
            return new ItemStack(Items.LAVA_BUCKET);
        }
        else
        {
            return ItemStack.EMPTY;
        }
    }
    else if (block == Blocks.WATER)
    {
        if (state.getValue(BlockLiquid.LEVEL) == 0)
        {
            return new ItemStack(Items.WATER_BUCKET);
        }
        else
        {
            return ItemStack.EMPTY;
        }
    }
    else if (block instanceof BlockDoor && state.getValue(BlockDoor.HALF) == BlockDoor.EnumDoorHalf.UPPER)
    {
        return ItemStack.EMPTY;
    }
    else if (block instanceof BlockBed && state.getValue(BlockBed.PART) == BlockBed.EnumPartType.HEAD)
    {
        return ItemStack.EMPTY;
    }
    else if (block instanceof BlockDoublePlant && state.getValue(BlockDoublePlant.HALF) == BlockDoublePlant.EnumBlockHalf.UPPER)
    {
        return ItemStack.EMPTY;
    }

    return null;
}
 
Example #4
Source File: DoublePlantRenderer.java    From GardenCollection with MIT License 4 votes vote down vote up
public IIcon getIcon (Block block, IBlockAccess blockAccess, int meta) {
    boolean isTopHalf = BlockDoublePlant.func_149887_c(meta);
    int baseMeta = BlockDoublePlant.func_149890_d(meta);

    return Blocks.double_plant.func_149888_a(isTopHalf, baseMeta);
}
 
Example #5
Source File: SunflowerRenderer.java    From GardenCollection with MIT License 4 votes vote down vote up
@Override
public void render (IBlockAccess world, int x, int y, int z, RenderBlocks renderer, Block block, int meta, int height, AxisAlignedBB[] bounds) {
    if (!(block instanceof BlockDoublePlant))
        return;

    plantRender.render(world, x, y, z, renderer, block, meta, height, bounds);
    if (height != 2)
        return;

    Tessellator tessellator = Tessellator.instance;

    double orientation = Math.cos((double)0 * 0.8D) * Math.PI * 0.1D;
    double aCos = Math.cos(orientation);
    double aSin = Math.sin(orientation);

    double xTR = 0.5D + 0.3D * aCos - 0.5D * aSin;
    double zTR = 0.5D + 0.5D * aCos + 0.3D * aSin;
    double xTL = 0.5D + 0.3D * aCos + 0.5D * aSin;
    double ZTL = 0.5D + -0.5D * aCos + 0.3D * aSin;
    double xBL = 0.5D + -0.05D * aCos + 0.5D * aSin;
    double zBL = 0.5D + -0.5D * aCos + -0.05D * aSin;
    double xBR = 0.5D + -0.05D * aCos - 0.5D * aSin;
    double zBR = 0.5D + 0.5D * aCos + -0.05D * aSin;

    IIcon icon = Blocks.double_plant.sunflowerIcons[0];
    double iconMinU = icon.getMinU();
    double iconMinV = icon.getMinV();
    double iconMaxU = icon.getMaxU();
    double iconMaxV = icon.getMaxV();

    tessellator.addVertexWithUV(x + xBL, y + 1.0D, z + zBL, iconMinU, iconMaxV);
    tessellator.addVertexWithUV(x + xBR, y + 1.0D, z + zBR, iconMaxU, iconMaxV);
    tessellator.addVertexWithUV(x + xTR, y + 0.0D, z + zTR, iconMaxU, iconMinV);
    tessellator.addVertexWithUV(x + xTL, y + 0.0D, z + ZTL, iconMinU, iconMinV);

    icon = Blocks.double_plant.sunflowerIcons[1];
    iconMinU = icon.getMinU();
    iconMinV = icon.getMinV();
    iconMaxU = icon.getMaxU();
    iconMaxV = icon.getMaxV();

    tessellator.addVertexWithUV(x + xBR, y + 1.0D, z + zBR, iconMinU, iconMaxV);
    tessellator.addVertexWithUV(x + xBL, y + 1.0D, z + zBL, iconMaxU, iconMaxV);
    tessellator.addVertexWithUV(x + xTL, y + 0.0D, z + ZTL, iconMaxU, iconMinV);
    tessellator.addVertexWithUV(x + xTR, y + 0.0D, z + zTR, iconMinU, iconMinV);
}
 
Example #6
Source File: GardenProxyRenderer.java    From GardenCollection with MIT License 4 votes vote down vote up
private boolean renderBlockDoublePlant(IBlockAccess world, RenderBlocks renderer, BlockDoublePlant block, int x, int y, int z, TileEntityGarden potData)
{
    Tessellator tessellator = Tessellator.instance;
    tessellator.setBrightness(block.getMixedBrightnessForBlock(renderer.blockAccess, x, y, z));
    int l = block.colorMultiplier(renderer.blockAccess, x, y, z);
    //if (l == world.getBiomeGenForCoords(x, z).getBiomeGrassColor(x, y, z))
    //    l = ColorizerGrass.getGrassColor(potData.getBiomeTemperature(), potData.getBiomeHumidity());

    float f = (float)(l >> 16 & 255) / 255.0F;
    float f1 = (float)(l >> 8 & 255) / 255.0F;
    float f2 = (float)(l & 255) / 255.0F;

    if (EntityRenderer.anaglyphEnable)
    {
        float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F;
        float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F;
        float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F;
        f = f3;
        f1 = f4;
        f2 = f5;
    }

    tessellator.setColorOpaque_F(f, f1, f2);
    long j1 = (long)(x * 3129871) ^ (long)z * 116129781L;
    j1 = j1 * j1 * 42317861L + j1 * 11L;
    double d19 = (double)x;
    double d0 = (double)y;
    double d1 = (double)z;
    //d19 += ((double)((float)(j1 >> 16 & 15L) / 15.0F) - 0.5D) * 0.3D;
    //d1 += ((double)((float)(j1 >> 24 & 15L) / 15.0F) - 0.5D) * 0.3D;
    int i1 = renderer.blockAccess.getBlockMetadata(x, y, z);
    boolean flag = false;
    boolean flag1 = BlockDoublePlant.func_149887_c(i1);
    int k1;

    if (flag1)
    {
        k1 = BlockDoublePlant.func_149890_d(renderer.blockAccess.getBlockMetadata(x, y - 1, z));
    }
    else
    {
        k1 = BlockDoublePlant.func_149890_d(i1);
    }

    IIcon iicon = block.func_149888_a(flag1, k1);
    renderer.drawCrossedSquares(iicon, d19, d0, d1, 1.0F);

    if (flag1 && k1 == 0)
    {
        IIcon iicon1 = block.sunflowerIcons[0];
        double d2 = Math.cos((double)j1 * 0.8D) * Math.PI * 0.1D;
        double d3 = Math.cos(d2);
        double d4 = Math.sin(d2);
        double d5 = (double)iicon1.getMinU();
        double d6 = (double)iicon1.getMinV();
        double d7 = (double)iicon1.getMaxU();
        double d8 = (double)iicon1.getMaxV();
        double d9 = 0.3D;
        double d10 = -0.05D;
        double d11 = 0.5D + 0.3D * d3 - 0.5D * d4;
        double d12 = 0.5D + 0.5D * d3 + 0.3D * d4;
        double d13 = 0.5D + 0.3D * d3 + 0.5D * d4;
        double d14 = 0.5D + -0.5D * d3 + 0.3D * d4;
        double d15 = 0.5D + -0.05D * d3 + 0.5D * d4;
        double d16 = 0.5D + -0.5D * d3 + -0.05D * d4;
        double d17 = 0.5D + -0.05D * d3 - 0.5D * d4;
        double d18 = 0.5D + 0.5D * d3 + -0.05D * d4;
        tessellator.addVertexWithUV(d19 + d15, d0 + 1.0D, d1 + d16, d5, d8);
        tessellator.addVertexWithUV(d19 + d17, d0 + 1.0D, d1 + d18, d7, d8);
        tessellator.addVertexWithUV(d19 + d11, d0 + 0.0D, d1 + d12, d7, d6);
        tessellator.addVertexWithUV(d19 + d13, d0 + 0.0D, d1 + d14, d5, d6);
        IIcon iicon2 = block.sunflowerIcons[1];
        d5 = (double)iicon2.getMinU();
        d6 = (double)iicon2.getMinV();
        d7 = (double)iicon2.getMaxU();
        d8 = (double)iicon2.getMaxV();
        tessellator.addVertexWithUV(d19 + d17, d0 + 1.0D, d1 + d18, d5, d8);
        tessellator.addVertexWithUV(d19 + d15, d0 + 1.0D, d1 + d16, d7, d8);
        tessellator.addVertexWithUV(d19 + d13, d0 + 0.0D, d1 + d14, d7, d6);
        tessellator.addVertexWithUV(d19 + d11, d0 + 0.0D, d1 + d12, d5, d6);
    }

    return true;
}