Java 类net.minecraftforge.common.util.BlockSnapshot 实例源码

项目:Uranium    文件:CraftBlockState.java   
public CraftBlockState(BlockSnapshot blocksnapshot)
{
    this.world = blocksnapshot.world.getWorld();
    this.x = blocksnapshot.x;
    this.y = blocksnapshot.y;
    this.z = blocksnapshot.z;
    this.type = net.minecraft.block.Block.getIdFromBlock(blocksnapshot.replacedBlock);
    this.light = (byte) blocksnapshot.replacedBlock.getLightValue();
    this.chunk = (CraftChunk) this.world.getBlockAt(this.x, this.y, this.z).getChunk();
    this.flag = 3;
    TileEntity te = this.world.getHandle().getTileEntity(this.x, this.y, this.z);
    if (te != null)
    {
        this.nbt = new NBTTagCompound();
        te.writeToNBT(this.nbt);
    }
    else
    {
        this.nbt = null;
    }

    this.createData((byte) blocksnapshot.meta);
}
项目:Uranium    文件:CaptureBlock.java   
/**
 * 激活方块破坏事件
 * <p>
 * 此方法应该在方块被真实的放置到世界<i><b>之前</b></i>调用
 * </p>
 * 
 * @param pSnapshot
 *            被破坏的方块
 * @param pSimulate
 *            是否为模拟
 * @return 事件是否被允许
 */
public boolean fireBlockBreak(BlockSnapshot pSnapshot,boolean pSimulate){
    if(!this.mEnable||this.isChecked(pSnapshot.world,pSnapshot.x,pSnapshot.y,pSnapshot.z,pSimulate))
        return true;
    if(!this.mAllow) return false;

    this.mEnable=false; // 设置未false,防止BlockEvent中添加检查过方块
    BlockEvent tEvent=new BlockEvent.BreakEvent(pSnapshot.x,pSnapshot.y,pSnapshot.z,pSnapshot.world,
            pSnapshot.getReplacedBlock(),pSnapshot.meta,this.mCapturePlayer);
    MinecraftForge.EVENT_BUS.post(tEvent);
    this.mEnable=true;

    if(!pSimulate){
        this.mergeBlockChangeResult(!tEvent.isCanceled());
    }
    return !tEvent.isCanceled();
}
项目:blockbuster    文件:ActionHandler.java   
/**
 * Another event listener for Action.PLACE_BLOCK
 */
