summaryrefslogtreecommitdiff
path: root/src/main/java/ihl/crop_harvestors/RubberTreeBlock.java
blob: 9cfdea1bf775f20ceee3bc777b19c7cbf752fa1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
package ihl.crop_harvestors;

import java.util.Random;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ic2.api.item.IC2Items;
import ihl.IHLModInfo;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;

public class RubberTreeBlock extends Block{
	
		IIcon textureSide, textureTop;
		TreeType type;
	
		public RubberTreeBlock(TreeType type1) 
		{
			super(Material.wood);
			type=type1;
		}

		@Override
	    public Item getItemDropped(int var1, Random rnd, int var2)
	    {
			switch(type)
			{
			case RUBBERTREE:
				return IC2Items.getItem("rubberWood").getItem();
			case SPRUCE:
				return Blocks.log.getItemDropped(var1, rnd, var2);
			default:
				return IC2Items.getItem("rubberWood").getItem();
			}
			
	    }
		
		@Override
		public boolean canSustainLeaves(IBlockAccess blockAccess, int x, int y, int z)
		{
			return true;
		}
		
		@Override
		public void	dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag)
		{
			ItemStack result;
			switch(type)
			{
			case RUBBERTREE:
				result = IC2Items.getItem("rubberWood").copy();
			case SPRUCE:
				result = new ItemStack(Blocks.log,1,1);
			default:
				result = IC2Items.getItem("rubberWood").copy();
			}
	        this.dropBlockAsItem(world, x, y, z, result);
		}
		
		@Override
		@SideOnly(Side.CLIENT)
		public void registerBlockIcons(IIconRegister par1IconRegister)
		{
			switch(type)
			{
			case RUBBERTREE:
		   		this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":blockRubWoodFront");
				this.textureTop = par1IconRegister.registerIcon(IHLModInfo.MODID + ":blockRubWoodTop");
				this.textureSide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":blockRubWoodSide");
			case SPRUCE:
		   		this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":blockSpruceFront");
				this.textureTop = par1IconRegister.registerIcon("minecraft:log_spruce_top");
				this.textureSide = par1IconRegister.registerIcon("minecraft:log_spruce");
			}
		}
		
		@Override
		@SideOnly(Side.CLIENT)
		public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) 
		{
			int facing=3;
			int mask[] = {
					0,1,2,3,4,5,
					1,0,3,2,4,5,
					3,2,0,1,4,5,
					2,3,1,0,4,5,
					2,3,5,4,0,1,
					2,3,4,5,1,0
					};
				facing=world.getBlockMetadata(x, y, z);
			switch (mask[facing*6+side])
			{
			case 0:
				return this.textureSide;
			case 1:
				return this.blockIcon;
			case 2:
				return this.textureTop;
			case 3:
				return this.textureTop;
			case 4:
				return this.textureSide;
			case 5:
				return this.textureSide;
			default:
				return this.textureSide;
			}
		}
		
		@Override
		@SideOnly(Side.CLIENT)
		public IIcon getIcon(int side, int meta) 
		{
			switch (side)
			{
			case 0:
				return this.textureTop;
			case 1:
				return this.textureTop;
			case 2:
				return this.blockIcon;
			case 3:
				return this.textureSide;
			case 4:
				return this.textureSide;
			case 5:
				return this.textureSide;
			default:
				return this.textureSide;
			}
		}
		
		public enum TreeType
		{
			RUBBERTREE,
			SPRUCE
		}
		
	    @Override
	    public boolean isWood(IBlockAccess world, int x, int y, int z)
	    {
	        return true;
	    }

	    @Override
	    public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face)
	    {
	        return 4;
	    }

	    @Override
	    public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face)
	    {
	        return 20;
	    }
		
}