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


Java BlockHelper类代码示例

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


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

示例1: outputResult

import cofh.lib.util.helpers.BlockHelper; //导入依赖的package包/类
private void outputResult() {
    // Check all sides if output side
    for (int i = 0; i < 6; i++) {
        if (this.getSideConfig(i) == 2) {
            // Grab the adjecent tile at the output side
            TileEntity adjecent = BlockHelper.getAdjacentTileEntity(this, i);
            
            // Check if the adjecent tile entity is an inventory (IIventory, ISidedInventory or IItemDuct)
            if (adjecent instanceof IInventory || adjecent instanceof ISidedInventory || adjecent instanceof IItemDuct) {
                // Try to output into the inventory
                if (InventoryHelper.isInsertion(adjecent)) {
                    ItemStack notInserted = InventoryHelper.addToInsertion(adjecent, i, this.getInventory()[1]);
                    this.getInventory()[1] = notInserted;
                }
            }
        }
    }
}
 
开发者ID:SKCraft,项目名称:SMES,代码行数:19,代码来源:TileEntityRareMetalExtractor.java

示例2: updateAdjacentHandlers

import cofh.lib.util.helpers.BlockHelper; //导入依赖的package包/类
public void updateAdjacentHandlers()
{
 if (ServerHelper.isClientWorld(worldObj)) {
  return;
 }
 for (int i = 0; i < 6; i++)
 {
  TileEntity localTileEntity = BlockHelper.getAdjacentTileEntity(this, i);
     if (EnergyHelper.isEnergyReceiverFromSide(localTileEntity, ForgeDirection.VALID_DIRECTIONS[(i ^ 0x1)])) {
   	  this.adjacentHandlers[i] = ((IEnergyReceiver)localTileEntity);
     } else {
   	  this.adjacentHandlers[i] = null;
     }
 }
   //this.cached = true;
}
 
开发者ID:CreativeMD,项目名称:RandomAdditions,代码行数:17,代码来源:TileEntityRAtoRF.java

示例3: rotateBlock

import cofh.lib.util.helpers.BlockHelper; //导入依赖的package包/类
@Override
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis){
	int meta = BlockHelper.getLeftSide(world.getBlockMetadata(x, y, z));
	world.setBlockMetadataWithNotify(x, y, z, meta, 3);
	((TileEntityCompressor)world.getTileEntity(x, y, z)).setOrientation(ForgeDirection.getOrientation(meta));
	return true;
}
 
开发者ID:MatheusVigaro,项目名称:JAM,代码行数:8,代码来源:BlockCompressor.java

示例4: onBlockStartBreak

import cofh.lib.util.helpers.BlockHelper; //导入依赖的package包/类
@Override
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
    World world = player.worldObj;

    if(!world.isRemote && getEnergyStored(stack) > 0){
        int xRadius = 0, yRadius = 0, zRadius = 0;

        if(isEmpowered(stack)){
            if (BlockHelper.getCurrentMousedOverSide(player) == 0 || BlockHelper.getCurrentMousedOverSide(player) == 1) {
                switch(MathHelper.floor_double((player.rotationYaw * 4F) / 360F + 0.5D) & 3) { //Stolen from MineFactoryReloaded https://github.com/powercrystals/MineFactoryReloaded/blob/master/src/powercrystals/minefactoryreloaded/block/BlockConveyor.java
                    case 0: zRadius = 1; break;
                    case 1: xRadius = 1; break;
                    case 2: zRadius = 1; break;
                    case 3: xRadius = 1; break;
                }
            } else {
                yRadius = 1;
            }
        }
        for(int a = x - xRadius; a <= x + xRadius; a++) {
            for (int b = y - yRadius; b <= y + yRadius; b++) {
                for(int c = z - zRadius; c <= z + zRadius; c++) {
                    if (world.blockExists(a, b, c) && !world.isAirBlock(x, y, z)) {
                        if (!(a == x && b == y && c == z)) { //don't harvest the same block twice
                            ToolHelper.harvestBlock(world, a, b, c, player);
                        }
                    }
                }
            }
        }
    }

    ToolHelper.drainEnergy(stack, player, getEnergyPerUse(stack, world.getBlock(x, y, z), world.getBlockMetadata(x, y, z)));
    return false;
}
 
开发者ID:goldenapple3,项目名称:RFDrills,代码行数:36,代码来源:ItemDrill.java

示例5: onBlockStartBreak

