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