erogenousbeef.core.common.CoordTriplet Java Examples

The following examples show how to use erogenousbeef.core.common.CoordTriplet. 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: TileEntityReactorRedNetPort.java    From BigReactors with MIT License 6 votes vote down vote up
protected void decodeSetting(NBTTagCompound settingTag) {
	int channel = settingTag.getInteger("channel");
	int settingIdx = settingTag.getInteger("setting");
	
	clearChannel(channel);
	
	channelCircuitTypes[channel] = CircuitType.values()[settingIdx];
	
	if(isInput(this.channelCircuitTypes[channel]) && CircuitType.canBeToggledBetweenPulseAndNormal(this.channelCircuitTypes[channel])) {
		inputActivatesOnPulse[channel] = settingTag.getBoolean("pulse");
	}

	if( CircuitType.hasCoordinate(channelCircuitTypes[channel]) ) {
		if(settingTag.hasKey("x")) {
			int x, y, z;
			x = settingTag.getInteger("x");
			y = settingTag.getInteger("y");
			z = settingTag.getInteger("z");
			coordMappings[channel] = new CoordTriplet(x, y, z);
		}
	}
}
 
Example #2
Source File: MultiblockControllerBase.java    From BeefCore with MIT License 6 votes vote down vote up
/**
 * Assimilate another controller into this controller.
 * Acquire all of the other controller's blocks and attach them
 * to this one.
 * 
 * @param other The controller to merge into this one.
 */
public void assimilate(MultiblockControllerBase other) {
	CoordTriplet otherReferenceCoord = other.getReferenceCoord();
	if(otherReferenceCoord != null && getReferenceCoord().compareTo(otherReferenceCoord) >= 0) {
		throw new IllegalArgumentException("The controller with the lowest minimum-coord value must consume the one with the higher coords");
	}

	TileEntity te;
	Set<IMultiblockPart> partsToAcquire = new HashSet<IMultiblockPart>(other.connectedParts);

	// releases all blocks and references gently so they can be incorporated into another multiblock
	other._onAssimilated(this);
	
	for(IMultiblockPart acquiredPart : partsToAcquire) {
		// By definition, none of these can be the minimum block.
		if(acquiredPart.isInvalid()) { continue; }
		
		connectedParts.add(acquiredPart);
		acquiredPart.onAssimilated(this);
		this.onBlockAdded(acquiredPart);
	}

	this.onAssimilate(other);
	other.onAssimilated(this);
}
 
Example #3
Source File: MultiblockTurbineSimulator.java    From reactor_simulator with MIT License 6 votes vote down vote up
protected void markReferenceCoordDirty() {
  if (worldObj == null || worldObj.isRemote) {
    return;
  }

  CoordTriplet referenceCoord = getReferenceCoord();
  if (referenceCoord == null) {
    return;
  }

  rpmUpdateTracker.onExternalUpdate();

  TileEntity saveTe = worldObj.getTileEntity(referenceCoord.x, referenceCoord.y, referenceCoord.z);
  worldObj.markTileEntityChunkModified(referenceCoord.x, referenceCoord.y, referenceCoord.z, saveTe);
  worldObj.markBlockForUpdate(referenceCoord.x, referenceCoord.y, referenceCoord.z);
}
 
Example #4
Source File: TileEntityReactorRedNetPort.java    From BigReactors with MIT License 6 votes vote down vote up
protected NBTTagCompound encodeSetting(int channel) {
	NBTTagCompound entry = new NBTTagCompound();
	
	entry.setInteger("channel", channel);
	entry.setInteger("setting", this.channelCircuitTypes[channel].ordinal());
	if(isInput(this.channelCircuitTypes[channel]) && CircuitType.canBeToggledBetweenPulseAndNormal(this.channelCircuitTypes[channel])) {
		entry.setBoolean("pulse", this.inputActivatesOnPulse[channel]);
	}
	if( CircuitType.hasCoordinate(this.channelCircuitTypes[channel]) ) {
		CoordTriplet coord = this.coordMappings[channel];
		if(coord != null) {
			entry.setInteger("x", coord.x);
			entry.setInteger("y", coord.y);
			entry.setInteger("z", coord.z);
		}
	}
	
	return entry;
}
 
Example #5
Source File: MultiblockWorldRegistry.java    From BeefCore with MIT License 6 votes vote down vote up
/**
 * Called when a multiblock part is added to the world, either via chunk-load or user action.
 * If its chunk is loaded, it will be processed during the next tick.
 * If the chunk is not loaded, it will be added to a list of objects waiting for a chunkload.
 * @param part The part which is being added to this world.
 */
