Java Code Examples for net.minecraftforge.common.util.ForgeDirection#VALID_DIRECTIONS

The following examples show how to use net.minecraftforge.common.util.ForgeDirection#VALID_DIRECTIONS . 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: PartFrame.java    From Framez with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void writeDesc(MCDataOutput packet) {

    if (hidden == null)
        hidden = new boolean[6];

    super.writeDesc(packet);

    for (int i = 0; i < 6; i++)
        packet.writeBoolean(hidden[i]);

    for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
        Collection<IFrameSideModifier> c = getSideModifiers(d);
        packet.writeInt(c.size());
        for (IFrameModifier m : c)
            packet.writeString(m.getType());
    }
}
 
Example 2
Source File: ProgWidgetPressureCondition.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected DroneAIBlockCondition getEvaluator(IDroneBase drone, IProgWidget widget){
    return new DroneAIBlockCondition(drone, (ProgWidgetAreaItemBase)widget){

        @Override
        protected boolean evaluate(ChunkPosition pos){
            TileEntity te = drone.getWorld().getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
            if(te instanceof IPneumaticMachine) {
                IAirHandler airHandler = ((IPneumaticMachine)te).getAirHandler();
                float pressure = Float.MIN_VALUE;
                for(ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                    if(getSides()[d.ordinal()]) {
                        pressure = Math.max(airHandler.getPressure(d), pressure);
                    }
                }
                return ((ICondition)widget).getOperator() == ICondition.Operator.EQUALS ? pressure == ((ICondition)widget).getRequiredCount() : pressure >= ((ICondition)widget).getRequiredCount();
            }
            return false;
        }

    };
}
 
Example 3
Source File: PathFinderDrone.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
/**
 * populates pathOptions with available points and returns the number of options found (args: unused1, currentPoint,
 * unused2, targetPoint, maxDistance)
 */
private int findPathOptions(Entity par1Entity, PathPoint par2PathPoint, PathPoint par3PathPoint, PathPoint par4PathPoint, float par5){
    int i = 0;
    byte b0 = 0;

    if(getVerticalOffset(par1Entity, par2PathPoint.xCoord, par2PathPoint.yCoord + 1, par2PathPoint.zCoord, par3PathPoint) == 1) {
        b0 = 1;
    }

    for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
        PathPoint safePoint = getSafePoint(par1Entity, par2PathPoint.xCoord + dir.offsetX, par2PathPoint.yCoord + dir.offsetY, par2PathPoint.zCoord + dir.offsetZ, par3PathPoint, b0);
        if(safePoint != null && !safePoint.isFirst && safePoint.distanceTo(par4PathPoint) < par5) {
            pathOptions[i++] = safePoint;
        }
    }

    return i;
}
 
Example 4
Source File: LogisticsManager.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
public static int getRequestedAmount(SemiBlockLogistics requester, FluidStack providingStack){
    int requestedAmount = requester instanceof ISpecificRequester ? ((ISpecificRequester)requester).amountRequested(providingStack) : providingStack.amount;
    if(requestedAmount == 0) return 0;
    providingStack = providingStack.copy();
    providingStack.amount = requestedAmount;
    FluidStack remainder = providingStack.copy();
    remainder.amount += requester.getIncomingFluid(remainder.getFluid());
    TileEntity te = requester.getTileEntity();
    if(te instanceof IFluidHandler) {
        IFluidHandler fluidHandler = (IFluidHandler)te;
        for(ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
            int fluidFilled = fluidHandler.fill(d, remainder, false);
            if(fluidFilled > 0) {
                remainder.amount -= fluidFilled;
                break;
            }
        }
    }
    providingStack.amount -= remainder.amount;
    if(providingStack.amount <= 0) return 0;
    return providingStack.amount;
}
 
Example 5
Source File: ChorusFlower.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
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;
}
 
