13
0
geforkt von Mirrors/Paper

Add material data classes for cake, jukeboxes, and diodes. Remove some unneeded ones.

By: Celtic Minstrel <celtic.minstrel.ca@>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2011-03-26 12:29:52 -04:00
Ursprung ae9f2fb195
Commit 9c5c4622e2
4 geänderte Dateien mit 168 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -87,7 +87,7 @@ public enum Material {
CACTUS(81),
CLAY(82),
SUGAR_CANE_BLOCK(83),
JUKEBOX(84),
JUKEBOX(84, Jukebox.class),
FENCE(85),
PUMPKIN(86),
NETHERRACK(87),
@ -95,9 +95,9 @@ public enum Material {
GLOWSTONE(89),
PORTAL(90),
JACK_O_LANTERN(91),
CAKE_BLOCK(92, 1),
DIODE_BLOCK_OFF(93),
DIODE_BLOCK_ON(94),
CAKE_BLOCK(92, 1, Cake.class),
DIODE_BLOCK_OFF(93, Diode.class),
DIODE_BLOCK_ON(94, Diode.class),
// ----- Item Separator -----
IRON_SPADE(256, 1, 250),
IRON_PICKAXE(257, 1, 250),
@ -166,7 +166,7 @@ public enum Material {
GRILLED_PORK(320, 1),
PAINTING(321),
GOLDEN_APPLE(322, 1),
SIGN(323, 1, Sign.class),
SIGN(323, 1),
WOOD_DOOR(324, 1),
BUCKET(325, 1),
WATER_BUCKET(326, 1),
@ -174,7 +174,7 @@ public enum Material {
MINECART(328, 1),
SADDLE(329, 1),
IRON_DOOR(330, 1),
REDSTONE(331, RedstoneWire.class),
REDSTONE(331),
SNOW_BALL(332, 16),
BOAT(333, 1),
LEATHER(334),

Datei anzeigen

@ -0,0 +1,61 @@
package org.bukkit.material;
import org.bukkit.Material;
public class Cake extends MaterialData {
public Cake(int type) {
super(type);
}
public Cake(Material type) {
super(type);
}
public Cake(int type, byte data) {
super(type, data);
}
public Cake(Material type, byte data) {
super(type, data);
}
/**
* Gets the number of slices eaten from this cake
*
* @return The number of slices eaten
*/
public int getSlicesEaten() {
return getData();
}
/**
* Gets the number of slices remaining on this cake
*
* @return The number of slices remaining
*/
public int getSlicesRemaining() {
return 6 - getData();
}
/**
* Sets the number of slices eaten from this cake
*
* @param n The number of slices eaten
*/
public void setSlicesEaten(int n) {
if (n < 6) {
setData((byte) n);
} // TODO: else destroy the block? Probably not possible though
}
/**
* Sets the number of slices remaining on this cake
*
* @param n The number of slices remaining
*/
public void setSlicesRemaining(int n) {
if (n > 6) n = 6;
setData((byte) (6 - n));
}
}

Datei anzeigen

@ -0,0 +1,43 @@
package org.bukkit.material;
import org.bukkit.Material;
public class Diode extends MaterialData {
public Diode(int type) {
super(type);
}
public Diode(Material type) {
super(type);
}
public Diode(int type, byte data) {
super(type, data);
}
public Diode(Material type, byte data) {
super(type, data);
}
/**
* Sets the delay of the repeater
*
* @param delay The new delay (1-4)
*/
public void setDelay(int delay) {
if (delay > 4) delay = 4;
if (delay < 1) delay = 1;
byte newData = (byte) (getData() & 0x3);
setData((byte) (newData | (delay - 1)));
}
/**
* Gets the delay of the repeater
*
* @return The delay (1-4)
*/
public int getDelay() {
return (getData() & 0xC) + 1;
}
}

Datei anzeigen

@ -0,0 +1,58 @@
package org.bukkit.material;
import org.bukkit.Material;
public class Jukebox extends MaterialData {
public Jukebox(int type) {
super(type);
}
public Jukebox(Material type) {
super(type);
}
public Jukebox(int type, byte data) {
super(type, data);
}
public Jukebox(Material type, byte data) {
super(type, data);
}
/**
* Gets the type of record currently playing
*
* @return The type of record (Material.GOLD_RECORD or Material.GREEN_RECORD), or null for none.
*/
public Material getPlaying() {
switch ((int) getData()) {
default:
case 0x0:
return null;
case 0x1:
return Material.GOLD_RECORD;
case 0x2:
return Material.GREEN_RECORD;
}
}
/**
* Sets the type of record currently playing
*
* @param rec The type of record (Material.GOLD_RECORD or Material.GREEN_RECORD), or null for none.
*/
public void setPlaying(Material rec) {
if (rec == null) setData((byte) 0x0);
else switch (rec) {
case GOLD_RECORD:
setData((byte) 0x1);
break;
case GREEN_RECORD:
setData((byte) 0x2);
break;
default:
setData((byte) 0x0);
}
}
}