@SubscribeEvent
public void onPlayerPlacesMultiBlock(MultiPlaceEvent event)
{
    EntityPlayer player = event.getPlayer();
    List<Action> events = CommonProxy.manager.getActions(player);

    if (!player.worldObj.isRemote && events != null)
    {
        List<BlockSnapshot> blocks = event.getReplacedBlockSnapshots();

        for (BlockSnapshot snapshot : blocks)
        {
            IBlockState state = snapshot.getCurrentBlock();
            Block block = state.getBlock();

            this.placeBlock(events, snapshot.getPos(), block, state);
        }
    }
}
项目:ThermosRebased    文件:CraftBlockState.java   
public CraftBlockState(BlockSnapshot blocksnapshot)
{
    this.world = blocksnapshot.world.getWorld();
    this.x = blocksnapshot.x;
    this.y = blocksnapshot.y;
    this.z = blocksnapshot.z;
    this.type = net.minecraft.block.Block.getIdFromBlock(blocksnapshot.replacedBlock);
    this.light = (byte) blocksnapshot.replacedBlock.getLightValue();
    this.chunk = (CraftChunk) this.world.getBlockAt(this.x, this.y, this.z).getChunk();
    this.flag = 3;
    TileEntity te = this.world.getHandle().getTileEntity(this.x, this.y, this.z);
    if (te != null)
    {
        this.nbt = new NBTTagCompound();
        te.writeToNBT(this.nbt);
    }
    else
    {
        this.nbt = null;
    }

    this.createData((byte) blocksnapshot.meta);
}
项目:Thermos    文件:CraftBlockState.java   
public CraftBlockState(BlockSnapshot blocksnapshot)
{
    this.world = blocksnapshot.world.getWorld();
    this.x = blocksnapshot.x;
    this.y = blocksnapshot.y;
    this.z = blocksnapshot.z;
    this.type = net.minecraft.block.Block.getIdFromBlock(blocksnapshot.replacedBlock);
    this.light = (byte) blocksnapshot.replacedBlock.getLightValue();
    this.chunk = (CraftChunk) this.world.getBlockAt(this.x, this.y, this.z).getChunk();
    this.flag = 3;
    TileEntity te = this.world.getHandle().getTileEntity(this.x, this.y, this.z);
    if (te != null)
    {
        this.nbt = new NBTTagCompound();
        te.writeToNBT(this.nbt);
    }
    else
    {
        this.nbt = null;
    }

    this.createData((byte) blocksnapshot.meta);
}
项目:KCauldron    文件:CraftBlockState.java   
public CraftBlockState(BlockSnapshot blocksnapshot)
{
    this.world = blocksnapshot.world.getWorld();
    this.x = blocksnapshot.x;
    this.y = blocksnapshot.y;
    this.z = blocksnapshot.z;
    this.type = net.minecraft.block.Block.getIdFromBlock(blocksnapshot.replacedBlock);
    this.light = (byte) blocksnapshot.replacedBlock.getLightValue();
    this.chunk = (CraftChunk) this.world.getBlockAt(this.x, this.y, this.z).getChunk();
    this.flag = 3;
    TileEntity te = this.world.getHandle().getTileEntity(this.x, this.y, this.z);
    if (te != null)
    {
        this.nbt = new NBTTagCompound();
        te.writeToNBT(this.nbt);
    }
    else
    {
        this.nbt = null;
    }

    this.createData((byte) blocksnapshot.meta);
}
项目:Cauldron-Reloaded    文件:CraftBlockState.java   
public CraftBlockState(BlockSnapshot blocksnapshot)
{
    this.world = blocksnapshot.world.getWorld();
    this.x = blocksnapshot.x;
    this.y = blocksnapshot.y;
    this.z = blocksnapshot.z;
    this.type = net.minecraft.block.Block.getIdFromBlock(blocksnapshot.replacedBlock);
    this.light = (byte) blocksnapshot.replacedBlock.getLightValue();
    this.chunk = (CraftChunk) this.world.getBlockAt(this.x, this.y, this.z).getChunk();
    this.flag = 3;
    TileEntity te = this.world.getHandle().getTileEntity(this.x, this.y, this.z);
    if (te != null)
    {
        this.nbt = new NBTTagCompound();
        te.writeToNBT(this.nbt);
    }
    else
    {
        this.nbt = null;
    }

    this.createData((byte) blocksnapshot.meta);
}
项目:FFoKC    文件:CraftBlockState.java   
public CraftBlockState(BlockSnapshot blocksnapshot)
{
    this.world = blocksnapshot.world.getWorld();
    this.x = blocksnapshot.x;
    this.y = blocksnapshot.y;
    this.z = blocksnapshot.z;
    this.type = net.minecraft.block.Block.getIdFromBlock(blocksnapshot.replacedBlock);
    this.light = (byte) blocksnapshot.replacedBlock.getLightValue();
    this.chunk = (CraftChunk) this.world.getBlockAt(this.x, this.y, this.z).getChunk();
    this.flag = 3;
    TileEntity te = this.world.getHandle().getTileEntity(this.x, this.y, this.z);
    if (te != null)
    {
        this.nbt = new NBTTagCompound();
        te.writeToNBT(this.nbt);
    }
    else
    {
        this.nbt = null;
    }

    this.createData((byte) blocksnapshot.meta);
}
项目:Hard-Science    文件:CommonEventHandler.java   
@SubscribeEvent
public static void onBlockMultiPlace(BlockEvent.MultiPlaceEvent event)
{
    if(event.getWorld().isRemote) return;

    LavaSimulator sim = Simulator.instance().lavaSimulator();
    if(sim != null)
    {
        for(BlockSnapshot snap : event.getReplacedBlockSnapshots())
        {
            if(!(snap.getCurrentBlock() instanceof LavaBlock))
            {
                sim.notifyBlockChange(event.getWorld(), snap.getPos());
            }
        }
    }
}
项目:D3Log    文件:ForgeEventHandlers.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
public void blockBreakEvent(BlockEvent.BreakEvent event)
{
    BlockSnapshotLogEvent log = new BlockSnapshotLogEvent();

    log.setType(TYPE_BLOCK_BREAK);
    log.setPlayerUUID(event.getPlayer());
    log.setPosition(event.world.provider.dimensionId, event.x, event.y, event.z);
    NBTTagCompound nbt = null;
    if (event.block.hasTileEntity(event.blockMetadata))
    {
        TileEntity te = event.world.getTileEntity(event.x, event.y, event.z);
        if (te != null)
        {
            nbt = new NBTTagCompound();
            te.writeToNBT(nbt);
        }
    }
    log.setData(new BlockSnapshot(event.world, event.x, event.y, event.z, event.block, event.blockMetadata, nbt));

    LoggingQueue.addToQueue(log);
}
项目:Generatormods    文件:Building.java   
public static void setBlockAndMetaNoLighting(World world, int i, int j, int k, Block blockId, int meta, int flag) {
    if (i < 0xfe363c80 || k < 0xfe363c80 || i >= 0x1c9c380 || k >= 0x1c9c380 || j < 0 || j > Building.WORLD_MAX_Y)
        return;
    Chunk chunk = world.getChunkFromChunkCoords(i >> 4, k >> 4);
       Block oldBlock = null;
       BlockSnapshot blockSnapshot = null;
       if ((flag & 1) != 0) {
           oldBlock = chunk.getBlock(i & 15, j, k & 15);
       }
       if(world.captureBlockSnapshots){
           blockSnapshot = BlockSnapshot.getBlockSnapshot(world, i, j, k, flag);
           world.capturedBlockSnapshots.add(blockSnapshot);
       }
       boolean success = chunk.func_150807_a(i & 0xf, j, k & 0xf, blockId, meta);
       if(!success && blockSnapshot != null){
           world.capturedBlockSnapshots.remove(blockSnapshot);
       }
       if(success && blockSnapshot == null){
           world.markAndNotifyBlock(i, j, k, chunk, oldBlock, blockId, flag);
       }
}
项目:OpenModsLib    文件:BlockManipulator.java   
public boolean place(IBlockState state, EnumFacing direction, EnumHand hand) {
    if (!world.isBlockLoaded(blockPos)) return false;

    if (spawnProtection) {
        if (!world.isBlockModifiable(player, blockPos)) return false;
    }

    final BlockSnapshot snapshot = BlockSnapshot.getBlockSnapshot(world, blockPos);

    if (!world.setBlockState(blockPos, state, blockPlaceFlags)) return false;

    if (ForgeEventFactory.onPlayerBlockPlace(player, snapshot, direction, hand).isCanceled()) {
        world.restoringBlockSnapshots = true;
        snapshot.restore(true, false);
        world.restoringBlockSnapshots = false;
        return false;
    }

    return true;
}
项目:Uranium    文件:CaptureBlock.java   
/**
 * 激活方块放置事件
 * <p>
 * 此方法应该在方块被真实的放置到世界<i><b>之后</b></i>调用
 * </p>
 * 
 * @param pSnapshot
 *            被替换的方块
 * @param pPlaced
 *            放置了的方块
 * @param pSimulate
 *            是否为模拟
 * @return 事件是否被允许
 */