public void onPartAdded(IMultiblockPart part) {
	CoordTriplet worldLocation = part.getWorldLocation();
	
	if(!worldObj.getChunkProvider().chunkExists(worldLocation.getChunkX(), worldLocation.getChunkZ())) {
		// Part goes into the waiting-for-chunk-load list
		Set<IMultiblockPart> partSet;
		long chunkHash = worldLocation.getChunkXZHash();
		synchronized(partsAwaitingChunkLoadMutex) {
			if(!partsAwaitingChunkLoad.containsKey(chunkHash)) {
				partSet = new HashSet<IMultiblockPart>();
				partsAwaitingChunkLoad.put(chunkHash, partSet);
			}
			else {
				partSet = partsAwaitingChunkLoad.get(chunkHash);
			}
			
			partSet.add(part);
		}
	}
	else {
		// Part goes into the orphan queue, to be checked this tick
		addOrphanedPartThreadsafe(part);
	}
}
 
Example #6
Source File: MultiblockTurbineSimulator.java    From reactor_simulator with MIT License 6 votes vote down vote up
protected void markReferenceCoordDirty() {
  if (worldObj == null || worldObj.isRemote) {
    return;
  }

  CoordTriplet referenceCoord = getReferenceCoord();
  if (referenceCoord == null) {
    return;
  }

  rpmUpdateTracker.onExternalUpdate();

  TileEntity saveTe = worldObj.getTileEntity(referenceCoord.x, referenceCoord.y, referenceCoord.z);
  worldObj.markTileEntityChunkModified(referenceCoord.x, referenceCoord.y, referenceCoord.z, saveTe);
  worldObj.markBlockForUpdate(referenceCoord.x, referenceCoord.y, referenceCoord.z);
}
 
Example #7
Source File: TileEntityReactorRedNetPort.java    From BigReactors with MIT License 6 votes vote down vote up
public TileEntityReactorRedNetPort() {
	super();
	
	channelCircuitTypes = new CircuitType[numChannels];
	coordMappings = new CoordTriplet[numChannels];
	inputActivatesOnPulse = new boolean[numChannels];
	oldValue = new int[numChannels];

	for(int i = 0; i < numChannels; i++) {
		channelCircuitTypes[i] = CircuitType.DISABLED;
		coordMappings[i] = null;
		inputActivatesOnPulse[i] = false;
		oldValue[i] = 0;
	}
	
	redNetwork = null;
	redNetInput = null;

	ticksSinceLastUpdate = 0;
}
 
Example #8
Source File: MultiblockTurbine.java    From BigReactors with MIT License 6 votes vote down vote up
@Override
protected void isBlockGoodForInterior(World world, int x, int y, int z) throws MultiblockValidationException {
	// We only allow air and functional parts in turbines.

	// Air is ok
	if(world.isAirBlock(x, y, z)) { return; }

	Block block = world.getBlock(x, y, z);
	int metadata = world.getBlockMetadata(x,y,z);

	// Coil windings below here:
	if(getCoilPartData(x, y, z, block, metadata) != null) {
		foundCoils.add(new CoordTriplet(x,y,z));
		return;
	}

	// Everything else, gtfo
	throw new MultiblockValidationException(String.format("%d, %d, %d is invalid for a turbine interior. Only rotor parts, metal blocks and empty space are allowed.", x, y, z));
}
 
Example #9
Source File: GuiReactorRedNetPort.java    From BigReactors with MIT License 6 votes vote down vote up
private String getControlRodLabelFromLocation(CircuitType circuitType, CoordTriplet location) {
	if(location == null) {
		return "-- ALL --";
	}
	else {
		TileEntity te = port.getWorldObj().getTileEntity(location.x, location.y, location.z);
		if( te instanceof TileEntityReactorControlRod ) {
			TileEntityReactorControlRod rod = (TileEntityReactorControlRod)te;
			if( rod.getName().equals("")) {
				return location.toString();
			}
			else {
				return rod.getName();
			}
		}
		else {
			return "INVALID: " + location.toString();
		}
	}
}
 
