Permalink
Browse files

Update the BaseItem classes

  • Loading branch information...
me4502 committed Jun 12, 2018
1 parent e39d453 commit 3ac47dc955552f452e38ec94d90448611ebc5cd7
@@ -19,6 +19,10 @@
package com.sk89q.worldedit.blocks;
import com.sk89q.worldedit.blocks.type.ItemType;
import com.sk89q.worldedit.blocks.type.ItemTypes;
import com.sk89q.worldedit.world.registry.BundledItemData;
import java.util.HashMap;
import java.util.Map;
@@ -30,18 +34,27 @@
*/
public class BaseItem {
private int id;
private short data;
private final Map<Integer, Integer> enchantments = new HashMap<Integer, Integer>();
private ItemType itemType;
private short damage;
private final Map<Integer, Integer> enchantments = new HashMap<>();
/**
* Construct the object.
*
* @param id ID of the item
*/
@Deprecated
public BaseItem(int id) {
this.id = id;
this.data = 0;
this(id, (short) 0);
}
/**
* Construct the object.
*
* @param itemType Type of the item
*/
public BaseItem(ItemType itemType) {
this.itemType = itemType;
}
/**
@@ -50,65 +63,89 @@ public BaseItem(int id) {
* @param id ID of the item
* @param data data value of the item
*/
@Deprecated
public BaseItem(int id, short data) {
this.id = id;
this.data = data;
setType(id);
this.damage = data;
}
/**
* Construct the object.
*
* @param itemType Type of the item
* @param damage Damage value of the item
*/
public BaseItem(ItemType itemType, short damage) {
this.itemType = itemType;
this.damage = damage;
}
/**
* Get the type of item.
*
* @return the id
*/
@Deprecated
public int getType() {
return id;
return this.itemType.getLegacyId();
}
/**
* Get the type of item.
* Set the type of item.
*
* @param id the id to set
*/
@Deprecated
public void setType(int id) {
this.id = id;
ItemType type = ItemTypes.getItemType(BundledItemData.getInstance().fromLegacyId(id));
setItemType(type);
}
/**
* Set the type of the item.
*
* @param itemType The type to set
*/
public void setItemType(ItemType itemType) {
this.itemType = itemType;
}
/**
* Get the damage value.
*
* @return the damage
*/
@Deprecated
public short getDamage() {
return data;
return this.damage;
}
/**
* Get the data value.
*
* @return the data
*/
@Deprecated
public short getData() {
return data;
return this.damage;
}
/**
* Set the data value.
*
* @param data the damage to set
* @param damage the damage to set
*/
@Deprecated
public void setDamage(short data) {
this.data = data;
public void setDamage(short damage) {
this.damage = damage;
}
/**
* Set the data value.
*
* @param data the damage to set
*/
@Deprecated
public void setData(short data) {
this.data = data;
this.damage = data;
}
/**
@@ -19,6 +19,8 @@
package com.sk89q.worldedit.blocks;
import com.sk89q.worldedit.blocks.type.ItemType;
/**
* Represents a stack of BaseItems.
*
@@ -33,33 +35,68 @@
*
* @param id with data value of 0.
*/
@Deprecated
public BaseItemStack(int id) {
super(id);
}
/**
* Construct the object with default stack size of one, with damage value of 0.
*
* @param itemType The item type
*/
public BaseItemStack(ItemType itemType) {
super(itemType);
}
/**
* Construct the object.
*
* @param id type ID
* @param amount amount in the stack
*/
@Deprecated
public BaseItemStack(int id, int amount) {
super(id);
this.amount = amount;
}
/**
* Construct the object.
*
* @param itemType The item type
* @param amount amount in the stack
*/
public BaseItemStack(ItemType itemType, int amount) {
super(itemType);
this.amount = amount;
}
/**
* Construct the object.
*
* @param id type ID
* @param amount amount in the stack
* @param data data value
*/
@Deprecated
public BaseItemStack(int id, int amount, short data) {
super(id, data);
this.amount = amount;
}
/**
* Construct the object.
*
* @param id The item type
* @param amount amount in the stack
* @param damage Damage value
*/
public BaseItemStack(ItemType id, int amount, short damage) {
super(id, damage);
this.amount = amount;
}
/**
* Get the number of items in the stack.
*
@@ -21,7 +21,10 @@
/**
* List of block IDs.
*
* {@Deprecated Please use {@link com.sk89q.worldedit.blocks.type.BlockTypes}}
*/
@Deprecated
public final class BlockID {
public static final int AIR = 0;
public static final int STONE = 1;
@@ -21,7 +21,10 @@
/**
* List of item IDs.
*
* {@Deprecated Please use {@link com.sk89q.worldedit.blocks.type.ItemTypes}}
*/
@Deprecated
public final class ItemID {
public static final int IRON_SHOVEL = 256;
Oops, something went wrong.

0 comments on commit 3ac47dc

Please sign in to comment.