public boolean fireBlockPlace(BlockSnapshot pSnapshot,Block pPlaced,boolean pSimulate){
    if(!this.mEnable||this.isChecked(pSnapshot.world,pSnapshot.x,pSnapshot.y,pSnapshot.z,pSimulate))
        return true;
    if(!this.mAllow) return false;

    this.mEnable=false; // 设置未false,防止BlockEvent中添加检查过方块
    BlockEvent tEvent=ForgeEventFactory.onPlayerBlockPlace(this.mCapturePlayer,pSnapshot,this.mSide);
    this.mEnable=true;

    if(!pSimulate){
        this.mergeBlockChangeResult(!tEvent.isCanceled());
    }
    return !tEvent.isCanceled();
}
项目:CustomWorldGen    文件:BlockEvent.java   
public PlaceEvent(BlockSnapshot blockSnapshot, IBlockState placedAgainst, EntityPlayer player, @Nullable EnumHand hand) {
    super(blockSnapshot.getWorld(), blockSnapshot.getPos(), blockSnapshot.getCurrentBlock());
    this.player = player;
    this.itemInHand = player.getHeldItem(hand != null ? hand : EnumHand.MAIN_HAND);
    this.blockSnapshot = blockSnapshot;
    this.placedBlock = blockSnapshot.getCurrentBlock();
    this.placedAgainst = placedAgainst;
    this.hand = hand;
    if (DEBUG)
    {
        System.out.printf("Created PlaceEvent - [PlacedBlock: %s ][PlacedAgainst: %s ][ItemStack: %s ][Player: %s ][Hand: %s]\n", getPlacedBlock(), placedAgainst, getItemInHand(), player, hand);
    }
}
项目:CustomWorldGen    文件:BlockEvent.java   
public MultiPlaceEvent(List<BlockSnapshot> blockSnapshots, IBlockState placedAgainst, EntityPlayer player, @Nullable EnumHand hand) {
    super(blockSnapshots.get(0), placedAgainst, player, hand);
    this.blockSnapshots = ImmutableList.copyOf(blockSnapshots);
    if (DEBUG)
    {
        System.out.printf("Created MultiPlaceEvent - [PlacedAgainst: %s ][ItemInHand: %s ][Player: %s ]\n", placedAgainst, this.getItemInHand(), player);
    }
}
项目:CustomWorldGen    文件:ForgeEventFactory.java   
public static MultiPlaceEvent onPlayerMultiBlockPlace(EntityPlayer player, List<BlockSnapshot> blockSnapshots, EnumFacing direction, @Nullable EnumHand hand)
{
    BlockSnapshot snap = blockSnapshots.get(0);
    IBlockState placedAgainst = snap.getWorld().getBlockState(snap.getPos().offset(direction.getOpposite()));
    MultiPlaceEvent event = new MultiPlaceEvent(blockSnapshots, placedAgainst, player, hand);
    MinecraftForge.EVENT_BUS.post(event);
    return event;
}
项目:CustomWorldGen    文件:ForgeEventFactory.java   
public static PlaceEvent onPlayerBlockPlace(EntityPlayer player, BlockSnapshot blockSnapshot, EnumFacing direction, @Nullable EnumHand hand)
{
    IBlockState placedAgainst = blockSnapshot.getWorld().getBlockState(blockSnapshot.getPos().offset(direction.getOpposite()));
    PlaceEvent event = new PlaceEvent(blockSnapshot, placedAgainst, player, hand);
    MinecraftForge.EVENT_BUS.post(event);
    return event;
}
项目:TRHS_Club_Mod_2016    文件:BlockEvent.java   
public PlaceEvent(BlockSnapshot blockSnapshot, Block placedAgainst, EntityPlayer player) {
    super(blockSnapshot.x, blockSnapshot.y, blockSnapshot.z, blockSnapshot.world, blockSnapshot.getCurrentBlock(), blockSnapshot.meta);
    this.player = player;
    this.itemInHand = player.func_71045_bC();
    this.blockSnapshot = blockSnapshot;
    this.placedBlock = blockSnapshot.getCurrentBlock();
    this.placedAgainst = placedAgainst;
    if (DEBUG)
    {
        System.out.printf("Created PlaceEvent - [PlacedBlock: %s ][PlacedAgainst: %s ][ItemStack: %s ][Player: %s ]\n", placedBlock, placedAgainst, player.func_71045_bC(), player);
    }
}
项目:TRHS_Club_Mod_2016    文件:BlockEvent.java   
public MultiPlaceEvent(List<BlockSnapshot> blockSnapshots, Block placedAgainst, EntityPlayer player) {
    super(blockSnapshots.get(0), placedAgainst, player);
    this.blockSnapshots = ImmutableList.copyOf(blockSnapshots);
    if (DEBUG)
    {
        System.out.printf("Created MultiPlaceEvent - [PlacedAgainst: %s ][ItemInHand: %s ][Player: %s ]\n", placedAgainst, this.itemInHand, player);
    }
}
项目:TRHS_Club_Mod_2016    文件:ForgeEventFactory.java   
public static MultiPlaceEvent onPlayerMultiBlockPlace(EntityPlayer player, List<BlockSnapshot> blockSnapshots, ForgeDirection direction)
{
    Block placedAgainst = blockSnapshots.get(0).world.func_147439_a(blockSnapshots.get(0).x + direction.getOpposite().offsetX, blockSnapshots.get(0).y + direction.getOpposite().offsetY, blockSnapshots.get(0).z + direction.getOpposite().offsetZ);

    MultiPlaceEvent event = new MultiPlaceEvent(blockSnapshots, placedAgainst, player);
    MinecraftForge.EVENT_BUS.post(event);
    return event;
}
项目:TRHS_Club_Mod_2016    文件:ForgeEventFactory.java   
public static PlaceEvent onPlayerBlockPlace(EntityPlayer player, BlockSnapshot blockSnapshot, ForgeDirection direction)
{
    Block placedAgainst = blockSnapshot.world.func_147439_a(blockSnapshot.x + direction.getOpposite().offsetX, blockSnapshot.y + direction.getOpposite().offsetY, blockSnapshot.z + direction.getOpposite().offsetZ);

    PlaceEvent event = new PlaceEvent(blockSnapshot, placedAgainst, player);
    MinecraftForge.EVENT_BUS.post(event);
    return event;
}
项目:MC-Prefab    文件:BuildingMethods.java   
/**
 * This method is used to determine if the player can build the structure.
 * 
 * @param configuration The structure configuration.
 * @param world The world to build the structure in.
 * @param startBlockPos The start location to start checking blocks.
 * @param endBlockPos The end location for checking blocks. Combined with the startBlockPos, this should be a cube.
 * @param player The player running this build request.
 * @return True if all blocks can be replaced. Otherwise false and send a
 *         message to the player.
 */
