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


Java BlockEvent.BreakEvent方法代码示例

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


在下文中一共展示了BlockEvent.BreakEvent方法的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: 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

示例4: 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

示例5: 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

示例6: onBlockBreak

import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onBlockBreak(BlockEvent.BreakEvent e)
{
    IBlockState state = e.getState();
    World world = e.getWorld();
    BlockPos pos = e.getPos();
    EntityPlayer player = e.getPlayer();
    ItemStack heldItem = player.getHeldItem(EnumHand.MAIN_HAND);
    if (state.getBlock() == Blocks.mob_spawner) {
        Map<Enchantment, Integer> enchants = EnchantmentHelper.getEnchantments(heldItem);
        if (enchants.containsKey(Enchantments.silkTouch)) {
            ItemStack stack = new ItemStack(Blocks.mob_spawner, 1, 0);
            NBTTagCompound nbttagcompound = new NBTTagCompound();
            world.getTileEntity(pos).writeToNBT(nbttagcompound);
            stack.setTagInfo("BlockEntityTag", nbttagcompound);

            e.setExpToDrop(0);
            e.getWorld().spawnEntityInWorld(new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), stack));
        }
    }
}
 
开发者ID:GamingsModding,项目名称:LittleThings-old,代码行数:22,代码来源:DropableSpawners.java

示例7: 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

示例8: onBlockBreak

import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onBlockBreak(BlockEvent.BreakEvent event){
    EntityPlayer player = event.getPlayer();
    if(player.isInsideOfMaterial(Material.WATER)) {
        //Player is inside water, check for lanolin
        if (player.getHeldItemMainhand().hasTagCompound() && player.getHeldItemMainhand().getTagCompound().hasKey("lanolin")) {
            int newLanolin = player.getHeldItemMainhand().getTagCompound().getInteger("lanolin") - 1;
            if (newLanolin <= 0)
                player.getHeldItemMainhand().getTagCompound().removeTag("lanolin");
            else
                player.getHeldItemMainhand().getTagCompound().setInteger("lanolin", newLanolin);
        }
    }
}
 
开发者ID:SirLyle,项目名称:Lanolin,代码行数:15,代码来源:EventHandlerCommon.java

示例9: onBlockBreak

import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public static void onBlockBreak(BlockEvent.BreakEvent event) {
    if (event.getState().getBlock() == Blocks.TALLGRASS) {
        float randomValue = event.getWorld().rand.nextFloat();
        if (randomValue >= 0.9) {
            event.getWorld().spawnEntity(new EntityItem(event.getWorld(),
                    event.getPos().getX(),
                    event.getPos().getY(),
                    event.getPos().getZ(),
                    new ItemStack(GeneraItems.ItemSeedNightshade, 1)));
        }
    }
}
 
开发者ID:BenjaminSutter,项目名称:genera,代码行数:14,代码来源:EventHandler.java

示例10: onBlockBreak

import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onBlockBreak(BlockEvent.BreakEvent evt) {
	/*
	if (evt.block instanceof LobbyBlock) {
		// RESETS DATA AND CANCELS EVENT
		LobbyTileEntity t = (LobbyTileEntity) evt.world.getTileEntity(evt.x, evt.y, evt.z);

		if (t != null) {
			PlayerData data;
			
			for (EntityPlayer p : UUIDUtil.getPlayersFromProfileUUIDs(evt.world, t.players)) {
				data = PlayerData.get(p);
				
				data.setReady(false);
				data.setInLobby(false);
				
				if (evt.world.isRemote)
					data.sendToServer();
				
				t.removePlayer(p);
				
				//PAYDAY.INSTANCE.sendToServer(new LobbyPlayerActionPacket(evt.x, evt.y, evt.z, true));
			}
		}
		//evt.setCanceled(true);
	}*/
}
 
开发者ID:TominoCZ,项目名称:PAYDAY,代码行数:28,代码来源:MEventHandler.java

示例11: onBlockBreak

import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
@SuppressWarnings({"ConstantConditions"})
public void onBlockBreak(BlockEvent.BreakEvent event) {
    if (    event.getPlayer().getHeldItemMainhand() != null &&
            new UItem(event.getPlayer().getHeldItemMainhand().getItem()).getId() == UItems.WOODEN_HOE.getId() &&
            event.getPlayer().isCreative()) {
        event.setCanceled(true);
        Evaluator.touchBlock(event.getPlayer(), new UBlockPos(event.getPos()));
    }
}
 
开发者ID:ternsip,项目名称:StructPro,代码行数:11,代码来源:Structpro.java

示例12: onBlockBreak

import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
@SuppressWarnings({"ConstantConditions"})
public void onBlockBreak(BlockEvent.BreakEvent event) {
    if (    event.getPlayer().getHeldItem() != null &&
            new UItem(event.getPlayer().getHeldItem().getItem()).getId() == UItems.WOODEN_HOE.getId() &&
            event.getPlayer().capabilities.isCreativeMode) {
        event.setCanceled(true);
        Evaluator.touchBlock(event.getPlayer(), new UBlockPos(event.x, event.y, event.z));
    }
}
 
开发者ID:ternsip,项目名称:StructPro,代码行数:11,代码来源:Structpro.java

示例13: onBlockBreak

