• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java BlockSnapshot类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.minecraftforge.common.util.BlockSnapshot的典型用法代码示例。如果您正苦于以下问题:Java BlockSnapshot类的具体用法?Java BlockSnapshot怎么用?Java BlockSnapshot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BlockSnapshot类属于net.minecraftforge.common.util包,在下文中一共展示了BlockSnapshot类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: CraftBlockState

import net.minecraftforge.common.util.BlockSnapshot; //导入依赖的package包/类
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);
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:24,代码来源:CraftBlockState.java


示例2: fireBlockBreak

import net.minecraftforge.common.util.BlockSnapshot; //导入依赖的package包/类
/**
 * 激活方块破坏事件
 * <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();
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:29,代码来源:CaptureBlock.java


示例3: onPlayerPlacesMultiBlock

import net.minecraftforge.common.util.BlockSnapshot; //导入依赖的package包/类
/**
 * 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);
        }
    }
}
 
开发者ID:mchorse,项目名称:blockbuster,代码行数:23,代码来源:ActionHandler.java


示例4: onBlockMultiPlace

import net.minecraftforge.common.util.BlockSnapshot; //导入依赖的package包/类
@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());
            }
        }
    }
}
 
开发者ID:grondag,项目名称:Hard-Science,代码行数:18,代码来源:CommonEventHandler.java


示例5: blockBreakEvent

import net.minecraftforge.common.util.BlockSnapshot; //导入依赖的package包/类
@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);
}
 
开发者ID:DoubleDoorDevelopment,项目名称:D3Log,代码行数:23,代码来源:ForgeEventHandlers.java


示例6: setBlockAndMetaNoLighting

import net.minecraftforge.common.util.BlockSnapshot; //导入依赖的package包/类
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);
       }
}
 
开发者ID:GotoLink,项目名称:Generatormods,代码行数:22,代码来源:Building.java


示例7: place

import net.minecraftforge.common.util.BlockSnapshot; //导入依赖的package包/类
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;
}
 
开发者ID:OpenMods,项目名称:OpenModsLib,代码行数:21,代码来源:BlockManipulator.java


示例8: fireBlockPlace

import net.minecraftforge.common.util.BlockSnapshot; //导入依赖的package包/类
/**
 * 激活方块放置事件
 * <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();
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:29,代码来源:CaptureBlock.java


示例9: PlaceEvent

import net.minecraftforge.common.util.BlockSnapshot; //导入依赖的package包/类
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);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:14,代码来源:BlockEvent.java


示例10: MultiPlaceEvent

import net.minecraftforge.common.util.BlockSnapshot; //导入依赖的package包/类
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);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:9,代码来源:BlockEvent.java


示例11: onPlayerMultiBlockPlace

import net.minecraftforge.common.util.BlockSnapshot; //导入依赖的package包/类
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;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:9,代码来源:ForgeEventFactory.java


示例12: onPlayerBlockPlace

import net.minecraftforge.common.util.BlockSnapshot; //导入依赖的package包/类
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;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:8,代码来源:ForgeEventFactory.java


示例13: PlaceEvent

import net.minecraftforge.common.util.BlockSnapshot; //导入依赖的package包/类
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);
    }
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:13,代码来源:BlockEvent.java


示例14: MultiPlaceEvent

import net.minecraftforge.common.util.BlockSnapshot; //导入依赖的package包/类
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);
    }
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:9,代码来源:BlockEvent.java


示例15: onPlayerMultiBlockPlace

import net.minecraftforge.common.util.BlockSnapshot; //导入依赖的package包/类
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;
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:9,代码来源:ForgeEventFactory.java


示例16: onPlayerBlockPlace

import net.minecraftforge.common.util.BlockSnapshot; //导入依赖的package包/类
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;
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:9,代码来源:ForgeEventFactory.java


示例17: CheckBuildSpaceForAllowedBlockReplacement

import net.minecraftforge.common.util.BlockSnapshot; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:Brian-Wuest,项目名称:MC-Prefab,代码行数:47,代码来源:BuildingMethods.java


示例18: setBlockState

import net.minecraftforge.common.util.BlockSnapshot; //导入依赖的package包/类
@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;
        }
    }
}
 
开发者ID:gegy1000,项目名称:BlockSystems,代码行数:39,代码来源:BlockSystemClient.java


示例19: apply

import net.minecraftforge.common.util.BlockSnapshot; //导入依赖的package包/类
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()));
	}
 
开发者ID:tiffit,项目名称:TaleCraft,代码行数:29,代码来源:Voxelator.java


示例20: applyChanges

import net.minecraftforge.common.util.BlockSnapshot; //导入依赖的package包/类
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."
			);
}
 
开发者ID:tiffit,项目名称:TaleCraft,代码行数:14,代码来源:CachedWorldDiff.java



注:本文中的net.minecraftforge.common.util.BlockSnapshot类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BluetoothStateException类代码示例发布时间:2022-05-21
下一篇:
Java FeatureStore类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap