Java 类net.minecraftforge.common.util.ForgeDirection 实例源码

项目:connor41-etfuturum2    文件:ChorusFlower.java   
public static boolean canPlantStay(World world, int x, int y, int z) {
    Block block = world.getBlock(x, y - 1, z);
    if (block != ModBlocks.chorus_plant && block != Blocks.end_stone) {
        if (block.isAir(world, x, y - 1, z)) {
            int adjecentCount = 0;
            for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
                Block adjecentBlock = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
                if (adjecentBlock == ModBlocks.chorus_plant)
                    adjecentCount++;
                else if (!adjecentBlock.isAir(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ))
                    return false;
            }
            return adjecentCount == 1;
        } else
            return false;
    } else
        return true;
}
项目:connor41-etfuturum2    文件:FrostedIce.java   
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
    if (world.isRemote)
        return;

    int surroundingBlockCount = 0;
    for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
        Block block = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
        if (block == this || block == Blocks.ice || block == Blocks.packed_ice)
            if (++surroundingBlockCount >= 4)
                break;
    }

    if (surroundingBlockCount < 4 || rand.nextInt(100) <= 33) {
        int meta = world.getBlockMetadata(x, y, z);
        if (meta < 3)
            world.setBlockMetadataWithNotify(x, y, z, meta + 1, 2);
        else
            world.setBlock(x, y, z, Blocks.water);
    }

    world.scheduleBlockUpdate(x, y, z, this, 40 + rand.nextInt(40));
}
项目:4Space-5    文件:TileEntityOxygenTransmitter.java   
@Override
public void refresh()
{
    if (!this.worldObj.isRemote)
    {
        this.adjacentConnections = null;

        for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
        {
            TileEntity tileEntity = new BlockVec3(this).getTileEntityOnSide(this.worldObj, side);

            if (tileEntity != null)
            {
                if (tileEntity.getClass() == this.getClass() && tileEntity instanceof INetworkProvider && !this.getNetwork().equals(((INetworkProvider) tileEntity).getNetwork()))
                {
                    this.setNetwork((IGridNetwork) this.getNetwork().merge(((INetworkProvider) tileEntity).getNetwork()));
                }
            }
        }

        this.getNetwork().refresh();
    }
}
项目:4Space-5    文件:TileEntityScreen.java   
private void joinLeft()
  {
    int meta = this.getBlockMetadata();
    int side = this.getLeft(meta);
    BlockVec3 vec = new BlockVec3(this);
    for (int z = -this.connectionsUp; z <= this.connectionsDown; z++)
{
        TileEntity tile;
    BlockVec3 newVec = vec.clone().modifyPositionFromSide(ForgeDirection.DOWN, z);
        if (z == 0) tile = this;
    else
    {
        tile = newVec.getTileEntity(this.worldObj);
    }
    if (tile instanceof TileEntityScreen && tile.getBlockMetadata() == meta && !tile.isInvalid())
    {
        TileEntityScreen screenTile = (TileEntityScreen)tile;
        screenTile.connectedLeft = true;
        TileEntity te2 = newVec.getTileEntityOnSide(this.worldObj, side);
        if (te2 instanceof TileEntityScreen && te2.getBlockMetadata() == meta && !te2.isInvalid())
        {
            screenTile.tryConnectLeft((TileEntityScreen) te2);
        }
    }
}
  }
