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);
}
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);
}
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);
}
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;
}
}
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;
}
Aggregations