Search in sources :

Example 1 with ItemInstance

use of net.minecraft.item.ItemInstance in project StationAPI by ModificationStation.

the class MessageListenerListener method handleGiveMeDiamonds.

public void handleGiveMeDiamonds(PlayerBase playerBase, Message message) {
    playerBase.sendMessage("Have a diamond!");
    playerBase.inventory.addStack(new ItemInstance(ItemBase.diamond));
}
Also used : ItemInstance(net.minecraft.item.ItemInstance)

Example 2 with ItemInstance

use of net.minecraft.item.ItemInstance in project StationAPI by ModificationStation.

the class ContainerFreezer method transferSlot.

@Override
public ItemInstance transferSlot(int i) {
    ItemInstance itemstack = null;
    Slot slot = (Slot) slots.get(i);
    if (slot != null && slot.hasItem()) {
        ItemInstance itemstack1 = slot.getItem();
        itemstack = itemstack1.copy();
        if (i == 2) {
            insertItem(itemstack1, 3, 39, true);
        } else if (i >= 3 && i < 30) {
            insertItem(itemstack1, 30, 39, false);
        } else if (i >= 30 && i < 39) {
            insertItem(itemstack1, 3, 30, false);
        } else {
            insertItem(itemstack1, 3, 39, false);
        }
        if (itemstack1.count == 0) {
            slot.setStack(null);
        } else {
            slot.markDirty();
        }
        if (itemstack1.count != itemstack.count) {
            slot.onCrafted(itemstack1);
        } else {
            return null;
        }
    }
    return itemstack;
}
Also used : Slot(net.minecraft.container.slot.Slot) ItemInstance(net.minecraft.item.ItemInstance)

Example 3 with ItemInstance

use of net.minecraft.item.ItemInstance in project StationAPI by ModificationStation.

the class ItemListener method registerItems.

@EventListener
public void registerItems(ItemRegistryEvent event) {
    // 8475
    testItem = new ModdedItem(of(MODID, "test_item")).setTranslationKey(MODID, "testItem");
    testMaterial = ToolMaterialFactory.create("testMaterial", 3, Integer.MAX_VALUE, Float.MAX_VALUE, Integer.MAX_VALUE - 2);
    // 8476
    testPickaxe = new ModdedPickaxe(of(MODID, "test_pickaxe"), testMaterial).setTranslationKey(MODID, "testPickaxe");
    // 8477
    testNBTItem = new NBTItem(of(MODID, "nbt_item")).setTranslationKey(MODID, "nbt_item");
    testModelItem = new ModelItem(of(MODID, "model_item")).setMaxStackSize(1).setTranslationKey(MODID, "idkSomething");
    ironOre = new TemplateItemBase(Identifier.of(MODID, "ironOre")).setTranslationKey(MODID, "ironOre");
    TagRegistry.INSTANCE.register(Identifier.of("blocks/ores/iron"), new ItemInstance(ironOre), e -> ironOre.id == e.itemId);
    TagRegistry.INSTANCE.register(Identifier.of("items/tools/pickaxes/testpickaxe"), new ItemInstance(testPickaxe), (e) -> e.itemId == testPickaxe.id);
}
Also used : TemplateItemBase(net.modificationstation.stationapi.api.template.item.TemplateItemBase) ItemInstance(net.minecraft.item.ItemInstance) EventListener(net.mine_diver.unsafeevents.listener.EventListener)

Example 4 with ItemInstance

use of net.minecraft.item.ItemInstance in project StationAPI by ModificationStation.

the class TileEntityFreezer method takeInventoryItem.

@Override
public ItemInstance takeInventoryItem(int i, int j) {
    if (frozenItemStacks[i] != null) {
        if (frozenItemStacks[i].count <= j) {
            ItemInstance itemstack = frozenItemStacks[i];
            frozenItemStacks[i] = null;
            return itemstack;
        }
        ItemInstance itemstack1 = frozenItemStacks[i].split(j);
        if (frozenItemStacks[i].count == 0) {
            frozenItemStacks[i] = null;
        }
        return itemstack1;
    } else {
        return null;
    }
}
Also used : ItemInstance(net.minecraft.item.ItemInstance)