Example #10
Source File: MultiblockControllerBase.java    From BeefCore with MIT License 5 votes vote down vote up
private int _shouldConsume(MultiblockControllerBase otherController) {
	CoordTriplet myCoord = getReferenceCoord();
	CoordTriplet theirCoord = otherController.getReferenceCoord();
	
	// Always consume other controllers if their reference coordinate is null - this means they're empty and can be assimilated on the cheap
	if(theirCoord == null) { return -1; }
	else { return myCoord.compareTo(theirCoord); }
}
 
Example #11
Source File: TileEntityTurbinePartBase.java    From BigReactors with MIT License 5 votes vote down vote up
@Override
public CoordTriplet getReferenceCoord() {
	if(isConnected()) {
		return getMultiblockController().getReferenceCoord();
	}
	else {
		return new CoordTriplet(xCoord, yCoord, zCoord);
	}
}
 
Example #12
Source File: MultiblockControllerBase.java    From BeefCore with MIT License 5 votes vote down vote up
/**
 * Force this multiblock to recalculate its minimum and maximum coordinates
 * from the list of connected parts.
 */
public void recalculateMinMaxCoords() {
	minimumCoord = new CoordTriplet(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
	maximumCoord = new CoordTriplet(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);

	for(IMultiblockPart part : connectedParts) {
		if(part.xCoord < minimumCoord.x) { minimumCoord.x = part.xCoord; }
		if(part.xCoord > maximumCoord.x) { maximumCoord.x = part.xCoord; }
		if(part.yCoord < minimumCoord.y) { minimumCoord.y = part.yCoord; }
		if(part.yCoord > maximumCoord.y) { maximumCoord.y = part.yCoord; }
		if(part.zCoord < minimumCoord.z) { minimumCoord.z = part.zCoord; }
		if(part.zCoord > maximumCoord.z) { maximumCoord.z = part.zCoord; }
	}
}
 
Example #13
Source File: MultiblockWorldRegistry.java    From BeefCore with MIT License 5 votes vote down vote up
/**
 * Called when a part is removed from the world, via user action or via chunk unloads.
 * This part is removed from any lists in which it may be, and its machine is marked for recalculation.
 * @param part The part which is being removed.
 */
public void onPartRemovedFromWorld(IMultiblockPart part) {
	CoordTriplet coord = part.getWorldLocation();
	if(coord != null) {
		long hash = coord.getChunkXZHash();
		
		if(partsAwaitingChunkLoad.containsKey(hash)) {
			synchronized(partsAwaitingChunkLoadMutex) {
				if(partsAwaitingChunkLoad.containsKey(hash)) {
					partsAwaitingChunkLoad.get(hash).remove(part);
					if(partsAwaitingChunkLoad.get(hash).size() <= 0) {
						partsAwaitingChunkLoad.remove(hash);
					}
				}
			}
		}
	}

	detachedParts.remove(part);
	if(orphanedParts.contains(part)) {
		synchronized(orphanedPartsMutex) {
			orphanedParts.remove(part);
		}
	}
	
	part.assertDetached();
}
 
Example #14
Source File: RectangularMultiblockTileEntityBase.java    From BeefCore with MIT License 5 votes vote down vote up
public void recalculateOutwardsDirection(CoordTriplet minCoord, CoordTriplet maxCoord) {
	outwards = ForgeDirection.UNKNOWN;
	position = PartPosition.Unknown;

	int facesMatching = 0;
	if(maxCoord.x == this.xCoord || minCoord.x == this.xCoord) { facesMatching++; }
	if(maxCoord.y == this.yCoord || minCoord.y == this.yCoord) { facesMatching++; }
	if(maxCoord.z == this.zCoord || minCoord.z == this.zCoord) { facesMatching++; }
	
	if(facesMatching <= 0) { position = PartPosition.Interior; }
	else if(facesMatching >= 3) { position = PartPosition.FrameCorner; }
	else if(facesMatching == 2) { position = PartPosition.Frame; }
	else {
		// 1 face matches
		if(maxCoord.x == this.xCoord) {
			position = PartPosition.EastFace;
			outwards = ForgeDirection.EAST;
		}
		else if(minCoord.x == this.xCoord) {
			position = PartPosition.WestFace;
			outwards = ForgeDirection.WEST;
		}
		else if(maxCoord.z == this.zCoord) {
			position = PartPosition.SouthFace;
			outwards = ForgeDirection.SOUTH;
		}
		else if(minCoord.z == this.zCoord) {
			position = PartPosition.NorthFace;
			outwards = ForgeDirection.NORTH;
		}
		else if(maxCoord.y == this.yCoord) {
			position = PartPosition.TopFace;
			outwards = ForgeDirection.UP;
		}
		else {
			position = PartPosition.BottomFace;
			outwards = ForgeDirection.DOWN;
		}
	}
}
 
Example #15
Source File: RectangularMultiblockTileEntityBase.java    From BeefCore with MIT License 5 votes vote down vote up
@Override
public void onMachineAssembled(MultiblockControllerBase controller) {
	CoordTriplet maxCoord = controller.getMaximumCoord();
	CoordTriplet minCoord = controller.getMinimumCoord();
	
	// Discover where I am on the reactor
	recalculateOutwardsDirection(minCoord, maxCoord);
}
 
Example #16
Source File: TileEntityReactorComputerPort.java    From BigReactors with MIT License 5 votes vote down vote up
private TileEntityReactorControlRod getControlRodFromArguments(MultiblockReactor reactor, Object[] arguments, int index) throws Exception {
	CoordTriplet coord = getControlRodCoordFromArguments(reactor, arguments, index);

	TileEntity te = worldObj.getTileEntity(coord.x, coord.y, coord.z);
	if(!(te instanceof TileEntityReactorControlRod)) {
		throw new Exception("Encountered an invalid tile entity when seeking a control rod. That's weird.");
	}
	
	return (TileEntityReactorControlRod)te;
}
 
Example #17
Source File: TileEntityReactorPartBase.java    From BigReactors with MIT License 5 votes vote down vote up
@Override
public CoordTriplet getReferenceCoord() {
	if(isConnected()) {
		return getMultiblockController().getReferenceCoord();
	}
	else {
		return new CoordTriplet(xCoord, yCoord, zCoord);
	}
}
 
Example #18
Source File: TileEntityReactorComputerPort.java    From BigReactors with MIT License 5 votes vote down vote up
private CoordTriplet getControlRodCoordFromArguments(MultiblockReactor reactor, Object[] arguments, int index) throws Exception {
	if(!(arguments[index] instanceof Double)) {
		throw new IllegalArgumentException(String.format("Invalid argument %d, expected Number", index));
	}
	
	int rodIndex = (int)Math.round((Double)arguments[index]);
	
	if(index < 0 || index >= reactor.getFuelRodCount()) {
		throw new IndexOutOfBoundsException(String.format("Invalid argument %d, control rod index is out of bounds", index));
	}
	
	return reactor.getControlRodLocations()[rodIndex];
}
 
Example #19
Source File: TileEntityReactorRedNetPort.java    From BigReactors with MIT License 5 votes vote down vote up
public void onCircuitUpdate(RedNetChange[] changes) {
	if(changes == null || changes.length < 1) { return; }
	
	for(int i = 0; i < changes.length; i++) {
		int channelID = changes[i].getChannel();
		CircuitType newType = changes[i].getType();
		
		channelCircuitTypes[channelID] = newType;
		
		if(CircuitType.canBeToggledBetweenPulseAndNormal(newType)) {
			inputActivatesOnPulse[channelID] = changes[i].getPulseOrToggle();
		}
		
		if(CircuitType.hasCoordinate(newType)) {
			CoordTriplet coord = changes[i].getCoord();
			
			// Validate that we're pointing at the right thing, just in case.
			if(coord != null) {
				TileEntity te = worldObj.getTileEntity(coord.x, coord.y, coord.z);
				if(!(te instanceof TileEntityReactorControlRod)) {
					BRLog.warning("Invalid tile entity reference at coordinate %s - rednet circuit expected a control rod", coord);
					coord = null;
				}
			}

			coordMappings[channelID] = coord;
		}
		else {
			coordMappings[channelID] = null;
		}
	}
	
	worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
	markDirty();
}
 
Example #20
Source File: ReactorCommandEjectToPortMessage.java    From BigReactors with MIT License 5 votes vote down vote up
@Override
public IMessage handleMessage(ReactorCommandEjectToPortMessage message, MessageContext ctx, MultiblockReactor reactor) {
	CoordTriplet dest = new CoordTriplet(message.portX, message.portY, message.portZ);
	if(message.ejectFuel) {
		reactor.ejectFuel(message.dumpExcess, dest);
	}
	else {
		reactor.ejectWaste(message.dumpExcess, dest);
	}
	return null;
}
 
Example #21
Source File: MultiblockTileEntityBase.java    From BeefCore with MIT License 5 votes vote down vote up
@Override
public IMultiblockPart[] getNeighboringParts() {
	CoordTriplet[] neighbors = new CoordTriplet[] {
			new CoordTriplet(this.xCoord-1, this.yCoord, this.zCoord),
			new CoordTriplet(this.xCoord, this.yCoord-1, this.zCoord),
			new CoordTriplet(this.xCoord, this.yCoord, this.zCoord-1),
			new CoordTriplet(this.xCoord, this.yCoord, this.zCoord+1),
			new CoordTriplet(this.xCoord, this.yCoord+1, this.zCoord),
			new CoordTriplet(this.xCoord+1, this.yCoord, this.zCoord)
	};

	TileEntity te;
	List<IMultiblockPart> neighborParts = new ArrayList<IMultiblockPart>();
	IChunkProvider chunkProvider = worldObj.getChunkProvider();
	for(CoordTriplet neighbor : neighbors) {
		if(!chunkProvider.chunkExists(neighbor.getChunkX(), neighbor.getChunkZ())) {
			// Chunk not loaded, skip it.
			continue;
		}

		te = this.worldObj.getTileEntity(neighbor.x, neighbor.y, neighbor.z);
		if(te instanceof IMultiblockPart) {
			neighborParts.add((IMultiblockPart)te);
		}
	}
	IMultiblockPart[] tmp = new IMultiblockPart[neighborParts.size()];
	return neighborParts.toArray(tmp);
}
 
Example #22
Source File: MultiblockTurbine.java    From BigReactors with MIT License 5 votes vote down vote up
protected void markReferenceCoordDirty() {
	if(worldObj == null || worldObj.isRemote) { return; }

	CoordTriplet referenceCoord = getReferenceCoord();
	if(referenceCoord == null) { return; }

	rpmUpdateTracker.onExternalUpdate();
	
	TileEntity saveTe = worldObj.getTileEntity(referenceCoord.x, referenceCoord.y, referenceCoord.z);
	worldObj.markTileEntityChunkModified(referenceCoord.x, referenceCoord.y, referenceCoord.z, saveTe);
	worldObj.markBlockForUpdate(referenceCoord.x, referenceCoord.y, referenceCoord.z);
}
 
Example #23
Source File: TileEntityReactorRedNetPort.java    From BigReactors with MIT License 5 votes vote down vote up
protected void setControlRodInsertion(int channel, CoordTriplet coordTriplet, int newValue) {
	if(!this.isConnected()) { return; }
	if(!this.worldObj.checkChunksExist(coordTriplet.x, coordTriplet.y, coordTriplet.z,
										coordTriplet.x, coordTriplet.y, coordTriplet.z)) {
		return;
	}
	
	TileEntity te = this.worldObj.getTileEntity(coordTriplet.x, coordTriplet.y, coordTriplet.z);
	if(te instanceof TileEntityReactorControlRod) {
		((TileEntityReactorControlRod)te).setControlRodInsertion((short)newValue);
	}
	else {
		clearChannel(channel);
	}
}
 
Example #24
Source File: TileEntityReactorRedNetPort.java    From BigReactors with MIT License 5 votes vote down vote up
protected TileEntity getMappedTileEntity(int channel) {
	if(channel < 0 || channel >= numChannels) { return null; }
	if(coordMappings[channel] == null) { return null; }
	
	CoordTriplet coord = coordMappings[channel];
	
	if(coord == null) { return null; }
	if(!this.worldObj.checkChunksExist(coord.x, coord.y, coord.z, coord.x, coord.y, coord.z)) {
		return null;
	}
	
	return this.worldObj.getTileEntity(coord.x, coord.y, coord.z);
}
 
Example #25
Source File: BlockReactorPart.java    From BigReactors with MIT License 5 votes vote down vote up
private IIcon getCasingEdgeIcon(TileEntityReactorPart part, MultiblockReactor reactor, int side) {
	if(reactor == null || !reactor.isAssembled()) { return _icons[METADATA_CASING][DEFAULT]; }

	CoordTriplet minCoord = reactor.getMinimumCoord();
	CoordTriplet maxCoord = reactor.getMaximumCoord();

	boolean xExtreme, yExtreme, zExtreme;
	xExtreme = yExtreme = zExtreme = false;

	if(part.xCoord == minCoord.x || part.xCoord == maxCoord.x) { xExtreme = true; }
	if(part.yCoord == minCoord.y || part.yCoord == maxCoord.y) { yExtreme = true; }
	if(part.zCoord == minCoord.z || part.zCoord == maxCoord.z) { zExtreme = true; }
	
	int idx = DEFAULT;
	if(!xExtreme) {
		if(side < 4) { idx = EASTWEST; }
	}
	else if(!yExtreme) {
		if(side > 1) {
			idx = VERTICAL;
		}
	}
	else { // !zExtreme
		if(side < 2) {
			idx = NORTHSOUTH;
		}
		else if(side > 3) {
			idx = EASTWEST;
		}
	}
	return _icons[METADATA_CASING][idx];
}
 
Example #26
Source File: MultiblockReactor.java    From BigReactors with MIT License 5 votes vote down vote up
protected void markReferenceCoordDirty() {
	if(worldObj == null || worldObj.isRemote) { return; }

	CoordTriplet referenceCoord = getReferenceCoord();
	if(referenceCoord == null) { return; }

	TileEntity saveTe = worldObj.getTileEntity(referenceCoord.x, referenceCoord.y, referenceCoord.z);
	worldObj.markTileEntityChunkModified(referenceCoord.x, referenceCoord.y, referenceCoord.z, saveTe);
}
 
Example #27
Source File: MultiblockReactor.java    From BigReactors with MIT License 5 votes vote down vote up
protected void calculateReactorVolume() {
	CoordTriplet minInteriorCoord = getMinimumCoord();
	minInteriorCoord.x += 1;
	minInteriorCoord.y += 1;
	minInteriorCoord.z += 1;
	
	CoordTriplet maxInteriorCoord = getMaximumCoord();
	maxInteriorCoord.x -= 1;
	maxInteriorCoord.y -= 1;
	maxInteriorCoord.z -= 1;
	
	reactorVolume = StaticUtils.ExtraMath.Volume(minInteriorCoord, maxInteriorCoord);
}
 
Example #28
Source File: MultiblockReactor.java    From BigReactors with MIT License 5 votes vote down vote up
public CoordTriplet[] getControlRodLocations() {
	CoordTriplet[] coords = new CoordTriplet[this.attachedControlRods.size()];
	int i = 0;
	for(TileEntityReactorControlRod cr : attachedControlRods) {
		coords[i++] = cr.getWorldLocation();
	}
	return coords;
}
 
Example #29
Source File: MultiblockReactor.java    From BigReactors with MIT License 5 votes vote down vote up
/**
 * Eject fuel contained in the reactor.
 * @param dumpAll If true, any remaining fuel will simply be lost.
 * @param destination If not null, then fuel will only be distributed to a port matching these coordinates.
 */
public void ejectFuel(boolean dumpAll, CoordTriplet destination) {
	// For now, we can optimize by only running this when we have enough waste to product an ingot
	int amtEjected = 0;

	String fuelReactantType = fuelContainer.getFuelType();
	if(fuelReactantType == null) { 
		return;
	}

	int minimumReactantAmount = Reactants.getMinimumReactantToProduceSolid(fuelReactantType);
	if(fuelContainer.getFuelAmount() >= minimumReactantAmount) {

		for(TileEntityReactorAccessPort port : attachedAccessPorts) {
			if(fuelContainer.getFuelAmount() < minimumReactantAmount) {
				continue;
			}
			
			if(!port.isConnected()) { continue; }
			if(destination != null && !destination.equals(port.xCoord, port.yCoord, port.zCoord)) {
				continue;
			}
			
			int reactantEjected = port.emitReactant(fuelReactantType, fuelContainer.getFuelAmount());
			fuelContainer.dumpFuel(reactantEjected);
			amtEjected += reactantEjected;
		}
	}

	if(dumpAll)
	{
		amtEjected += fuelContainer.getFuelAmount();
		fuelContainer.setFuel(null);
	}

	if(amtEjected > 0) {
		markReferenceCoordForUpdate();
		markReferenceCoordDirty();
	}
}
 
Example #30
Source File: MultiblockReactorSimulator.java    From reactor_simulator with MIT License 5 votes vote down vote up
protected void calculateReactorVolume() {
  CoordTriplet minInteriorCoord = minCoord.copy();
  minInteriorCoord.x += 1;
  minInteriorCoord.y += 1;
  minInteriorCoord.z += 1;

  CoordTriplet maxInteriorCoord = maxCoord.copy();
  maxInteriorCoord.x -= 1;
  maxInteriorCoord.y -= 1;
  maxInteriorCoord.z -= 1;

  reactorVolume = StaticUtils.ExtraMath.Volume(minInteriorCoord, maxInteriorCoord);
}