Search in sources :

Example 16 with CraftItemStack

use of org.bukkit.craftbukkit.v.inventory.CraftItemStack in project Arclight by IzzelAliz.

the class StonecuttingRecipeMixin method bridge$toBukkitRecipe.

@Override
public Recipe bridge$toBukkitRecipe() {
    CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
    CraftStonecuttingRecipe recipe = new CraftStonecuttingRecipe(CraftNamespacedKey.fromMinecraft(this.getId()), result, CraftRecipe.toBukkit(this.ingredient));
    recipe.setGroup(this.group);
    return recipe;
}
Also used : CraftItemStack(org.bukkit.craftbukkit.v.inventory.CraftItemStack) CraftStonecuttingRecipe(org.bukkit.craftbukkit.v.inventory.CraftStonecuttingRecipe)

Example 17 with CraftItemStack

use of org.bukkit.craftbukkit.v.inventory.CraftItemStack in project Arclight by IzzelAliz.

the class CampfireTileEntityMixin method cookAndDrop.

/**
 * @author IzzelAliz
 * @reason
 */
@Overwrite
private void cookAndDrop() {
    for (int i = 0; i < this.inventory.size(); ++i) {
        ItemStack before = this.inventory.get(i);
        if (!before.isEmpty()) {
            ++this.cookingTimes[i];
            if (this.cookingTimes[i] >= this.cookingTotalTimes[i]) {
                IInventory iinventory = new Inventory(before);
                ItemStack after = this.world.getRecipeManager().getRecipe(IRecipeType.CAMPFIRE_COOKING, iinventory, this.world).map((cookingRecipe) -> cookingRecipe.getCraftingResult(iinventory)).orElse(before);
                BlockPos blockpos = this.getPos();
                CraftItemStack craftBefore = CraftItemStack.asCraftMirror(before);
                org.bukkit.inventory.ItemStack bukkitAfter = CraftItemStack.asBukkitCopy(after);
                BlockCookEvent event = new BlockCookEvent(CraftBlock.at(this.world, this.pos), craftBefore, bukkitAfter);
                Bukkit.getPluginManager().callEvent(event);
                if (event.isCancelled()) {
                    continue;
                }
                ItemStack cookFinal = CraftItemStack.asNMSCopy(event.getResult());
                InventoryHelper.spawnItemStack(this.world, blockpos.getX(), blockpos.getY(), blockpos.getZ(), cookFinal);
                this.inventory.set(i, ItemStack.EMPTY);
                this.inventoryChanged();
            }
        }
    }
}
Also used : IInventory(net.minecraft.inventory.IInventory) CraftItemStack(org.bukkit.craftbukkit.v.inventory.CraftItemStack) BlockCookEvent(org.bukkit.event.block.BlockCookEvent) InventoryHelper(net.minecraft.inventory.InventoryHelper) Inventory(net.minecraft.inventory.Inventory) BlockPos(net.minecraft.util.math.BlockPos) Overwrite(org.spongepowered.asm.mixin.Overwrite) Final(org.spongepowered.asm.mixin.Final) IRecipeType(net.minecraft.item.crafting.IRecipeType) CampfireTileEntity(net.minecraft.tileentity.CampfireTileEntity) ItemStack(net.minecraft.item.ItemStack) Mixin(org.spongepowered.asm.mixin.Mixin) IInventory(net.minecraft.inventory.IInventory) CraftBlock(org.bukkit.craftbukkit.v.block.CraftBlock) TileEntityType(net.minecraft.tileentity.TileEntityType) Shadow(org.spongepowered.asm.mixin.Shadow) TileEntity(net.minecraft.tileentity.TileEntity) NonNullList(net.minecraft.util.NonNullList) Bukkit(org.bukkit.Bukkit) CraftItemStack(org.bukkit.craftbukkit.v.inventory.CraftItemStack) BlockPos(net.minecraft.util.math.BlockPos) CraftItemStack(org.bukkit.craftbukkit.v.inventory.CraftItemStack) ItemStack(net.minecraft.item.ItemStack) BlockCookEvent(org.bukkit.event.block.BlockCookEvent) Inventory(net.minecraft.inventory.Inventory) IInventory(net.minecraft.inventory.IInventory) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Aggregations

CraftItemStack (org.bukkit.craftbukkit.v.inventory.CraftItemStack)17 ItemStack (net.minecraft.item.ItemStack)8 Overwrite (org.spongepowered.asm.mixin.Overwrite)6 IInventory (net.minecraft.inventory.IInventory)5 IInventoryBridge (io.izzel.arclight.common.bridge.inventory.IInventoryBridge)3 DoubleSidedInventory (net.minecraft.inventory.DoubleSidedInventory)3 BlockPos (net.minecraft.util.math.BlockPos)3 CraftInventoryDoubleChest (org.bukkit.craftbukkit.v.inventory.CraftInventoryDoubleChest)3 InventoryMoveItemEvent (org.bukkit.event.inventory.InventoryMoveItemEvent)3 Inventory (org.bukkit.inventory.Inventory)3 ServerPlayerEntityBridge (io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge)2 IWorldPosCallableBridge (io.izzel.arclight.common.bridge.util.IWorldPosCallableBridge)2 Random (java.util.Random)2 EnchantmentData (net.minecraft.enchantment.EnchantmentData)2 Ingredient (net.minecraft.item.crafting.Ingredient)2 Bukkit (org.bukkit.Bukkit)2 Final (org.spongepowered.asm.mixin.Final)2 Mixin (org.spongepowered.asm.mixin.Mixin)2 Shadow (org.spongepowered.asm.mixin.Shadow)2 Inject (org.spongepowered.asm.mixin.injection.Inject)2