Example 6
Source File: HeatBehaviourLiquidTransition.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
protected void transformSourceBlock(Block turningBlockSource, Block turningBlockFlowing){
    if(FluidUtils.isSourceBlock(getWorld(), getX(), getY(), getZ())) {
        getWorld().setBlock(getX(), getY(), getZ(), turningBlockSource);
        onLiquidTransition(getX(), getY(), getZ());
    } else {
        Set<ChunkPosition> traversed = new HashSet<ChunkPosition>();
        Stack<ChunkPosition> pending = new Stack<ChunkPosition>();
        pending.push(new ChunkPosition(getX(), getY(), getZ()));
        while(!pending.isEmpty()) {
            ChunkPosition pos = pending.pop();
            for(ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                ChunkPosition newPos = new ChunkPosition(pos.chunkPosX + d.offsetX, pos.chunkPosY + d.offsetY, pos.chunkPosZ + d.offsetZ);
                Block checkingBlock = getWorld().getBlock(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ);
                if((checkingBlock == getBlock() || getBlock() == Blocks.flowing_water && checkingBlock == Blocks.water || getBlock() == Blocks.flowing_lava && checkingBlock == Blocks.lava) && traversed.add(newPos)) {
                    if(FluidUtils.isSourceBlock(getWorld(), newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ)) {
                        getWorld().setBlock(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ, turningBlockSource);
                        onLiquidTransition(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ);
                        return;
                    } else {
                        getWorld().setBlock(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ, turningBlockFlowing);
                        onLiquidTransition(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ);
                        pending.push(newPos);
                    }
                }
            }
        }
    }
}
 
Example 7
Source File: TileEntityPressureTube.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public void updateConnections(World world, int x, int y, int z){
    sidesConnected = new boolean[6];
    boolean hasModule = false;
    for(ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
        TileEntity te = getTileCache()[direction.ordinal()].getTileEntity();
        IPneumaticMachine machine = ModInteractionUtils.getInstance().getMachine(te);
        if(machine != null) {
            sidesConnected[direction.ordinal()] = isConnectedTo(direction) && machine.isConnectedTo(direction.getOpposite());
        } else if(te instanceof ISidedPneumaticMachine) {
            sidesConnected[direction.ordinal()] = ((ISidedPneumaticMachine)te).getAirHandler(direction.getOpposite()) != null;
        }
        if(modules[direction.ordinal()] != null) {
            hasModule = true;
        }
    }
    int sidesCount = 0;
    for(boolean bool : sidesConnected) {
        if(bool) sidesCount++;
    }
    if(sidesCount == 1 && !hasModule) {
        for(int i = 0; i < 6; i++) {
            if(sidesConnected[i]) {
                if(isConnectedTo(ForgeDirection.getOrientation(i).getOpposite())) sidesConnected[i ^ 1] = true;
                break;
            }
        }
    }
    for(int i = 0; i < 6; i++) {
        if(modules[i] != null && modules[i].isInline()) sidesConnected[i] = false;
    }
}
 
Example 8
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 9
Source File: TileEntityAssemblyController.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
private void getMachines(List<IAssemblyMachine> machineList, int x, int y, int z){
    for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
        if(dir == ForgeDirection.UP || dir == ForgeDirection.DOWN) continue;
        TileEntity te = worldObj.getTileEntity(x + dir.offsetX, y, z + dir.offsetZ);
        if(te instanceof IAssemblyMachine && !machineList.contains(te)) {
            machineList.add((IAssemblyMachine)te);
            getMachines(machineList, te.xCoord, te.yCoord, te.zCoord);
        }
    }
}
 
Example 10
Source File: TubeModuleRedstoneReceiving.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onNeighborBlockUpdate(){
    redstoneLevel = 0;
    for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
        if(dir == side || isInline() && side != dir.getOpposite()) redstoneLevel = Math.max(redstoneLevel, pressureTube.world().getIndirectPowerLevelTo(pressureTube.x() + side.offsetX, pressureTube.y() + side.offsetY, pressureTube.z() + side.offsetZ, side.ordinal()));
    }
}
 
