本文整理汇总了Java中ethanjones.cubes.item.ItemStack类的典型用法代码示例。如果您正苦于以下问题:Java ItemStack类的具体用法?Java ItemStack怎么用?Java ItemStack使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ItemStack类属于ethanjones.cubes.item包,在下文中一共展示了ItemStack类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CreativeInventory
import ethanjones.cubes.item.ItemStack; //导入依赖的package包/类
public CreativeInventory() {
super("core:creative");
fixed = true;
voidInputItems = true;
ArrayList<ItemStack> list = new ArrayList<ItemStack>();
for (ItemBlock itemBlock : IDManager.getItemBlocks()) {
for (int j : itemBlock.block.displayMetaValues()) {
list.add(new ItemStack(itemBlock, itemBlock.getStackCountMax(), j));
}
}
for (Item item : IDManager.getItems()) {
list.add(new ItemStack(item, item.getStackCountMax()));
}
int n=list.size();
while (n % 9 != 0 ||n < 27) {
list.add(null);
n= list.size();
}
itemStacks = list.toArray(new ItemStack[list.size()]);
}
示例2: updateCrafting
import ethanjones.cubes.item.ItemStack; //导入依赖的package包/类
public void updateCrafting(boolean reduce) {
if (reduce) {
for (int i = 0; i < 9; i++) {
if (itemStacks[i] != null) InventoryHelper.reduceCount(this, i);
}
}
ItemStack stack = CraftingManager.match(this);
if (stack != null) {
output.itemStacks[0] = stack;
output.stack = true;
} else {
output.itemStacks[0] = null;
output.stack = false;
}
}
示例3: updateIf1
import ethanjones.cubes.item.ItemStack; //导入依赖的package包/类
private void updateIf1() {
ItemTool.mine(client.getPlayer(), clickType == ClickType.mine);
ItemStack itemStack = client.getPlayer().getInventory().selectedItemStack();
boolean b = true;
BlockIntersection blockIntersection = BlockIntersection.getBlockIntersection(client.getPlayer().position,
client.getPlayer().angle, server.world);
if (blockIntersection != null) {
BlockReference r = blockIntersection.getBlockReference();
b = !server.world.getBlock(r.blockX, r.blockY, r.blockZ).onButtonPress(clickType, client.getPlayer(),
r.blockX, r.blockY, r.blockZ);
}
if (b && itemStack != null) {
b = !itemStack.item.onButtonPress(clickType, itemStack, client.getPlayer(),
client.getPlayer().getInventory().hotbarSelected);
}
if (clickType == ClickType.place)
clickType = ClickType.none;
}
示例4: CreativeInventory
import ethanjones.cubes.item.ItemStack; //导入依赖的package包/类
public CreativeInventory() {
super("core:creative");
fixed = true;
voidInputItems = true;
ArrayList<ItemStack> list = new ArrayList<ItemStack>();
for (ItemBlock itemBlock : IDManager.getItemBlocks()) {
for (int j : itemBlock.block.displayMetaValues()) {
list.add(new ItemStack(itemBlock, itemBlock.getStackCountMax(), j));
}
}
for (Item item : IDManager.getItems()) {
list.add(new ItemStack(item, item.getStackCountMax()));
}
while (list.size() % 9 != 0 || list.size() < 27) {
list.add(null);
}
itemStacks = list.toArray(new ItemStack[list.size()]);
}
示例5: PlayerInventory
import ethanjones.cubes.item.ItemStack; //导入依赖的package包/类
public PlayerInventory(Player player) {
super("core:player", 36);
this.hotbarSelected = 0;
this.player = player;
// start with tools
this.itemStacks[0] = new ItemStack(Items.pickaxe);
this.itemStacks[1] = new ItemStack(Items.axe);
this.itemStacks[2] = new ItemStack(Items.shovel);
}
示例6: handlePacket
import ethanjones.cubes.item.ItemStack; //导入依赖的package包/类
@Override
public void handlePacket() {
ClientIdentifier client = Cubes.getServer().getClient(getSocketMonitor());
PlayerInventory inventory = client.getPlayer().getInventory();
ItemStack itemStack = InventoryHelper.reduceCount(inventory, inventory.hotbarSelected);
if (itemStack != null) {
ItemEntity itemEntity = new ItemEntity();
itemEntity.itemStack = itemStack;
itemEntity.position.set(client.getPlayer().position);
itemEntity.motion.set(client.getPlayer().angle);
itemEntity.age = -3000 / Cubes.tickMS;
Cubes.getServer().world.addEntity(itemEntity);
}
}
示例7: transferIf2
import ethanjones.cubes.item.ItemStack; //导入依赖的package包/类
private static boolean transferIf2(Inventory targetInv, int targetNum){
if (targetInv.cancelInputItems) {
return true;
} else if (targetInv.fixed) {
if (targetInv.voidInputItems) {
itemActor.itemStack.count = 0;
} else {
return true;
}
} else if (targetInv.itemStacks[targetNum] == null) {
ItemStack copy = itemActor.itemStack.copy();
if (m.modifier()) {
copy.count = 1;
targetInv.itemStacks[targetNum] = copy;
itemActor.itemStack.count--;
} else {
targetInv.itemStacks[targetNum] = copy;
itemActor.itemStack.count = 0;
}
} else if (InventoryHelper.sameItem(targetInv.itemStacks[targetNum], itemActor.itemStack)) {
int transferAmount = Math.min(m.modifier() ? 1 : itemActor.itemStack.count,
itemActor.itemStack.item.getStackCountMax() - targetInv.itemStacks[targetNum].count);
targetInv.itemStacks[targetNum].count += transferAmount;
itemActor.itemStack.count -= transferAmount;
} else {
ItemStack i = itemActor.itemStack;
itemActor.itemStack = targetInv.itemStacks[targetNum];
targetInv.itemStacks[targetNum] = i;
}
}
示例8: ItemActor
import ethanjones.cubes.item.ItemStack; //导入依赖的package包/类
public ItemActor(final ItemStack itemStack, Inventory inventory, final int num) {
super(new ItemDrawable(false));
this.itemStack = itemStack;
this.inventory = inventory;
this.num = num;
setSize(32f, 32f);
setTouchable(Touchable.disabled);
setVisible(!Compatibility.get().isTouchScreen());
}
示例9: drawText
import ethanjones.cubes.item.ItemStack; //导入依赖的package包/类
public static void drawText(Batch batch, float x, float y, ItemStack itemStack) {
if (itemStack == null || itemStack.item.getStackCountMax() == 1) return;
BitmapFontCache cache = Fonts.smallHUD.getCache();
cache.clear();
GlyphLayout layout = cache.addText(Integer.toString(itemStack.count), x, y, 32f, Align.right, false);
cache.translate(0, layout.height);
cache.draw(batch);
}
示例10: enter
import ethanjones.cubes.item.ItemStack; //导入依赖的package包/类
@Override
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
ItemStack stack = actor.getStack();
if (stack == null)
return;
inside = true;
tooltip.setItemStack(stack);
tooltip.setVisible(true);
tmp.set(x, y);
event.getListenerActor().localToStageCoordinates(tmp);
tooltip.setPosition(tmp.x + position.x + offset.x, tmp.y + position.y + offset.y);
tooltip.toFront();
}
示例11: reduceCount
import ethanjones.cubes.item.ItemStack; //导入依赖的package包/类
public static ItemStack reduceCount(Inventory inventory, int stack) {
if (inventory.itemStacks[stack] == null) return null;
Item item = inventory.itemStacks[stack].item;
int meta = inventory.itemStacks[stack].meta;
if (inventory.itemStacks[stack].count > 1) {
inventory.itemStacks[stack].count--;
} else {
inventory.itemStacks[stack] = null;
}
inventory.sync();
return new ItemStack(item, 1, meta);
}
示例12: addItemstack
import ethanjones.cubes.item.ItemStack; //导入依赖的package包/类
public static void addItemstack(Inventory inventory, ItemStack itemstack) {
for (int i = 0; i < inventory.itemStacks.length; i++) {
if (inventory.itemStacks[i] == null) {
inventory.itemStacks[i] = itemstack;
break;
} else if (inventory.itemStacks[i].item == itemstack.item && inventory.itemStacks[i].meta == itemstack.meta) {
if (inventory.itemStacks[i].count + itemstack.count <= itemstack.item.getStackCountMax()) {
inventory.itemStacks[i].count += itemstack.count;
break;
}
}
}
inventory.sync();
}
示例13: read
import ethanjones.cubes.item.ItemStack; //导入依赖的package包/类
@Override
public void read(DataGroup dataGroup) {
DataGroup[] groups = dataGroup.getArray("itemstacks", DataGroup.class);
if (itemStacks.length != groups.length)
itemStacks = new ItemStack[groups.length];
for (int i = 0; i < itemStacks.length; i++) {
DataGroup d = groups[i];
if (d.size() > 0) {
itemStacks[i] = ItemStack.readItemStack(d);
} else {
itemStacks[i] = null;
}
}
}
示例14: parseStack
import ethanjones.cubes.item.ItemStack; //导入依赖的package包/类
public static ItemStack parseStack(JsonValue js) {
if (js.isString()) {
return new ItemStack(getItem(js.asString()));
} else if (js.isObject()) {
JsonObject obj = js.asObject();
JsonValue id = obj.get("id");
if (id == null)
throw new JsonException("No id");
return new ItemStack(getItem(id.asString()), obj.getInt("count", 1), obj.getInt("meta", 0));
} else if (js.isNull()) {
return null;
}
throw new JsonException("Invalid type " + js.toString());
}
示例15: match
import ethanjones.cubes.item.ItemStack; //导入依赖的package包/类
public static ItemStack match(CraftingInventory inventory) {
for (CraftingRecipe craftingRecipe : crafting_manager.list) {
ItemStack stack = craftingRecipe.match(inventory);
if (stack != null) return stack.copy();
}
return null;
}