项目:4Space-5    文件:TileBaseUniversalElectrical.java   
@RuntimeInterface(clazz = "ic2.api.energy.tile.IEnergyAcceptor", modID = "IC2")
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
{
    //Don't add connection to IC2 grid if it's a Galacticraft tile
    if (emitter instanceof IElectrical || emitter instanceof IConductor)
    {
        return false;
    }

    try
    {
        Class<?> energyTile = Class.forName("ic2.api.energy.tile.IEnergyTile");
        if (!energyTile.isInstance(emitter))
        {
            return false;
        }
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }

    return this.getElectricalInputDirections().contains(direction);
}
项目:4Space-5    文件:ChunkProviderMars.java   
public ChunkProviderMars(World par1World, long seed, boolean mapFeaturesEnabled)
{
    super(par1World, seed, mapFeaturesEnabled);
    this.dungeonGenerator.otherRooms.add(new RoomEmptyMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
    this.dungeonGenerator.otherRooms.add(new RoomSpawnerMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
    this.dungeonGenerator.otherRooms.add(new RoomSpawnerMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
    this.dungeonGenerator.otherRooms.add(new RoomSpawnerMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
    this.dungeonGenerator.otherRooms.add(new RoomSpawnerMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
    this.dungeonGenerator.otherRooms.add(new RoomSpawnerMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
    this.dungeonGenerator.otherRooms.add(new RoomSpawnerMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
    this.dungeonGenerator.otherRooms.add(new RoomSpawnerMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
    this.dungeonGenerator.otherRooms.add(new RoomSpawnerMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
    this.dungeonGenerator.otherRooms.add(new RoomChestsMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
    this.dungeonGenerator.otherRooms.add(new RoomChestsMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
    this.dungeonGenerator.bossRooms.add(new RoomBossMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
    this.dungeonGenerator.treasureRooms.add(new RoomTreasureMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
}
项目:4Space-5    文件:BlockOxygenDistributor.java   
@Override
public IIcon getIcon(int side, int metadata)
{
    if (side == 0 || side == 1)
    {
        return this.iconMachineSide;
    }
    else if (side == metadata + 2)
    {
        return this.iconOutput;
    }
    else if (side == ForgeDirection.getOrientation(metadata + 2).getOpposite().ordinal())
    {
        return this.iconInput;
    }
    else
    {
        return this.iconDistributor;
    }
}
项目:4Space-5    文件:TileEntityElectrolyzer.java   
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
{
    int metaside = this.getBlockMetadata() + 2;
    int side = from.ordinal();
    if (side == (metaside ^ 1))
    {
        return this.liquidTank2.drain(maxDrain, doDrain);
    }

    //2->5 3->4 4->2 5->3
    if (7 - (metaside ^ (metaside > 3 ? 0 : 1)) == (side ^ 1))
    {
        return this.liquidTank.drain(maxDrain, doDrain);
    }

    return null;
}
项目:TFCTech    文件:PipeFluidsBlueSteel.java   
@Override
public int getIconIndex(ForgeDirection direction) {
    switch (direction) {
    case UNKNOWN:
        return ModPipeIconProvider.TYPE.PipeFluidsBlueSteel_Center.ordinal();
    case DOWN:
        return ModPipeIconProvider.TYPE.PipeFluidsBlueSteel_Down.ordinal();
    case UP:
        return ModPipeIconProvider.TYPE.PipeFluidsBlueSteel_Up.ordinal();
    case NORTH:
        return ModPipeIconProvider.TYPE.PipeFluidsBlueSteel_North.ordinal();
    case SOUTH:
        return ModPipeIconProvider.TYPE.PipeFluidsBlueSteel_South.ordinal();
    case WEST:
        return ModPipeIconProvider.TYPE.PipeFluidsBlueSteel_West.ordinal();
    case EAST:
        return ModPipeIconProvider.TYPE.PipeFluidsBlueSteel_East.ordinal();
    default:
        throw new IllegalArgumentException("direction out of bounds");
    }
}
项目:ExtraUtilities    文件:TileEntityDrum.java   
public int fill(final ForgeDirection from, final FluidStack resource, final boolean doFill) {
    if (this.sided && from.ordinal() > 1) {
        return 0;
    }
    final boolean t2 = this.tank.getFluid() == null;
    final int t3 = this.tank.fill(resource, doFill);
    if (doFill) {
        if (t2 && this.tank.getFluid() != null && !this.tank.getFluid().isFluidEqual(this.prevFluid)) {
            this.prevFluid = this.tank.getFluid().copy();
            this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
        }
        if (t3 != 0) {
            this.recentlyFilled = true;
            this.markDirty();
        }
    }
    return t3;
}
项目:ExtraUtilities    文件:PipeModSorting.java   
@Override
public int limitTransfer(final TileEntity dest, final ForgeDirection side, final INodeBuffer buffer) {
    if (buffer.getBuffer() instanceof ItemStack && dest instanceof IInventory) {
        final ItemStack item = (ItemStack)buffer.getBuffer();
        final IInventory inv = TNHelper.getInventory(dest);
        boolean empty = true;
        for (final int i : InvHelper.getSlots(inv, side.ordinal())) {
            if (inv.getStackInSlot(i) != null) {
                empty = false;
                if (InvHelper.sameMod(inv.getStackInSlot(i), item)) {
                    return -1;
                }
            }
        }
        return empty ? -1 : 0;
    }
    return -1;
}
项目:PopularMMOS-EpicProportions-Mod    文件:ItemPumpkinJen_Seeds.java   
/**
 * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
 * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
 */
public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_)
{
    if (p_77648_7_ != 1)
    {
        return false;
    }
    else if (p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_) && p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_ + 1, p_77648_6_, p_77648_7_, p_77648_1_))
    {
        if (p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_).canSustainPlant(p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_, ForgeDirection.UP, this) && p_77648_3_.isAirBlock(p_77648_4_, p_77648_5_ + 1, p_77648_6_))
        {
            p_77648_3_.setBlock(p_77648_4_, p_77648_5_ + 1, p_77648_6_, this.field_150925_a);
            --p_77648_1_.stackSize;
            return true;
        }
        else
        {
            return false;
        }
    }
    else
    {
        return false;
    }
}
项目:RFUtilities    文件:BlockTransistor.java   
@Override
public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side)
{
    TileEntity te = world.getTileEntity(x, y, z);
    ForgeDirection fd;
    switch (side)
    {
        case -1: fd = ForgeDirection.UP; break;
        case  0: fd = ForgeDirection.NORTH; break;
        case  1: fd = ForgeDirection.EAST; break;
        case  2: fd = ForgeDirection.SOUTH; break;
        case  3: fd = ForgeDirection.WEST; break;
        default: fd = ForgeDirection.UNKNOWN; break;
    }
    return te instanceof TileEntityTransistor && ((TileEntityTransistor)te).canConnectRedstone(fd);
}
项目:connor41-etfuturum2    文件:EtFuturumWorldGenerator.java   
public static void generateChorusPlant(World world, int x, int y, int z, int pass) {
    int height;
    for (height = 0; height < 4; height++) {
        if (!ChorusFlower.canPlantStay(world, x, y + height, z)) {
            world.setBlock(x, y + height, z, ModBlocks.chorus_flower, 5, 2);
            break;
        }
        world.setBlock(x, y + height, z, ModBlocks.chorus_plant);
    }
    if (height > 1) {
        world.setBlock(x, y + height, z, ModBlocks.chorus_plant);
        boolean grew = false;

        if (pass < 5) {
            ForgeDirection[] dirs = new ForgeDirection[] { ForgeDirection.EAST, ForgeDirection.WEST, ForgeDirection.NORTH, ForgeDirection.SOUTH };
            for (int j = 0; j < world.rand.nextInt(4); j++) {
                ForgeDirection dir = dirs[world.rand.nextInt(dirs.length)];
                int xx = x + dir.offsetX;
                int yy = y + height + dir.offsetY;
                int zz = z + dir.offsetZ;
                if (world.isAirBlock(xx, yy, zz) && ChorusFlower.isSpaceAroundFree(world, xx, yy, zz, dir.getOpposite())) {
                    generateChorusPlant(world, xx, yy, zz, pass + 1);
                    grew = true;
                }
            }
        }

        if (!grew)
            world.setBlock(x, y + height, z, ModBlocks.chorus_flower, 5, 2);
    }
}
项目:connor41-etfuturum2    文件:ChorusFlower.java   
public static boolean isSpaceAroundFree(World world, int x, int y, int z, ForgeDirection skip) {
    Iterator<ForgeDirection> iterator = Arrays.asList(ForgeDirection.VALID_DIRECTIONS).iterator();

    ForgeDirection dir;
    do {
        if (!iterator.hasNext())
            return true;
        dir = iterator.next();
    } while (dir == skip || world.isAirBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ));

    return false;
}
项目:connor41-etfuturum2    文件:Sponge.java   
private boolean absorb(World world, int x, int y, int z) {
    LinkedList<Tuple> linkedlist = Lists.newLinkedList();
    ArrayList<WorldCoord> arraylist = Lists.newArrayList();
    linkedlist.add(new Tuple(new WorldCoord(x, y, z), 0));
    int i = 0;
    WorldCoord blockpos1;

    while (!linkedlist.isEmpty()) {
        Tuple tuple = linkedlist.poll();
        blockpos1 = (WorldCoord) tuple.getFirst();
        int j = (Integer) tuple.getSecond();

        for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
            WorldCoord blockpos2 = blockpos1.add(dir);

            if (world.getBlock(blockpos2.x, blockpos2.y, blockpos2.z).getMaterial() == Material.water) {
                world.setBlockToAir(blockpos2.x, blockpos2.y, blockpos2.z);
                arraylist.add(blockpos2);
                i++;
                if (j < 6)
                    linkedlist.add(new Tuple(blockpos2, j + 1));
            }
        }

        if (i > 64)
            break;
    }

    Iterator<WorldCoord> iterator = arraylist.iterator();

    while (iterator.hasNext()) {
        blockpos1 = iterator.next();
        world.notifyBlockOfNeighborChange(blockpos1.x, blockpos1.y, blockpos1.z, Blocks.air);
    }

    return i > 0;
}
项目:connor41-etfuturum2    文件:Sponge.java   
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
    if (world.getBlockMetadata(x, y, z) == 1) {
        ForgeDirection dir = getRandomDirection(rand);

        if (dir != ForgeDirection.UP && !World.doesBlockHaveSolidTopSurface(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ)) {
            double d0 = x;
            double d1 = y;
            double d2 = z;

            if (dir == ForgeDirection.DOWN) {
                d1 -= 0.05D;
                d0 += rand.nextDouble();
                d2 += rand.nextDouble();
            } else {
                d1 += rand.nextDouble() * 0.8D;

                if (dir == ForgeDirection.EAST || dir == ForgeDirection.WEST) {
                    d2 += rand.nextDouble();

                    if (dir == ForgeDirection.EAST)
                        d0++;
                    else
                        d0 += 0.05D;
                } else {
                    d0 += rand.nextDouble();

                    if (dir == ForgeDirection.SOUTH)
                        d2++;
                    else
                        d2 += 0.05D;
                }
            }

            world.spawnParticle("dripWater", d0, d1, d2, 0.0D, 0.0D, 0.0D);
        }
    }
}
项目:connor41-etfuturum2    文件:EndRod.java   
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
    ForgeDirection dir = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z));

    if (dir == ForgeDirection.DOWN || dir == ForgeDirection.UP)
        setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 1.0F, 0.625F);
    else if (dir == ForgeDirection.WEST || dir == ForgeDirection.EAST)
        setBlockBounds(0.0F, 0.375F, 0.375F, 1.0F, 0.625F, 0.625F);
    else if (dir == ForgeDirection.NORTH || dir == ForgeDirection.SOUTH)
        setBlockBounds(0.375F, 0.375F, 0.0F, 0.625F, 0.625F, 1.0F);
}
项目:connor41-etfuturum2    文件:EndRod.java   
@Override
public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta) {
    ForgeDirection dir = ForgeDirection.getOrientation(side).getOpposite();
    if (world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ) != this)
        dir = dir.getOpposite();
    return dir.ordinal();
}
项目:connor41-etfuturum2    文件:TileEntityEndRodRenderer.java   
@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTicks) {
    OpenGLHelper.pushMatrix();
    OpenGLHelper.translate(x, y, z);
    OpenGLHelper.colour(0xFFFFFF);
    bindTexture(TextureMap.locationBlocksTexture);

    ForgeDirection dir = ForgeDirection.getOrientation(tile.getBlockMetadata());
    switch (dir) {
        case DOWN:
            OpenGLHelper.rotate(180, 1, 0, 0);
            OpenGLHelper.translate(0, -1, -1);
            break;
        case EAST:
            OpenGLHelper.rotate(270, 0, 0, 1);
            OpenGLHelper.translate(-1, 0, 0);
            break;
        case NORTH:
            OpenGLHelper.rotate(270, 1, 0, 0);
            OpenGLHelper.translate(0, -1, 0);
            break;
        case SOUTH:
            OpenGLHelper.rotate(90, 1, 0, 0);
            OpenGLHelper.translate(0, 0, -1);
            break;
        case WEST:
            OpenGLHelper.rotate(90, 0, 0, 1);
            OpenGLHelper.translate(0, -1, 0);
            break;
        default:
            break;
    }

    renderRod(renderer, tile.getBlockType(), tile.getBlockMetadata());

    OpenGLHelper.popMatrix();
}
项目:ThaumOres    文件:TOInfusedOreWandTrigger.java   
@Override
public boolean executeAction(World world, ItemStack wand, EntityPlayer player, int x, int y, int z, int side,
        int event) {
    int md = world.getBlockMetadata(x, y, z);
    BlockInfusedBlockOre block = (BlockInfusedBlockOre) world.getBlock(x, y, z);
    if (world.isRemote) {
        for (int i = 0; i < 10; i++)
            if (md < 6)
                UtilsFX.infusedStoneSparkle(world, x, y, z, md + 1);
        return false;
    } else {
        ForgeDirection dir = ForgeDirection.getOrientation(side);
        int iX = dir.equals(ForgeDirection.EAST) ? x + 1 : dir.equals(ForgeDirection.WEST) ? x - 1 : x;
        int iY = dir.equals(ForgeDirection.UP) ? y + 1 : dir.equals(ForgeDirection.DOWN) ? y - 1 : y;
        int iZ = dir.equals(ForgeDirection.SOUTH) ? z + 1 : dir.equals(ForgeDirection.NORTH) ? z - 1 : z;
        for (ItemStack item : block.getDropsWand(world, x, y, z, md, player.isSneaking())) {
            float f = 0.7F;
            double d0 = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
            double d1 = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
            double d2 = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
            EntityItem entityitem = new EntityItem(world, (double) iX + d0, (double) iY + d1, (double) iZ + d2,
                    item);
            entityitem.delayBeforeCanPickup = 10;
            world.spawnEntityInWorld(entityitem);

        }
        world.setBlock(x, y, z, block.getBaseBlock(), block.getBaseMeta(), 2);
        return true;
    }
}
项目:ExtraUtilities    文件:BlockTransferNode.java   
public BoxModel getModel(final int metadata) {
    final ForgeDirection dir = ForgeDirection.getOrientation(metadata);
    final BoxModel boxes = new BoxModel();
    final float w = 0.125f;
    boxes.add(new Box(0.0625f, 0.0f, 0.0625f, 0.9375f, 0.0625f, 0.9375f).rotateToSide(dir).setTextureSides(dir.ordinal(), BlockTransferNode.nodeBase));
    boxes.add(new Box(0.1875f, 0.0625f, 0.1875f, 0.8125f, 0.25f, 0.8125f).rotateToSide(dir));
    boxes.add(new Box(0.3125f, 0.25f, 0.3125f, 0.6875f, 0.375f, 0.6875f).rotateToSide(dir));
    boxes.add(new Box(0.375f, 0.25f, 0.375f, 0.625f, 0.375f, 0.625f).rotateToSide(dir).setTexture(BlockTransferNode.nodeBase).setAllSideInvisible().setSideInvisible(dir.getOpposite().ordinal(), false));
    return boxes;
}
项目:4Space-5    文件:MjAPI.java   
private static BatteryField getMjBatteryField(Class c, String kind, ForgeDirection side) {
    BatteryHolder holder = new BatteryHolder();
    holder.clazz = c;
    holder.kind = kind;
    holder.side = side;

    BatteryField bField = mjBatteries.get(holder);

    if (bField == null) {
        for (Field f : JavaTools.getAllFields(c)) {
            MjBattery battery = f.getAnnotation(MjBattery.class);

            if (battery != null && kind.equals(battery.kind())) {
                if (!contains(battery.sides(), side) && !contains(battery.sides(), ForgeDirection.UNKNOWN)) {
                    continue;
                }
                f.setAccessible(true);
                bField = new BatteryField();
                bField.field = f;
                bField.battery = battery;

                if (double.class.equals(f.getType())) {
                    bField.kind = BatteryKind.Value;
                } else if (f.getType().isPrimitive()) {
                    throw new RuntimeException(
                            "MJ battery needs to be object or double type");
                } else {
                    bField.kind = BatteryKind.Container;
                }

                mjBatteries.put(holder, bField);

                return bField;
            }
        }
        mjBatteries.put(holder, invalidBatteryField);
    }

    return bField == invalidBatteryField ? null : bField;
}
项目:FiveNightsAtFreddysUniverseMod    文件:BlockCamera.java   
public boolean canPlaceBlockOnSide(World par1World, int par2, int par3, int par4, int par5){

      ForgeDirection dir = ForgeDirection.getOrientation(par5);
      return (dir == NORTH && par1World.isSideSolid(par2, par3, par4 + 1, NORTH)) ||
             (dir == SOUTH && par1World.isSideSolid(par2, par3, par4 - 1, SOUTH)) ||
             (dir == WEST  && par1World.isSideSolid(par2 + 1, par3, par4, WEST )) ||
             (dir == EAST  && par1World.isSideSolid(par2 - 1, par3, par4, EAST ));
  }