public static boolean CheckBuildSpaceForAllowedBlockReplacement(StructureConfiguration configuration, World world, BlockPos startBlockPos, BlockPos endBlockPos, EntityPlayer player)
{
    // Check each block in the space to be cleared if it's protected from
    // breaking or placing, if it is return false.
    for (BlockPos currentPos : BlockPos.getAllInBox(startBlockPos, endBlockPos))
    {
        IBlockState blockState = world.getBlockState(currentPos);

        if (!blockState.getBlock().isAir(blockState, world, currentPos))
        {
            BlockEvent.BreakEvent breakEvent = new BlockEvent.BreakEvent(world, currentPos, world.getBlockState(currentPos), player);

            if (MinecraftForge.EVENT_BUS.post(breakEvent))
            {
                return false;
            }
        }

        BlockEvent.PlaceEvent placeEvent = new BlockEvent.PlaceEvent(new BlockSnapshot(world, currentPos, blockState), Blocks.AIR.getDefaultState(), player, EnumHand.MAIN_HAND);

        if (MinecraftForge.EVENT_BUS.post(placeEvent))
        {
            return false;
        }

        // A hardness of less than 0 is unbreakable.
        if (blockState.getBlockHardness(world, currentPos) < 0.0f)
        {
            // This is bedrock or some other type of unbreakable block. Don't allow this block to be broken by a structure.
            return false;
        }
    }

    return true;
}
项目:BlockSystems    文件:BlockSystemClient.java   
@Override
public boolean setBlockState(BlockPos pos, IBlockState newState, int flags) {
    if (!this.isValid(pos)) {
        return false;
    } else if (!this.isRemote && this.worldInfo.getTerrainType() == WorldType.DEBUG_WORLD) {
        return false;
    } else {
        Chunk chunk = this.getChunkFromBlockCoords(pos);
        if (chunk instanceof EmptyBlockSystemChunk) {
            chunk = this.chunkProviderClient.loadChunk(pos.getX() >> 4, pos.getZ() >> 4);
        }
        BlockSnapshot snapshot = null;
        if (this.captureBlockSnapshots && !this.isRemote) {
            snapshot = BlockSnapshot.getBlockSnapshot(this, pos, flags);
            this.capturedBlockSnapshots.add(snapshot);
        }
        IBlockState oldState = this.getBlockState(pos);
        int oldLight = oldState.getLightValue(this, pos);
        int oldOpacity = oldState.getLightOpacity(this, pos);
        IBlockState state = chunk.setBlockState(pos, newState);
        if (state == null) {
            if (snapshot != null) {
                this.capturedBlockSnapshots.remove(snapshot);
            }
            return false;
        } else {
            if (newState.getLightOpacity(this, pos) != oldOpacity || newState.getLightValue(this, pos) != oldLight) {
                this.theProfiler.startSection("checkLight");
                this.checkLight(pos);
                this.theProfiler.endSection();
            }
            if (snapshot == null) {
                this.markAndNotifyBlock(pos, chunk, state, newState, flags);
            }
            return true;
        }
    }
}
项目:TaleCraft    文件:Voxelator.java   
public static void apply(VXShape shape, VXPredicate predicate, VXAction action, World world, EntityPlayer player) {

        final BlockPos center = shape.getCenter();
        final BlockRegion region = shape.getRegion();
        final MutableBlockPos offset = new MutableBlockPos(center);

        final List<BlockSnapshot> previous = Lists.newArrayList();
        final List<BlockSnapshot> changes = Lists.newArrayList();

        final CachedWorldDiff fworld = new CachedWorldDiff(world, previous, changes);

        UndoRegion before = new UndoRegion(region, world);

        for(final BlockPos pos : BlockPos.getAllInBox(region.getMin(), region.getMax())) {
            offset.set(pos);
            offset.__sub(center);
            if(shape.test(pos, center, offset, fworld)) {
                if(predicate.test(pos, center, offset, fworld)){
                    action.apply(pos, center, offset, fworld);
                }
            }
        }

        fworld.applyChanges(true);

        UndoRegion after = new UndoRegion(region, world);
        UndoTask.TASKS.add(new UndoTask(before, after, "Voxelator", player.getName()));
    }
