net.minecraftforge.common.util.ForgeDirection Java Examples

The following examples show how to use net.minecraftforge.common.util.ForgeDirection. 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: TileEntityPneumaticDoorBase.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound tag){
    super.readFromNBT(tag);
    progress = tag.getFloat("extension");
    opening = tag.getBoolean("opening");
    redstoneMode = tag.getInteger("redstoneMode");
    orientation = ForgeDirection.getOrientation(tag.getInteger("orientation"));
    rightGoing = tag.getBoolean("rightGoing");
    // Read in the ItemStacks in the inventory from NBT
    NBTTagList tagList = tag.getTagList("Items", 10);
    inventory = new ItemStack[getSizeInventory()];
    for(int i = 0; i < tagList.tagCount(); ++i) {
        NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
        byte slot = tagCompound.getByte("Slot");
        if(slot >= 0 && slot < inventory.length) {
            inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound);
        }
    }
}
 
Example #2
Source File: TileEntityUVLightBox.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void updateEntity(){
    super.updateEntity();
    if(!worldObj.isRemote) {
        ticksExisted++;
        if(getPressure(ForgeDirection.UNKNOWN) >= PneumaticValues.MIN_PRESSURE_UV_LIGHTBOX && inventory[0] != null && inventory[0].getItem() == Itemss.emptyPCB && inventory[0].getItemDamage() > 0) {

            addAir((int)(-PneumaticValues.USAGE_UV_LIGHTBOX * getSpeedUsageMultiplierFromUpgrades(getUpgradeSlots())), ForgeDirection.UNKNOWN);
            if(ticksExisted % Math.max(1, (int)(TileEntityConstants.LIGHT_BOX_0_100_TIME / (5 * getSpeedMultiplierFromUpgrades(getUpgradeSlots())))) == 0) {
                if(!areLightsOn) {
                    areLightsOn = true;
                    updateNeighbours();
                }
                inventory[0].setItemDamage(Math.max(0, inventory[0].getItemDamage() - 1));
            }
        } else if(areLightsOn) {
            areLightsOn = false;
            updateNeighbours();
        }
        if(oldRedstoneStatus != shouldEmitRedstone()) {
            oldRedstoneStatus = !oldRedstoneStatus;
            updateNeighbours();
        }
    }
}
 
Example #3
Source File: HeatExchangerManager.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
public IHeatExchangerLogic getLogic(World world, int x, int y, int z, ForgeDirection side){
    if(!world.blockExists(x, y, z)) return null;
    TileEntity te = world.getTileEntity(x, y, z);
    if(te instanceof IHeatExchanger) {
        return ((IHeatExchanger)te).getHeatExchangerLogic(side);
    } else {
        if(world.isAirBlock(x, y, z)) {
            return AIR_EXCHANGER;
        } else {
            Block block = world.getBlock(x, y, z);
            if(block instanceof IHeatExchanger) {
                return ((IHeatExchanger)block).getHeatExchangerLogic(side);
            } else {
                IHeatExchanger exchanger = specialBlockExchangers.get(block);
                return exchanger == null ? null : exchanger.getHeatExchangerLogic(side);
            }
        }
    }
}
 