项目:RFUtilities    文件:BlockCapacitor.java   
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int meta, float hitX, float hitY, float hitZ)
{
    TileEntity te = world.getTileEntity(x, y, z);
    if (te instanceof TileEntityCapacitor && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemMultimeter && !world.isRemote)
    {
        player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("desc.rfutilities:stored.name") + " " + ((TileEntityCapacitor)te).getEnergyStored(ForgeDirection.UNKNOWN) + " " + StatCollector.translateToLocal("desc.rfutilities:rf.name") + " / " + ((TileEntityCapacitor)te).getMaxEnergyStored(ForgeDirection.UNKNOWN) + " " + StatCollector.translateToLocal("desc.rfutilities:rf.name")));
        //LogHelper.info(((TileEntityCapacitor)world.getTileEntity(x, y, z)).type);
        return true;
    }
    return false;
}
项目:RFUtilities    文件:TileEntityDiode.java   
@Override
public boolean canConnectEnergy(ForgeDirection fd)
{
    switch (worldObj.getBlockMetadata(xCoord, yCoord, zCoord))
    {
        case 2: return (fd == ForgeDirection.NORTH || fd == ForgeDirection.SOUTH);
        case 3: return (fd == ForgeDirection.EAST || fd == ForgeDirection.WEST);
        case 4: return (fd == ForgeDirection.NORTH || fd == ForgeDirection.SOUTH);
        case 5: return (fd == ForgeDirection.EAST || fd == ForgeDirection.WEST);
        default: return false;
    }
}
项目:4Space-5    文件:NetworkHelper.java   
/**
 * Tries to find the electricity network based in a tile entity and checks
 * to see if it is a conductor. All machines should use this function to
 * search for a connecting conductor around it.
 *
 * @param conductor         - The TileEntity conductor
 * @param approachDirection - The direction you are approaching this wire from.
 * @return The ElectricityNetwork or null if not found.
 */
