use of net.minecraft.server.v1_16_R2.Item in project powerbot by powerbot.
the class TicketDestroy method poll.
@Override
public void poll() {
if (ctx.properties.getProperty("key.token.disable", "").equals("true")) {
// TODO: review this random event
return;
}
final Item item = ctx.backpack.select().id(Constants.TICKETDESTROY_ITEMS).poll();
if (!item.valid() || !ctx.hud.opened(Hud.Window.BACKPACK) || !ctx.players.local().idle()) {
priority.set(0);
return;
}
priority.set(3);
if (!ctx.backpack.scroll(item)) {
return;
}
if (((ctx.varpbits.varpbit(1448) & 0xFF00) >>> 8) < (item.id() == Constants.TICKETDESTROY_ITEMS[0] ? 10 : 9)) {
item.interact("Claim");
return;
}
if (!item.interact("Destroy")) {
return;
}
final Widget widget = ctx.widgets.widget(1183);
if (!Condition.wait(new Condition.Check() {
@Override
public boolean poll() {
return widget.valid();
}
})) {
return;
}
Component component = null;
for (final Component c : widget.components()) {
if (c.visible() && c.tooltip().trim().equalsIgnoreCase("destroy")) {
component = c;
break;
}
}
if (component != null && component.interact("Destroy")) {
Condition.wait(new Condition.Check() {
@Override
public boolean poll() {
return item.component().itemId() == -1;
}
}, 175);
}
}
use of net.minecraft.server.v1_16_R2.Item in project PublicCrafters by BananaPuncher714.
the class CustomInventoryCrafting method setItems.
protected void setItems(List<org.bukkit.inventory.ItemStack> items) {
int index = 0;
for (org.bukkit.inventory.ItemStack item : items) {
this.items.set(index++, CraftItemStack.asNMSCopy(item));
}
// Want to update the result without having to use a real player
if (this.resultInventory instanceof InventoryCraftResult) {
CustomContainerWorkbench container = new CustomContainerWorkbench(0, manager.mockPlayer.getBukkitEntity(), bloc, this, (InventoryCraftResult) resultInventory);
container.a(this);
CraftingInventory crafting = (CraftingInventory) container.getBukkitView().getTopInventory();
Bukkit.getPluginManager().callEvent(new PrepareItemCraftEvent(crafting, container.getBukkitView(), false));
}
display.forceUpdate();
}
use of net.minecraft.server.v1_16_R2.Item in project PublicCrafters by BananaPuncher714.
the class CustomInventoryCrafting method setItem.
@Override
public void setItem(int index, ItemStack item) {
// Instead of updating one container, update all the containers
// That are looking at the table, basically the viewers
items.set(index, item);
for (Container container : containers) {
container.a(this);
}
// Update the armorstand grid
display.update();
}
use of net.minecraft.server.v1_16_R2.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 net.minecraft.server.v1_16_R2.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);
}
Aggregations