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


Java BlockRedstoneEvent.getOldCurrent方法代码示例

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


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

示例1: doPhysics

import org.bukkit.event.block.BlockRedstoneEvent; //导入方法依赖的package包/类
public void doPhysics(World world, int i, int j, int k, Block block) {
    if (!world.isStatic) {
        boolean flag = world.isBlockIndirectlyPowered(i, j, k);
        int l = world.getData(i, j, k);
        boolean flag1 = (l & 1) != 0;

        // CraftBukkit start
        org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(i, j, k);
        int old = flag1 ? 15 : 0;
        int current = flag ? 15 : 0;

        BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, old, current);
        world.getServer().getPluginManager().callEvent(eventRedstone);
        // CraftBukkit end

        if (eventRedstone.getNewCurrent() > 0 && !(eventRedstone.getOldCurrent() > 0)) { // CraftBukkit
            world.setData(i, j, k, l | 1, 4);
            world.a(i, j, k, this, this.a(world));
        } else if (!(eventRedstone.getNewCurrent() > 0) && eventRedstone.getOldCurrent() > 0) { // CraftBukkit
            world.setData(i, j, k, l & -2, 4);
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:24,代码来源:BlockCommand.java

示例2: doPhysics

import org.bukkit.event.block.BlockRedstoneEvent; //导入方法依赖的package包/类
public void doPhysics(World world, int i, int j, int k, int l) {
    if (!world.isStatic) {
        boolean flag = world.isBlockIndirectlyPowered(i, j, k);
        int i1 = world.getData(i, j, k);
        boolean flag1 = (i1 & 1) != 0;

        // CraftBukkit start
        org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
        int old = flag1 ? 15 : 0;
        int current = flag ? 15 : 0;

        BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
        world.getServer().getPluginManager().callEvent(eventRedstone);
        // CraftBukkit end

        if (eventRedstone.getNewCurrent() > 0 && !(eventRedstone.getOldCurrent() > 0)) { // CraftBukkit
            world.setData(i, j, k, i1 | 1, 4);
            world.a(i, j, k, this.id, this.a(world));
        } else if (!(eventRedstone.getNewCurrent() > 0) && eventRedstone.getOldCurrent() > 0) { // CraftBukkit
            world.setData(i, j, k, i1 & -2, 4);
        }
    }
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:24,代码来源:BlockCommand.java

示例3: onNeighborBlockChange

import org.bukkit.event.block.BlockRedstoneEvent; //导入方法依赖的package包/类
public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_)
{
    if (!p_149695_1_.isRemote)
    {
        boolean flag = p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_);
        int l = p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_);
        boolean flag1 = (l & 1) != 0;
        // CraftBukkit start
        org.bukkit.block.Block bukkitBlock = p_149695_1_.getWorld().getBlockAt(p_149695_2_, p_149695_3_, p_149695_4_);
        int old = flag1 ? 15 : 0;
        int current = flag ? 15 : 0;
        BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, old, current);
        p_149695_1_.getServer().getPluginManager().callEvent(eventRedstone);
        // CraftBukkit end

        if (eventRedstone.getNewCurrent() > 0 && !(eventRedstone.getOldCurrent() > 0))   // CraftBukkit
        {
            p_149695_1_.setBlockMetadataWithNotify(p_149695_2_, p_149695_3_, p_149695_4_, l | 1, 4);
            p_149695_1_.scheduleBlockUpdate(p_149695_2_, p_149695_3_, p_149695_4_, this, this.tickRate(p_149695_1_));
        }
        else if (!(eventRedstone.getNewCurrent() > 0) && eventRedstone.getOldCurrent() > 0)     // CraftBukkit
        {
            p_149695_1_.setBlockMetadataWithNotify(p_149695_2_, p_149695_3_, p_149695_4_, l & -2, 4);
        }
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:27,代码来源:BlockCommandBlock.java

示例4: onBlockRedstone

import org.bukkit.event.block.BlockRedstoneEvent; //导入方法依赖的package包/类
@EventHandler(priority=EventPriority.HIGH )
public void onBlockRedstone(BlockRedstoneEvent event) 
{
	System.out.println("  ");
	Block block = event.getBlock();
	int iBlockID = block.getTypeId();
	if (iBlockID==69 || iBlockID==77 || iBlockID==143) {  return; }
	if(event.getOldCurrent() >=1 && event.getNewCurrent() == 0 ) { return; }
	System.out.println(" plugin:  onBlockRedstone()  ");
	System.out.println("     iBlockID = " + iBlockID);
	if(plugin.itemFrame1 != null)
	{
		//  funzelt  :-)
		//ItemStack  item01 = new ItemStack( Helper.random_IntRange(2, 128) );
		//plugin.itemFrame1.setItem(item01);
	}
	if(event.getNewCurrent()>=1) {
		plugin.umschauenNachSchild(block, event);
	}
	return;
}
 
开发者ID:Kryssi79,项目名称:RahmenTests,代码行数:22,代码来源:RahmenListener.java

示例5: onBlockRedstone

import org.bukkit.event.block.BlockRedstoneEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockRedstone(BlockRedstoneEvent e)
{
	if (e.getBlock().getType() == Material.REDSTONE_TORCH_OFF
			|| e.getBlock().getType() == Material.REDSTONE_TORCH_ON)
	{
		final Block above = e.getBlock().getRelative(BlockFace.UP);
		String[] arguments = DropperManager.getSpecialDropper(above);
		
		if (arguments == null)
			return;
		
		if (e.getOldCurrent() == 0 && e.getNewCurrent() > 0
				&& !above.isBlockPowered()
				&& !DropperManager.isRegistered(above))
		{
			DropperManager.register(above, arguments);
		}
		else if (e.getOldCurrent() > 0 && e.getNewCurrent() == 0
				&& above.isBlockPowered()
				&& DropperManager.isRegistered(above))
		{
			DropperManager.unregister(above);
		}
	}
}
 
开发者ID:riking,项目名称:GrandVide,代码行数:27,代码来源:GVEventListener.java

示例6: onBlockRedstone

import org.bukkit.event.block.BlockRedstoneEvent; //导入方法依赖的package包/类
@EventHandler
public void onBlockRedstone(BlockRedstoneEvent event) {
    if (event.getOldCurrent() != 0 || event.getNewCurrent() == 0) {
        return;
    }
    Block block = event.getBlock();
    World world = block.getWorld();
    String worldName = world.getName();
    Map<BlockVector, BankSet> worldInteresting = bankInfo.get(worldName);
    if (worldInteresting == null) {
        worldInteresting = buildWorldInteresting(worldName);
        bankInfo.put(worldName, worldInteresting);
    }
    BlockVector target = new BlockVector(block.getX(), block.getY(), block.getZ());
    BankSet targetBank = worldInteresting.get(target);
    if (targetBank != null) {
        targetBank.shelveItems(world);
    }
}
 
开发者ID:crast,项目名称:MondoChest,代码行数:20,代码来源:RedstoneListener.java

示例7: CheckRedstone

import org.bukkit.event.block.BlockRedstoneEvent; //导入方法依赖的package包/类
@EventHandler
public void CheckRedstone(BlockRedstoneEvent event){
	if(ConfigOptimize.AntiRedstoneenable){
		if(event.getOldCurrent() > event.getNewCurrent()){
            return;
        }
        final Block block = event.getBlock();
        Location loc = block.getLocation();
        if(CheckedTimes.get(loc) == null){
            CheckedTimes.put(loc, 0);
        }
        CheckedTimes.put(loc, CheckedTimes.get(loc) + 1);

        if(CheckedTimes.get(loc) > ConfigOptimize.AntiRedstoneTimes){
            if(ConfigOptimize.AntiRedstoneRemoveBlockList.contains(block.getType().name())){
	Bukkit.getScheduler().runTaskLater(EscapeLag.MainThis,new Runnable(){
		public void run(){
			block.setType(Material.AIR);
		}
	},1);
                String message = ConfigOptimize.AntiRedstoneMessage;
                message = StringUtils.replace(message, "%location%", loc.toString());
                AzureAPI.bc(message);
            }
        }
	}
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:28,代码来源:AntiRedstone.java

示例8: handleBlockRedstone

import org.bukkit.event.block.BlockRedstoneEvent; //导入方法依赖的package包/类
public void handleBlockRedstone(BlockRedstoneEvent event) {
    if ((event.getOldCurrent() != 0) == (event.getNewCurrent() != 0)) return;

    Block block = event.getBlock();

    for (BlockFace face : BridgeManager.faces) {
        Block faceBlock = block.getRelative(face);

        if(this.storage.getGearblock(new BlockCoord(faceBlock)) != null) {
            this.waitingBlocks.add(faceBlock);
        }
    }
}
 
开发者ID:Aleksey-Terzi,项目名称:CastleGates,代码行数:14,代码来源:BridgeEventHandler.java

示例9: onRedstone

import org.bukkit.event.block.BlockRedstoneEvent; //导入方法依赖的package包/类
@EventHandler
public void onRedstone(BlockRedstoneEvent event) {
    if (event.getNewCurrent() == event.getOldCurrent()) {
        return;
    }

    if (isProtectedForRedstone(event.getBlock())) {
        event.setNewCurrent(event.getOldCurrent());
    }
}
 
开发者ID:rutgerkok,项目名称:BlockLocker,代码行数:11,代码来源:BlockDestroyListener.java

示例10: a

import org.bukkit.event.block.BlockRedstoneEvent; //导入方法依赖的package包/类
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Block block) {
    if (!world.isClientSide) {
        TileEntity tileentity = world.getTileEntity(blockposition);

        if (tileentity instanceof TileEntityCommand) {
            TileEntityCommand tileentitycommand = (TileEntityCommand) tileentity;
            boolean flag = world.isBlockIndirectlyPowered(blockposition);
            boolean flag1 = tileentitycommand.e();
            boolean flag2 = tileentitycommand.g();

        // CraftBukkit start
        org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
        int old = flag1 ? 15 : 0;
        int current = flag ? 15 : 0;

        BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, old, current);
        world.getServer().getPluginManager().callEvent(eventRedstone);
        // CraftBukkit end

        if (eventRedstone.getNewCurrent() > 0 && !(eventRedstone.getOldCurrent() > 0)) { // CraftBukkit
                tileentitycommand.a(true);
                if (tileentitycommand.j() != TileEntityCommand.Type.SEQUENCE && !flag2) {
                    boolean flag3 = !tileentitycommand.k() || this.e(world, blockposition, iblockdata);

                    tileentitycommand.c(flag3);
                    world.a(blockposition, (Block) this, this.a(world));
                    if (flag3) {
                        this.c(world, blockposition);
                    }
                }
        } else if (!(eventRedstone.getNewCurrent() > 0) && eventRedstone.getOldCurrent() > 0) { // CraftBukkit
                tileentitycommand.a(false);
            }

        }
    }
}
 
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:38,代码来源:BlockCommand.java