import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onBlockBreak(BlockEvent.BreakEvent event) {
    World world = event.getWorld();
    IBlockState state = world.getBlockState(event.getPos());
    BlockPos pos = event.getPos();
    if (!state.getBlock().isWood(world, pos)) {
        return;
    }
    int radius = 16;
    int dirX = Math.max(-1, Math.min(1, pos.getX() - (int)Math.round(event.getPlayer().posX - 0.5)));
    int dirZ = Math.max(-1, Math.min(1, pos.getZ() - (int)Math.round(event.getPlayer().posZ - 0.5)));
    LinkedList<BlockPos> queue = new LinkedList<BlockPos>();
    HashMap<BlockPos, Integer> used = new HashMap<BlockPos, Integer>();
    queue.add(pos);
    int leaf = 5;
    used.put(pos, leaf);
    while (!queue.isEmpty()) {
        BlockPos top = queue.pollFirst();
        for (int dx = -1; dx <= 1; ++dx) {
            for (int dy = -1; dy <= 1; ++dy) {
                for (int dz = -1; dz <= 1; ++dz) {
                    BlockPos nPos = top.add(dx, dy, dz);
                    int step = used.get(top);
                    if (step <= 0 || nPos.distanceSq(pos) > radius * radius) {
                        continue;
                    }
                    IBlockState nState = world.getBlockState(nPos);
                    boolean log = nState.getBlock().isWood(world, nPos);
                    boolean leaves = nState.getBlock().isLeaves(nState, world, nPos);
                    if ((dy >= 0 && step == leaf && log) || leaves) {
                        step = step - (leaves ? 1 : 0);
                        if (!used.containsKey(nPos) || used.get(nPos) < step) {
                            used.put(nPos, step);
                            queue.push(nPos);
                        }
                    }
                }
            }
        }
    }
    for (Map.Entry<BlockPos, Integer> entry : used.entrySet()) {
        BlockPos blockPos = entry.getKey();
        if (!pos.equals(blockPos) && isDraggable(world, blockPos.add(0, -1, 0))) {
            int oy = blockPos.getY() - pos.getY();
            drop(world, blockPos, blockPos.add(oy * dirX, 0, oy * dirZ));
        }
    }
}
 
开发者ID:ternsip,项目名称:ChopDown,代码行数:49,代码来源:ChopDown.java

示例14: doMining

import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
void doMining(World world, EntityPlayerMP player, int x, int y, int z)	// Calling this 27 times, to blast mine a 3x3x3 area
{
	Block toBeBroken = world.getBlock(x, y, z);
	int meta = world.getBlockMetadata(x, y, z);

	if (toBeBroken.getBlockHardness(world, x, y, z) == -1) { return; }	// Unbreakable

	if (toBeBroken.getHarvestLevel(meta) > 1) { return; }
	if (toBeBroken.getMaterial() == Material.water) { return; }
	if (toBeBroken.getMaterial() == Material.lava) { return; }
	if (toBeBroken.getMaterial() == Material.air) { return; }
	if (toBeBroken.getMaterial() == Material.portal) { return; }

	// Need to do checks here against invalid blocks
	if (toBeBroken == Blocks.water) { return; }
	if (toBeBroken == Blocks.flowing_water) { return; }
	if (toBeBroken == Blocks.lava) { return; }
	if (toBeBroken == Blocks.flowing_lava) { return; }
	if (toBeBroken == Blocks.obsidian) { return; }
	if (toBeBroken == Blocks.mob_spawner) { return; }

	// Crashing blocks: Redstone Lamp, Extended Piston
	// They're likely trying to drop things that cannot be dropped (active states of themselves)

	//WorldSettings.GameType gametype = WorldSettings.GameType.getByName("survival");
	WorldSettings.GameType gametype = world.getWorldInfo().getGameType();
	BlockEvent.BreakEvent event = ForgeHooks.onBlockBreakEvent(world, gametype, player, x, y, z);

	if (event.isCanceled()) { return; }	// Not allowed to do this

	//toBeBroken.dropBlockAsItem(world, x, x, z, meta, 0);	// The last one is Fortune

	boolean removalSuccess = world.setBlockToAir(x, y, z);
	if (removalSuccess) { toBeBroken.onBlockDestroyedByPlayer(world, x, y, z, meta); }

	Item preBlockItem = toBeBroken.getItemDropped(meta, player.getRNG(), 0);

	if (preBlockItem == null) { return; }	// Item doesn't exist

	ItemStack blockItem = new ItemStack(preBlockItem);

	blockItem.setItemDamage(meta);

	EntityItem entityItem = new EntityItem(world, x, y + 0.5d, z, blockItem);
	entityItem.delayBeforeCanPickup = 10;

	world.spawnEntityInWorld(entityItem);
}
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:49,代码来源:PowderKnuckle_Mod.java

示例15: removeBanner

import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void removeBanner(BlockEvent.BreakEvent event) {
	TileEntity banner = event.getWorld().getTileEntity(event.getPos());
	if(banner != null && banner instanceof TileEntityBanner){
		if(getPatterns((TileEntityBanner) banner).contains(TF2weapons.redPattern)){
			event.getWorld().getCapability(TF2weapons.WORLD_CAP, null).banners.remove(event.getPos());
		}
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:10,代码来源:TF2EventsCommon.java


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