Search in sources :

Example 1 with Item

use of Item in project MechanicsMain by WeaponMechanics.

the class NonNullList_1_13_R2 method set.

@Override
public ItemStack set(int index, ItemStack newItem) {
    ItemStack oldItem = get(index);
    Item item = (Item) ReflectionUtil.invokeField(itemField, newItem);
    if (newItem.getCount() == 0 && item != null) {
        newItem.setCount(1);
        consumer.accept(CraftItemStack.asBukkitCopy(oldItem), CraftItemStack.asBukkitCopy(newItem), index);
        newItem.setCount(0);
    } else if (!ItemStack.matches(oldItem, newItem)) {
        consumer.accept(CraftItemStack.asBukkitCopy(oldItem), CraftItemStack.asBukkitCopy(newItem), index);
    }
    return super.set(index, newItem);
}
Also used : Item(net.minecraft.server.v1_13_R2.Item) ItemStack(net.minecraft.server.v1_13_R2.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack)

Example 2 with Item

use of Item in project MechanicsMain by WeaponMechanics.

the class NonNullList_1_16_R3 method set.

@Override
public ItemStack set(int index, ItemStack newItem) {
    ItemStack oldItem = get(index);
    Item item = (Item) ReflectionUtil.invokeField(itemField, newItem);
    if (newItem.getCount() == 0 && item != null) {
        newItem.setCount(1);
        consumer.accept(CraftItemStack.asBukkitCopy(oldItem), CraftItemStack.asBukkitCopy(newItem), index);
        newItem.setCount(0);
    } else if (!ItemStack.matches(oldItem, newItem)) {
        consumer.accept(CraftItemStack.asBukkitCopy(oldItem), CraftItemStack.asBukkitCopy(newItem), index);
    }
    return super.set(index, newItem);
}
Also used : Item(net.minecraft.server.v1_16_R3.Item) ItemStack(net.minecraft.server.v1_16_R3.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack)

Example 3 with Item

use of Item in project MechanicsMain by WeaponMechanics.

the class NonNullList_1_12_R1 method set.

@Override
public ItemStack set(int index, ItemStack newItem) {
    ItemStack oldItem = get(index);
    Item item = (Item) ReflectionUtil.invokeField(itemField, newItem);
    if (newItem.getCount() == 0 && item != null) {
        newItem.setCount(1);
        consumer.accept(CraftItemStack.asBukkitCopy(oldItem), CraftItemStack.asBukkitCopy(newItem), index);
        newItem.setCount(0);
    } else if (!ItemStack.matches(oldItem, newItem)) {
        consumer.accept(CraftItemStack.asBukkitCopy(oldItem), CraftItemStack.asBukkitCopy(newItem), index);
    }
    return super.set(index, newItem);
}
Also used : Item(net.minecraft.server.v1_12_R1.Item) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_12_R1.ItemStack)

Example 4 with Item

use of Item in project dodo by devhawala.

the class ChsDatabase method getEntryProperty.

// 0 => entry not found
// 1 => entry found, but not property
// 2 => entry found, but wrong property type (group, not item)
// 3 => both found
public int getEntryProperty(ThreePartName forPattern, int property, ObjectName distinguishedObject, Item value) {
    ChsEntry e = this.findEntryForPattern(forPattern);
    if (e == null) {
        return 0;
    }
    if (distinguishedObject != null) {
        distinguishedObject.object.set(e.getObjectName());
        distinguishedObject.domain.set(this.domainName);
        distinguishedObject.organization.set(this.organizationName);
    }
    Item item = e.getItemProperty(property);
    if (item != null) {
        value.clear();
        for (int i = 0; i < item.size(); i++) {
            value.add().set(item.get(i).get());
        }
        return 3;
    } else {
        return (e.getGroupProperty(property) != null) ? 2 : 1;
    }
}
Also used : Item(dev.hawala.xns.level4.chs.Clearinghouse3.Item)

Example 5 with Item

use of Item in project KomanJava by dpsclem.

the class Map method CreateRandomMap.

public static Map CreateRandomMap() {
    var table = new Cell[Map.MapWidth][Map.MapHeight];
    for (int i = 0; i < Map.MapWidth; i++) {
        for (int j = 0; j < Map.MapHeight; j++) {
            if (ThreadLocalRandom.current().nextInt(1, 11) == 1)
                table[i][j] = new Cell(CellMaterial.Wall, i, j);
            else
                table[i][j] = new Cell(CellMaterial.Floor, i, j);
        }
    }
    var randomMap = new Map(table);
    randomMap.addItemOnMap(new Item("key", 10, "file:resources/graphics/sprite/key.png"), 3, 3);
    randomMap.addItemOnMap(new Item("pioche", 10, "file:resources/graphics/sprite/pioche.png"), 3, 5);
    randomMap.addItemOnMap(new Usable("moneybag", 0, false, UsableType.MONEYBAG, null, 15, "file:resources/graphics/sprite/moneybag.png"), 8, 2);
    randomMap.addEntityOnMap(new Entity(2, 2, EntityStatus.INACTIVE, EntityType.MONSTER, "file:resources/graphics/sprite/monster1.gif"));
    return randomMap;
}
Also used : Item(Item) Entity(Entity)

Aggregations

Item (org.orcid.jaxb.model.notification.permission_v2.Item)19 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)7 Field (java.lang.reflect.Field)6 ItemStack (org.bukkit.inventory.ItemStack)5 Test (org.junit.Test)5 Items (org.orcid.jaxb.model.notification.permission_v2.Items)5 Item (net.minecraft.server.v1_8_R3.Item)3 Entity (Entity)2 Item (Item)2 Font (java.awt.Font)2 Point (java.awt.Point)2 ArrayList (java.util.ArrayList)2 Item (net.minecraft.server.v1_13_R2.Item)2 Item (net.minecraft.server.v1_14_R1.Item)2 Item (net.minecraft.server.v1_15_R1.Item)2 Item (net.minecraft.server.v1_16_R3.Item)2 MinecraftKey (net.minecraft.server.v1_8_R3.MinecraftKey)2 NBTTagCompound (net.minecraft.server.v1_8_R3.NBTTagCompound)2 Item (net.minecraft.server.v1_9_R2.Item)2 MinecraftKey (net.minecraft.server.v1_9_R2.MinecraftKey)2