Java Code Examples for net.minecraftforge.common.util.ForgeDirection#getRotation()

The following examples show how to use net.minecraftforge.common.util.ForgeDirection#getRotation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockArcaneDropper.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
    int metadata = world.getBlockMetadata(x, y, z);

    ForgeDirection direction = ForgeDirection.getOrientation(metadata & 7);
    boolean flipped = (metadata & 8) == 8;

    if(direction == ForgeDirection.SOUTH
            || direction == ForgeDirection.NORTH) {
        flipped = !flipped;
    }

    ForgeDirection rotated = direction.getRotation(flipped ? ForgeDirection.getOrientation((direction.ordinal() + 4) % 6) : ForgeDirection.getOrientation((direction.ordinal() + 2) % 6));

    return direction != side && rotated != side && rotated.getOpposite() != side;
}
 
Example 2
Source File: ModelUniversalSensor.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
public void renderModel(float size, float dishRotation, boolean[] sidesConnected){
    Base1.render(size);
    Base2.render(size);
    GL11.glPushMatrix();
    GL11.glRotatef(dishRotation, 0, 1, 0);
    Dish1.render(size);
    Dish2.render(size);
    Dish3.render(size);
    Dish4.render(size);
    Dish5.render(size);
    Dish6.render(size);
    GL11.glPopMatrix();
    ForgeDirection d = ForgeDirection.EAST;
    for(int i = 0; i < 4; i++) {
        d = d.getRotation(ForgeDirection.UP);
        if(sidesConnected[d.ordinal()]) {
            TubeConnection.rotateAngleY = (float)(i * Math.PI / 2);
            TubeConnection.render(size);
        }
    }
}
 
Example 3
Source File: BlockPressureTube.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Determine if this block can make a redstone connection on the side provided,
 * Useful to control which sides are inputs and outputs for redstone wires.
 *
 * Side:
 *  -1: UP
 *   0: NORTH
 *   1: EAST
 *   2: SOUTH
 *   3: WEST
 *
 * @param world The current world
 * @param x X Position
 * @param y Y Position
 * @param z Z Position
 * @param side The side that is trying to make the connection
 * @return True to make the connection
 */
@Override
public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side){
    if(side < 0 || side > 3) return false;
    TileEntityPressureTube tube = (TileEntityPressureTube)world.getTileEntity(x, y, z);
    ForgeDirection d = ForgeDirection.NORTH;
    for(int i = 0; i < side; i++) {
        d = d.getRotation(ForgeDirection.UP);
    }
    side = d.ordinal();
    for(int i = 0; i < 6; i++) {
        if(tube.modules[i] != null) {
            if((side ^ 1) == i || i != side && tube.modules[i].isInline()) {//if we are on the same side, or when we have an 'in line' module that is not on the opposite side.
                if(tube.modules[i] instanceof TubeModuleRedstoneEmitting) return true;
            }
        }
    }
    return false;
}
 
Example 4
Source File: TileEntityVortexTube.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
public ForgeDirection getTubeDirection(){
    ForgeDirection d;

    switch(getRotation()){
        case DOWN:
        case NORTH:
        case UP:
            d = ForgeDirection.WEST;
            break;
        case SOUTH:
            d = ForgeDirection.EAST;
            break;
        case WEST:
            d = ForgeDirection.SOUTH;
            break;
        case EAST:
            d = ForgeDirection.NORTH;
            break;
        default:
            d = ForgeDirection.SOUTH;
    }
    for(int i = 0; i < roll; i++) {
        d = d.getRotation(getRotation());
    }
    return d;
}
 
Example 5
Source File: ModelKeroseneLamp.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void renderStatic(float size, TileEntity te){
    ForgeDirection sideConnected = ForgeDirection.DOWN;
    if(te != null) {
        sideConnected = ((TileEntityKeroseneLamp)te).getSideConnected();
    }

    Tank.render(size);
    Holder1.render(size);
    Holder2.render(size);
    Base.render(size);
    Top.render(size);
    if(sideConnected != ForgeDirection.DOWN) {
        Support1.render(size);
        if(sideConnected != ForgeDirection.UP) {
            SupportSide.rotateAngleY = 0;
            ForgeDirection rotation = ((TileEntityKeroseneLamp)te).getRotation();
            if(rotation != ForgeDirection.UP && rotation != ForgeDirection.DOWN) {
                while(sideConnected != rotation.getOpposite()) {
                    sideConnected = sideConnected.getRotation(ForgeDirection.DOWN);
                    SupportSide.rotateAngleY += Math.toRadians(90);
                }
            }
            SupportSide2.rotateAngleY = SupportSide.rotateAngleY;
            SupportSide.render(size);
            SupportSide2.render(size);
        }
    }
    if(te != null) {
        FluidTankInfo info = ((TileEntityKeroseneLamp)te).getTankInfo(null)[0];
        if(info.fluid != null && info.fluid.amount > 10) {
            float percentageFull = (float)info.fluid.amount / info.capacity;
            RenderInfo renderInfo = new RenderInfo(-3 / 16F + 0.01F, 23 / 16F - percentageFull * 2.999F / 16F, -3 / 16F + 0.01F, 3 / 16F - 0.01F, 22.99F / 16F, 3 / 16F - 0.01F);
            RenderUtils.INSTANCE.renderLiquid(info, renderInfo, te.getWorldObj());
        }
    }
}