import cofh.lib.util.helpers.BlockHelper; //导入依赖的package包/类
@Override
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
    World world = player.worldObj;

    if(!world.isRemote && getEnergyStored(stack) > 0){
        int xRadius = 0, yRadius = 0, zRadius = 0;

        switch (getMode(stack)){
            case 1: if (BlockHelper.getCurrentMousedOverSide(player) == 0 || BlockHelper.getCurrentMousedOverSide(player) == 1) { //if looking at the top or bottom of a block
                switch(MathHelper.floor_double((player.rotationYaw * 4F) / 360F + 0.5D) & 3) { //Stolen from MineFactoryReloaded https://github.com/powercrystals/MineFactoryReloaded/blob/master/src/powercrystals/minefactoryreloaded/block/BlockConveyor.java
                    case 0: zRadius = 1; break;
                    case 1: xRadius = 1; break;
                    case 2: zRadius = 1; break;
                    case 3: xRadius = 1; break;
                }
            } else
                yRadius = 1; break;
            case 2: xRadius = 1; yRadius = 1; zRadius = 1; break;
            case 3: xRadius = 2; yRadius = 2; zRadius = 2; break;
        }

        for (int a = x - xRadius; a <= x + xRadius; a++) {
            for (int b = y - yRadius; b <= y + yRadius; b++) {
                for(int c = z - zRadius; c <= z + zRadius; c++) {
                    if (world.blockExists(a, b, c) && !world.isAirBlock(a, b, c)) {
                        if (!(a == x && b == y && c == z)) //don't harvest the same block twice silly!
                            ToolHelper.harvestBlock(world, a, b, c, player);
                    }
                }
            }
        }
    }

    ToolHelper.drainEnergy(stack, player, getEnergyPerUse(stack, world.getBlock(x, y, z), world.getBlockMetadata(x, y, z)));
    return false;
}
 
开发者ID:goldenapple3,项目名称:RFDrills,代码行数:37,代码来源:ItemSoulCrusher.java

示例6: rotateBlock

import cofh.lib.util.helpers.BlockHelper; //导入依赖的package包/类
@Override
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) {
	int meta = world.getBlockMetadata(x,y,z);
	int newMeta = BlockHelper.getLeftSide(meta);
	world.setBlockMetadataWithNotify(x,y,z,newMeta,3);
	((TilePackager) world.getTileEntity(x, y, z)).setOrientation(ForgeDirection.getOrientation(newMeta).getOpposite());
	return true;
}
 
开发者ID:MCUpdater,项目名称:AutoPackager,代码行数:9,代码来源:BlockPackager.java

示例7: onItemRightClick

import cofh.lib.util.helpers.BlockHelper; //导入依赖的package包/类
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
    MovingObjectPosition blockPos = BlockHelper.getCurrentMovingObjectPosition(player, true);
    if (blockPos != null && blockPos.sideHit >= 0) {
        player.setItemInUse(itemStack, this.getMaxItemUseDuration(itemStack));
    }
    return itemStack;
}
 
开发者ID:Tonius,项目名称:SimplyJetpacks,代码行数:9,代码来源:ItemJetpackFueller.java

示例8: rotateBlock

import cofh.lib.util.helpers.BlockHelper; //导入依赖的package包/类
@Override
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) {
	int meta = world.getBlockMetadata(x,y,z);
	int newMeta = BlockHelper.getLeftSide(meta);
	world.setBlockMetadataWithNotify(x,y,z,newMeta,3);
	return true;
}
 
开发者ID:smbarbour,项目名称:Reconstructor,代码行数:8,代码来源:BlockRecon.java

示例9: addToPriorityInventory

import cofh.lib.util.helpers.BlockHelper; //导入依赖的package包/类
public static int addToPriorityInventory(World world, int x, int y, int z, ItemStack stack) {
	int meta = world.getBlockMetadata(x,y,z);
	List<Integer> sides = new ArrayList<Integer>(Arrays.asList(BlockHelper.getBelowSide(meta),BlockHelper.getRightSide(meta),BlockHelper.getOppositeSide(meta),BlockHelper.getLeftSide(meta),BlockHelper.getAboveSide(meta)));
	for (Integer side : sides) {
		TileEntity target;
		target = BlockHelper.getAdjacentTileEntity(world, x, y, z, side.intValue());
		if (target instanceof ISidedInventory || target instanceof IInventory) {
			if (add((IInventory) target, stack, ForgeDirection.values()[BlockHelper.getOppositeSide(side)], true).stackSize > 0) {
				return add((IInventory) target, stack, ForgeDirection.values()[BlockHelper.getOppositeSide(side)], false).stackSize;
			}
		}
	}
	return 0;
}
 
开发者ID:smbarbour,项目名称:Reconstructor,代码行数:15,代码来源:Utils.java

示例10: updateAdjacentHandler

