本文整理汇总了Java中cn.nukkit.item.Item.clone方法的典型用法代码示例。如果您正苦于以下问题:Java Item.clone方法的具体用法?Java Item.clone怎么用?Java Item.clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.nukkit.item.Item
的用法示例。
在下文中一共展示了Item.clone方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canAddItem
import cn.nukkit.item.Item; //导入方法依赖的package包/类
@Override
public boolean canAddItem(Item item) {
item = item.clone();
boolean checkDamage = item.hasMeta();
boolean checkTag = item.getCompoundTag() != null;
for (int i = 0; i < this.getSize(); ++i) {
Item slot = this.getItem(i);
if (item.equals(slot, checkDamage, checkTag)) {
int diff;
if ((diff = slot.getMaxStackSize() - slot.getCount()) > 0) {
item.setCount(item.getCount() - diff);
}
} else if (slot.getId() == Item.AIR) {
item.setCount(item.getCount() - this.getMaxStackSize());
}
if (item.getCount() <= 0) {
return true;
}
}
return false;
}
示例2: ShapedRecipe
import cn.nukkit.item.Item; //导入方法依赖的package包/类
public ShapedRecipe(Item result, int height, int width) {
for (int y = 0; y < height; y++) {
if (width == 0 || width > 3) {
throw new IllegalStateException("Crafting rows should be 1, 2, 3 characters, not " + width);
}
this.ingredients.put(y, new HashMap<Integer, Item>() {
{
for (int i = 0; i < width; i++) {
put(i, null);
}
}
});
}
this.output = result.clone();
}
示例3: FurnaceSmeltEvent
import cn.nukkit.item.Item; //导入方法依赖的package包/类
public FurnaceSmeltEvent(BlockEntityFurnace furnace, Item source, Item result) {
super(furnace.getBlock());
this.source = source.clone();
this.source.setCount(1);
this.result = result;
this.furnace = furnace;
}
示例4: BaseTransaction
import cn.nukkit.item.Item; //导入方法依赖的package包/类
public BaseTransaction(Inventory inventory, int slot, Item sourceItem, Item targetItem) {
this.inventory = inventory;
this.slot = slot;
this.sourceItem = sourceItem.clone();
this.targetItem = targetItem.clone();
this.creationTime = System.currentTimeMillis();
}
示例5: setItem
import cn.nukkit.item.Item; //导入方法依赖的package包/类
@Override
public boolean setItem(int index, Item item, boolean send) {
item = item.clone();
if (index < 0 || index >= this.size) {
return false;
} else if (item.getId() == 0 || item.getCount() <= 0) {
return this.clear(index);
}
InventoryHolder holder = this.getHolder();
if (holder instanceof Entity) {
EntityInventoryChangeEvent ev = new EntityInventoryChangeEvent((Entity) holder, this.getItem(index), item, index);
Server.getInstance().getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
this.sendSlot(index, this.getViewers());
return false;
}
item = ev.getNewItem();
}
Item old = this.getItem(index);
this.slots.put(index, item.clone());
this.onSlotChange(index, old, send);
return true;
}
示例6: setItem
import cn.nukkit.item.Item; //导入方法依赖的package包/类
@Override
public boolean setItem(int index, Item item) {
item = item.clone();
if (index < 0 || index >= this.size) {
return false;
} else if (item.getId() == 0 || item.getCount() <= 0) {
return this.clear(index);
}
InventoryHolder holder = this.getHolder();
if (holder instanceof Entity) {
EntityInventoryChangeEvent ev = new EntityInventoryChangeEvent((Entity) holder, this.getItem(index), item, index);
Server.getInstance().getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
this.sendSlot(index, this.getViewers());
return false;
}
item = ev.getNewItem();
}
Item old = this.getItem(index);
this.slots.put(index, item.clone());
this.onSlotChange(index, old);
return true;
}
示例7: onInteract
import cn.nukkit.item.Item; //导入方法依赖的package包/类
public boolean onInteract(Player player, Item item) {
Item change;
if (item.getId() == 0) {
this.sendHand(player);
this.sendArmor(player);
player.getInventory().sendContents(player);
return false;
} else if (item.isHelmet()) {
change = this.getHelmet();
this.setHelmet(item.clone());
} else if (item.isChestplate()) {
change = this.getChestPlate();
this.setChestPlate(item.clone());
} else if (item.isLeggings()) {
change = this.getLeggins();
this.setLeggins(item.clone());
} else if (item.isBoots()) {
change = this.getBoots();
this.setBoots(item.clone());
} else {
if (item.getCount() > 1) {
change = item.clone();
change.setCount(change.getCount() - 1);
player.getInventory().setItemInHand(change);
player.getInventory().addItem(this.getHand());
item.setCount(1);
this.setHand(item.clone());
return false;
} else {
change = this.getHand();
this.setHand(item);
}
}
player.getInventory().setItemInHand(change);
return false;
}
示例8: onActivate
import cn.nukkit.item.Item; //导入方法依赖的package包/类
@Override
public boolean onActivate(Item item, Player player) {
BlockEntity blockEntity = this.getLevel().getBlockEntity(this);
BlockEntityItemFrame itemFrame = (BlockEntityItemFrame) blockEntity;
if (itemFrame.getItem().getId() == Item.AIR) {
// We can't use Item.get(item.getId(), item.getDamage(), 1) because
// we need to keep the item's NBT tags
Item itemOnFrame = item.clone(); // So we clone the item
itemOnFrame.setCount(1); // Change it to only one item (if we keep +1, visual glitches will happen)
itemFrame.setItem(itemOnFrame); // And then we set it on the item frame
// The item will be removed from the player's hand a few lines ahead
this.getLevel().addSound(new ItemFrameItemAddedSound(this));
if (player != null && player.isSurvival()) {
int count = item.getCount();
if (count-- <= 0) {
player.getInventory().setItemInHand(new ItemBlock(new BlockAir(), 0, 0));
return true;
}
item.setCount(count);
player.getInventory().setItemInHand(item);
}
} else {
int itemRot = itemFrame.getItemRotation();
if (itemRot >= 7) {
itemRot = 0;
} else {
itemRot++;
}
itemFrame.setItemRotation(itemRot);
this.getLevel().addSound(new ItemFrameItemRotated(this));
}
return true;
}
示例9: setItem
import cn.nukkit.item.Item; //导入方法依赖的package包/类
@Override
public boolean setItem(int index, Item item, boolean send) {
item = item.clone();
if (index < 0 || index >= this.size) {
return false;
} else if (item.getId() == 0 || item.getCount() <= 0) {
return this.clear(index, send);
}
InventoryHolder holder = this.getHolder();
if (holder instanceof Entity) {
EntityInventoryChangeEvent ev = new EntityInventoryChangeEvent((Entity) holder, this, this.getItem(index), item, index);
Server.getInstance().getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
this.sendSlot(index, this.getViewers());
return false;
}
item = ev.getNewItem();
}
Item old = this.getItem(index);
this.slots.put(index, item.clone());
this.onSlotChange(index, old, send);
return true;
}
示例10: ShapelessRecipe
import cn.nukkit.item.Item; //导入方法依赖的package包/类
public ShapelessRecipe(Item result) {
this.output = result.clone();
}
示例11: setInput
import cn.nukkit.item.Item; //导入方法依赖的package包/类
public void setInput(Item item) {
ingredient = item.clone();
}
示例12: BrewingRecipe
import cn.nukkit.item.Item; //导入方法依赖的package包/类
public BrewingRecipe(Item result, Item ingredient, Item potion) {
this.output = result.clone();
this.ingredient = ingredient.clone();
this.potion = potion.clone();
}
示例13: setInput
import cn.nukkit.item.Item; //导入方法依赖的package包/类
public void setInput(Item item) {
this.ingredient = item.clone();
}