use of net.minecraft.server.v1_16_R3.Item in project powerbot by powerbot.
the class DrawItems method repaint.
public void repaint(final Graphics render) {
if (!ctx.game.loggedIn()) {
return;
}
render.setFont(new Font("Arial", 0, 10));
render.setColor(Color.green);
if (ctx.bank.opened()) {
final Component container = ctx.widgets.component(Constants.BANK_WIDGET, Constants.BANK_ITEMS);
final Rectangle r = container.viewportRect();
if (r != null) {
for (final Item item : ctx.bank.select()) {
final Component c = item.component();
if (c == null) {
continue;
}
final Rectangle r2 = c.boundingRect();
if (r2 == null) {
continue;
}
if (c.relativePoint().y == 0 || !r.contains(r2)) {
continue;
}
final Point p = c.screenPoint();
render.drawString(c.itemId() + "", p.x, p.y + c.height());
}
}
}
if (ctx.backpack.component().visible()) {
for (final Item item : ctx.backpack.select()) {
final Component c = item.component();
if (c == null) {
continue;
}
final Point p = c.screenPoint();
render.drawString(c.itemId() + "", p.x, p.y + c.height());
}
}
if (ctx.equipment.component().visible()) {
for (final Item item : ctx.equipment.select()) {
if (item == null) {
continue;
}
final Component c = item.component();
if (c == null) {
continue;
}
final Point p = c.screenPoint();
render.drawString(c.itemId() + "", p.x, p.y + c.height());
}
}
}
use of net.minecraft.server.v1_16_R3.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_R3.Item in project WildChests by BG-Software-LLC.
the class NMSAdapter_v1_16_R3 method getNearbyItems.
@Override
public Stream<Item> getNearbyItems(Location location, int range, boolean onlyChunk, KeySet blacklisted, KeySet whitelisted) {
World world = ((CraftWorld) location.getWorld()).getHandle();
List<Entity> entityList = new ArrayList<>();
if (onlyChunk) {
Chunk chunk = ((CraftChunk) location.getChunk()).getHandle();
for (int i = 0; i < chunk.entitySlices.length; i++) entityList.addAll(chunk.entitySlices[i]);
entityList = entityList.stream().filter(entity -> entity instanceof EntityItem).collect(Collectors.toList());
} else {
AxisAlignedBB boundingBox = new AxisAlignedBB(location.getX() + range, location.getY() + range, location.getZ() + range, location.getX() - range, location.getY() - range, location.getZ() - range);
entityList = world.getEntities(null, boundingBox, entity -> entity instanceof EntityItem);
}
return entityList.stream().map(entity -> (Item) entity.getBukkitEntity()).filter(item -> !blacklisted.contains(item.getItemStack()) && (whitelisted.isEmpty() || whitelisted.contains(item.getItemStack())));
}
use of net.minecraft.server.v1_16_R3.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_R3.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();
}
Aggregations