本文整理汇总了Java中net.minecraftforge.common.util.BlockSnapshot类的典型用法代码示例。如果您正苦于以下问题:Java BlockSnapshot类的具体用法?Java BlockSnapshot怎么用?Java BlockSnapshot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BlockSnapshot类属于net.minecraftforge.common.util包,在下文中一共展示了BlockSnapshot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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();
}
示例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);
}
}
}
示例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());
}
}
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}