    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().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)).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        private boolean field_85159_M;
    075
    076        public Material(MapColor par1MapColor)
    077        {
    078            this.materialMapColor = par1MapColor;
    079        }
    080
    081        /**
    082         * Returns if blocks of these materials are liquids.
    083         */
    084        public boolean isLiquid()
    085        {
    086            return false;
    087        }
    088
    089        public boolean isSolid()
    090        {
    091            return true;
    092        }
    093
    094        /**
    095         * Will prevent grass from growing on dirt underneath and kill any grass below it if it returns true
    096         */
    097        public boolean getCanBlockGrass()
    098        {
    099            return true;
    100        }
    101
    102        /**
    103         * Returns if this material is considered solid or not
    104         */
    105        public boolean blocksMovement()
    106        {
    107            return true;
    108        }
    109
    110        /**
    111         * Marks the material as translucent
    112         */
    113        private Material setTranslucent()
    114        {
    115            this.isTranslucent = true;
    116            return this;
    117        }
    118
    119        /**
    120         * Disables the ability to harvest this material.
    121         */
    122        protected Material setNoHarvest()
    123        {
    124            this.canHarvest = false;
    125            return this;
    126        }
    127
    128        /**
    129         * Set the canBurn bool to True and return the current object.
    130         */
    131        protected Material setBurning()
    132        {
    133            this.canBurn = true;
    134            return this;
    135        }
    136
    137        /**
    138         * Returns if the block can burn or not.
    139         */
    140        public boolean getCanBurn()
    141        {
    142            return this.canBurn;
    143        }
    144
    145        /**
    146         * Sets the material as a form of ground cover, e.g. Snow
    147         */
    148        public Material setGroundCover()
    149        {
    150            this.groundCover = true;
    151            return this;
    152        }
    153
    154        /**
    155         * Return whether the material is a form of ground cover, e.g. Snow
    156         */
    157        public boolean isGroundCover()
    158        {
    159            return this.groundCover;
    160        }
    161
    162        /**
    163         * Indicate if the material is opaque
    164         */
    165        public boolean isOpaque()
    166        {
    167            return this.isTranslucent ? false : this.blocksMovement();
    168        }
    169
    170        /**
    171         * Returns true if material can be harvested by player.
    172         */
    173        public boolean isHarvestable()
    174        {
    175            return this.canHarvest;
    176        }
    177
    178        /**
    179         * Returns the mobility information of the material, 0 = free, 1 = can't push but can move over, 2 = total
    180         * immobility and stop pistons.
    181         */
    182        public int getMaterialMobility()
    183        {
    184            return this.mobilityFlag;
    185        }
    186
    187        /**
    188         * This type of material can't be pushed, but pistons can move over it.
    189         */
    190        protected Material setNoPushMobility()
    191        {
    192            this.mobilityFlag = 1;
    193            return this;
    194        }
    195
    196        /**
    197         * This type of material can't be pushed, and pistons are blocked to move.
    198         */
    199        protected Material setImmovableMobility()
    200        {
    201            this.mobilityFlag = 2;
    202            return this;
    203        }
    204
    205        protected Material func_85158_p()
    206        {
    207            this.field_85159_M = true;
    208            return this;
    209        }
    210
    211        public boolean func_85157_q()
    212        {
    213            return this.field_85159_M;
    214        }
    215    }