Search in sources :

Example 1 with Surrogate

use of org.spongepowered.asm.mixin.injection.Surrogate in project SpongeCommon by SpongePowered.

the class MixinBlockDropper method afterDispense.

@Surrogate
private void afterDispense(World worldIn, BlockPos pos, CallbackInfo callbackInfo, BlockSourceImpl blocksourceimpl, TileEntityDispenser tileentitydispenser, int i, ItemStack itemstack, ItemStack itemstack1) {
    // after setInventorySlotContents
    tileentitydispenser.setInventorySlotContents(i, itemstack1);
    // Transfer worked if remainder is one less than the original stack
    if (itemstack1.getCount() == itemstack.getCount() - 1) {
        IMixinInventory capture = forCapture(tileentitydispenser);
        Inventory sourceInv = toInventory(tileentitydispenser);
        SpongeCommonEventFactory.captureTransaction(capture, sourceInv, i, itemstack);
        EnumFacing enumfacing = (EnumFacing) worldIn.getBlockState(pos).getValue(BlockDispenser.FACING);
        BlockPos blockpos = pos.offset(enumfacing);
        IInventory iinventory = TileEntityHopper.getInventoryAtPosition(worldIn, (double) blockpos.getX(), (double) blockpos.getY(), (double) blockpos.getZ());
        SpongeCommonEventFactory.callTransferPost(capture, sourceInv, toInventory(iinventory));
    }
    callbackInfo.cancel();
}
Also used : IInventory(net.minecraft.inventory.IInventory) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) IMixinInventory(org.spongepowered.common.interfaces.IMixinInventory) Inventory(org.spongepowered.api.item.inventory.Inventory) IInventory(net.minecraft.inventory.IInventory) IMixinInventory(org.spongepowered.common.interfaces.IMixinInventory) Surrogate(org.spongepowered.asm.mixin.injection.Surrogate)

Aggregations

IInventory (net.minecraft.inventory.IInventory)1 EnumFacing (net.minecraft.util.EnumFacing)1 BlockPos (net.minecraft.util.math.BlockPos)1 Inventory (org.spongepowered.api.item.inventory.Inventory)1 Surrogate (org.spongepowered.asm.mixin.injection.Surrogate)1 IMixinInventory (org.spongepowered.common.interfaces.IMixinInventory)1