Search in sources :

Example 11 with Item

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());
        }
    }
}
Also used : Item(org.powerbot.script.rt6.Item) Rectangle(java.awt.Rectangle) Point(java.awt.Point) Component(org.powerbot.script.rt6.Component) Font(java.awt.Font)

Example 12 with Item

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);
    }
}
Also used : Condition(org.powerbot.script.Condition) Item(org.powerbot.script.rt6.Item) Widget(org.powerbot.script.rt6.Widget) Component(org.powerbot.script.rt6.Component)

Example 13 with Item

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())));
}
Also used : AxisAlignedBB(net.minecraft.server.v1_16_R3.AxisAlignedBB) InventoryHolder(com.bgsoftware.wildchests.objects.inventory.InventoryHolder) DataInputStream(java.io.DataInputStream) AxisAlignedBB(net.minecraft.server.v1_16_R3.AxisAlignedBB) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Entity(net.minecraft.server.v1_16_R3.Entity) Item(org.bukkit.entity.Item) Inventory(org.bukkit.inventory.Inventory) CraftHumanEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftHumanEntity) ArrayList(java.util.ArrayList) Location(org.bukkit.Location) ByteArrayInputStream(java.io.ByteArrayInputStream) DataOutputStream(java.io.DataOutputStream) NBTTagCompound(net.minecraft.server.v1_16_R3.NBTTagCompound) BigInteger(java.math.BigInteger) ChestType(com.bgsoftware.wildchests.api.objects.ChestType) KeySet(com.bgsoftware.wildchests.key.KeySet) Material(org.bukkit.Material) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack) NBTTagList(net.minecraft.server.v1_16_R3.NBTTagList) TileEntityChest(net.minecraft.server.v1_16_R3.TileEntityChest) World(net.minecraft.server.v1_16_R3.World) HumanEntity(org.bukkit.entity.HumanEntity) EntityItem(net.minecraft.server.v1_16_R3.EntityItem) DataOutput(java.io.DataOutput) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) EntityHuman(net.minecraft.server.v1_16_R3.EntityHuman) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) Collectors(java.util.stream.Collectors) Particle(org.bukkit.Particle) ItemStack(net.minecraft.server.v1_16_R3.ItemStack) Base64(java.util.Base64) List(java.util.List) Stream(java.util.stream.Stream) NBTReadLimiter(net.minecraft.server.v1_16_R3.NBTReadLimiter) CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk) Chunk(net.minecraft.server.v1_16_R3.Chunk) NBTCompressedStreamTools(net.minecraft.server.v1_16_R3.NBTCompressedStreamTools) Entity(net.minecraft.server.v1_16_R3.Entity) CraftHumanEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftHumanEntity) HumanEntity(org.bukkit.entity.HumanEntity) Item(org.bukkit.entity.Item) EntityItem(net.minecraft.server.v1_16_R3.EntityItem) ArrayList(java.util.ArrayList) World(net.minecraft.server.v1_16_R3.World) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk) Chunk(net.minecraft.server.v1_16_R3.Chunk) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk) EntityItem(net.minecraft.server.v1_16_R3.EntityItem)

Example 14 with Item

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();
}
Also used : CraftingInventory(org.bukkit.inventory.CraftingInventory) PublicCraftingInventory(io.github.bananapuncher714.crafters.implementation.api.PublicCraftingInventory) PrepareItemCraftEvent(org.bukkit.event.inventory.PrepareItemCraftEvent) InventoryCraftResult(net.minecraft.server.v1_16_R3.InventoryCraftResult)

Example 15 with Item

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();
}
Also used : Container(net.minecraft.server.v1_16_R3.Container) SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_16_R3.ContainerManager_v1_16_R3.SelfContainer)

Aggregations

Item (org.orcid.jaxb.model.notification.permission_v2.Item)19 CraftItemStack (org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack)10 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)7 Field (java.lang.reflect.Field)6 NBTTagCompound (net.minecraft.server.v1_16_R3.NBTTagCompound)6 ItemStack (org.bukkit.inventory.ItemStack)6 Test (org.junit.Test)5 Items (org.orcid.jaxb.model.notification.permission_v2.Items)5 ArrayList (java.util.ArrayList)4 CraftPlayer (org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer)3 CraftFakePlayerImpl (com.denizenscript.denizen.nms.v1_16.impl.entities.CraftFakePlayerImpl)2 EntityItemProjectileImpl (com.denizenscript.denizen.nms.v1_16.impl.entities.EntityItemProjectileImpl)2 EntityTag (com.denizenscript.denizen.objects.EntityTag)2 ItemTag (com.denizenscript.denizen.objects.ItemTag)2 PlayerTag (com.denizenscript.denizen.objects.PlayerTag)2 FakeEntity (com.denizenscript.denizen.utilities.entity.FakeEntity)2 Mechanism (com.denizenscript.denizencore.objects.Mechanism)2 Font (java.awt.Font)2 Point (java.awt.Point)2 Item (net.minecraft.server.v1_13_R2.Item)2