当前位置: 首页>>代码示例>>Java>>正文


Java BlockEvent类代码示例

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


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

示例1: fireBlockBreak

import net.minecraftforge.event.world.BlockEvent; //导入依赖的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

示例2: blockBreakEvent

import net.minecraftforge.event.world.BlockEvent; //导入依赖的package包/类
@SubscribeEvent
public void blockBreakEvent(BlockEvent.BreakEvent event)
{
    EntityPlayer player = event.getPlayer();
    ItemStack OmniItem = null;
    if(EnchantmentHelper.getEnchantmentLevel(ModEnchantment.runicenchantment, player.getHeldItem(EnumHand.MAIN_HAND) )>0)
        OmniItem = player.getHeldItem(EnumHand.MAIN_HAND);
    else if(EnchantmentHelper.getEnchantmentLevel(ModEnchantment.runicenchantment, player.getHeldItem(EnumHand.OFF_HAND) )>0)
        OmniItem = player.getHeldItem(EnumHand.OFF_HAND);
    else return;

    CompiledSymbol[] script = ModDust.getScriptFromItem(OmniItem);
    if(script==null)return;

    new ScriptExecutor(script, player, OmniItem, ScriptExecutor.StartPoint.BLOCK_BREAK, event.getPos());
}
 
开发者ID:Drazuam,项目名称:RunicArcana,代码行数:17,代码来源:ScriptActivationEventHandler.java

示例3: onWitherBoneHarvestEvent

import net.minecraftforge.event.world.BlockEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onWitherBoneHarvestEvent(BlockEvent.HarvestDropsEvent event) {
	if (event.getHarvester() == null) {
		return;
	}

	EntityPlayer player = event.getHarvester();
	ItemStack stack = player.getHeldItemMainhand();

	boolean flag = false;

	if (stack.getItem() instanceof IHaftTool) {
		if (IHaftTool.getHaftMat(stack) == ModMaterials.HAFT_WITHER_BONE) {
			flag = true;
		}
	}

	if (flag) {
		if (player.dimension != DimensionType.NETHER.getId()) {
			stack.damageItem(7, player);
		}
	}
}
 
开发者ID:the-realest-stu,项目名称:Adventurers-Toolbox,代码行数:24,代码来源:SpecialToolAbilityHandler.java

示例4: canCreateFluidSource

