001 package net.minecraft.src;
002
003 public class Material
004 {
005 public static final Material air = new MaterialTransparent(MapColor.airColor);
006
007 /** The material used by BlockGrass. */
008 public static final Material grass = new Material(MapColor.grassColor);
009 public static final Material ground = new Material(MapColor.dirtColor);
010 public static final Material wood = (new Material(MapColor.woodColor)).setBurning();
011 public static final Material rock = (new Material(MapColor.stoneColor)).setNoHarvest();
012 public static final Material iron = (new Material(MapColor.ironColor)).setNoHarvest();
013 public static final Material water = (new MaterialLiquid(MapColor.waterColor)).setNoPushMobility();
014 public static final Material lava = (new MaterialLiquid(MapColor.tntColor)).setNoPushMobility();
015 public static final Material leaves = (new Material(MapColor.foliageColor)).setBurning().setTranslucent().setNoPushMobility();
016 public static final Material plants = (new MaterialLogic(MapColor.foliageColor)).setNoPushMobility();
017 public static final Material vine = (new MaterialLogic(MapColor.foliageColor)).setBurning().setNoPushMobility().setGroundCover();
018 public static final Material sponge = new Material(MapColor.clothColor);
019 public static final Material cloth = (new Material(MapColor.clothColor)).setBurning();
020 public static final Material fire = (new MaterialTransparent(MapColor.airColor)).setNoPushMobility();
021 public static final Material sand = new Material(MapColor.sandColor);
022 public static final Material circuits = (new MaterialLogic(MapColor.airColor)).setNoPushMobility();
023 public static final Material glass = (new Material(MapColor.airColor)).setTranslucent();
024 public static final Material redstoneLight = new Material(MapColor.airColor);
025 public static final Material tnt = (new Material(MapColor.tntColor)).setBurning().setTranslucent();
026 public static final Material field_76261_t = (new Material(MapColor.foliageColor)).setNoPushMobility();
027 public static final Material ice = (new Material(MapColor.iceColor)).setTranslucent();
028 public static final Material snow = (new MaterialLogic(MapColor.snowColor)).setGroundCover().setTranslucent().setNoHarvest().setNoPushMobility();
029
030 /** The material for crafted snow. */
031 public static final Material craftedSnow = (new Material(MapColor.snowColor)).setNoHarvest();
032 public static final Material cactus = (new Material(MapColor.foliageColor)).setTranslucent().setNoPushMobility();
033 public static final Material clay = new Material(MapColor.clayColor);
034
035 /** pumpkin */
036 public static final Material pumpkin = (new Material(MapColor.foliageColor)).setNoPushMobility();
037 public static final Material dragonEgg = (new Material(MapColor.foliageColor)).setNoPushMobility();
038
039 /** Material used for portals */
040 public static final Material portal = (new MaterialPortal(MapColor.airColor)).setImmovableMobility();
041
042 /** Cake's material, see BlockCake */
043 public static final Material cake = (new Material(MapColor.airColor)).setNoPushMobility();
044
045 /** Web's material. */
046 public static final Material web = (new MaterialWeb(MapColor.clothColor)).setNoHarvest().setNoPushMobility();
047
048 /** Pistons' material. */
049 public static final Material piston = (new Material(MapColor.stoneColor)).setImmovableMobility();
050
051 /** Bool defining if the block can burn or not. */
052 private boolean canBurn;
053
054 /** Indicates if the material is a form of ground cover, e.g. Snow */
055 private boolean groundCover;
056
057 /** Indicates if the material is translucent */
058 private boolean isTranslucent;
059
060 /** The color index used to draw the blocks of this material on maps. */
061 public final MapColor materialMapColor;
062
063 /**
064 * Determines if the materials is one that can be collected by the player.
065 */
066 private boolean canHarvest = true;
067
068 /**
069 * Mobility information flag. 0 indicates that this block is normal, 1 indicates that it can't push other blocks, 2
070 * indicates that it can't be pushed.
071 */
072 private int mobilityFlag;
073
074 public Material(MapColor par1MapColor)
075 {
076 this.materialMapColor = par1MapColor;
077 }
078
079 /**
080 * Returns if blocks of these materials are liquids.
081 */
082 public boolean isLiquid()
083 {
084 return false;
085 }
086
087 public boolean isSolid()
088 {
089 return true;
090 }
091
092 /**
093 * Will prevent grass from growing on dirt underneath and kill any grass below it if it returns true
094 */
095 public boolean getCanBlockGrass()
096 {
097 return true;
098 }
099
100 /**
101 * Returns if this material is considered solid or not
102 */
103 public boolean blocksMovement()
104 {
105 return true;
106 }
107
108 /**
109 * Marks the material as translucent
110 */
111 private Material setTranslucent()
112 {
113 this.isTranslucent = true;
114 return this;
115 }
116
117 /**
118 * Disables the ability to harvest this material.
119 */
120 protected Material setNoHarvest()
121 {
122 this.canHarvest = false;
123 return this;
124 }
125
126 /**
127 * Set the canBurn bool to True and return the current object.
128 */
129 protected Material setBurning()
130 {
131 this.canBurn = true;
132 return this;
133 }
134
135 /**
136 * Returns if the block can burn or not.
137 */
138 public boolean getCanBurn()
139 {
140 return this.canBurn;
141 }
142
143 /**
144 * Sets the material as a form of ground cover, e.g. Snow
145 */
146 public Material setGroundCover()
147 {
148 this.groundCover = true;
149 return this;
150 }
151
152 /**
153 * Return whether the material is a form of ground cover, e.g. Snow
154 */
155 public boolean isGroundCover()
156 {
157 return this.groundCover;
158 }
159
160 /**
161 * Indicate if the material is opaque
162 */
163 public boolean isOpaque()
164 {
165 return this.isTranslucent ? false : this.blocksMovement();
166 }
167
168 /**
169 * Returns true if material can be harvested by player.
170 */
171 public boolean isHarvestable()
172 {
173 return this.canHarvest;
174 }
175
176 /**
177 * Returns the mobility information of the material, 0 = free, 1 = can't push but can move over, 2 = total
178 * immobility and stop pistons.
179 */
180 public int getMaterialMobility()
181 {
182 return this.mobilityFlag;
183 }
184
185 /**
186 * This type of material can't be pushed, but pistons can move over it.
187 */
188 protected Material setNoPushMobility()
189 {
190 this.mobilityFlag = 1;
191 return this;
192 }
193
194 /**
195 * This type of material can't be pushed, and pistons are blocked to move.
196 */
197 protected Material setImmovableMobility()
198 {
199 this.mobilityFlag = 2;
200 return this;
201 }
202 }