public static IElectricityNetwork getElectricalNetworkFromTileEntity(TileEntity tileEntity, ForgeDirection approachDirection)
{
    if (tileEntity != null)
    {
        if (tileEntity instanceof INetworkProvider)
        {
            if (tileEntity instanceof IConnector)
            {
                if (((IConnector) tileEntity).canConnect(approachDirection.getOpposite(), NetworkType.POWER))
                {
                    if (((INetworkProvider) tileEntity).getNetwork() instanceof IElectricityNetwork)
                    {
                        return (IElectricityNetwork) ((INetworkProvider) tileEntity).getNetwork();
                    }
                }
            }
            else
            {
                if (((INetworkProvider) tileEntity).getNetwork() instanceof IElectricityNetwork)
                {
                    return (IElectricityNetwork) ((INetworkProvider) tileEntity).getNetwork();
                }
            }
        }
    }

    return null;
}
项目:4Space-5    文件:DungeonRoomSpawner.java   
public DungeonRoomSpawner(DungeonMapGen dungeon, int posX, int posY, int posZ, ForgeDirection entranceDir) {
    super(dungeon, posX, posY, posZ, entranceDir);
    if (this.worldObj != null) {
        this.rand = new Random(this.worldObj.getSeed() * posX * posY * 57 * posZ);
        this.sizeX = this.rand.nextInt(5) + 6;
        this.sizeY = this.rand.nextInt(2) + 4;
        this.sizeZ = this.rand.nextInt(5) + 6;
    }
}
项目:NyaSamaRailway    文件:BlockSignalLight.java   
public void updateLight(World world, int x ,int y, int z) {
    if (world.getTileEntity(x, y, z) == null) return;
    if (world.getTileEntity(x, y, z) instanceof SignalLight) {
        SignalLight signalLight = (SignalLight) world.getTileEntity(x, y, z);
        boolean isEnable;
        if (signalLight.getSender() == null) {
            isEnable = signalLight.isPowered ^ thisBlockIsPowered(world, x, y, z);
        } else {
            isEnable = signalLight.senderIsPowered() ^ thisBlockIsPowered(world, x, y, z);
        }
        int meta = world.getBlockMetadata(x, y, z);
        int old = meta;

        meta = meta & 0x3;
        if (signalLight.isBlinking) {
            if (signalLight.delay > 10) {
                if (signalLight.delay < 20) {
                    signalLight.delay += 1;
                } else {
                    signalLight.delay = 0;
                }
                meta = setLightState(isEnable, meta, signalLight.lightType);
            } else {
                signalLight.delay += 1;
            }
        } else {
            meta = setLightState(isEnable, meta, signalLight.lightType);
        }

        ForgeDirection lightDir = getLightDir(world, x, y, z);
        boolean isLightOn = isLightOn(world, x, y, z);
        BlockLoader.lineBeam.lightCtl(world, x, y, z, lightDir, 16, isLightOn);

        if (old != meta || !signalLight.prevLightType.equals(signalLight.lightType)) {
            signalLight.prevLightType = signalLight.lightType;
            world.setBlockMetadataWithNotify(x, y, z, meta, 3);
            world.markBlockForUpdate(x, y, z);
        }
    }
}
项目:MidgarCrusade    文件:WorldGenBigTreesDim.java   
/**
 * Returns a boolean indicating whether or not the current location for the tree, spanning basePos to to the height
 * limit, is valid.
 */
