Skip to content

Instantly share code, notes, and snippets.

@Deamon5550
Created March 20, 2017 20:09
Show Gist options
  • Save Deamon5550/78ed5877f765364c7c297de6168e6e38 to your computer and use it in GitHub Desktop.
Save Deamon5550/78ed5877f765364c7c297de6168e6e38 to your computer and use it in GitHub Desktop.
package net.minecraft.block.material;
public class Material {
public static final Material AIR = new MaterialTransparent(MapColor.AIR);
public static final Material GRASS = new Material(MapColor.GRASS);
public static final Material GROUND = new Material(MapColor.DIRT);
public static final Material WOOD = new Material(MapColor.WOOD).setBurning();
public static final Material ROCK = new Material(MapColor.STONE).setRequiresTool();
public static final Material IRON = new Material(MapColor.IRON).setRequiresTool();
public static final Material ANVIL = new Material(MapColor.IRON).setRequiresTool().setImmovableMobility();
public static final Material WATER = new MaterialLiquid(MapColor.WATER).setNoPushMobility();
public static final Material LAVA = new MaterialLiquid(MapColor.TNT).setNoPushMobility();
public static final Material LEAVES = new Material(MapColor.FOLIAGE).setBurning().setTranslucent().setNoPushMobility();
public static final Material PLANTS = new MaterialLogic(MapColor.FOLIAGE).setNoPushMobility();
public static final Material VINE = new MaterialLogic(MapColor.FOLIAGE).setBurning().setNoPushMobility().setReplaceable();
public static final Material SPONGE = new Material(MapColor.YELLOW);
public static final Material CLOTH = new Material(MapColor.CLOTH).setBurning();
public static final Material FIRE = new MaterialTransparent(MapColor.AIR).setNoPushMobility();
public static final Material SAND = new Material(MapColor.SAND);
public static final Material CIRCUITS = new MaterialLogic(MapColor.AIR).setNoPushMobility();
public static final Material CARPET = new MaterialLogic(MapColor.CLOTH).setBurning();
public static final Material GLASS = new Material(MapColor.AIR).setTranslucent().setAdventureModeExempt();
public static final Material REDSTONE_LIGHT = new Material(MapColor.AIR).setAdventureModeExempt();
public static final Material TNT = new Material(MapColor.TNT).setBurning().setTranslucent();
public static final Material CORAL = new Material(MapColor.FOLIAGE).setNoPushMobility();
public static final Material ICE = new Material(MapColor.ICE).setTranslucent().setAdventureModeExempt();
public static final Material PACKED_ICE = new Material(MapColor.ICE).setAdventureModeExempt();
public static final Material SNOW = new MaterialLogic(MapColor.SNOW).setReplaceable().setTranslucent().setRequiresTool().setNoPushMobility();
public static final Material CRAFTED_SNOW = new Material(MapColor.SNOW).setRequiresTool();
public static final Material CACTUS = new Material(MapColor.FOLIAGE).setTranslucent().setNoPushMobility();
public static final Material CLAY = new Material(MapColor.CLAY);
public static final Material GOURD = new Material(MapColor.FOLIAGE).setNoPushMobility();
public static final Material DRAGON_EGG = new Material(MapColor.FOLIAGE).setNoPushMobility();
public static final Material PORTAL = new MaterialPortal(MapColor.AIR).setImmovableMobility();
public static final Material CAKE = new Material(MapColor.AIR).setNoPushMobility();
public static final Material WEB = new Material(MapColor.CLOTH) {
public boolean blocksMovement() {
return false;
}
}.setRequiresTool().setNoPushMobility();
public static final Material PISTON = new Material(MapColor.STONE).setImmovableMobility();
public static final Material BARRIER = new Material(MapColor.AIR).setRequiresTool().setImmovableMobility();
public static final Material STRUCTURE_VOID = new MaterialTransparent(MapColor.AIR);
private boolean canBurn;
private boolean replaceable;
private boolean isTranslucent;
private final MapColor materialMapColor;
private boolean requiresNoTool = true;
private EnumPushReaction mobilityFlag = EnumPushReaction.NORMAL;
private boolean isAdventureModeExempt;
public Material(MapColor color) {
this.materialMapColor = color;
}
public boolean isLiquid() {
return false;
}
public boolean isSolid() {
return true;
}
public boolean blocksLight() {
return true;
}
public boolean blocksMovement() {
return true;
}
private Material setTranslucent() {
this.isTranslucent = true;
return this;
}
protected Material setRequiresTool() {
this.requiresNoTool = false;
return this;
}
protected Material setBurning() {
this.canBurn = true;
return this;
}
public boolean getCanBurn() {
return this.canBurn;
}
public Material setReplaceable() {
this.replaceable = true;
return this;
}
public boolean isReplaceable() {
return this.replaceable;
}
public boolean isOpaque() {
return this.isTranslucent ? false : blocksMovement();
}
public boolean isToolNotRequired() {
return this.requiresNoTool;
}
public EnumPushReaction getMobilityFlag() {
return this.mobilityFlag;
}
protected Material setNoPushMobility() {
this.mobilityFlag = EnumPushReaction.DESTROY;
return this;
}
protected Material setImmovableMobility() {
this.mobilityFlag = EnumPushReaction.BLOCK;
return this;
}
protected Material setAdventureModeExempt() {
this.isAdventureModeExempt = true;
return this;
}
public MapColor getMaterialMapColor() {
return this.materialMapColor;
}
}
package net.minecraft.block.material;
import net.minecraft.block.material.EnumPushReaction;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.MaterialLiquid;
import net.minecraft.block.material.MaterialLogic;
import net.minecraft.block.material.MaterialPortal;
import net.minecraft.block.material.MaterialTransparent;
public class Material {
public static final Material AIR;
public static final Material GRASS;
public static final Material GROUND;
public static final Material WOOD;
public static final Material ROCK;
public static final Material IRON;
public static final Material ANVIL;
public static final Material WATER;
public static final Material LAVA;
public static final Material LEAVES;
public static final Material PLANTS;
public static final Material VINE;
public static final Material SPONGE;
public static final Material CLOTH;
public static final Material FIRE;
public static final Material SAND;
public static final Material CIRCUITS;
public static final Material CARPET;
public static final Material GLASS;
public static final Material REDSTONE_LIGHT;
public static final Material TNT;
public static final Material CORAL;
public static final Material ICE;
public static final Material PACKED_ICE;
public static final Material SNOW;
public static final Material CRAFTED_SNOW;
public static final Material CACTUS;
public static final Material CLAY;
public static final Material GOURD;
public static final Material DRAGON_EGG;
public static final Material PORTAL;
public static final Material CAKE;
public static final Material WEB;
public static final Material PISTON;
public static final Material BARRIER;
public static final Material STRUCTURE_VOID;
private boolean canBurn;
private boolean replaceable;
private boolean isTranslucent;
private final MapColor materialMapColor;
private boolean requiresNoTool = true;
private EnumPushReaction mobilityFlag;
private boolean isAdventureModeExempt;
public Material(MapColor color) {
this.mobilityFlag = EnumPushReaction.NORMAL;
this.materialMapColor = color;
}
public boolean isLiquid() {
return false;
}
public boolean isSolid() {
return true;
}
public boolean blocksLight() {
return true;
}
public boolean blocksMovement() {
return true;
}
private Material setTranslucent() {
this.isTranslucent = true;
return this;
}
protected Material setRequiresTool() {
this.requiresNoTool = false;
return this;
}
protected Material setBurning() {
this.canBurn = true;
return this;
}
public boolean getCanBurn() {
return this.canBurn;
}
public Material setReplaceable() {
this.replaceable = true;
return this;
}
public boolean isReplaceable() {
return this.replaceable;
}
public boolean isOpaque() {
return this.isTranslucent?false:this.blocksMovement();
}
public boolean isToolNotRequired() {
return this.requiresNoTool;
}
public EnumPushReaction getMobilityFlag() {
return this.mobilityFlag;
}
protected Material setNoPushMobility() {
this.mobilityFlag = EnumPushReaction.DESTROY;
return this;
}
protected Material setImmovableMobility() {
this.mobilityFlag = EnumPushReaction.BLOCK;
return this;
}
protected Material setAdventureModeExempt() {
this.isAdventureModeExempt = true;
return this;
}
public MapColor getMaterialMapColor() {
return this.materialMapColor;
}
static {
AIR = new MaterialTransparent(MapColor.AIR);
GRASS = new Material(MapColor.GRASS);
GROUND = new Material(MapColor.DIRT);
WOOD = (new Material(MapColor.WOOD)).setBurning();
ROCK = (new Material(MapColor.STONE)).setRequiresTool();
IRON = (new Material(MapColor.IRON)).setRequiresTool();
ANVIL = (new Material(MapColor.IRON)).setRequiresTool().setImmovableMobility();
WATER = (new MaterialLiquid(MapColor.WATER)).setNoPushMobility();
LAVA = (new MaterialLiquid(MapColor.TNT)).setNoPushMobility();
LEAVES = (new Material(MapColor.FOLIAGE)).setBurning().setTranslucent().setNoPushMobility();
PLANTS = (new MaterialLogic(MapColor.FOLIAGE)).setNoPushMobility();
VINE = (new MaterialLogic(MapColor.FOLIAGE)).setBurning().setNoPushMobility().setReplaceable();
SPONGE = new Material(MapColor.YELLOW);
CLOTH = (new Material(MapColor.CLOTH)).setBurning();
FIRE = (new MaterialTransparent(MapColor.AIR)).setNoPushMobility();
SAND = new Material(MapColor.SAND);
CIRCUITS = (new MaterialLogic(MapColor.AIR)).setNoPushMobility();
CARPET = (new MaterialLogic(MapColor.CLOTH)).setBurning();
GLASS = (new Material(MapColor.AIR)).setTranslucent().setAdventureModeExempt();
REDSTONE_LIGHT = (new Material(MapColor.AIR)).setAdventureModeExempt();
TNT = (new Material(MapColor.TNT)).setBurning().setTranslucent();
CORAL = (new Material(MapColor.FOLIAGE)).setNoPushMobility();
ICE = (new Material(MapColor.ICE)).setTranslucent().setAdventureModeExempt();
PACKED_ICE = (new Material(MapColor.ICE)).setAdventureModeExempt();
SNOW = (new MaterialLogic(MapColor.SNOW)).setReplaceable().setTranslucent().setRequiresTool().setNoPushMobility();
CRAFTED_SNOW = (new Material(MapColor.SNOW)).setRequiresTool();
CACTUS = (new Material(MapColor.FOLIAGE)).setTranslucent().setNoPushMobility();
CLAY = new Material(MapColor.CLAY);
GOURD = (new Material(MapColor.FOLIAGE)).setNoPushMobility();
DRAGON_EGG = (new Material(MapColor.FOLIAGE)).setNoPushMobility();
PORTAL = (new MaterialPortal(MapColor.AIR)).setImmovableMobility();
CAKE = (new Material(MapColor.AIR)).setNoPushMobility();
WEB = (new Material(MapColor.CLOTH) {
public boolean blocksMovement() {
return false;
}
}).setRequiresTool().setNoPushMobility();
PISTON = (new Material(MapColor.STONE)).setImmovableMobility();
BARRIER = (new Material(MapColor.AIR)).setRequiresTool().setImmovableMobility();
STRUCTURE_VOID = new MaterialTransparent(MapColor.AIR);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment