mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 00:07:56 +01:00
Renamed ItemStack.set/getDamage to durability, which is now a short. Added Material.getMaxDurability
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
63181e1c59
commit
6f3347fe1c
@ -95,10 +95,11 @@ public enum Material {
|
|||||||
PORTAL(90),
|
PORTAL(90),
|
||||||
JACK_O_LANTERN(91),
|
JACK_O_LANTERN(91),
|
||||||
CAKE_BLOCK(92, 1),
|
CAKE_BLOCK(92, 1),
|
||||||
IRON_SPADE(256),
|
// ----- Item Separator -----
|
||||||
IRON_PICKAXE(257),
|
IRON_SPADE(256, 1, 250),
|
||||||
IRON_AXE(258),
|
IRON_PICKAXE(257, 1, 250),
|
||||||
FLINT_AND_STEEL(259, 1),
|
IRON_AXE(258, 1, 250),
|
||||||
|
FLINT_AND_STEEL(259, 1, 64),
|
||||||
APPLE(260, 1),
|
APPLE(260, 1),
|
||||||
BOW(261, 1),
|
BOW(261, 1),
|
||||||
ARROW(262),
|
ARROW(262),
|
||||||
@ -106,57 +107,57 @@ public enum Material {
|
|||||||
DIAMOND(264),
|
DIAMOND(264),
|
||||||
IRON_INGOT(265),
|
IRON_INGOT(265),
|
||||||
GOLD_INGOT(266),
|
GOLD_INGOT(266),
|
||||||
IRON_SWORD(267, 1),
|
IRON_SWORD(267, 1, 59),
|
||||||
WOOD_SWORD(268, 1),
|
WOOD_SWORD(268, 1, 59),
|
||||||
WOOD_SPADE(269, 1),
|
WOOD_SPADE(269, 1, 59),
|
||||||
WOOD_PICKAXE(270, 1),
|
WOOD_PICKAXE(270, 1, 59),
|
||||||
WOOD_AXE(271, 1),
|
WOOD_AXE(271, 1, 59),
|
||||||
STONE_SWORD(272, 1),
|
STONE_SWORD(272, 1, 131),
|
||||||
STONE_SPADE(273, 1),
|
STONE_SPADE(273, 1, 131),
|
||||||
STONE_PICKAXE(274, 1),
|
STONE_PICKAXE(274, 1, 131),
|
||||||
STONE_AXE(275, 1),
|
STONE_AXE(275, 1, 131),
|
||||||
DIAMOND_SWORD(276, 1),
|
DIAMOND_SWORD(276, 1, 1561),
|
||||||
DIAMOND_SPADE(277, 1),
|
DIAMOND_SPADE(277, 1, 1561),
|
||||||
DIAMOND_PICKAXE(278, 1),
|
DIAMOND_PICKAXE(278, 1, 1561),
|
||||||
DIAMOND_AXE(279, 1),
|
DIAMOND_AXE(279, 1, 1561),
|
||||||
STICK(280),
|
STICK(280),
|
||||||
BOWL(281),
|
BOWL(281),
|
||||||
MUSHROOM_SOUP(282, 1),
|
MUSHROOM_SOUP(282, 1),
|
||||||
GOLD_SWORD(283, 1),
|
GOLD_SWORD(283, 1, 32),
|
||||||
GOLD_SPADE(284, 1),
|
GOLD_SPADE(284, 1, 32),
|
||||||
GOLD_PICKAXE(285, 1),
|
GOLD_PICKAXE(285, 1, 32),
|
||||||
GOLD_AXE(286, 1),
|
GOLD_AXE(286, 1, 32),
|
||||||
STRING(287),
|
STRING(287),
|
||||||
FEATHER(288),
|
FEATHER(288),
|
||||||
SULPHUR(289),
|
SULPHUR(289),
|
||||||
WOOD_HOE(290, 1),
|
WOOD_HOE(290, 1, 59),
|
||||||
STONE_HOE(291, 1),
|
STONE_HOE(291, 1, 131),
|
||||||
IRON_HOE(292, 1),
|
IRON_HOE(292, 1, 250),
|
||||||
DIAMOND_HOE(293, 1),
|
DIAMOND_HOE(293, 1, 1561),
|
||||||
GOLD_HOE(294, 1),
|
GOLD_HOE(294, 1, 32),
|
||||||
SEEDS(295),
|
SEEDS(295),
|
||||||
WHEAT(296),
|
WHEAT(296),
|
||||||
BREAD(297, 1),
|
BREAD(297, 1),
|
||||||
LEATHER_HELMET(298, 1),
|
LEATHER_HELMET(298, 1, 33),
|
||||||
LEATHER_CHESTPLATE(299, 1),
|
LEATHER_CHESTPLATE(299, 1, 47),
|
||||||
LEATHER_LEGGINGS(300, 1),
|
LEATHER_LEGGINGS(300, 1, 45),
|
||||||
LEATHER_BOOTS(301, 1),
|
LEATHER_BOOTS(301, 1, 39),
|
||||||
CHAINMAIL_HELMET(302, 1),
|
CHAINMAIL_HELMET(302, 1, 66),
|
||||||
CHAINMAIL_CHESTPLATE(303, 1),
|
CHAINMAIL_CHESTPLATE(303, 1, 95),
|
||||||
CHAINMAIL_LEGGINGS(304, 1),
|
CHAINMAIL_LEGGINGS(304, 1, 91),
|
||||||
CHAINMAIL_BOOTS(305, 1),
|
CHAINMAIL_BOOTS(305, 1, 78),
|
||||||
IRON_HELMET(306, 1),
|
IRON_HELMET(306, 1, 135),
|
||||||
IRON_CHESTPLATE(307, 1),
|
IRON_CHESTPLATE(307, 1, 191),
|
||||||
IRON_LEGGINGS(308, 1),
|
IRON_LEGGINGS(308, 1, 183),
|
||||||
IRON_BOOTS(309, 1),
|
IRON_BOOTS(309, 1, 159),
|
||||||
DIAMOND_HELMET(310, 1),
|
DIAMOND_HELMET(310, 1, 271),
|
||||||
DIAMOND_CHESTPLATE(311, 1),
|
DIAMOND_CHESTPLATE(311, 1, 383),
|
||||||
DIAMOND_LEGGINGS(312, 1),
|
DIAMOND_LEGGINGS(312, 1, 367),
|
||||||
DIAMOND_BOOTS(313, 1),
|
DIAMOND_BOOTS(313, 1, 319),
|
||||||
GOLD_HELMET(314, 1),
|
GOLD_HELMET(314, 1, 67),
|
||||||
GOLD_CHESTPLATE(315, 1),
|
GOLD_CHESTPLATE(315, 1, 95),
|
||||||
GOLD_LEGGINGS(316, 1),
|
GOLD_LEGGINGS(316, 1, 91),
|
||||||
GOLD_BOOTS(317, 1),
|
GOLD_BOOTS(317, 1, 79),
|
||||||
FLINT(318),
|
FLINT(318),
|
||||||
PORK(319, 1),
|
PORK(319, 1),
|
||||||
GRILLED_PORK(320, 1),
|
GRILLED_PORK(320, 1),
|
||||||
@ -185,7 +186,7 @@ public enum Material {
|
|||||||
POWERED_MINECART(343, 1),
|
POWERED_MINECART(343, 1),
|
||||||
EGG(344, 16),
|
EGG(344, 16),
|
||||||
COMPASS(345),
|
COMPASS(345),
|
||||||
FISHING_ROD(346),
|
FISHING_ROD(346, 1, 64),
|
||||||
WATCH(347),
|
WATCH(347),
|
||||||
GLOWSTONE_DUST(348),
|
GLOWSTONE_DUST(348),
|
||||||
RAW_FISH(349),
|
RAW_FISH(349),
|
||||||
@ -202,6 +203,7 @@ public enum Material {
|
|||||||
private static final Map<Integer, Material> lookupId = new HashMap<Integer, Material>();
|
private static final Map<Integer, Material> lookupId = new HashMap<Integer, Material>();
|
||||||
private static final Map<String, Material> lookupName = new HashMap<String, Material>();
|
private static final Map<String, Material> lookupName = new HashMap<String, Material>();
|
||||||
private final int maxStack;
|
private final int maxStack;
|
||||||
|
private final short durability;
|
||||||
|
|
||||||
private Material(final int id) {
|
private Material(final int id) {
|
||||||
this(id, 64);
|
this(id, 64);
|
||||||
@ -211,14 +213,23 @@ public enum Material {
|
|||||||
this(id, stack, null);
|
this(id, stack, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Material(final int id, final int stack, final int durability) {
|
||||||
|
this(id, stack, durability, null);
|
||||||
|
}
|
||||||
|
|
||||||
private Material(final int id, final Class<? extends MaterialData> data) {
|
private Material(final int id, final Class<? extends MaterialData> data) {
|
||||||
this(id, 64, data);
|
this(id, 64, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Material(final int id, final int stack, final Class<? extends MaterialData> data) {
|
private Material(final int id, final int stack, final Class<? extends MaterialData> data) {
|
||||||
|
this(id, -1, stack, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Material(final int id, final int durability, final int stack, final Class<? extends MaterialData> data) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.data = data;
|
this.durability = (short)durability;
|
||||||
this.maxStack = stack;
|
this.maxStack = stack;
|
||||||
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -239,6 +250,15 @@ public enum Material {
|
|||||||
return maxStack;
|
return maxStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the maximum durability of this material
|
||||||
|
*
|
||||||
|
* @return Maximum durability for this material
|
||||||
|
*/
|
||||||
|
public short getMaxDurability() {
|
||||||
|
return durability;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the MaterialData class associated with this Material
|
* Gets the MaterialData class associated with this Material
|
||||||
*
|
*
|
||||||
|
@ -11,7 +11,7 @@ public class ItemStack {
|
|||||||
private int type;
|
private int type;
|
||||||
private int amount = 0;
|
private int amount = 0;
|
||||||
private MaterialData data = null;
|
private MaterialData data = null;
|
||||||
private byte damage = 0;
|
private short durability = 0;
|
||||||
|
|
||||||
public ItemStack(final int type) {
|
public ItemStack(final int type) {
|
||||||
this(type, 0);
|
this(type, 0);
|
||||||
@ -22,32 +22,32 @@ public class ItemStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack(final int type, final int amount) {
|
public ItemStack(final int type, final int amount) {
|
||||||
this(type, amount, (byte) 0);
|
this(type, amount, (short) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack(final Material type, final int amount) {
|
public ItemStack(final Material type, final int amount) {
|
||||||
this(type.getId(), amount);
|
this(type.getId(), amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack(final int type, final int amount, final byte damage) {
|
public ItemStack(final int type, final int amount, final short damage) {
|
||||||
this(type, amount, damage, null);
|
this(type, amount, damage, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack(final Material type, final int amount, final byte damage) {
|
public ItemStack(final Material type, final int amount, final short damage) {
|
||||||
this(type.getId(), amount, damage);
|
this(type.getId(), amount, damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack(final int type, final int amount, final byte damage, final Byte data) {
|
public ItemStack(final int type, final int amount, final short damage, final Byte data) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
this.damage = damage;
|
this.durability = damage;
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
createData(data);
|
createData(data);
|
||||||
this.damage = data;
|
this.durability = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack(final Material type, final int amount, final byte damage, final Byte data) {
|
public ItemStack(final Material type, final int amount, final short damage, final Byte data) {
|
||||||
this(type.getId(), amount, damage, data);
|
this(type.getId(), amount, damage, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,29 +140,21 @@ public class ItemStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the damage of this item<br /><br />
|
* Sets the durability of this item
|
||||||
*
|
*
|
||||||
* 0x00 represents an item which cannot be damaged<br />
|
* @param durability Durability of this item
|
||||||
* 0x01 represents an item at maximum health<br />
|
|
||||||
* 0x32 represents an item with no health left
|
|
||||||
*
|
|
||||||
* @param damage Damage of this item
|
|
||||||
*/
|
*/
|
||||||
public void setDamage(final byte damage) {
|
public void setDurability(final short durability) {
|
||||||
this.damage = damage;
|
this.durability = durability;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the damage of this item<br /><br />
|
* Gets the durability of this item
|
||||||
*
|
*
|
||||||
* 0x00 represents an item which cannot be damaged<br />
|
* @return Durability of this item
|
||||||
* 0x01 represents an item at maximum health<br />
|
|
||||||
* 0x32 represents an item with no health left
|
|
||||||
*
|
|
||||||
* @return Damage of this item
|
|
||||||
*/
|
*/
|
||||||
public byte getDamage() {
|
public short getDurability() {
|
||||||
return damage;
|
return durability;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user