Jump to content

[1.7.2] Custom Tree


tiffit

Recommended Posts

Well, maybe the 1.6.4 tutorial would work for 1.7.2. There's still plenty of 1.6.4 modding tutorials that are still viable to use for 1.7.2. Try following the tutorial and see what you can come up with.

if (user.hasKnowledgeOfJava) {

    if (user.question.hasCode) {

        return interpetHelpfulResponse(user.getQuestion());

    } else {

        return "Could you post your code please?";

    }

} else {

    return "Learn some freaking Java!";

}

Link to comment
Share on other sites

If you have some programming experience adapting the code will be no problem.

If you don't, you should not be modding.

I have programming experience, but adapting minecraft code is very hard. The log is hard cause its abstract and I have tried to change some stuff but it just ends up crashing when I go to my custom creative tab.

Link to comment
Share on other sites

Crash:

 ---- Minecraft Crash Report ----
// There are four lights!

Time: 4/26/14 11:15 AM
Description: Rendering item

java.lang.NullPointerException: Rendering item
at com.tiffit.MoFoodMod.trees.lemonLog.getTopIcon(lemonLog.java:75)
at net.minecraft.block.BlockRotatedPillar.getIcon(BlockRotatedPillar.java:64)
at net.minecraft.block.Block.getBlockTextureFromSide(Block.java:720)
at net.minecraft.item.ItemBlock.getIconFromDamage(ItemBlock.java:51)
at net.minecraft.item.Item.getIconIndex(Item.java:471)
at net.minecraft.item.ItemStack.getIconIndex(ItemStack.java:139)
at net.minecraft.client.renderer.entity.RenderItem.renderItemIntoGUI(RenderItem.java:422)
at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:565)
at net.minecraft.client.gui.GuiIngame.renderInventorySlot(GuiIngame.java:978)
at net.minecraftforge.client.GuiIngameForge.renderHotbar(GuiIngameForge.java:206)
at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:141)
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1187)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1063)
at net.minecraft.client.Minecraft.run(Minecraft.java:951)
at net.minecraft.client.main.Main.main(Main.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at com.tiffit.MoFoodMod.trees.lemonLog.getTopIcon(lemonLog.java:75)
at net.minecraft.block.BlockRotatedPillar.getIcon(BlockRotatedPillar.java:64)
at net.minecraft.block.Block.getBlockTextureFromSide(Block.java:720)
at net.minecraft.item.ItemBlock.getIconFromDamage(ItemBlock.java:51)
at net.minecraft.item.Item.getIconIndex(Item.java:471)
at net.minecraft.item.ItemStack.getIconIndex(ItemStack.java:139)
at net.minecraft.client.renderer.entity.RenderItem.renderItemIntoGUI(RenderItem.java:422)

-- Item being rendered --
Details:
Item Type: net.minecraft.item.ItemBlock@1a352828
Item Aux: 0
Item NBT: null
Item Foil: false
Stacktrace:
at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:565)
at net.minecraft.client.gui.GuiIngame.renderInventorySlot(GuiIngame.java:978)
at net.minecraftforge.client.GuiIngameForge.renderHotbar(GuiIngameForge.java:206)
at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:141)

