added support for SmoothBrick and changed steps to a TexturedMaterial
This commit is contained in:
parent
7e5b2c1f30
commit
e7d0831d41
@ -110,7 +110,7 @@ public enum Material {
|
|||||||
LOCKED_CHEST(95),
|
LOCKED_CHEST(95),
|
||||||
TRAP_DOOR(96, TrapDoor.class),
|
TRAP_DOOR(96, TrapDoor.class),
|
||||||
MONSTER_EGGS(97),
|
MONSTER_EGGS(97),
|
||||||
SMOOTH_BRICK(98),
|
SMOOTH_BRICK(98, SmoothBrick.class),
|
||||||
HUGE_MUSHROOM_1(99),
|
HUGE_MUSHROOM_1(99),
|
||||||
HUGE_MUSHROOM_2(100),
|
HUGE_MUSHROOM_2(100),
|
||||||
IRON_FENCE(101),
|
IRON_FENCE(101),
|
||||||
|
48
src/main/java/org/bukkit/material/SmoothBrick.java
Normal file
48
src/main/java/org/bukkit/material/SmoothBrick.java
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package org.bukkit.material;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the different types of smooth bricks.
|
||||||
|
*/
|
||||||
|
public class SmoothBrick extends TexturedMaterial {
|
||||||
|
|
||||||
|
private static final List<Material> textures = new ArrayList<Material>();
|
||||||
|
static {
|
||||||
|
textures.add(Material.STONE);
|
||||||
|
textures.add(Material.MOSSY_COBBLESTONE);
|
||||||
|
textures.add(Material.COBBLESTONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SmoothBrick() {
|
||||||
|
super(Material.SMOOTH_BRICK);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SmoothBrick(final int type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SmoothBrick(final Material type) {
|
||||||
|
super((textures.contains(type)) ? Material.SMOOTH_BRICK : type);
|
||||||
|
if (textures.contains(type)) {
|
||||||
|
setMaterial(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SmoothBrick(final int type, final byte data) {
|
||||||
|
super(type, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SmoothBrick(final Material type, final byte data) {
|
||||||
|
super(type, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Material> getTextures() {
|
||||||
|
return textures;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,19 +1,22 @@
|
|||||||
package org.bukkit.material;
|
package org.bukkit.material;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the different types of steps.
|
* Represents the different types of steps.
|
||||||
*/
|
*/
|
||||||
public class Step extends MaterialData {
|
public class Step extends TexturedMaterial {
|
||||||
private static HashSet<Material> stepTypes = new HashSet<Material>();
|
private static final List<Material> textures = new ArrayList<Material>();
|
||||||
static {
|
static {
|
||||||
stepTypes.add(Material.SANDSTONE);
|
textures.add(Material.STONE);
|
||||||
stepTypes.add(Material.WOOD);
|
textures.add(Material.SANDSTONE);
|
||||||
stepTypes.add(Material.COBBLESTONE);
|
textures.add(Material.WOOD);
|
||||||
stepTypes.add(Material.STONE);
|
textures.add(Material.COBBLESTONE);
|
||||||
|
textures.add(Material.BRICK);
|
||||||
|
textures.add(Material.SMOOTH_BRICK);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Step() {
|
public Step() {
|
||||||
@ -25,8 +28,8 @@ public class Step extends MaterialData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Step(final Material type) {
|
public Step(final Material type) {
|
||||||
super((stepTypes.contains(type)) ? Material.STEP : type);
|
super((textures.contains(type)) ? Material.STEP : type);
|
||||||
if (stepTypes.contains(type)) {
|
if (textures.contains(type)) {
|
||||||
setMaterial(type);
|
setMaterial(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -39,55 +42,8 @@ public class Step extends MaterialData {
|
|||||||
super(type, data);
|
super(type, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the current Material this step is made of
|
|
||||||
*
|
|
||||||
* @return Material of this step
|
|
||||||
*/
|
|
||||||
public Material getMaterial() {
|
|
||||||
switch ((int) getData()) {
|
|
||||||
case 1:
|
|
||||||
return Material.SANDSTONE;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
return Material.WOOD;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
return Material.COBBLESTONE;
|
|
||||||
|
|
||||||
case 0:
|
|
||||||
default:
|
|
||||||
return Material.STONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the material this step is made of
|
|
||||||
*
|
|
||||||
* @param material New material of this step
|
|
||||||
*/
|
|
||||||
public void setMaterial(Material material) {
|
|
||||||
switch (material) {
|
|
||||||
case SANDSTONE:
|
|
||||||
setData((byte) 0x1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WOOD:
|
|
||||||
setData((byte) 0x2);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case COBBLESTONE:
|
|
||||||
setData((byte) 0x3);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case STONE:
|
|
||||||
default:
|
|
||||||
setData((byte) 0x0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public List<Material> getTextures() {
|
||||||
return getMaterial() + " " + super.toString();
|
return textures;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
68
src/main/java/org/bukkit/material/TexturedMaterial.java
Normal file
68
src/main/java/org/bukkit/material/TexturedMaterial.java
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
package org.bukkit.material;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents textured materials like steps and smooth bricks
|
||||||
|
*/
|
||||||
|
public abstract class TexturedMaterial extends MaterialData {
|
||||||
|
|
||||||
|
public TexturedMaterial(Material m) {
|
||||||
|
super(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TexturedMaterial(int type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TexturedMaterial(final int type, final byte data) {
|
||||||
|
super(type, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TexturedMaterial(final Material type, final byte data) {
|
||||||
|
super(type, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a list of possible textures. The first element of the list will be used as a default.
|
||||||
|
*
|
||||||
|
* @return a list of possible textures for this block
|
||||||
|
*/
|
||||||
|
public abstract List<Material> getTextures();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current Material this block is made of
|
||||||
|
*
|
||||||
|
* @return Material of this block
|
||||||
|
*/
|
||||||
|
public Material getMaterial() {
|
||||||
|
int n = (int) getData();
|
||||||
|
if (n > getTextures().size() - 1) {
|
||||||
|
n = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return getTextures().get(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the material this block is made of
|
||||||
|
*
|
||||||
|
* @param material
|
||||||
|
* New material of this block
|
||||||
|
*/
|
||||||
|
public void setMaterial(Material material) {
|
||||||
|
if (getTextures().contains(material)) {
|
||||||
|
setData((byte) getTextures().indexOf(material));
|
||||||
|
} else {
|
||||||
|
setData((byte) 0x0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getMaterial() + " " + super.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user