Example #4
Source File: BlockConnected.java    From GardenCollection with MIT License 6 votes vote down vote up
public int calcConnectionFlags (IBlockAccess world, int x, int y, int z) {
    Block blockYNeg = world.getBlock(x, y - 1, z);
    Block blockYPos = world.getBlock(x, y + 1, z);
    Block blockZNeg = world.getBlock(x, y, z - 1);
    Block blockZPos = world.getBlock(x, y, z + 1);
    Block blockXNeg = world.getBlock(x - 1, y, z);
    Block blockXPos = world.getBlock(x + 1, y, z);

    boolean hardYNeg = isNeighborHardConnection(world, x, y - 1, z, blockYNeg, ForgeDirection.DOWN);
    boolean hardYPos = isNeighborHardConnection(world, x, y + 1, z, blockYPos, ForgeDirection.UP);
    boolean hardZNeg = isNeighborHardConnection(world, x, y, z - 1, blockZNeg, ForgeDirection.NORTH);
    boolean hardZPos = isNeighborHardConnection(world, x, y, z + 1, blockZPos, ForgeDirection.SOUTH);
    boolean hardXNeg = isNeighborHardConnection(world, x - 1, y, z, blockXNeg, ForgeDirection.WEST);
    boolean hardXPos = isNeighborHardConnection(world, x + 1, y, z, blockXPos, ForgeDirection.EAST);

    boolean extYNeg = isNeighborExtConnection(world, x, y - 1, z, blockYNeg, ForgeDirection.DOWN);
    boolean extYPos = isNeighborExtConnection(world, x, y + 1, z, blockYPos, ForgeDirection.UP);
    boolean extZNeg = isNeighborExtConnection(world, x, y, z - 1, blockZNeg, ForgeDirection.NORTH);
    boolean extZPos = isNeighborExtConnection(world, x, y, z + 1, blockZPos, ForgeDirection.SOUTH);
    boolean extXNeg = isNeighborExtConnection(world, x - 1, y, z, blockXNeg, ForgeDirection.WEST);
    boolean extXPos = isNeighborExtConnection(world, x + 1, y, z, blockXPos, ForgeDirection.EAST);

    return (hardYNeg ? 1 : 0) | (hardYPos ? 2 : 0) | (hardZNeg ? 4 : 0) | (hardZPos ? 8 : 0) | (hardXNeg ? 16 : 0) | (hardXPos ? 32 : 0)
        | (extYNeg ? 64 : 0) | (extYPos ? 128 : 0) | (extZNeg ? 256 : 0) | (extZPos ? 512 : 0) | (extXNeg ? 1024 : 0) | (extXPos ? 2048 : 0);
}
 
Example #5
Source File: BlockReactorRedstonePort.java    From BigReactors with MIT License 5 votes vote down vote up
/**
 * A randomly called display update to be able to add particles or other items for display
 */
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random par5Random)
{
	TileEntity te = world.getTileEntity(x, y, z);
    if (te instanceof TileEntityReactorRedstonePort)
    {
    	TileEntityReactorRedstonePort port = (TileEntityReactorRedstonePort)te;
    	if(port.isRedstoneActive()) {
            ForgeDirection out = port.getOutwardsDir();
            
            if(out != ForgeDirection.UNKNOWN) {
                double particleX, particleY, particleZ;
                particleY = y + 0.45D + par5Random.nextFloat() * 0.1D;

                if(out.offsetX > 0)
                	particleX = x + par5Random.nextFloat() * 0.1D + 1.1D;
                else
                	particleX = x + 0.45D + par5Random.nextFloat() * 0.1D;
                
                if(out.offsetZ > 0)
                	particleZ = z + par5Random.nextFloat() * 0.1D + 1.1D;
                else
                	particleZ = z + 0.45D + par5Random.nextFloat() * 0.1D;

                world.spawnParticle("reddust", particleX, particleY, particleZ, 0.0D, par5Random.nextFloat() * 0.1D, 0.0D);
            }
    	}
    }
}
 
Example #6
Source File: FarmLogicHelium.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean cultivate(int x, int y, int z, ForgeDirection d, int extent){
    for(int i = 0; i < extent; i++) {
        if(tryPlaceSoil(x + d.offsetX * i, y + d.offsetY * i - 2, z + d.offsetZ * i)) return true;
    }
    for(int i = 0; i < extent; i++) {
        if(manageCrops(x + d.offsetX * i, y + d.offsetY * i - 3, z + d.offsetZ * i)) return true;
    }
    return false;
}
 
Example #7
Source File: TileEntityVortexTube.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public IHeatExchangerLogic getHeatExchangerLogic(ForgeDirection side){
    if(side == ForgeDirection.UNKNOWN || side == getRotation().getOpposite()) {
        return hotHeatExchanger;
    } else if(side == getRotation()) {
        return coldHeatExchanger;
    } else {
        return null;
    }
}
 
Example #8
Source File: EntityDrone.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setEmittingRedstone(ForgeDirection side, int value){
    if(emittingRedstoneValues[side.ordinal()] != value) {
        emittingRedstoneValues[side.ordinal()] = value;
        worldObj.notifyBlocksOfNeighborChange((int)Math.floor(posX + width / 2), (int)Math.floor(posY), (int)Math.floor(posZ + width / 2), Blockss.droneRedstoneEmitter);
    }
}
 
Example #9
Source File: TileStickyJar.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Aspect getEssentiaType(ForgeDirection paramForgeDirection) {
    if(isValid()) {
        syncToParent();
        Aspect result = parent.getEssentiaType(changeDirection(paramForgeDirection));
        syncFromParent();
        return result;
    }
    return null;
}
 