Example 11
Source File: TileEntityUniversalSensor.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onNeighborTileUpdate(){
    super.onNeighborTileUpdate();
    for(ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
        TileEntity te = worldObj.getTileEntity(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);
        if(te instanceof IPneumaticMachine) {
            sidesConnected[direction.ordinal()] = ((IPneumaticMachine)te).isConnectedTo(direction.getOpposite());
        } else {
            sidesConnected[direction.ordinal()] = false;
        }
    }
}
 
Example 12
Source File: TileEntityProgrammer.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public boolean hasEnoughPuzzleStacks(EntityPlayer player, ItemStack stack){
    int amountLeft = stack.stackSize;
    if(player != null) {
        for(int i = 0; i < player.inventory.getSizeInventory(); i++) {
            ItemStack playerStack = player.inventory.getStackInSlot(i);
            if(PneumaticCraftUtils.areStacksEqual(playerStack, stack, true, true, false, false)) {
                amountLeft -= playerStack.stackSize;
                if(amountLeft <= 0) return true;
            }
        }
    }

    for(ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
        IInventory neighbor = IOHelper.getInventoryForTE(getWorldObj().getTileEntity(xCoord + d.offsetX, yCoord + d.offsetY, zCoord + d.offsetZ));
        for(int slot : IOHelper.getAccessibleSlotsForInventory(neighbor, d.getOpposite())) {
            if(IOHelper.canExtractItemFromInventory(neighbor, stack, slot, d.getOpposite().ordinal())) {
                ItemStack neighborStack = neighbor.getStackInSlot(slot);
                if(PneumaticCraftUtils.areStacksEqual(neighborStack, stack, true, true, false, false)) {
                    amountLeft -= neighborStack.stackSize;
                    if(amountLeft <= 0) return true;
                }
            }
        }
    }

    return false;
}
 
Example 13
Source File: TileEntityWrathCage.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
void drawEssentia()
{
    for(int x = 0;x < ForgeDirection.VALID_DIRECTIONS.length;x++){
        ForgeDirection current = ForgeDirection.VALID_DIRECTIONS[x];
        TileEntity te = ThaumcraftApiHelper.getConnectableTile(worldObj, xCoord, yCoord, zCoord, current);
        if(te != null) {
            IEssentiaTransport ic = (IEssentiaTransport)te;
            if(ic.canOutputTo(current.getOpposite()) && special < 64 //THE DIRECTION HERE MAY BE WRONG SPITEFULFOXY SO CHECK IT
                && ic.getEssentiaType(current.getOpposite()) == aspect && ic.getEssentiaAmount(current.getOpposite()) > 0 && ic.takeEssentia(aspect, 1, current.getOpposite()) == 1) {
                special++;
                worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
                return;
            }
            else if(ic.canOutputTo(current.getOpposite()) && wrath < 64 && special < Config.wrathCost
                && ic.getEssentiaType(current.getOpposite()) == DarkAspects.WRATH && ic.getEssentiaAmount(current.getOpposite()) > 0 && ic.takeEssentia(DarkAspects.WRATH, 1, current.getOpposite()) == 1) {
                wrath++;
                worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
                return;
            }
            else if(ic.canOutputTo(current.getOpposite()) && sloth < 64 && special < Config.wrathCost && wrath < Config.wrathCost
                && ic.getEssentiaType(current.getOpposite()) == DarkAspects.SLOTH && ic.getEssentiaAmount(current.getOpposite()) > 0 && ic.takeEssentia(DarkAspects.SLOTH, 1, current.getOpposite()) == 1) {
                sloth++;
                worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
                return;
            }
        }
    }
}
 