boolean validTreeLocation()
{
    int[] aint = new int[] {this.basePos[0], this.basePos[1], this.basePos[2]};
    int[] aint1 = new int[] {this.basePos[0], this.basePos[1] + this.heightLimit - 1, this.basePos[2]};
    Block block = this.worldObj.getBlock(this.basePos[0], this.basePos[1] - 1, this.basePos[2]);

    boolean isSoil = block.canSustainPlant(worldObj, basePos[0], basePos[1] - 1, basePos[2], ForgeDirection.UP, (BlockSapling)Blocks.sapling);
    if (!isSoil)
    {
        return false;
    }
    else
    {
        int i = this.checkBlockLine(aint, aint1);

        if (i == -1)
        {
            return true;
        }
        else if (i < 6)
        {
            return false;
        }
        else
        {
            this.heightLimit = i;
            return true;
        }
    }
}
项目:RFUtilities    文件:TileEntityInvisibleTesseract.java   
@Override
public int receiveEnergy(ForgeDirection fd, int amount, boolean simulate)
{
    if (isActive && canConnectEnergy(fd))
    {
        if (isSender)
        {
            if (!tesseracts.isEmpty())
            {
                int toSend = 0;
                for (TileEntityInvisibleTesseract te:tesseracts)
                {
                    toSend += te.receiveEnergy(amount, simulate);
                }
                return toSend;
            }
            else
            {
                return 0;
            }
        }
        else
        {
            return 0;
        }
    }
    else
    {
        return 0;
    }
}
项目:NyaSamaRailway    文件:BlockTriSignalLight.java   
public void updateLight(World world, int x , int y, int z) {
    if (world.getTileEntity(x, y, z) instanceof TriSignalLight) {
        TriSignalLight triSignalLight = (TriSignalLight) world.getTileEntity(x, y, z);
        int old = world.getBlockMetadata(x, y, z);
        int meta = old & 0x3;

        switch (triSignalLight.state) {
            case TriSignalLight.STATE_POS: // Y
                meta |= 0x4;
                break;
            case TriSignalLight.STATE_NEG: // R
                meta |= 0x8;
                break;
            case TriSignalLight.STATE_ZERO: // G
                meta &= 0x3;
                break;
            default:
                break;
        }

        triSignalLight.prevState = triSignalLight.state;
        triSignalLight.state = TriSignalLight.STATE_ZERO;

        ForgeDirection lightDir = getLightDir(world, x, y, z);
        BlockLoader.lineBeam.lightCtl(world, x, y, z, lightDir, 8, true);

        if (old != meta) {
            world.setBlockMetadataWithNotify(x, y, z, meta, 3);
            world.notifyBlockChange(x, y, z, this);
            world.markBlockForUpdate(x, y, z);
        }
    }
}
项目:4Space-5    文件:Vector3.java   
/**
 * Converts Vector3 into a ForgeDirection.
 */