Example #10
Source File: TileEntityBeefBase.java    From BigReactors with MIT License 5 votes vote down vote up
public TileEntityBeefBase() {
	super();

	facing = ForgeDirection.NORTH.ordinal();

	exposures = new int[6];
	for(int i = 0; i < exposures.length; i++) {
		exposures[i] = SIDE_UNEXPOSED;
	}

	ticksSinceLastUpdate = 0;
	updatePlayers = new HashSet<EntityPlayer>();
}
 
Example #11
Source File: BlockThinLog.java    From GardenCollection with MIT License 5 votes vote down vote up
private boolean isNeighborHardConnectionY (IBlockAccess world, int x, int y, int z, Block block, ForgeDirection side) {
    if (isNeighborHardConnection(world, x, y, z, block, side))
        return true;

    return block instanceof BlockLeavesBase
        || block == ModBlocks.thinLogFence;
}
 
Example #12
Source File: TileEntityCache.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public static TileEntityCache[] getDefaultCache(World world, int x, int y, int z){
    TileEntityCache[] cache = new TileEntityCache[6];
    for(int i = 0; i < 6; i++) {
        ForgeDirection d = ForgeDirection.getOrientation(i);
        cache[i] = new TileEntityCache(world, x + d.offsetX, y + d.offsetY, z + d.offsetZ);
    }
    return cache;
}
 
Example #13
Source File: Position.java    From Framez with GNU General Public License v3.0 5 votes vote down vote up
public Position(double ci, double cj, double ck, ForgeDirection corientation) {
	x = ci;
	y = cj;
	z = ck;
	orientation = corientation;

	if (orientation == null) {
		orientation = ForgeDirection.UNKNOWN;
	}
}
 
Example #14
Source File: TileEntityPneumaticGenerator.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void drawEnergy(double amount){
    int efficiency = Config.pneumaticGeneratorEfficiency;
    if(efficiency < 1) efficiency = 1;
    int airUsage = (int)(amount / 0.25F * 100F / efficiency);
    addAir(-airUsage, ForgeDirection.UNKNOWN);
    heatExchanger.addHeat(airUsage / 40);
    outputting = true;
    curEnergyProduction = (int)amount;
}
 
Example #15
Source File: BlockPneumaticDoor.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){
    TileEntityPneumaticDoorBase doorBase = getDoorBase(world, x, y, z);
    if(!world.isRemote && doorBase != null && doorBase.redstoneMode == 2 && doorBase.getPressure(ForgeDirection.UNKNOWN) >= PneumaticValues.MIN_PRESSURE_PNEUMATIC_DOOR) {
        doorBase.setOpening(!doorBase.isOpening());
        doorBase.setNeighborOpening(doorBase.isOpening());
        return true;
    }
    return false;
}
 
Example #16
Source File: TileEntityAerialInterface.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void updateEntity(){
    if(!worldObj.isRemote && updateNeighbours) {
        updateNeighbours = false;
        updateNeighbours();
    }
    if(!worldObj.isRemote) {
        if(getPressure(ForgeDirection.UNKNOWN) > PneumaticValues.MIN_PRESSURE_AERIAL_INTERFACE && isConnectedToPlayer) {
            if(energyRF != null) tickRF();
            addAir(-PneumaticValues.USAGE_AERIAL_INTERFACE, ForgeDirection.UNKNOWN);
            if(worldObj.getTotalWorldTime() % 40 == 0) dispenserUpgradeInserted = getUpgrades(ItemMachineUpgrade.UPGRADE_DISPENSER_DAMAGE) > 0;
            if(worldObj.getTotalWorldTime() % 20 == 0) {
                EntityPlayer player = getPlayer();
                if(player != null && player.getAir() <= 280) {
                    player.setAir(player.getAir() + 20);
                    addAir(-4000, null);
                }
            }
        }
        if(worldObj.getTotalWorldTime() % 20 == 0) getPlayerInventory();
    }

    if(oldRedstoneStatus != shouldEmitRedstone()) {
        oldRedstoneStatus = shouldEmitRedstone();
        updateNeighbours = true;
    }

    super.updateEntity();

}
 