Example 14
Source File: SubTileFunctional.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
@Override
public void onUpdate() {
	super.onUpdate();

	linkPool();

	if(linkedPool != null && isValidBinding()) {
		IManaPool pool = (IManaPool) linkedPool;
		int manaInPool = pool.getCurrentMana();
		int manaMissing = getMaxMana() - mana;
		int manaToRemove = Math.min(manaMissing, manaInPool);
		pool.recieveMana(-manaToRemove);
		addMana(manaToRemove);
	}

	if(acceptsRedstone()) {
		redstoneSignal = 0;
		for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
			int redstoneSide = supertile.getWorldObj().getIndirectPowerLevelTo(supertile.xCoord + dir.offsetX, supertile.yCoord + dir.offsetY, supertile.zCoord + dir.offsetZ, dir.ordinal());
			redstoneSignal = Math.max(redstoneSignal, redstoneSide);
		}
	}

	if(supertile.getWorldObj().isRemote) {
		double particleChance = 1F - (double) mana / (double) getMaxMana() / 3.5F;
		Color color = new Color(getColor());
		if(Math.random() > particleChance)
			BotaniaAPI.internalHandler.sparkleFX(supertile.getWorldObj(), supertile.xCoord + 0.3 + Math.random() * 0.5, supertile.yCoord + 0.5 + Math.random()  * 0.5, supertile.zCoord + 0.3 + Math.random() * 0.5, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random(), 5);
	}
}
 
Example 15
Source File: TileEntityKeroseneLamp.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onNeighborBlockUpdate(){
    super.onNeighborBlockUpdate();
    sideConnected = ForgeDirection.DOWN;
    for(ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
        int x = xCoord + d.offsetX;
        int y = yCoord + d.offsetY;
        int z = zCoord + d.offsetZ;
        Block block = worldObj.getBlock(x, y, z);
        if(block.isSideSolid(worldObj, x, y, z, d.getOpposite())) {
            sideConnected = d;
            break;
        }
    }
}
 
Example 16
Source File: TileKnowledgeBook.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void searchForCognitio() {
    if((ticksExisted & 31) == 0) {
        int drainRange = 4;
        ForgeDirection[] toTry = ForgeDirection.VALID_DIRECTIONS;
        for (ForgeDirection dir : toTry) {
            if(dir == null) continue; //LUL should not happen...
            if(EssentiaHandler.drainEssentia(this, Aspect.MIND, dir, drainRange)) {
                ticksCognitio += COGNITIO_TICKS;
                worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
                markDirty();
                break;
            }
        }
    }
}
 
Example 17
Source File: BlockPressureTube.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 origin, Vec3 direction){
    MovingObjectPosition bestMOP = null;
    AxisAlignedBB bestAABB = null;

    setBlockBounds(BBConstants.PRESSURE_PIPE_MIN_POS, BBConstants.PRESSURE_PIPE_MIN_POS, BBConstants.PRESSURE_PIPE_MIN_POS, BBConstants.PRESSURE_PIPE_MAX_POS, BBConstants.PRESSURE_PIPE_MAX_POS, BBConstants.PRESSURE_PIPE_MAX_POS);
    MovingObjectPosition mop = super.collisionRayTrace(world, x, y, z, origin, direction);
    if(isCloserMOP(origin, bestMOP, mop)) {
        bestMOP = mop;
        bestAABB = AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
    }

    TileEntityPressureTube tube = ModInteractionUtils.getInstance().getTube(world.getTileEntity(x, y, z));
    for(int i = 0; i < 6; i++) {
        if(tube.sidesConnected[i]) {
            setBlockBounds(boundingBoxes[i]);
            mop = super.collisionRayTrace(world, x, y, z, origin, direction);
            if(isCloserMOP(origin, bestMOP, mop)) {
                bestMOP = mop;
                bestAABB = AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
            }
        }
    }

    if(bestMOP != null) bestMOP.hitInfo = ForgeDirection.UNKNOWN;//unknown indicates we hit the tube.

    TubeModule[] modules = tube.modules;
    for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
        if(modules[dir.ordinal()] != null) {
            setBlockBounds(modules[dir.ordinal()].boundingBoxes[dir.ordinal()]);
            mop = super.collisionRayTrace(world, x, y, z, origin, direction);
            if(isCloserMOP(origin, bestMOP, mop)) {
                mop.hitInfo = dir;
                bestMOP = mop;
                bestAABB = AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
            }
        }
    }
    if(bestAABB != null) setBlockBounds(bestAABB);
    return bestMOP;
}
 