public ForgeDirection toForgeDirection()
{
    for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
    {
        if (this.x == direction.offsetX && this.y == direction.offsetY && this.z == direction.offsetZ)
        {
            return direction;
        }
    }

    return ForgeDirection.UNKNOWN;
}
项目:ExtraUtilities    文件:FakeRenderBlocks.java   
public boolean matchBlock(final int side2, final int x2, final int y2, final int z2) {
    final Block block = this.blockAccess.getBlock(x2, y2, z2);
    if (block == this.curBlock) {
        return this.curMeta == this.blockAccess.getBlockMetadata(x2, y2, z2);
    }
    if (block instanceof IBlockAppearance) {
        final IBlockAppearance block2 = (IBlockAppearance)block;
        return block2.supportsVisualConnections() && this.curBlock == block2.getVisualBlock(this.blockAccess, x2, y2, z2, ForgeDirection.getOrientation(side2)) && this.curMeta == block2.getVisualMeta(this.blockAccess, x2, y2, z2, ForgeDirection.getOrientation(side2));
    }
    return false;
}
项目:ExtraUtilities    文件:TileEntityRetrievalNodeLiquid.java   
public void unloadTank() {
    if (this.buffer.isEmpty()) {
        return;
    }
    final int dir = this.getBlockMetadata() % 6;
    final ForgeDirection side = ForgeDirection.getOrientation(dir).getOpposite();
    if (this.worldObj.getTileEntity(this.xCoord + Facing.offsetsXForSide[dir], this.yCoord + Facing.offsetsYForSide[dir], this.zCoord + Facing.offsetsZForSide[dir]) instanceof IFluidHandler) {
        final IFluidHandler dest = (IFluidHandler)this.worldObj.getTileEntity(this.xCoord + Facing.offsetsXForSide[dir], this.yCoord + Facing.offsetsYForSide[dir], this.zCoord + Facing.offsetsZForSide[dir]);
        final FluidTank tank = (FluidTank)this.buffer.getBuffer();
        final int a = dest.fill(side, tank.getFluid(), this.initDirection());
        if (a > 0) {
            dest.fill(side, tank.drain(a, true), true);
        }
    }
}
项目:4Space-5    文件:TileBaseUniversalConductor.java   
@RuntimeInterface(clazz = "cofh.api.energy.IEnergyReceiver", modID = "")
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate)
{
    if (this.getNetwork() == null)
    {
        return 0;
    }
    float receiveGC = maxReceive * EnergyConfigHandler.RF_RATIO;
    float sentGC = receiveGC - this.getNetwork().produce(receiveGC, !simulate, 1);
    return MathHelper.floor_float(sentGC / EnergyConfigHandler.RF_RATIO);
}
项目:4Space-5    文件:BlockVec3.java   
/**
 * No chunk load: returns null if chunk to side is unloaded
 */