Example #17
Source File: BlockVortexTube.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack){
    super.onBlockPlacedBy(world, x, y, z, par5EntityLiving, par6ItemStack);
    TileEntityVortexTube te = (TileEntityVortexTube)world.getTileEntity(x, y, z);
    for(int i = 0; i < 4; i++) {
        te.rotateRoll(1);
        ForgeDirection d = te.getTubeDirection();
        IPneumaticMachine pneumaticMachine = ModInteractionUtils.getInstance().getMachine(world.getTileEntity(x + d.offsetX, y + d.offsetY, z + d.offsetZ));
        if(pneumaticMachine != null && pneumaticMachine.isConnectedTo(d.getOpposite())) break;
    }
}
 
Example #18
Source File: WailaTubeModuleHandler.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public static void addModuleInfo(List<String> currenttip, TileEntityPressureTube tube, NBTTagCompound tubeTag, ForgeDirection dir){
    if(dir != ForgeDirection.UNKNOWN) {
        NBTTagList moduleList = tubeTag.getTagList("modules", 10);
        for(int i = 0; i < moduleList.tagCount(); i++) {
            NBTTagCompound moduleTag = moduleList.getCompoundTagAt(i);
            if(dir == ForgeDirection.getOrientation(moduleTag.getInteger("side"))) {
                if(tube != null && tube.modules[dir.ordinal()] != null) {
                    TubeModule module = tube.modules[dir.ordinal()];
                    module.readFromNBT(moduleTag);
                    module.addInfo(currenttip);
                }
            }
        }
    }
}
 
Example #19
Source File: TileStickyJar.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ForgeDirection changeDirection(ForgeDirection face) {
    if(placedOn == ForgeDirection.UP) {
        if(face == ForgeDirection.UP || face == ForgeDirection.DOWN) {
            return face.getOpposite();
        }
        return face;
    }

    if(placedOn == ForgeDirection.DOWN) {
        return face;
    }


    if(face == ForgeDirection.UP) {
        return ForgeDirection.NORTH;
    }
    if(face == ForgeDirection.DOWN) {
        return ForgeDirection.SOUTH;
    }
    if(face == placedOn) {
        return ForgeDirection.DOWN;
    }
    if(face == placedOn.getOpposite()) {
        return ForgeDirection.UP;
    }


    switch (placedOn) {
        case EAST: return face == ForgeDirection.NORTH ? ForgeDirection.WEST : ForgeDirection.EAST;
        case SOUTH: return face.getOpposite();
        case WEST: return face == ForgeDirection.SOUTH ? ForgeDirection.WEST : ForgeDirection.EAST;
    }

    return face;
}
 
Example #20
Source File: TileEssentiaCompressor.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean canOutputTo(ForgeDirection direction) {
    if(isMultiblockFormed() && multiblockYIndex == 1) { //The middle one
        return direction == ForgeDirection.SOUTH ||
                direction == ForgeDirection.NORTH ||
                direction == ForgeDirection.EAST ||
                direction == ForgeDirection.WEST;
    }
    return false;
}
 
Example #21
Source File: TileEntityDroneRedstoneEmitter.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void updateEntity(){
    for(ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
        if(Blockss.droneRedstoneEmitter.isProvidingWeakPower(worldObj, xCoord, yCoord, zCoord, d.ordinal()) > 0) {
            return;
        }
    }
    worldObj.setBlockToAir(xCoord, yCoord, zCoord);
}
 
Example #22
Source File: BlockPneumaticDoorBase.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
private void updateDoorSide(TileEntityPneumaticDoorBase doorBase){
    TileEntity teDoor = doorBase.getWorldObj().getTileEntity(doorBase.xCoord + doorBase.orientation.offsetX, doorBase.yCoord, doorBase.zCoord + doorBase.orientation.offsetZ);
    if(teDoor instanceof TileEntityPneumaticDoor) {
        TileEntityPneumaticDoor door = (TileEntityPneumaticDoor)teDoor;
        if(doorBase.orientation.getRotation(ForgeDirection.UP) == ForgeDirection.getOrientation(door.getBlockMetadata() % 6) && door.rightGoing || doorBase.orientation.getRotation(ForgeDirection.DOWN) == ForgeDirection.getOrientation(door.getBlockMetadata() % 6) && !door.rightGoing) {
            door.rightGoing = !door.rightGoing;
            door.setRotation(0);
        }
    }
}
 