Example 18
Source File: TileEntityAirCannon.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
private void updateTrackedItems(){
    if(trackedItemIds != null) {
        trackedItems.clear();
        for(Entity entity : (List<Entity>)worldObj.loadedEntityList) {
            if(trackedItemIds.contains(entity.getUniqueID()) && entity instanceof EntityItem) {
                trackedItems.add((EntityItem)entity);
            }
        }
        trackedItemIds = null;
    }
    Iterator<EntityItem> iterator = trackedItems.iterator();
    while(iterator.hasNext()) {
        EntityItem item = iterator.next();
        if(item.worldObj != worldObj || item.isDead) {
            iterator.remove();
        } else {
            Map<ChunkPosition, ForgeDirection> positions = new HashMap<ChunkPosition, ForgeDirection>();
            double range = 0.2;
            for(ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                double posX = item.posX + d.offsetX * range;
                double posY = item.posY + d.offsetY * range;
                double posZ = item.posZ + d.offsetZ * range;
                positions.put(new ChunkPosition((int)Math.floor(posX), (int)Math.floor(posY), (int)Math.floor(posZ)), d.getOpposite());
            }
            for(Entry<ChunkPosition, ForgeDirection> entry : positions.entrySet()) {
                ChunkPosition pos = entry.getKey();
                TileEntity te = worldObj.getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
                IInventory inv = IOHelper.getInventoryForTE(te);
                ItemStack remainder = IOHelper.insert(inv, item.getEntityItem(), entry.getValue().ordinal(), false);
                if(remainder != null) {
                    item.setEntityItemStack(remainder);
                } else {
                    item.setDead();
                    iterator.remove();
                    lastInsertingInventory = new ChunkPosition(te.xCoord, te.yCoord, te.zCoord);
                    lastInsertingInventorySide = entry.getValue();
                    break;
                }
            }
        }
    }
}
 
Example 19
Source File: TileEntityGasLift.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public boolean suckLiquid(){
    Block block = worldObj.getBlock(xCoord, yCoord - currentDepth - 1, zCoord);
    Fluid fluid = FluidRegistry.lookupFluidForBlock(block);
    if(fluid != null) {
        if(fill(ForgeDirection.UNKNOWN, new FluidStack(fluid, 1000), false) == 1000) {
            if(pumpingLake == null) {
                pumpingLake = new ArrayList<ChunkPosition>();
                Stack<ChunkPosition> pendingPositions = new Stack<ChunkPosition>();
                ChunkPosition thisPos = new ChunkPosition(xCoord, yCoord - currentDepth - 1, zCoord);
                pendingPositions.add(thisPos);
                pumpingLake.add(thisPos);
                while(!pendingPositions.empty()) {
                    ChunkPosition checkingPos = pendingPositions.pop();
                    for(ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                        if(d == ForgeDirection.DOWN) continue;
                        ChunkPosition newPos = new ChunkPosition(checkingPos.chunkPosX + d.offsetX, checkingPos.chunkPosY + d.offsetY, checkingPos.chunkPosZ + d.offsetZ);
                        if(PneumaticCraftUtils.distBetween(newPos, xCoord + 0.5, yCoord - currentDepth - 1, zCoord + 0.5) <= MAX_PUMP_RANGE && worldObj.getBlock(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ) == block && !pumpingLake.contains(newPos)) {
                            pendingPositions.add(newPos);
                            pumpingLake.add(newPos);
                        }
                    }
                }
                Collections.sort(pumpingLake, new ChunkPositionSorter(xCoord + 0.5, yCoord - currentDepth - 1, zCoord + 0.5));
                Collections.reverse(pumpingLake);
            }
            ChunkPosition curPos = null;
            boolean foundSource = false;
            while(pumpingLake.size() > 0) {
                curPos = pumpingLake.get(0);
                if(worldObj.getBlock(curPos.chunkPosX, curPos.chunkPosY, curPos.chunkPosZ) == block && worldObj.getBlockMetadata(curPos.chunkPosX, curPos.chunkPosY, curPos.chunkPosZ) == 0) {
                    foundSource = true;
                    break;
                }
                pumpingLake.remove(0);
            }
            if(pumpingLake.size() == 0) {
                pumpingLake = null;
            } else if(foundSource) {
                worldObj.setBlockToAir(curPos.chunkPosX, curPos.chunkPosY, curPos.chunkPosZ);
                fill(ForgeDirection.UNKNOWN, new FluidStack(fluid, 1000), true);
                addAir(-100, ForgeDirection.UNKNOWN);
                status = 1;
            }
        }
        return true;
    } else {
        pumpingLake = null;
        return false;
    }
}
 
