    001    package net.minecraft.block.material;
    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)).setRequiresTool();
    012        public static final Material iron = (new Material(MapColor.ironColor)).setRequiresTool();
    013        public static final Material anvil = (new Material(MapColor.ironColor)).setRequiresTool().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().setReplaceable();
    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().func_85158_p();
    025        public static final Material redstoneLight = (new Material(MapColor.airColor)).func_85158_p();
    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().func_85158_p();
    029        public static final Material snow = (new MaterialLogic(MapColor.snowColor)).setReplaceable().setTranslucent().setRequiresTool().setNoPushMobility();
    030
    031        /** The material for crafted snow. */
    032        public static final Material craftedSnow = (new Material(MapColor.snowColor)).setRequiresTool();
    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)).setRequiresTool().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        /**
    056         * Determines whether blocks with this material can be "overwritten" by other blocks when placed - eg snow, vines
    057         * and tall grass.
    058         */
    059        private boolean replaceable;
    060
    061        /** Indicates if the material is translucent */
    062        private boolean isTranslucent;
    063
    064        /** The color index used to draw the blocks of this material on maps. */
    065        public final MapColor materialMapColor;
    066
    067        /**
    068         * Determines if the material can be harvested without a tool (or with the wrong tool)
    069         */
    070        private boolean requiresNoTool = true;
    071
    072        /**
    073         * Mobility information flag. 0 indicates that this block is normal, 1 indicates that it can't push other blocks, 2
    074         * indicates that it can't be pushed.
    075         */
    076        private int mobilityFlag;
    077        private boolean field_85159_M;
    078
    079        public Material(MapColor par1MapColor)
    080        {
    081            this.materialMapColor = par1MapColor;
    082        }
    083
    084        /**
    085         * Returns if blocks of these materials are liquids.
    086         */
    087        public boolean isLiquid()
    088        {
    089            return false;
    090        }
    091
    092        public boolean isSolid()
    093        {
    094            return true;
    095        }
    096
    097        /**
    098         * Will prevent grass from growing on dirt underneath and kill any grass below it if it returns true
    099         */
    100        public boolean getCanBlockGrass()
    101        {
    102            return true;
    103        }
    104
    105        /**
    106         * Returns if this material is considered solid or not
    107         */
    108        public boolean blocksMovement()
    109        {
    110            return true;
    111        }
    112
    113        /**
    114         * Marks the material as translucent
    115         */
    116        private Material setTranslucent()
    117        {
    118            this.isTranslucent = true;
    119            return this;
    120        }
    121
    122        /**
    123         * Makes blocks with this material require the correct tool to be harvested.
    124         */
    125        protected Material setRequiresTool()
    126        {
    127            this.requiresNoTool = false;
    128            return this;
    129        }
    130
    131        /**
    132         * Set the canBurn bool to True and return the current object.
    133         */
    134        protected Material setBurning()
    135        {
    136            this.canBurn = true;
    137            return this;
    138        }
    139
    140        /**
    141         * Returns if the block can burn or not.
    142         */
    143        public boolean getCanBurn()
    144        {
    145            return this.canBurn;
    146        }
    147
    148        /**
    149         * Sets {@link #replaceable} to true.
    150         */
    151        public Material setReplaceable()
    152        {
    153            this.replaceable = true;
    154            return this;
    155        }
    156
    157        /**
    158         * Returns whether the material can be replaced by other blocks when placed - eg snow, vines and tall grass.
    159         */
    160        public boolean isReplaceable()
    161        {
    162            return this.replaceable;
    163        }
    164
    165        /**
    166         * Indicate if the material is opaque
    167         */
    168        public boolean isOpaque()
    169        {
    170            return this.isTranslucent ? false : this.blocksMovement();
    171        }
    172
    173        /**
    174         * Returns true if the material can be harvested without a tool (or with the wrong tool)
    175         */
    176        public boolean isToolNotRequired()
    177        {
    178            return this.requiresNoTool;
    179        }
    180
    181        /**
    182         * Returns the mobility information of the material, 0 = free, 1 = can't push but can move over, 2 = total
    183         * immobility and stop pistons.
    184         */
    185        public int getMaterialMobility()
    186        {
    187            return this.mobilityFlag;
    188        }
    189
    190        /**
    191         * This type of material can't be pushed, but pistons can move over it.
    192         */
    193        protected Material setNoPushMobility()
    194        {
    195            this.mobilityFlag = 1;
    196            return this;
    197        }
    198
    199        /**
    200         * This type of material can't be pushed, and pistons are blocked to move.
    201         */
    202        protected Material setImmovableMobility()
    203        {
    204            this.mobilityFlag = 2;
    205            return this;
    206        }
    207
    208        protected Material func_85158_p()
    209        {
    210            this.field_85159_M = true;
    211            return this;
    212        }
    213
    214        public boolean func_85157_q()
    215        {
    216            return this.field_85159_M;
    217        }
    218    }