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