Example #23
Source File: BlockLaserBeamSource.java    From Artifacts with MIT License 5 votes vote down vote up
@Override
public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int meta)
{
    ForgeDirection dir = ForgeDirection.getOrientation(meta);
    return (dir == NORTH && world.getBlock(x, y, z + 1).isSideSolid(world, x, y, z + 1, NORTH)) ||
           (dir == SOUTH && world.getBlock(x, y, z - 1).isSideSolid(world, x, y, z - 1, SOUTH)) ||
           (dir == WEST  && world.getBlock(x + 1, y, z).isSideSolid(world, x + 1, y, z, WEST )) ||
           (dir == EAST  && world.getBlock(x - 1, y, z).isSideSolid(world, x - 1, y, z, EAST ));
}
 
Example #24
Source File: BlockTrackEntryRF.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean shouldTrackWithThisEntry(IBlockAccess world, int x, int y, int z, Block block, TileEntity te){
    if(te instanceof IEnergyConnection) {
        IEnergyConnection connection = (IEnergyConnection)te;
        for(ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
            if(connection.canConnectEnergy(d)) return true;
        }
    }
    return false;
}
 
Example #25
Source File: TileEntityReactorPowerTap.java    From BigReactors with MIT License 5 votes vote down vote up
/** This will be called by the Reactor Controller when this tap should be providing power.
 * @return Power units remaining after consumption.
 */
public int onProvidePower(int units) {
	if(rfNetwork == null) {
		return units;
	}
	
	ForgeDirection approachDirection = getOutwardsDir().getOpposite();
	int energyConsumed = rfNetwork.receiveEnergy(approachDirection, (int)units, false);
	units -= energyConsumed;
	
	return units;
}
 
Example #26
Source File: BlockPneumaticDoorBase.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean rotateBlock(World world, EntityPlayer player, int x, int y, int z, ForgeDirection side){
    if(player.isSneaking()) {
        return super.rotateBlock(world, player, x, y, z, side);
    } else {
        TileEntity te = world.getTileEntity(x, y, z);
        if(te instanceof TileEntityPneumaticDoorBase) {
            TileEntityPneumaticDoorBase teDb = (TileEntityPneumaticDoorBase)te;
            teDb.orientation = teDb.orientation.getRotation(ForgeDirection.UP);
            return true;
        }
        return false;
    }
}
 
Example #27
Source File: TileEntityPoweredInventoryFluid.java    From BigReactors with MIT License 5 votes vote down vote up
/** Drains fluid out of internal tanks, distribution is left entirely to the IFluidHandler.
* 
* This method is not Fluid-sensitive.
   * @param from Orientation the fluid is drained to.
   * @param maxDrain Maximum amount of fluid to drain.
   * @param doDrain If false draining will only be simulated.
   * @return FluidStack representing the fluid and amount actually drained from the ITankContainer
   */
  public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
  	int tankToDrain = 0;
  	if(from != ForgeDirection.UNKNOWN) {
  		tankToDrain = getExposedTankFromSide(from.ordinal());
  	}

  	if(tankToDrain <= FLUIDTANK_NONE) {
  		return null;
  	} else {
  		return drain(tankToDrain, maxDrain, doDrain);
  	}
  }
 
Example #28
Source File: SubmapManagerSlab.java    From Chisel-2 with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void postRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
	if (!hadOverride) {
		((RenderBlocksCTM) renderer).rendererOld.clearOverrideBlockTexture();
	}
}
 
Example #29
Source File: BlockAerialInterface.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon(int side, int meta){
    switch(ForgeDirection.getOrientation(side)){
        case UP:
            return topTexture;
        case DOWN:
            return bottomTexture;
        default:
            return blockIcon;
    }
}
 
Example #30
Source File: BlockPneumaticDoorBase.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side){
    ForgeDirection d = ForgeDirection.getOrientation(side);
    TileEntityPneumaticDoorBase te = (TileEntityPneumaticDoorBase)world.getTileEntity(x - d.offsetX, y - d.offsetY, z - d.offsetZ);
    ItemStack camoStack = te.getStackInSlot(TileEntityPneumaticDoorBase.CAMO_SLOT);
    if(camoStack != null && camoStack.getItem() instanceof ItemBlock) {
        Block block = ((ItemBlock)camoStack.getItem()).field_150939_a;
        if(PneumaticCraftUtils.isRenderIDCamo(block.getRenderType())) {
            return true;
        }
    }
    return false;
}