import net.minecraftforge.event.world.BlockEvent; //导入依赖的package包/类
@SubscribeEvent
public static void canCreateFluidSource(BlockEvent.CreateFluidSourceEvent event)
{
    if (event.getResult() != Event.Result.DEFAULT)
        return;

    if (applyModifiers(event))
        return;

    Block block = event.getState().getBlock();

    if (block instanceof CSBlock)
    {
        ContentBlockBase content = ((CSBlock) block).getContent();
        if (content instanceof ContentBlockFluid)
        {
            ContentBlockFluid fluid = (ContentBlockFluid) content;
            event.setResult(fluid.canCreateSource ? Event.Result.ALLOW : Event.Result.DENY);
        }
    }
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:22,代码来源:EventHandler.java

示例5: applyModifiers

import net.minecraftforge.event.world.BlockEvent; //导入依赖的package包/类
private static boolean applyModifiers(BlockEvent.CreateFluidSourceEvent event)
{
    Block block = event.getState().getBlock();

    for (FluidModifier modifier : FluidModifier.getModifiers())
    {
        if (block.getRegistryName() != null && block.getRegistryName().equals(modifier.block))
        {
            if (modifier.canCreateSource != null)
            {
                event.setResult(modifier.canCreateSource ? Event.Result.ALLOW : Event.Result.DENY);
                return true;
            }
        }
    }

    return false;
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:19,代码来源:EventHandler.java

示例6: stopBreak

import net.minecraftforge.event.world.BlockEvent; //导入依赖的package包/类
@SubscribeEvent
public void stopBreak(BlockEvent.BreakEvent event) {

	if (event.getPlayer().getHeldItem(EnumHand.MAIN_HAND) != null && event.getPlayer().getHeldItem(EnumHand.MAIN_HAND).getItem() instanceof ItemUsable) {
		event.setCanceled(true);
	}
	if (event.getPlayer().getActivePotionEffect(TF2weapons.bonk) != null) {
		event.setCanceled(true);
	}
	if (event.getPlayer().getCapability(TF2weapons.WEAPONS_CAP, null).invisTicks > 0) {
		event.setCanceled(true);
	}
	if (event.getPlayer().getActivePotionEffect(TF2weapons.stun) != null) {
		event.setCanceled(true);
	}
	if (WeaponsCapability.get(event.getPlayer()).isDisguised()) {
		disguise(event.getPlayer(), false);
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:20,代码来源:TF2EventsCommon.java

示例7: eventBreakEvent

import net.minecraftforge.event.world.BlockEvent; //导入依赖的package包/类
@SubscribeEvent
public void eventBreakEvent(BlockEvent.BreakEvent event) {
	World world = event.world;
	int x = event.x;
	int y = event.y;
	int z = event.z;
	EntityPlayer player = event.getPlayer();

	if (player != null && player.getHeldItem() != null && player.getHeldItem().getItem() == Items.stick) {
		if (TOConfig.debugEnable && TOConfig.debugRemover && !world.isRemote
				&& player.capabilities.isCreativeMode) {
			int radius = TOConfig.debugRemoverScannerRadius;
			for (int xx = x - radius; xx < x + radius; xx++)
				for (int zz = z - radius; zz < z + radius; zz++)
					for (int yy = 0; yy < 257; yy++)
						if (!(world.getBlock(xx, yy, zz) instanceof BlockInfusedBlockOre))
							world.setBlock(xx, yy, zz, Blocks.air, 0, 2);
			String text = "[DEBUG " + ThaumOresMod.NAME + "] Removed blocks at " + x + ";" + z + " with radius "
					+ radius;
			player.addChatMessage(new ChatComponentText(text));
			ThaumOresMod.log.info(text);
		}
	}
}
 
开发者ID:MJaroslav,项目名称:ThaumOres,代码行数:25,代码来源:TOEvents.java

示例8: playerTick

import net.minecraftforge.event.world.BlockEvent; //导入依赖的package包/类
@SubscribeEvent
public void playerTick(BlockEvent.BreakEvent breakEvent)
{
    World world = breakEvent.getWorld();
    BlockPos pos = breakEvent.getPos();
    IBlockState state = world.getBlockState(pos);
    Block block = state.getBlock();

    if(block instanceof BlockWorldScaleOre)
    {
        if(state.getValue(BlockWorldScaleOre.CRACKED) < 5) {
            ((BlockWorldScaleOre)block).addCracks(world,pos,state,1);
            breakEvent.setCanceled(true);
        }
    }
}
 
开发者ID:DaedalusGame,项目名称:BetterWithAddons,代码行数:17,代码来源:HarvestHandler.java

示例9: recordBlock

import net.minecraftforge.event.world.BlockEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST) // Act after any cancellations
public void recordBlock(BlockEvent.PlaceEvent event) {
    IBlockState bs = event.placedBlock;
    Block block = bs.getBlock();
    if (event.player == null) return;
    if (event.world.isRemote) return;
    if (event.player instanceof FakePlayer) return;
    if (block.getBlockHardness(event.world, event.pos) <= 0F) return;
    if (PlayerUtil.isPlayerCreative(event.player)) return;

    int idmd = hash(bs);
    final ItemStack theItem = toItem(block, event.world, event.pos, bs);
    final PlacedBlock at = new PlacedBlock(FzUtil.getWorldDimension(event.world), event.pos, idmd, theItem);
    markPlacement(event.player, at);
    if (event.player instanceof EntityPlayerMP) {
        send(event.player, at);
    }
}
 
开发者ID:purpleposeidon,项目名称:Factorization,代码行数:19,代码来源:BlockUndo.java

示例10: redstoneUpdate

import net.minecraftforge.event.world.BlockEvent; //导入依赖的package包/类
@SubscribeEvent
public void redstoneUpdate(BlockEvent.NeighborNotifyEvent event)
{
    World world = event.getWorld();
    BlockPos pos = event.getPos();
    IBlockState state = event.getState();

    if(state.getBlock() != Blocks.REDSTONE_WIRE)
        return;

    if(!willRedstoneBoil(world,pos))
        return;

    if(state.getValue(BlockRedstoneWire.POWER) > 0)
        return;

    scheduleRedstone(world,pos,9);
}
 
开发者ID:DaedalusGame,项目名称:BetterWithAddons,代码行数:19,代码来源:RedstoneBoilHandler.java

示例11: onSnitchBreak

import net.minecraftforge.event.world.BlockEvent; //导入依赖的package包/类
@SubscribeEvent
public void onSnitchBreak(BlockEvent.BreakEvent event)
{
    BlockPos pos = event.getPos();
    Location loc = new Location(pos.getX(), pos.getY(), pos.getZ(), snitchMaster.getCurrentWorld());

    Snitch snitch = manager.getSnitches().remove(loc);
    if (snitch != null)
    {
        snitchMaster.individualJourneyMapUpdate(snitch);

        manager.saveSnitches();

        SnitchMaster.SendMessageToPlayer("Removed snitch at " + loc.toString());
    }

}
 
开发者ID:MrLittleKitty,项目名称:Snitch-Master,代码行数:18,代码来源:SnitchListeners.java

示例12: breakE

import net.minecraftforge.event.world.BlockEvent; //导入依赖的package包/类
@SubscribeEvent
public void breakE(BlockEvent.BreakEvent event)
{
	if(event.getWorld() !=null && !event.getWorld().isRemote && event.getWorld().provider.getDimension() == ModDimensions.CUBE_ID){
		PlayerCube cube = CubeManager.getInstance().getPlayerCubeFromPos(event.getWorld(), event.getPos());
		if(cube !=null){
			for(TileEntityPlayerCubePortal portal : cube.watchers){
				if (portal.mobileChunk.addBlockWithState(event.getPos(), Blocks.AIR.getDefaultState())) {
	                portal.mobileChunk.removeChunkBlockTileEntity(event.getPos());
	            }
	            portal.mobileChunk.setChunkModified();
	            portal.mobileChunk.onChunkLoad();
			}
		}
	}
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:17,代码来源:EventHandler.java

示例13: onBlockPlace

import net.minecraftforge.event.world.BlockEvent; //导入依赖的package包/类
@SubscribeEvent
public void onBlockPlace(BlockEvent.PlaceEvent e) {
    if (!e.getWorld().isRemote) {
        for (EnumFacing facing : EnumFacing.VALUES) {
            TileEntity tile = e.getWorld().getTileEntity(e.getBlockSnapshot().getPos().offset(facing));

            if (tile != null && TileEntityPipeEStorage.isNetworkTile(tile)) {
                EStorageNetwork network = TileEntityPipeEStorage.getTileNetwork(tile);
                if (network != null && !network.hasAbility(e.getPlayer(), NetworkAbility.BUILD)) {
                    ChatUtil.sendNoSpam(e.getPlayer(), Lang.localize("gui.networkability."+NetworkAbility.BUILD.getId()));

                    e.setCanceled(true);

                    return;
                }
            }
        }
    }
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:20,代码来源:EventHandler.java

示例14: onBlockBreak

import net.minecraftforge.event.world.BlockEvent; //导入依赖的package包/类
@SubscribeEvent
public void onBlockBreak(BlockEvent.BreakEvent e) {
    if (!e.getWorld().isRemote) {
        TileEntity tile = e.getWorld().getTileEntity(e.getPos());

        if (tile != null && TileEntityPipeEStorage.isNetworkTile(tile)) {
        	 EStorageNetwork network = TileEntityPipeEStorage.getTileNetwork(tile);

            if (network != null && !network.hasAbility(e.getPlayer(), NetworkAbility.BUILD)) {
            	ChatUtil.sendNoSpam(e.getPlayer(), Lang.localize("gui.networkability."+NetworkAbility.BUILD.getId()));

                e.setCanceled(true);
            }
        }
    }
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:17,代码来源:EventHandler.java

示例15: placeBlock

import net.minecraftforge.event.world.BlockEvent; //导入依赖的package包/类
@SubscribeEvent
public void placeBlock(BlockEvent.PlaceEvent event) {
	for (Arena arena : arenas) {
		if (!arena.getPlayers().contains(event.getPlayer().getUniqueID()) || arena.getWorld() != event.getWorld())
			continue;

		if (!event.getWorld().isRemote && arena.getBoss() instanceof EntityZachriel)
			((EntityZachriel) arena.getBoss()).nemezDrive.trackBlock(event.getPos(), event.getWorld().getBlockState(event.getPos()));

		//if (!event.getWorld().isRemote)
		//	for (ZachTimeManager timeManager : zachHourGlasses) {
		//		if (timeManager.getEntityZachriel().getEntityId() == arena.getBossID()) {
		//			timeManager.trackBlock(Blocks.AIR.getDefaultState(), event.getPos());
		//		}
		//	}
	}
}
 
开发者ID:TeamWizardry,项目名称:Wizardry,代码行数:18,代码来源:ArenaManager.java


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