public TileEntity getTileEntityOnSide(World world, ForgeDirection side)
{
    int x = this.x;
    int y = this.y;
    int z = this.z;
    switch (side.ordinal())
    {
    case 0:
        y--;
        break;
    case 1:
        y++;
        break;
    case 2:
        z--;
        break;
    case 3:
        z++;
        break;
    case 4:
        x--;
        break;
    case 5:
        x++;
        break;
    default:
        return null;
    }
    if (world.blockExists(x, y, z))
    {
        return world.getTileEntity(x, y, z);
    }
    else
    {
        return null;
    }
}
项目:4Space-5    文件:BlockSulfurTorch.java   
@Override
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block par5) {
    if (this.dropTorchIfCantStay(par1World, par2, par3, par4)) {
        final int i1 = par1World.getBlockMetadata(par2, par3, par4);
        boolean flag = false;

        if (!par1World.isSideSolid(par2 - 1, par3, par4, ForgeDirection.EAST, true) && i1 == 1) {
            flag = true;
        }

        if (!par1World.isSideSolid(par2 + 1, par3, par4, ForgeDirection.WEST, true) && i1 == 2) {
            flag = true;
        }

        if (!par1World.isSideSolid(par2, par3, par4 - 1, ForgeDirection.SOUTH, true) && i1 == 3) {
            flag = true;
        }

        if (!par1World.isSideSolid(par2, par3, par4 + 1, ForgeDirection.NORTH, true) && i1 == 4) {
            flag = true;
        }

        if (!this.canPlaceTorchOn(par1World, par2, par3 - 1, par4) && i1 == 5) {
            flag = true;
        }

        if (flag) {
            this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
            par1World.setBlockToAir(par2, par3, par4);
        }
    }
}
项目:4Space-5    文件:DungeonRoomTreasure.java   
public DungeonRoomTreasure(DungeonMapGen dungeon, int posX, int posY, int posZ, ForgeDirection entranceDir) {
    super(dungeon, posX, posY, posZ, entranceDir);
    if (this.worldObj != null) {
        final Random rand = new Random(this.worldObj.getSeed() * posX * posY * 57 * posZ);
        this.sizeX = rand.nextInt(6) + 7;
        this.sizeY = rand.nextInt(2) + 5;
        this.sizeZ = rand.nextInt(6) + 7;
    }
}
项目:4Space-5    文件:RoomChestsMoon.java   
public RoomChestsMoon(MapGenDungeon dungeon, int posX, int posY, int posZ, ForgeDirection entranceDir)
{
    super(dungeon, posX, posY, posZ, entranceDir);
    if (this.worldObj != null)
    {
        final Random rand = new Random(this.worldObj.getSeed() * posX * posY * 57 * posZ);
        this.sizeX = rand.nextInt(5) + 6;
        this.sizeY = rand.nextInt(2) + 4;
        this.sizeZ = rand.nextInt(5) + 6;
    }
}