项目:TaleCraft    文件:CachedWorldDiff.java   
public void applyChanges(boolean physics) {
    long time = System.currentTimeMillis();
    int changeCount = 0;
    for(BlockSnapshot snapshot : changes) {
        previous.add(BlockSnapshot.getBlockSnapshot(world, snapshot.getPos()));
        snapshot.restore(true, physics);
        changeCount++;
    }

    TaleCraft.logger.info("Changed " + changeCount
            + " block(s). Operation took " + ((double)System.currentTimeMillis()-(double)time)/1000D + "s."
            );
}
项目:ItemBlacklist    文件:ServerEventHandlers.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void multiPlaceEvent(BlockEvent.MultiPlaceEvent event)
{
    EntityPlayer player = event.getPlayer();
    ItemStack itemInHand = event.getItemInHand();
    if (player == null || itemInHand == null) return;
    if (!Helper.shouldCare(event.getPlayer())) return;
    if (GlobalBanList.isBanned(player.dimension, itemInHand))
    {
        player.sendStatusMessage(new TextComponentString(ItemBlacklist.message), true);
        if (ItemBlacklist.log) ItemBlacklist.getLogger().info("{} tried to use {} at {} (Place Block. Banned Item in hand)", player.getName(), itemInHand.getDisplayName(), event.getPos());
        if (event.isCancelable())
            event.setCanceled(true);
        GlobalBanList.process(player.dimension, player.inventory);
    }
    else
    {
        for (BlockSnapshot blockSnapshot : event.getReplacedBlockSnapshots())
        {
            IBlockState blockState = blockSnapshot.getCurrentBlock();
            Block block = blockState.getBlock();
            Item item = Item.getItemFromBlock(block);
            //if (item == null) continue;
            ItemStack stack = new ItemStack(item, 1, block.damageDropped(blockState));
            if (!GlobalBanList.isBanned(player.dimension, stack)) continue;
            player.sendStatusMessage(new TextComponentString(ItemBlacklist.message), true);
            if (ItemBlacklist.log) ItemBlacklist.getLogger().info("{} tried to use {} at {} (Place Block. Banned Item placed.)", player.getName(), itemInHand.getDisplayName(), event.getPos());
            if (event.isCancelable())
                event.setCanceled(true);
            GlobalBanList.process(player.dimension, player.inventory);
            break;
        }
    }
}
项目:D3Log    文件:BlockPlaceLogEvent.java   
@Override
public void rollback()
{
    if (blockPlaceData == null) return;
    if (blockPlaceData.before != null)
    {
        for (BlockSnapshot snapshot : blockPlaceData.before)
        {
            snapshot.world = DimensionManager.getWorld(snapshot.dimId);
            snapshot.restore(true);
        }
    }
}
项目:D3Log    文件:ForgeEventHandlers.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
public void blockPlaceEvent(BlockEvent.PlaceEvent event)
{
    BlockPlaceLogEvent log = new BlockPlaceLogEvent();

    log.setType(TYPE_BLOCK_PLACE);
    log.setPlayerUUID(event.player);
    log.setPosition(event.world.provider.dimensionId, event.x, event.y, event.z);
    log.setItemHolding(event.itemInHand);
    NBTTagCompound nbt = null;
    if (event.block.hasTileEntity(event.blockMetadata))
    {
        TileEntity te = event.world.getTileEntity(event.x, event.y, event.z);
        if (te != null)
        {
            nbt = new NBTTagCompound();
            te.writeToNBT(nbt);
        }
    }
    log.setAfter(new BlockSnapshot(event.world, event.x, event.y, event.z, event.block, event.blockMetadata, nbt));
    if (event instanceof BlockEvent.MultiPlaceEvent)
    {
         log.setBefore(((BlockEvent.MultiPlaceEvent) event).getReplacedBlockSnapshots().toArray(new BlockSnapshot[((BlockEvent.MultiPlaceEvent) event).getReplacedBlockSnapshots().size()]));
    }
    else
    {
        log.setBefore(event.blockSnapshot);
    }
    LoggingQueue.addToQueue(log);
}
项目:HardModeTweaks    文件:SleepManager.java   
@SubscribeEvent
public void blockPlaceEvent(BlockEvent.MultiPlaceEvent event) {
    if (event.getPlacedBlock().getBlock() instanceof BlockBed) {
        BedPlacements bedPlacements = getBedPlacements(event.getWorld());
        for (BlockSnapshot snap : event.getReplacedBlockSnapshots()) {
            bedPlacements.onBedPlaced(event.getWorld(), snap.getPos());
        }
    }
}
项目:Uranium    文件:CraftWorld.java   
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
    net.minecraft.world.gen.feature.WorldGenerator gen;
    switch (type) {
    case BIG_TREE:
        gen = new net.minecraft.world.gen.feature.WorldGenBigTree(true);
        break;
    case BIRCH:
        gen = new net.minecraft.world.gen.feature.WorldGenForest(true, false);
        break;
    case REDWOOD:
        gen = new net.minecraft.world.gen.feature.WorldGenTaiga2(true);
        break;
    case TALL_REDWOOD:
        gen = new net.minecraft.world.gen.feature.WorldGenTaiga1();
        break;
    case JUNGLE:
        gen = new net.minecraft.world.gen.feature.WorldGenMegaJungle(true, 10, 20, 3, 3); // Magic values as in BlockSapling
        break;
    case SMALL_JUNGLE:
        gen = new net.minecraft.world.gen.feature.WorldGenTrees(true, 4 + rand.nextInt(7), 3, 3, false);
        break;
    case JUNGLE_BUSH:
        gen = new net.minecraft.world.gen.feature.WorldGenShrub(3, 0);
        break;
    case RED_MUSHROOM:
        gen = new net.minecraft.world.gen.feature.WorldGenBigMushroom(1);
        break;
    case BROWN_MUSHROOM:
        gen = new net.minecraft.world.gen.feature.WorldGenBigMushroom(0);
        break;
    case SWAMP:
        gen = new net.minecraft.world.gen.feature.WorldGenSwamp();
        break;
    case ACACIA:
        gen = new net.minecraft.world.gen.feature.WorldGenSavannaTree(true);
        break;
    case DARK_OAK:
        gen = new net.minecraft.world.gen.feature.WorldGenCanopyTree(true);
        break;
    case MEGA_REDWOOD:
        gen = new net.minecraft.world.gen.feature.WorldGenMegaPineTree(true, rand.nextBoolean());
        break;
    case TALL_BIRCH:
        gen = new net.minecraft.world.gen.feature.WorldGenForest(true, true);
        break;
    case TREE:
    default:
        gen = new net.minecraft.world.gen.feature.WorldGenTrees(true);
        break;
    }

    CaptureTree tCapture=world.mCapture.startTreeGenCapture(null,loc);
    boolean grownTree = gen.generate(world, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
    tCapture.markHandled();
    if (grownTree) { // Copy block data to delegate
        for (BlockSnapshot blocksnapshot : tCapture.mCapturedBlocks) {
            int x = blocksnapshot.x;
            int y = blocksnapshot.y;
            int z = blocksnapshot.z;
            net.minecraft.block.Block oldBlock = world.getBlock(x, y, z); 
            int newId = net.minecraft.block.Block.getIdFromBlock(blocksnapshot.replacedBlock);
            int data = blocksnapshot.meta;
            int flag = blocksnapshot.flag;
            delegate.setTypeIdAndData(x, y, z, newId, data);
            net.minecraft.block.Block newBlock = world.getBlock(x, y, z); 
            world.markAndNotifyBlock(x, y, z, null, oldBlock, newBlock, flag);
        }
        return true;
    }
    else {
        return false;
    }
}
项目:Uranium    文件:ACapture.java   
protected BlockSnapshot addCapturedBlock(World pWorld,int pPosX,int pPosY,int pPosZ){
    return this.addCapturedBlock(pWorld,pPosX,pPosY,pPosZ,3);
}
项目:Uranium    文件:ACapture.java   
protected BlockSnapshot addCapturedBlock(World pWorld,int pPosX,int pPosY,int pPosZ,int pFlag){
    return this.addCapturedBlock(BlockSnapshot.getBlockSnapshot(pWorld,pPosX,pPosY,pPosZ,pFlag));
}
项目:Uranium    文件:ACapture.java   
protected BlockSnapshot addCapturedBlock(BlockSnapshot pSnapshot){
    if(!this.mEnable) return pSnapshot;

    this.mCapturedBlocks.add(pSnapshot);
    return pSnapshot;
}
项目:CustomWorldGen    文件:BlockEvent.java   
@Deprecated
public PlaceEvent(BlockSnapshot blockSnapshot, IBlockState placedAgainst, EntityPlayer player)
{
    this(blockSnapshot, placedAgainst, player, null);
}
项目:CustomWorldGen    文件:BlockEvent.java   
@Deprecated
public MultiPlaceEvent(List<BlockSnapshot> blockSnapshots, IBlockState placedAgainst, EntityPlayer player)
{
    this(blockSnapshots, placedAgainst, player, null);
}
项目:CustomWorldGen    文件:ForgeEventFactory.java   
/**
 * @deprecated Use {@link #onPlayerMultiBlockPlace(EntityPlayer, List, EnumFacing, EnumHand)} instead.
 */