-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityClientPlayerMP['Player575'/394, l='MpServer', x=-61.50, y=71.62, z=263.50]]
Chunk stats: MultiplayerChunkCache: 200, 200
Level seed: 0
Level generator: ID 00 - default, ver 1. Features enabled: false
Level generator options: 
Level spawn location: World: (-52,64,256), Chunk: (at 12,4,0 in -4,16; contains blocks -64,0,256 to -49,255,271), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
Level time: 2354 game time, 2354 day time
Level dimension: 0
Level storage version: 0x00000 - Unknown?
Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
Forced entities: 125 total; [EntityZombie['Zombie'/275, l='MpServer', x=16.13, y=12.00, z=318.31], EntitySkeleton['Skeleton'/274, l='MpServer', x=16.56, y=12.00, z=315.78], EntitySheep['Sheep'/258, l='MpServer', x=11.53, y=62.00, z=278.53], EntitySheep['Sheep'/259, l='MpServer', x=13.72, y=64.00, z=287.28], EntitySkeleton['Skeleton'/256, l='MpServer', x=12.38, y=12.00, z=272.06], EntitySheep['Sheep'/257, l='MpServer', x=12.81, y=61.00, z=281.59], EntityVillager['Villager'/262, l='MpServer', x=10.53, y=66.00, z=293.47], EntityVillager['Villager'/263, l='MpServer', x=12.69, y=67.00, z=296.38], EntitySheep['Sheep'/260, l='MpServer', x=10.84, y=64.00, z=284.97], EntityVillager['Villager'/261, l='MpServer', x=13.41, y=64.00, z=284.75], EntitySkeleton['Skeleton'/264, l='MpServer', x=2.03, y=11.00, z=313.50], EntityZombie['Zombie'/39, l='MpServer', x=-141.50, y=29.00, z=210.97], EntityPig['Pig'/42, l='MpServer', x=-139.66, y=64.00, z=269.94], EntityPig['Pig'/41, l='MpServer', x=-138.81, y=64.00, z=265.09], EntityCow['Cow'/46, l='MpServer', x=-138.50, y=66.00, z=277.50], EntityCow['Cow'/44, l='MpServer', x=-135.44, y=65.00, z=281.28], EntityCow['Cow'/45, l='MpServer', x=-136.50, y=64.00, z=282.66], EntitySheep['Sheep'/51, l='MpServer', x=-134.34, y=66.00, z=298.78], EntitySheep['Sheep'/50, l='MpServer', x=-130.88, y=67.00, z=300.06], EntitySheep['Sheep'/49, l='MpServer', x=-131.47, y=67.00, z=294.66], EntityPig['Pig'/48, l='MpServer', x=-140.50, y=66.00, z=274.69], EntitySquid['Squid'/55, l='MpServer', x=-119.84, y=58.28, z=244.50], EntitySquid['Squid'/54, l='MpServer', x=-120.81, y=57.06, z=240.06], EntityItem['item.tile.flower2.oxeyeDaisy'/59, l='MpServer', x=-122.00, y=63.13, z=293.28], EntityItem['item.tile.flower2.oxeyeDaisy'/58, l='MpServer', x=-121.84, y=62.13, z=296.88], EntityZombie['Zombie'/57, l='MpServer', x=-122.50, y=30.00, z=274.38], EntitySquid['Squid'/56, l='MpServer', x=-125.66, y=59.94, z=243.81], EntitySkeleton['Skeleton'/61, l='MpServer', x=-122.09, y=13.00, z=322.50], EntitySheep['Sheep'/60, l='MpServer', x=-126.16, y=64.00, z=292.16], EntityZombie['Zombie'/76, l='MpServer', x=-100.69, y=25.00, z=258.91], EntitySpider['Spider'/77, l='MpServer', x=-106.28, y=20.00, z=285.00], EntityZombie['Zombie'/78, l='MpServer', x=-108.50, y=23.00, z=295.50], EntityBat['Bat'/79, l='MpServer', x=-102.25, y=22.09, z=288.41], EntitySkeleton['Skeleton'/72, l='MpServer', x=-106.50, y=30.00, z=223.50], EntitySkeleton['Skeleton'/73, l='MpServer', x=-104.06, y=30.00, z=219.47], EntityCreeper['Creeper'/74, l='MpServer', x=-107.50, y=30.00, z=224.50], EntityZombie['Zombie'/75, l='MpServer', x=-98.97, y=27.00, z=264.50], EntitySheep['Sheep'/93, l='MpServer', x=-86.50, y=64.00, z=220.94], EntitySheep['Sheep'/92, l='MpServer', x=-82.19, y=64.00, z=208.81], EntitySheep['Sheep'/95, l='MpServer', x=-82.09, y=66.00, z=222.47], EntitySheep['Sheep'/94, l='MpServer', x=-87.78, y=64.00, z=220.69], EntitySheep['Sheep'/91, l='MpServer', x=-86.63, y=64.00, z=195.22], EntitySpider['Spider'/102, l='MpServer', x=-82.59, y=37.00, z=260.28], EntitySheep['Sheep'/103, l='MpServer', x=-81.56, y=72.00, z=263.88], EntityItem['item.tile.mushroom'/100, l='MpServer', x=-82.94, y=25.13, z=270.13], EntityBat['Bat'/101, l='MpServer', x=-82.69, y=27.09, z=271.00], EntityBat['Bat'/98, l='MpServer', x=-94.75, y=35.09, z=245.75], EntitySheep['Sheep'/99, l='MpServer', x=-92.19, y=64.00, z=243.13], EntitySheep['Sheep'/96, l='MpServer', x=-88.91, y=64.00, z=221.13], EntitySheep['Sheep'/97, l='MpServer', x=-83.78, y=66.00, z=225.31], EntityChicken['Chicken'/110, l='MpServer', x=-87.53, y=68.00, z=330.56], EntityZombie['Zombie'/111, l='MpServer', x=-81.72, y=46.00, z=340.78], EntityCreeper['Creeper'/108, l='MpServer', x=-90.03, y=51.00, z=332.50], EntityZombie['Zombie'/109, l='MpServer', x=-85.06, y=50.00, z=333.50], EntitySkeleton['Skeleton'/106, l='MpServer', x=-91.69, y=28.00, z=305.00], EntityZombie['Zombie'/107, l='MpServer', x=-83.00, y=26.00, z=316.44], EntitySkeleton['Skeleton'/104, l='MpServer', x=-89.50, y=22.00, z=300.50], EntityZombie['Zombie'/105, l='MpServer', x=-93.56, y=18.22, z=296.69], EntityChicken['Chicken'/116, l='MpServer', x=-85.63, y=68.00, z=340.44], EntityChicken['Chicken'/115, l='MpServer', x=-95.44, y=68.00, z=341.47], EntityZombie['Zombie'/113, l='MpServer', x=-90.84, y=44.00, z=341.50], EntityZombie['Zombie'/112, l='MpServer', x=-81.09, y=47.00, z=343.44], EntitySheep['Sheep'/127, l='MpServer', x=-72.22, y=67.00, z=248.13], EntitySkeleton['Skeleton'/126, l='MpServer', x=-65.75, y=36.00, z=243.66], EntitySkeleton['Skeleton'/125, l='MpServer', x=-68.50, y=37.00, z=253.06], EntitySheep['Sheep'/124, l='MpServer', x=-74.56, y=69.00, z=231.53], EntitySheep['Sheep'/123, l='MpServer', x=-64.63, y=66.00, z=221.25], EntitySheep['Sheep'/122, l='MpServer', x=-79.50, y=64.00, z=210.50], EntitySkeleton['Skeleton'/137, l='MpServer', x=-76.94, y=20.00, z=299.44], EntitySheep['Sheep'/136, l='MpServer', x=-78.47, y=77.00, z=270.78], EntitySkeleton['Skeleton'/139, l='MpServer', x=-66.44, y=15.00, z=306.13], EntitySkeleton['Skeleton'/138, l='MpServer', x=-79.03, y=41.00, z=301.63], EntityCreeper['Creeper'/141, l='MpServer', x=-66.25, y=45.00, z=327.94], EntityBat['Bat'/140, l='MpServer', x=-71.25, y=20.09, z=312.63], EntityZombie['Zombie'/143, l='MpServer', x=-78.38, y=46.00, z=342.03], EntitySkeleton['Skeleton'/142, l='MpServer', x=-79.47, y=49.00, z=331.91], EntitySheep['Sheep'/129, l='MpServer', x=-76.97, y=67.00, z=252.88], EntitySheep['Sheep'/128, l='MpServer', x=-67.47, y=68.00, z=250.56], EntitySkeleton['Skeleton'/131, l='MpServer', x=-65.38, y=27.00, z=262.94], EntitySheep['Sheep'/130, l='MpServer', x=-78.88, y=67.00, z=253.19], EntitySheep['Sheep'/133, l='MpServer', x=-69.22, y=72.00, z=271.22], EntityBat['Bat'/132, l='MpServer', x=-74.25, y=38.91, z=264.59], EntitySheep['Sheep'/135, l='MpServer', x=-69.16, y=71.00, z=269.19], EntitySheep['Sheep'/134, l='MpServer', x=-78.13, y=72.00, z=267.47], EntityClientPlayerMP['Player575'/394, l='MpServer', x=-61.50, y=71.62, z=263.50], EntityZombie['Zombie'/145, l='MpServer', x=-69.94, y=48.00, z=338.41], EntitySkeleton['Skeleton'/167, l='MpServer', x=-60.56, y=23.00, z=188.06], EntityZombie['Zombie'/165, l='MpServer', x=-52.16, y=23.00, z=187.31], EntityBat['Bat'/186, l='MpServer', x=-62.25, y=28.09, z=292.75], EntitySkeleton['Skeleton'/187, l='MpServer', x=-63.50, y=16.00, z=296.84], EntitySpider['Spider'/184, l='MpServer', x=-51.53, y=36.00, z=283.81], EntityBat['Bat'/185, l='MpServer', x=-56.47, y=37.28, z=285.94], EntitySheep['Sheep'/190, l='MpServer', x=-52.50, y=74.00, z=295.59], EntityWolf['Wolf'/191, l='MpServer', x=-49.91, y=68.00, z=310.88], EntitySpider['Spider'/188, l='MpServer', x=-61.50, y=36.00, z=288.00], EntitySheep['Sheep'/189, l='MpServer', x=-61.53, y=73.00, z=294.16], EntitySheep['Sheep'/178, l='MpServer', x=-62.78, y=66.00, z=223.53], EntitySheep['Sheep'/179, l='MpServer', x=-58.88, y=65.00, z=224.94], EntitySheep['Sheep'/177, l='MpServer', x=-61.84, y=66.00, z=222.38], EntitySheep['Sheep'/182, l='MpServer', x=-60.41, y=69.00, z=257.19], EntityBat['Bat'/183, l='MpServer', x=-49.84, y=21.91, z=278.84], EntityZombie['Zombie'/180, l='MpServer', x=-59.50, y=38.00, z=250.03], EntitySheep['Sheep'/181, l='MpServer', x=-50.38, y=67.00, z=243.63], EntitySpider['Spider'/205, l='MpServer', x=-47.84, y=36.00, z=284.22], EntityBat['Bat'/204, l='MpServer', x=-46.47, y=21.06, z=266.69], EntityWolf['Wolf'/207, l='MpServer', x=-41.44, y=69.00, z=303.25], EntitySheep['Sheep'/206, l='MpServer', x=-41.88, y=65.00, z=275.34], EntityWolf['Wolf'/193, l='MpServer', x=-55.25, y=68.00, z=312.44], EntityWolf['Wolf'/192, l='MpServer', x=-52.50, y=67.00, z=309.50], EntitySheep['Sheep'/239, l='MpServer', x=-8.97, y=63.00, z=231.66], EntitySheep['Sheep'/238, l='MpServer', x=-12.16, y=63.00, z=219.50], EntitySheep['Sheep'/232, l='MpServer', x=-18.41, y=69.00, z=341.44], EntitySheep['Sheep'/231, l='MpServer', x=-22.91, y=69.00, z=337.56], EntitySheep['Sheep'/229, l='MpServer', x=-28.03, y=71.00, z=331.53], EntityCreeper['Creeper'/228, l='MpServer', x=-28.06, y=13.00, z=318.47], EntityCreeper['Creeper'/227, l='MpServer', x=-27.78, y=52.00, z=276.13], EntityCreeper['Creeper'/226, l='MpServer', x=-30.59, y=52.00, z=274.66], EntityItem['item.item.Tomato'/225, l='MpServer', x=-21.88, y=63.13, z=260.66], EntitySheep['Sheep'/224, l='MpServer', x=-20.75, y=63.00, z=222.50], EntitySheep['Sheep'/244, l='MpServer', x=-13.69, y=68.00, z=338.69], EntitySheep['Sheep'/245, l='MpServer', x=-13.13, y=68.00, z=336.69], EntitySheep['Sheep'/242, l='MpServer', x=-13.94, y=68.00, z=334.03], EntitySheep['Sheep'/243, l='MpServer', x=-1.09, y=67.00, z=330.91], EntitySheep['Sheep'/240, l='MpServer', x=-0.56, y=64.00, z=225.34], EntityItem['item.tile.doublePlant.rose'/241, l='MpServer', x=-3.28, y=63.13, z=272.94]]
Retry entities: 0 total; []
Server brand: fml,forge
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:418)
at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2556)
at net.minecraft.client.Minecraft.run(Minecraft.java:973)
at net.minecraft.client.main.Main.main(Main.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

-- System Details --
Details:
Minecraft Version: 1.7.2
Operating System: Mac OS X (x86_64) version 10.8.5
Java Version: 1.7.0_45, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 690763008 bytes (658 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 16982 (950992 bytes; 0 MB) allocated, 16982 (950992 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94
FML: MCP v9.01-pre FML v7.2.116.1024 Minecraft Forge 10.12.0.1024 6 mods loaded, 6 mods active
mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
FML{7.2.116.1024} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.0.1024.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Forge{10.12.0.1024} [Minecraft Forge] (forgeSrc-1.7.2-10.12.0.1024.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
CodeChickenCore{rc_} [CodeChicken Core] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
NotEnoughItems{rc_} [Not Enough Items] (NotEnoughItems-1.7.2-rc2.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
MoFoodMod{Alpha 1.0.0} [MoFoodMod] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Launched Version: 1.6
LWJGL: 2.9.1
OpenGL: Intel HD Graphics 4000 OpenGL Engine GL version 2.1 INTEL-8.16.74, Intel Inc.
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: []
Current Language: English (US)
Profiler Position: N/A (disabled)
Vec3 Pool Size: 46 (2576 bytes; 0 MB) allocated, 46 (2576 bytes; 0 MB) used
Anisotropic Filtering: Off (1)

 

 

Lemon Log Class:

package com.tiffit.MoFoodMod.trees;

import java.util.Random;

import com.tiffit.MoFoodMod.ModBase;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRotatedPillar;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class lemonLog extends BlockRotatedPillar{

    public lemonLog()
    {
        super(Material.wood);
        this.setCreativeTab(ModBase.MoFoodModTab);
        this.setHardness(2.0F);
        this.setStepSound(soundTypeWood);
    }

 @SideOnly(Side.CLIENT)
    protected IIcon[] field_150167_a;
    @SideOnly(Side.CLIENT)
    protected IIcon[] field_150166_b;
    private static final String __OBFID = "CL_00000266";

public lemonLog(Material p_i45425_1_) {
	super(p_i45425_1_);
}
   public int quantityDropped(Random p_149745_1_)
    {
        return 1;
    }

    public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_)
    {
        byte b0 = 4;
        int i1 = b0 + 1;

        if (p_149749_1_.checkChunksExist(p_149749_2_ - i1, p_149749_3_ - i1, p_149749_4_ - i1, p_149749_2_ + i1, p_149749_3_ + i1, p_149749_4_ + i1))
        {
            for (int j1 = -b0; j1 <= b0; ++j1)
            {
                for (int k1 = -b0; k1 <= b0; ++k1)
                {
                    for (int l1 = -b0; l1 <= b0; ++l1)
                    {
                        Block block = p_149749_1_.getBlock(p_149749_2_ + j1, p_149749_3_ + k1, p_149749_4_ + l1);
                        if (block.isLeaves(p_149749_1_, p_149749_2_ + j1, p_149749_3_ + k1, p_149749_4_ + l1))
                        {
                            block.beginLeavesDecay(p_149749_1_, p_149749_2_ + j1, p_149749_3_ + k1, p_149749_4_ + l1);
                        }
                    }
                }
            }
        }
    }

    @SideOnly(Side.CLIENT)
    protected IIcon getSideIcon(int p_150163_1_)
    {
        return this.field_150167_a[p_150163_1_ % this.field_150167_a.length];
    }

    @SideOnly(Side.CLIENT)
    protected IIcon getTopIcon(int p_150161_1_)
    {
        return this.field_150166_b[p_150161_1_ % this.field_150166_b.length];
    }

    @Override
    public boolean canSustainLeaves(IBlockAccess world, int x, int y, int z)
    {
        return true;
    }

    @Override
    public boolean isWood(IBlockAccess world, int x, int y, int z)
    {
        return true;
    }

}

Link to comment
Share on other sites

You have to register your icons and fill the IICon arrays you reference (protected IIcon[] field_150167_a; protected IIcon[] field_150166_b) with the results. Otherwise, you crash with an NPE as you did.

Link to comment
Share on other sites

Ok, I got the wood to work, but how would I make my leaf not abstract? Like what would I change?

 

package com.tiffit.MoFoodMod.trees;

import java.util.ArrayList;
import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockLeavesBase;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.ColorizerFoliage;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public abstract class lemonLeaf extends BlockLeavesBase implements IShearable
{
    int[] field_150128_a;
    @SideOnly(Side.CLIENT)
    protected int field_150127_b;
    protected IIcon[][] field_150129_M = new IIcon[2][];
    private static final String __OBFID = "CL_00000263";

    public lemonLeaf()
    {
        super(Material.leaves, false);
        this.setTickRandomly(true);
        this.setCreativeTab(CreativeTabs.tabDecorations);
        this.setHardness(0.2F);
        this.setLightOpacity(1);
        this.setStepSound(soundTypeGrass);
    }

    @SideOnly(Side.CLIENT)
    public int getBlockColor()
    {
        double d0 = 0.5D;
        double d1 = 1.0D;
        return ColorizerFoliage.getFoliageColor(d0, d1);
    }

    /**
     * Returns the color this block should be rendered. Used by leaves.
     */
    @SideOnly(Side.CLIENT)
    public int getRenderColor(int p_149741_1_)
    {
        return ColorizerFoliage.getFoliageColorBasic();
    }

    /**
     * Returns a integer with hex for 0xrrggbb with this color multiplied against the blocks color. Note only called
     * when first determining what to render.
     */
    @SideOnly(Side.CLIENT)
    public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_)
    {
        int l = 0;
        int i1 = 0;
        int j1 = 0;

        for (int k1 = -1; k1 <= 1; ++k1)
        {
            for (int l1 = -1; l1 <= 1; ++l1)
            {
                int i2 = p_149720_1_.getBiomeGenForCoords(p_149720_2_ + l1, p_149720_4_ + k1).getBiomeFoliageColor(p_149720_2_ + l1, p_149720_3_, p_149720_4_ + k1);
                l += (i2 & 16711680) >> 16;
                i1 += (i2 & 65280) >> 8;
                j1 += i2 & 255;
            }
        }

        return (l / 9 & 255) << 16 | (i1 / 9 & 255) << 8 | j1 / 9 & 255;
    }

    public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_)
    {
        byte b0 = 1;
        int i1 = b0 + 1;

        if (p_149749_1_.checkChunksExist(p_149749_2_ - i1, p_149749_3_ - i1, p_149749_4_ - i1, p_149749_2_ + i1, p_149749_3_ + i1, p_149749_4_ + i1))
        {
            for (int j1 = -b0; j1 <= b0; ++j1)
            {
                for (int k1 = -b0; k1 <= b0; ++k1)
                {
                    for (int l1 = -b0; l1 <= b0; ++l1)
                    {
                        Block block = p_149749_1_.getBlock(p_149749_2_ + j1, p_149749_3_ + k1, p_149749_4_ + l1);
                        if (block.isLeaves(p_149749_1_, p_149749_2_ + j1, p_149749_3_ + k1, p_149749_4_ + l1))
                        {
                            block.beginLeavesDecay(p_149749_1_, p_149749_2_ + j1, p_149749_3_ + k1, p_149749_4_ + l1);
                        }
                    }
                }
            }
        }
    }

    /**
     * Ticks the block if it's been scheduled
     */
    public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_)
    {
        if (!p_149674_1_.isRemote)
        {
            int l = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_);

            if ((l &  != 0 && (l & 4) == 0)
            {
                byte b0 = 4;
                int i1 = b0 + 1;
                byte b1 = 32;
                int j1 = b1 * b1;
                int k1 = b1 / 2;

                if (this.field_150128_a == null)
                {
                    this.field_150128_a = new int[b1 * b1 * b1];
                }

                int l1;

                if (p_149674_1_.checkChunksExist(p_149674_2_ - i1, p_149674_3_ - i1, p_149674_4_ - i1, p_149674_2_ + i1, p_149674_3_ + i1, p_149674_4_ + i1))
                {
                    int i2;
                    int j2;

                    for (l1 = -b0; l1 <= b0; ++l1)
                    {
                        for (i2 = -b0; i2 <= b0; ++i2)
                        {
                            for (j2 = -b0; j2 <= b0; ++j2)
                            {
                                Block block = p_149674_1_.getBlock(p_149674_2_ + l1, p_149674_3_ + i2, p_149674_4_ + j2);

                                if (!block.canSustainLeaves(p_149674_1_, p_149674_2_ + l1, p_149674_3_ + i2, p_149674_4_ + j2))
                                {
                                    if (block.isLeaves(p_149674_1_, p_149674_2_ + l1, p_149674_3_ + i2, p_149674_4_ + j2))
                                    {
                                        this.field_150128_a[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -2;
                                    }
                                    else
                                    {
                                        this.field_150128_a[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -1;
                                    }
                                }
                                else
                                {
                                    this.field_150128_a[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = 0;
                                }
                            }
                        }
                    }

                    for (l1 = 1; l1 <= 4; ++l1)
                    {
                        for (i2 = -b0; i2 <= b0; ++i2)
                        {
                            for (j2 = -b0; j2 <= b0; ++j2)
                            {
                                for (int k2 = -b0; k2 <= b0; ++k2)
                                {
                                    if (this.field_150128_a[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1] == l1 - 1)
                                    {
                                        if (this.field_150128_a[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2)
                                        {
                                            this.field_150128_a[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
                                        }

                                        if (this.field_150128_a[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2)
                                        {
                                            this.field_150128_a[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
                                        }

                                        if (this.field_150128_a[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] == -2)
                                        {
                                            this.field_150128_a[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] = l1;
                                        }

                                        if (this.field_150128_a[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] == -2)
                                        {
                                            this.field_150128_a[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] = l1;
                                        }

                                        if (this.field_150128_a[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] == -2)
                                        {
                                            this.field_150128_a[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] = l1;
                                        }

                                        if (this.field_150128_a[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] == -2)
                                        {
                                            this.field_150128_a[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] = l1;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                l1 = this.field_150128_a[k1 * j1 + k1 * b1 + k1];

                if (l1 >= 0)
                {
                    p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, l & -9, 4);
                }
                else
                {
                    this.removeLeaves(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_);
                }
            }
        }
    }

    /**
     * A randomly called display update to be able to add particles or other items for display
     */
    @SideOnly(Side.CLIENT)
    public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_)
    {
        if (p_149734_1_.canLightningStrikeAt(p_149734_2_, p_149734_3_ + 1, p_149734_4_) && !World.doesBlockHaveSolidTopSurface(p_149734_1_, p_149734_2_, p_149734_3_ - 1, p_149734_4_) && p_149734_5_.nextInt(15) == 1)
        {
            double d0 = (double)((float)p_149734_2_ + p_149734_5_.nextFloat());
            double d1 = (double)p_149734_3_ - 0.05D;
            double d2 = (double)((float)p_149734_4_ + p_149734_5_.nextFloat());
            p_149734_1_.spawnParticle("dripWater", d0, d1, d2, 0.0D, 0.0D, 0.0D);
        }
    }

    private void removeLeaves(World p_150126_1_, int p_150126_2_, int p_150126_3_, int p_150126_4_)
    {
        this.dropBlockAsItem(p_150126_1_, p_150126_2_, p_150126_3_, p_150126_4_, p_150126_1_.getBlockMetadata(p_150126_2_, p_150126_3_, p_150126_4_), 0);
        p_150126_1_.setBlockToAir(p_150126_2_, p_150126_3_, p_150126_4_);
    }

    /**
     * Returns the quantity of items to drop on block destruction.
     */
    public int quantityDropped(Random p_149745_1_)
    {
        return p_149745_1_.nextInt(20) == 0 ? 1 : 0;
    }

    public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
    {
        return Item.getItemFromBlock(Blocks.sapling);
    }

    /**
     * Drops the block items with a specified chance of dropping the specified items
     */
    public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_)
    {
        if (!p_149690_1_.isRemote)
        {
            int j1 = this.func_150123_b(p_149690_5_);

            if (p_149690_7_ > 0)
            {
                j1 -= 2 << p_149690_7_;

                if (j1 < 10)
                {
                    j1 = 10;
                }
            }

            if (p_149690_1_.rand.nextInt(j1) == 0)
            {
                Item item = this.getItemDropped(p_149690_5_, p_149690_1_.rand, p_149690_7_);
                this.dropBlockAsItem(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, new ItemStack(item, 1, this.damageDropped(p_149690_5_)));
            }

            j1 = 200;

            if (p_149690_7_ > 0)
            {
                j1 -= 10 << p_149690_7_;

                if (j1 < 40)
                {
                    j1 = 40;
                }
            }

            this.func_150124_c(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, j1);
        }
    }

    protected void func_150124_c(World p_150124_1_, int p_150124_2_, int p_150124_3_, int p_150124_4_, int p_150124_5_, int p_150124_6_) {}

    protected int func_150123_b(int p_150123_1_)
    {
        return 20;
    }

    /**
     * Called when the player destroys a block with an item that can harvest it. (i, j, k) are the coordinates of the
     * block and l is the block's subtype/damage.
     */
    public void harvestBlock(World p_149636_1_, EntityPlayer p_149636_2_, int p_149636_3_, int p_149636_4_, int p_149636_5_, int p_149636_6_)
    {
        {
            super.harvestBlock(p_149636_1_, p_149636_2_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_);
        }
    }

    /**
     * Determines the damage on the item the block drops. Used in cloth and wood.
     */
    public int damageDropped(int p_149692_1_)
    {
        return p_149692_1_ & 3;
    }

    /**
     * Is this block (a) opaque and (b) a full 1m cube?  This determines whether or not to render the shared face of two
     * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
     */
    public boolean isOpaqueCube()
    {
        return !this.field_150121_P;
    }

    /**
     * Gets the block's texture. Args: side, meta
     */
    @SideOnly(Side.CLIENT)
    public abstract IIcon getIcon(int var1, int var2);

    /**
     * Pass true to draw this block using fancy graphics, or false for fast graphics.
     */
    @SideOnly(Side.CLIENT)
    public void setGraphicsLevel(boolean p_150122_1_)
    {
        this.field_150121_P = p_150122_1_;
        this.field_150127_b = p_150122_1_ ? 0 : 1;
    }

    /**
     * Returns an item stack containing a single instance of the current block type. 'i' is the block's subtype/damage
     * and is ignored for blocks which do not support subtypes. Blocks which cannot be harvested should return null.
     */
    protected ItemStack createStackedBlock(int p_149644_1_)
    {
        return new ItemStack(Item.getItemFromBlock(this), 1, p_149644_1_ & 3);
    }

    public abstract String[] func_150125_e();


    @Override
    public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int z)
    {
        return true;
    }

    @Override
    public ArrayList<ItemStack> onSheared(ItemStack item, IBlockAccess world, int x, int y, int z, int fortune)
    {
        ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
        ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z) & 3));
        return ret;
    }

    @Override
    public void beginLeavesDecay(World world, int x, int y, int z)
    {

        int i2 = world.getBlockMetadata(x, y, z);

        if ((i2 &  == 0)
        {
            world.setBlockMetadataWithNotify(x, y, z, i2 | 8, 4);
        }
        world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) | 8, 4);
    }

    @Override
    public boolean isLeaves(IBlockAccess world, int x, int y, int z)
    {
        return true;
    }
}

Link to comment
Share on other sites

remove the word abstract from the class definition. (basic java here)

 

change

public abstract class lemonLeaf extends BlockLeavesBase implements IShearable

to

public class lemonLeaf extends BlockLeavesBase implements IShearable

Then you must provide a method for every abstract method in the superclass and interfaces. The methods can even be empty or return null, 0, false, etc. They must be there to make the class concrete.

 

 

The rest is up to how you want your leaves to work.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.