Example 20
Source File: SubTileGenerating.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 4 votes vote down vote up
@Override
public void onUpdate() {
	super.onUpdate();

	linkCollector();

	if(canGeneratePassively()) {
		int delay = getDelayBetweenPassiveGeneration();
		if(delay > 0 && ticksExisted % delay == 0 && !supertile.getWorldObj().isRemote) {
			if(shouldSyncPassiveGeneration())
				sync();
			addMana(getValueForPassiveGeneration());
		}
	}
	emptyManaIntoCollector();

	if(acceptsRedstone()) {
		redstoneSignal = 0;
		for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
			int redstoneSide = supertile.getWorldObj().getIndirectPowerLevelTo(supertile.xCoord + dir.offsetX, supertile.yCoord + dir.offsetY, supertile.zCoord + dir.offsetZ, dir.ordinal());
			redstoneSignal = Math.max(redstoneSignal, redstoneSide);
		}
	}

	if(supertile.getWorldObj().isRemote) {
		double particleChance = 1F - (double) mana / (double) getMaxMana() / 3.5F;
		Color color = new Color(getColor());
		if(Math.random() > particleChance)
			BotaniaAPI.internalHandler.sparkleFX(supertile.getWorldObj(), supertile.xCoord + 0.3 + Math.random() * 0.5, supertile.yCoord + 0.5 + Math.random()  * 0.5, supertile.zCoord + 0.3 + Math.random() * 0.5, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random(), 5);
	}

	boolean passive = isPassiveFlower();
	if(!supertile.getWorldObj().isRemote) {
		int muhBalance = BotaniaAPI.internalHandler.getPassiveFlowerDecay();

		if(passive && muhBalance > 0 && passiveDecayTicks > muhBalance) {
			supertile.getWorldObj().playAuxSFX(2001, supertile.xCoord, supertile.yCoord, supertile.zCoord, Block.getIdFromBlock(supertile.getBlockType()));
			if(supertile.getWorldObj().getBlock(supertile.xCoord, supertile.yCoord - 1, supertile.zCoord).isSideSolid(supertile.getWorldObj(), supertile.xCoord, supertile.yCoord - 1, supertile.zCoord, ForgeDirection.UP))
				supertile.getWorldObj().setBlock(supertile.xCoord, supertile.yCoord, supertile.zCoord, Blocks.deadbush);
			else supertile.getWorldObj().setBlockToAir(supertile.xCoord, supertile.yCoord, supertile.zCoord);
		}
	}

	if(!overgrowth && passive)
		passiveDecayTicks++;
}