import cofh.lib.util.helpers.BlockHelper; //导入依赖的package包/类
protected void updateAdjacentHandler(int paramInt1, int paramInt2, int paramInt3)
{
 if (ServerHelper.isClientWorld(worldObj)) {
  return;
 }
 int i = BlockHelper.determineAdjacentSide(this, paramInt1, paramInt2, paramInt3);
 
 TileEntity localTileEntity = worldObj.getTileEntity(paramInt1, paramInt2, paramInt3);
 if (EnergyHelper.isEnergyReceiverFromSide(localTileEntity, ForgeDirection.VALID_DIRECTIONS[(i ^ 0x1)])) {
  this.adjacentHandlers[i] = ((IEnergyReceiver)localTileEntity);
 } else {
  this.adjacentHandlers[i] = null;
 }
}
 
开发者ID:CreativeMD,项目名称:RandomAdditions,代码行数:15,代码来源:TileEntityRAtoRF.java

示例11: getRotatedSide

import cofh.lib.util.helpers.BlockHelper; //导入依赖的package包/类
public int getRotatedSide(int side) {
    return BlockHelper.ICON_ROTATION_MAP[facing][side];
}
 
开发者ID:mengy007,项目名称:KinetiCraft2-1.7.10-wip,代码行数:4,代码来源:KC2TileEntityBase.java

示例12: rotateBlock

import cofh.lib.util.helpers.BlockHelper; //导入依赖的package包/类
@Override
public boolean rotateBlock() {
    return setFacing(BlockHelper.SIDE_LEFT[facing]);
}
 
开发者ID:mengy007,项目名称:KinetiCraft2-1.7.10-wip,代码行数:5,代码来源:KC2TileEntityBase.java

示例13: onUsingTick

import cofh.lib.util.helpers.BlockHelper; //导入依赖的package包/类
@Override
public void onUsingTick(ItemStack itemStack, EntityPlayer player, int count) {
    MovingObjectPosition blockPos = BlockHelper.getCurrentMovingObjectPosition(player, true);
    if (blockPos == null || blockPos.sideHit < 0) {
        player.setItemInUse(null, 1);
    } else {
        player.setItemInUse(itemStack, this.getMaxItemUseDuration(itemStack));
        if (player.worldObj.isRemote) {
            return;
        }
        
        ItemStack chestplate = player.getCurrentArmor(2);
        if (chestplate == null || !(chestplate.getItem() instanceof ItemPack)) {
            return;
        }
        ItemPack packItem = (ItemPack) chestplate.getItem();
        PackBase pack = packItem.getPack(chestplate);
        if (pack == null) {
            return;
        }
        FuelType fuelType = pack.fuelType;
        
        ForgeDirection pullSide = ForgeDirection.values()[blockPos.sideHit];
        player.worldObj.getBlock(blockPos.blockX, blockPos.blockY, blockPos.blockZ);
        TileEntity tile = player.worldObj.getTileEntity(blockPos.blockX, blockPos.blockY, blockPos.blockZ);
        int toPull = Math.min(pack.fuelPerTickIn, packItem.getMaxFuelStored(chestplate) - packItem.getFuelStored(chestplate));
        int pulled = 0;
        
        if (fuelType == FuelType.ENERGY && tile instanceof IEnergyProvider) {
            IEnergyProvider energyTile = (IEnergyProvider) tile;
            pulled = energyTile.extractEnergy(pullSide, toPull, false);
            
        } else if (fuelType == FuelType.FLUID) {
            if (tile instanceof IFluidHandler) {
                IFluidHandler fluidTile = (IFluidHandler) tile;
                FluidStack fluid = fluidTile.drain(pullSide, toPull, false);
                if (fluid == null || !fluid.getFluid().getName().equals(pack.fuelFluid)) {
                    return;
                }
                fluid = fluidTile.drain(pullSide, toPull, true);
                pulled = fluid.amount;
            }
        }
        
        if (pulled > 0) {
            packItem.addFuel(chestplate, pulled, false);
        }
    }
}
 
开发者ID:Tonius,项目名称:SimplyJetpacks,代码行数:50,代码来源:ItemJetpackFueller.java

示例14: resetSides

import cofh.lib.util.helpers.BlockHelper; //导入依赖的package包/类
/**
 * Reset configs on all sides to their base values.
 * 
 * Base values:
 * West of facing is input,
 * East of facing is output
 * 
 * @return True if reset was successful, false otherwise.
 */
@Override
public boolean resetSides() {
    this.sideSlots[BlockHelper.getRightSide(getFacing().ordinal())] = 1;
    this.sideSlots[BlockHelper.getLeftSide(getFacing().ordinal())] = 2;
    return true;
}
 
开发者ID:SKCraft,项目名称:SMES,代码行数:16,代码来源:TileEntityRareMetalExtractor.java


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