Search in sources :

Example 6 with SpongeBlockSnapshot

use of org.spongepowered.common.block.SpongeBlockSnapshot in project SpongeCommon by SpongePowered.

the class MixinBlockDispenser method onDispenseHead.

@Inject(method = "dispense", at = @At(value = "HEAD"))
public void onDispenseHead(World worldIn, BlockPos pos, CallbackInfo ci) {
    final IBlockState state = worldIn.getBlockState(pos);
    final SpongeBlockSnapshot spongeBlockSnapshot = ((IMixinWorldServer) worldIn).createSpongeBlockSnapshot(state, state, pos, BlockChangeFlags.ALL);
    final IMixinChunk mixinChunk = (IMixinChunk) worldIn.getChunkFromBlockCoords(pos);
    this.context = BlockPhase.State.DISPENSE.createPhaseContext().source(spongeBlockSnapshot).owner(() -> mixinChunk.getBlockOwner(pos)).notifier(() -> mixinChunk.getBlockNotifier(pos)).buildAndSwitch();
}
Also used : SpongeBlockSnapshot(org.spongepowered.common.block.SpongeBlockSnapshot) IBlockState(net.minecraft.block.state.IBlockState) IMixinChunk(org.spongepowered.common.interfaces.IMixinChunk) IMixinWorldServer(org.spongepowered.common.interfaces.world.IMixinWorldServer) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

IBlockState (net.minecraft.block.state.IBlockState)6 SpongeBlockSnapshot (org.spongepowered.common.block.SpongeBlockSnapshot)6 IMixinWorldServer (org.spongepowered.common.interfaces.world.IMixinWorldServer)4 WorldServer (net.minecraft.world.WorldServer)3 BlockSnapshot (org.spongepowered.api.block.BlockSnapshot)3 Block (net.minecraft.block.Block)2 EntityItem (net.minecraft.entity.item.EntityItem)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 BlockPos (net.minecraft.util.math.BlockPos)2 TileEntity (org.spongepowered.api.block.tileentity.TileEntity)2 Entity (org.spongepowered.api.entity.Entity)2 World (org.spongepowered.api.world.World)2 ItemDropData (org.spongepowered.common.event.tracking.context.ItemDropData)2 IMixinChunk (org.spongepowered.common.interfaces.IMixinChunk)2 IMixinTileEntity (org.spongepowered.common.interfaces.block.tile.IMixinTileEntity)2 IMixinLocation (org.spongepowered.common.interfaces.world.IMixinLocation)2 SpongeBlockChangeFlag (org.spongepowered.common.world.SpongeBlockChangeFlag)2 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1 ITileEntityProvider (net.minecraft.block.ITileEntityProvider)1