| 1 | package net.minecraft.block.material;
|
| 2 |
|
| 3 | public class Material
|
| 4 | {
|
| 5 | public static final Material air = new MaterialTransparent(MapColor.airColor);
|
| 6 | public static final Material grass = new Material(MapColor.grassColor);
|
| 7 | public static final Material ground = new Material(MapColor.dirtColor);
|
| 8 | public static final Material wood = (new Material(MapColor.woodColor)).setBurning();
|
| 9 | public static final Material rock = (new Material(MapColor.stoneColor)).setRequiresTool();
|
| 10 | public static final Material iron = (new Material(MapColor.ironColor)).setRequiresTool();
|
| 11 | public static final Material anvil = (new Material(MapColor.ironColor)).setRequiresTool().setImmovableMobility();
|
| 12 | public static final Material water = (new MaterialLiquid(MapColor.waterColor)).setNoPushMobility();
|
| 13 | public static final Material lava = (new MaterialLiquid(MapColor.tntColor)).setNoPushMobility();
|
| 14 | public static final Material leaves = (new Material(MapColor.foliageColor)).setBurning().setTranslucent().setNoPushMobility();
|
| 15 | public static final Material plants = (new MaterialLogic(MapColor.foliageColor)).setNoPushMobility();
|
| 16 | public static final Material vine = (new MaterialLogic(MapColor.foliageColor)).setBurning().setNoPushMobility().setReplaceable();
|
| 17 | public static final Material sponge = new Material(MapColor.yellowColor);
|
| 18 | public static final Material cloth = (new Material(MapColor.clothColor)).setBurning();
|
| 19 | public static final Material fire = (new MaterialTransparent(MapColor.airColor)).setNoPushMobility();
|
| 20 | public static final Material sand = new Material(MapColor.sandColor);
|
| 21 | public static final Material circuits = (new MaterialLogic(MapColor.airColor)).setNoPushMobility();
|
| 22 | public static final Material carpet = (new MaterialLogic(MapColor.clothColor)).setBurning();
|
| 23 | public static final Material glass = (new Material(MapColor.airColor)).setTranslucent().setAdventureModeExempt();
|
| 24 | public static final Material redstoneLight = (new Material(MapColor.airColor)).setAdventureModeExempt();
|
| 25 | public static final Material tnt = (new Material(MapColor.tntColor)).setBurning().setTranslucent();
|
| 26 | public static final Material coral = (new Material(MapColor.foliageColor)).setNoPushMobility();
|
| 27 | public static final Material ice = (new Material(MapColor.iceColor)).setTranslucent().setAdventureModeExempt();
|
| 28 | public static final Material packedIce = (new Material(MapColor.iceColor)).setAdventureModeExempt();
|
| 29 | public static final Material snow = (new MaterialLogic(MapColor.snowColor)).setReplaceable().setTranslucent().setRequiresTool().setNoPushMobility();
|
| 30 |
|
| 31 | /** The material for crafted snow. */
|
| 32 | public static final Material craftedSnow = (new Material(MapColor.snowColor)).setRequiresTool();
|
| 33 | public static final Material cactus = (new Material(MapColor.foliageColor)).setTranslucent().setNoPushMobility();
|
| 34 | public static final Material clay = new Material(MapColor.clayColor);
|
| 35 | public static final Material gourd = (new Material(MapColor.foliageColor)).setNoPushMobility();
|
| 36 | public static final Material dragonEgg = (new Material(MapColor.foliageColor)).setNoPushMobility();
|
| 37 | public static final Material portal = (new MaterialPortal(MapColor.airColor)).setImmovableMobility();
|
| 38 | public static final Material cake = (new Material(MapColor.airColor)).setNoPushMobility();
|
| 39 | public static final Material web = (new Material(MapColor.clothColor)
|
| 40 | {
|
| 41 | public boolean blocksMovement()
|
| 42 | {
|
| 43 | return false;
|
| 44 | }
|
| 45 | }).setRequiresTool().setNoPushMobility();
|
| 46 |
|
| 47 | /** Pistons' material. */
|
| 48 | public static final Material piston = (new Material(MapColor.stoneColor)).setImmovableMobility();
|
| 49 | public static final Material barrier = (new Material(MapColor.airColor)).setRequiresTool().setImmovableMobility();
|
| 50 |
|
| 51 | /** Bool defining if the block can burn or not. */
|
| 52 | private boolean canBurn;
|
| 53 |
|
| 54 | /**
|
| 55 | * Determines whether blocks with this material can be "overwritten" by other blocks when placed - eg snow, vines
|
| 56 | * and tall grass.
|
| 57 | */
|
| 58 | private boolean replaceable;
|
| 59 |
|
| 60 | /** Indicates if the material is translucent */
|
| 61 | private boolean isTranslucent;
|
| 62 |
|
| 63 | /** The color index used to draw the blocks of this material on maps. */
|
| 64 | private final MapColor materialMapColor;
|
| 65 |
|
| 66 | /**
|
| 67 | * Determines if the material can be harvested without a tool (or with the wrong tool)
|
| 68 | */
|
| 69 | private boolean requiresNoTool = true;
|
| 70 |
|
| 71 | /**
|
| 72 | * Mobility information flag. 0 indicates that this block is normal, 1 indicates that it can't push other blocks, 2
|
| 73 | * indicates that it can't be pushed.
|
| 74 | */
|
| 75 | private int mobilityFlag;
|
| 76 | private boolean isAdventureModeExempt;
|
| 77 |
|
| 78 | public Material(MapColor color)
|
| 79 | {
|
| 80 | this.materialMapColor = color;
|
| 81 | }
|
| 82 |
|
| 83 | /**
|
| 84 | * Returns if blocks of these materials are liquids.
|
| 85 | */
|
| 86 | public boolean isLiquid()
|
| 87 | {
|
| 88 | return false;
|
| 89 | }
|
| 90 |
|
| 91 | /**
|
| 92 | * Returns true if the block is a considered solid. This is true by default.
|
| 93 | */
|
| 94 | public boolean isSolid()
|
| 95 | {
|
| 96 | return true;
|
| 97 | }
|
| 98 |
|
| 99 | /**
|
| 100 | * Will prevent grass from growing on dirt underneath and kill any grass below it if it returns true
|
| 101 | */
|
| 102 | public boolean blocksLight()
|
| 103 | {
|
| 104 | return true;
|
| 105 | }
|
| 106 |
|
| 107 | /**
|
| 108 | * Returns if this material is considered solid or not
|
| 109 | */
|
| 110 | public boolean blocksMovement()
|
| 111 | {
|
| 112 | return true;
|
| 113 | }
|
| 114 |
|
| 115 | /**
|
| 116 | * Marks the material as translucent
|
| 117 | */
|
| 118 | private Material setTranslucent()
|
| 119 | {
|
| 120 | this.isTranslucent = true;
|
| 121 | return this;
|
| 122 | }
|
| 123 |
|
| 124 | /**
|
| 125 | * Makes blocks with this material require the correct tool to be harvested.
|
| 126 | */
|
| 127 | protected Material setRequiresTool()
|
| 128 | {
|
| 129 | this.requiresNoTool = false;
|
| 130 | return this;
|
| 131 | }
|
| 132 |
|
| 133 | /**
|
| 134 | * Set the canBurn bool to True and return the current object.
|
| 135 | */
|
| 136 | protected Material setBurning()
|
| 137 | {
|
| 138 | this.canBurn = true;
|
| 139 | return this;
|
| 140 | }
|
| 141 |
|
| 142 | /**
|
| 143 | * Returns if the block can burn or not.
|
| 144 | */
|
| 145 | public boolean getCanBurn()
|
| 146 | {
|
| 147 | return this.canBurn;
|
| 148 | }
|
| 149 |
|
| 150 | /**
|
| 151 | * Sets {@link #replaceable} to true.
|
| 152 | */
|
| 153 | public Material setReplaceable()
|
| 154 | {
|
| 155 | this.replaceable = true;
|
| 156 | return this;
|
| 157 | }
|
| 158 |
|
| 159 | /**
|
| 160 | * Returns whether the material can be replaced by other blocks when placed - eg snow, vines and tall grass.
|
| 161 | */
|
| 162 | public boolean isReplaceable()
|
| 163 | {
|
| 164 | return this.replaceable;
|
| 165 | }
|
| 166 |
|
| 167 | /**
|
| 168 | * Indicate if the material is opaque
|
| 169 | */
|
| 170 | public boolean isOpaque()
|
| 171 | {
|
| 172 | return this.isTranslucent ? false : this.blocksMovement();
|
| 173 | }
|
| 174 |
|
| 175 | /**
|
| 176 | * Returns true if the material can be harvested without a tool (or with the wrong tool)
|
| 177 | */
|
| 178 | public boolean isToolNotRequired()
|
| 179 | {
|
| 180 | return this.requiresNoTool;
|
| 181 | }
|
| 182 |
|
| 183 | /**
|
| 184 | * Returns the mobility information of the material, 0 = free, 1 = can't push but can move over, 2 = total
|
| 185 | * immobility and stop pistons.
|
| 186 | */
|
| 187 | public int getMaterialMobility()
|
| 188 | {
|
| 189 | return this.mobilityFlag;
|
| 190 | }
|
| 191 |
|
| 192 | /**
|
| 193 | * This type of material can't be pushed, but pistons can move over it.
|
| 194 | */
|
| 195 | protected Material setNoPushMobility()
|
| 196 | {
|
| 197 | this.mobilityFlag = 1;
|
| 198 | return this;
|
| 199 | }
|
| 200 |
|
| 201 | /**
|
| 202 | * This type of material can't be pushed, and pistons are blocked to move.
|
| 203 | */
|
| 204 | protected Material setImmovableMobility()
|
| 205 | {
|
| 206 | this.mobilityFlag = 2;
|
| 207 | return this;
|
| 208 | }
|
| 209 |
|
| 210 | /**
|
| 211 | * @see #isAdventureModeExempt()
|
| 212 | */
|
| 213 | protected Material setAdventureModeExempt()
|
| 214 | {
|
| 215 | this.isAdventureModeExempt = true;
|
| 216 | return this;
|
| 217 | }
|
| 218 |
|
| 219 | /**
|
| 220 | * Retrieves the color index of the block. This is is the same color used by vanilla maps to represent this block.
|
| 221 | */
|
| 222 | public MapColor getMaterialMapColor()
|
| 223 | {
|
| 224 | return this.materialMapColor;
|
| 225 | }
|
| 226 | }
|
| 227 |
|