Example 5 with ItemInstance

use of net.minecraft.item.ItemInstance in project StationAPI by ModificationStation.

the class TileEntityFreezer method tick.

@Override
public void tick() {
    if (frozenPowerRemaining > 0) {
        frozenPowerRemaining--;
        if (currentFrozen != null) {
            frozenProgress++;
        }
    }
    if (currentFrozen != null && (frozenItemStacks[0] == null || frozenItemStacks[0].itemId != currentFrozen.frozenFrom.itemId)) {
        currentFrozen = null;
        frozenProgress = 0;
    }
    if (currentFrozen != null && frozenProgress >= currentFrozen.frozenPowerNeeded) {
        if (frozenItemStacks[2] == null) {
            setInventoryItem(2, new ItemInstance(currentFrozen.frozenTo.getType(), 1, currentFrozen.frozenTo.getDamage()));
        } else {
            setInventoryItem(2, new ItemInstance(currentFrozen.frozenTo.getType(), getInventoryItem(2).count + 1, currentFrozen.frozenTo.getDamage()));
        }
        if (getInventoryItem(0).itemId == ItemBase.waterBucket.id || getInventoryItem(0).itemId == ItemBase.lavaBucket.id) {
            setInventoryItem(0, new ItemInstance(ItemBase.bucket));
        } else {
            takeInventoryItem(0, 1);
        }
        frozenProgress = 0;
        currentFrozen = null;
        frozenTimeForItem = 0;
    }
    if (frozenPowerRemaining <= 0 && currentFrozen != null && getInventoryItem(1) != null && getInventoryItem(1).itemId == BlockBase.SNOW_BLOCK.id) {
        frozenPowerRemaining += 500;
        takeInventoryItem(1, 1);
    }
    if (currentFrozen == null) {
        ItemInstance itemstack = getInventoryItem(0);
        for (Frozen frozen : frozen) {
            if (itemstack == null || frozen == null || itemstack.itemId != frozen.frozenFrom.itemId || itemstack.getDamage() != frozen.frozenFrom.getDamage()) {
                continue;
            }
            if (frozenItemStacks[2] == null) {
                currentFrozen = frozen;
                frozenTimeForItem = currentFrozen.frozenPowerNeeded;
                continue;
            }
            if (frozenItemStacks[2].itemId == frozen.frozenTo.itemId && frozen.frozenTo.getType().getMaxStackSize() > frozenItemStacks[2].count) {
                currentFrozen = frozen;
                frozenTimeForItem = currentFrozen.frozenPowerNeeded;
            }
        }
    }
}
Also used : Frozen(net.modificationstation.sltest.util.Frozen) ItemInstance(net.minecraft.item.ItemInstance)

Aggregations

ItemInstance (net.minecraft.item.ItemInstance)12 TagEntry (net.modificationstation.stationapi.api.tags.TagEntry)6 EventListener (net.mine_diver.unsafeevents.listener.EventListener)3 ListenerPriority (net.mine_diver.unsafeevents.listener.ListenerPriority)2 LOGGER (net.modificationstation.stationapi.api.StationAPI.LOGGER)2 TagRegisterEvent (net.modificationstation.stationapi.api.event.tags.TagRegisterEvent)2 Entrypoint (net.modificationstation.stationapi.api.mod.entrypoint.Entrypoint)2 EventBusPolicy (net.modificationstation.stationapi.api.mod.entrypoint.EventBusPolicy)2 Identifier (net.modificationstation.stationapi.api.registry.Identifier)2 TagRegistry (net.modificationstation.stationapi.api.tags.TagRegistry)2 BlockBase (net.minecraft.block.BlockBase)1 Slot (net.minecraft.container.slot.Slot)1 ItemBase (net.minecraft.item.ItemBase)1 CompoundTag (net.minecraft.util.io.CompoundTag)1 ListTag (net.minecraft.util.io.ListTag)1 Frozen (net.modificationstation.sltest.util.Frozen)1 TemplateItemBase (net.modificationstation.stationapi.api.template.item.TemplateItemBase)1