示例11: redstoneChange

import org.bukkit.event.block.BlockRedstoneEvent; //导入方法依赖的package包/类
/**
 * Called when a block is charged.
 * When the furnace block is powered, starts the factory and toggles on any attached levers.
 * On completion, toggles off any attached levers.
 */
   @EventHandler()
public void redstoneChange(BlockRedstoneEvent e)
{	
	// Only trigger on transition from 0 to positive
	if (e.getOldCurrent() > 0 || e.getNewCurrent() == 0) {
		return;
	}
	
	// Allow this to be disabled with config
	if (!FactoryModPlugin.REDSTONE_START_ENABLED) {
		return;
	}
	
	Block rsBlock = e.getBlock();
	BlockFace[] directions = null;
	if (rsBlock.getType() == Material.REDSTONE_WIRE) {
		directions = ProductionFactory.REDSTONE_FACES;
	} else if (rsBlock.getType() == Material.WOOD_BUTTON) {
		directions = new BlockFace[] {((Attachable) rsBlock.getState().getData()).getAttachedFace()};
	} else if (rsBlock.getType() == Material.STONE_BUTTON) {
		directions = new BlockFace[] {((Attachable) rsBlock.getState().getData()).getAttachedFace()};
	} else if (rsBlock.getType() == Material.LEVER) {
		directions = new BlockFace[] {((Attachable) rsBlock.getState().getData()).getAttachedFace()};
	} else {
		return; // Don't care
	}
	
	
	for (BlockFace direction : directions) {
		Block block = rsBlock.getRelative(direction);
		
		//Is the block part of a factory?
		if(block.getType() == Material.FURNACE || block.getType() == Material.BURNING_FURNACE)
		{
			if (factoryMan.factoryExistsAt(block.getLocation()))
			{					
				//Is the factory a production factory?
				if (productionMan.factoryExistsAt(block.getLocation()))
				{
					ProductionFactory factory = (ProductionFactory) productionMan.getFactory(block.getLocation());
					
					Block lever = factory.findActivationLever();
					if (lever == null) {
						// No lever - don't respond to redstone
						return;
					}
					
					if (!factory.getActive()) {
						// Try to start the factory
						factory.togglePower();
					}
				}
			}
		}
	}
}
 
开发者ID:gmlaxfanatic,项目名称:FactoryMod,代码行数:62,代码来源:RedstoneListener.java


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