@Deprecated
public static MultiPlaceEvent onPlayerMultiBlockPlace(EntityPlayer player, List<BlockSnapshot> blockSnapshots, EnumFacing direction)
{
    return onPlayerMultiBlockPlace(player, blockSnapshots, direction, null);
}
项目:CustomWorldGen    文件:ForgeEventFactory.java   
/**
 * @deprecated Use {@link #onPlayerBlockPlace(EntityPlayer, BlockSnapshot, EnumFacing, EnumHand)} instead.
 */
@Deprecated
public static PlaceEvent onPlayerBlockPlace(EntityPlayer player, BlockSnapshot blockSnapshot, EnumFacing direction)
{
    return onPlayerBlockPlace(player, blockSnapshot, direction, null);
}
项目:ThermosRebased    文件:CraftWorld.java   
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
    net.minecraft.world.gen.feature.WorldGenerator gen;
    switch (type) {
    case BIG_TREE:
        gen = new net.minecraft.world.gen.feature.WorldGenBigTree(true);
        break;
    case BIRCH:
        gen = new net.minecraft.world.gen.feature.WorldGenForest(true, false);
        break;
    case REDWOOD:
        gen = new net.minecraft.world.gen.feature.WorldGenTaiga2(true);
        break;
    case TALL_REDWOOD:
        gen = new net.minecraft.world.gen.feature.WorldGenTaiga1();
        break;
    case JUNGLE:
        gen = new net.minecraft.world.gen.feature.WorldGenMegaJungle(true, 10, 20, 3, 3); // Magic values as in BlockSapling
        break;
    case SMALL_JUNGLE:
        gen = new net.minecraft.world.gen.feature.WorldGenTrees(true, 4 + rand.nextInt(7), 3, 3, false);
        break;
    case JUNGLE_BUSH:
        gen = new net.minecraft.world.gen.feature.WorldGenShrub(3, 0);
        break;
    case RED_MUSHROOM:
        gen = new net.minecraft.world.gen.feature.WorldGenBigMushroom(1);
        break;
    case BROWN_MUSHROOM:
        gen = new net.minecraft.world.gen.feature.WorldGenBigMushroom(0);
        break;
    case SWAMP:
        gen = new net.minecraft.world.gen.feature.WorldGenSwamp();
        break;
    case ACACIA:
        gen = new net.minecraft.world.gen.feature.WorldGenSavannaTree(true);
        break;
    case DARK_OAK:
        gen = new net.minecraft.world.gen.feature.WorldGenCanopyTree(true);
        break;
    case MEGA_REDWOOD:
        gen = new net.minecraft.world.gen.feature.WorldGenMegaPineTree(true, rand.nextBoolean());
        break;
    case TALL_BIRCH:
        gen = new net.minecraft.world.gen.feature.WorldGenForest(true, true);
        break;
    case TREE:
    default:
        gen = new net.minecraft.world.gen.feature.WorldGenTrees(true);
        break;
    }

    world.captureTreeGeneration = true;
    world.captureBlockSnapshots = true;
    boolean grownTree = gen.generate(world, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
    world.captureBlockSnapshots = false;
    world.captureTreeGeneration = false;
    if (grownTree) { // Copy block data to delegate
        for (BlockSnapshot blocksnapshot : world.capturedBlockSnapshots) {
            int x = blocksnapshot.x;
            int y = blocksnapshot.y;
            int z = blocksnapshot.z;
            net.minecraft.block.Block oldBlock = world.getBlock(x, y, z); 
            int newId = net.minecraft.block.Block.getIdFromBlock(blocksnapshot.replacedBlock);
            int data = blocksnapshot.meta;
            int flag = blocksnapshot.flag;
            delegate.setTypeIdAndData(x, y, z, newId, data);
            net.minecraft.block.Block newBlock = world.getBlock(x, y, z); 
            world.markAndNotifyBlock(x, y, z, null, oldBlock, newBlock, flag);
        }
        world.capturedBlockSnapshots.clear();
        return true;
    }
    else {
        world.capturedBlockSnapshots.clear();
        return false;
    }
}
项目:TaleCraft    文件:CachedWorldDiff.java   
public CachedWorldDiff(World world, List<BlockSnapshot> previous, List<BlockSnapshot> changes) {
    this.world = world;
    this.changes = changes;
    this.previous = previous;
}
项目:TaleCraft    文件:CachedWorldDiff.java   
public void setBlockState(BlockPos pos, IBlockState newState) {
    changes.add(new BlockSnapshot(world, pos, newState));
}