erogenousbeef.bigreactors.api.registry.Reactants Java Examples

The following examples show how to use erogenousbeef.bigreactors.api.registry.Reactants. 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: CommonProxy.java    From BigReactors with MIT License 6 votes vote down vote up
public void postInit() {
	BRConfig.CONFIGURATION.load();
	boolean autoAddUranium = BRConfig.CONFIGURATION.get("Compatibility", "autoAddUranium",
														true,
														"If true, automatically adds all "
														+"unregistered ingots found as clones"
														+"of standard yellorium fuel").getBoolean(true);
	if(autoAddUranium) {
		Reactants.registerSolid("ingotUranium", StandardReactants.yellorium);
	}

	BRConfig.CONFIGURATION.save();
	
	registerWithOtherMods();
	
	// Easter Egg - Check if today is valentine's day. If so, change all particles to hearts.
	Calendar calendar = Calendar.getInstance();
	BigReactors.isValentinesDay = (calendar.get(Calendar.MONTH) == 1 && calendar.get(Calendar.DAY_OF_MONTH) == 14);
}
 
Example #2
Source File: ReactantContainer.java    From BigReactors with MIT License 6 votes vote down vote up
public void deserialize(ByteBuf buffer) {
	capacity = buffer.readInt();
	for(int i = 0; i < tankNames.length; i++) {
		tanks[i] = null;

		boolean hasReactant = buffer.readBoolean();
		if(hasReactant) {
			String reactantName = ByteBufUtils.readUTF8String(buffer);
			int amount = buffer.readInt();
			
			if(!Reactants.isKnown(reactantName)) {
				BRLog.warning("Read an unknown reactant <%s> from a network message; tank %s will remain empty", reactantName, tankNames[i]);
			}
			else {
				tanks[i] = new ReactantStack(reactantName, amount);
				levelAtLastUpdate[i] = amount;
			}
		}
	}
}
 
Example #3
Source File: RecipeHandlerCyaniteReprocessor.java    From NEI-Integration with MIT License 5 votes vote down vote up
@Override
public void loadAllRecipes() {
    for (OreDictToReactantMapping o : solidToReactant.values()) {
        ReactantData data = Reactants.getReactant(o.getProduct());
        if (data.isWaste()) {
            for (ItemStack ore : OreDictionary.getOres(o.getSource())) {
                this.arecipes.add(new CachedCyaniteReprocessorRecipe(ore, OreDictionary.getOres("ingotBlutonium").get(0)));
            }
        }
    }
}
 
Example #4
Source File: SlotReactorInput.java    From BigReactors with MIT License 5 votes vote down vote up
@Override
public boolean isItemValid(ItemStack stack) {
	if(stack == null) { return false; }
	
	if(fuel) {
		return Reactants.isFuel(stack);
	}
	else {
		return Reactants.isWaste(stack);
	}
}
 
Example #5
Source File: TileEntityCyaniteReprocessor.java    From BigReactors with MIT License 5 votes vote down vote up
@Override
public boolean isItemValidForSlot(int slot, ItemStack itemstack) {
	if(itemstack == null) { return true; }
	
	if(slot == SLOT_OUTLET) {
		return Reactants.isFuel(itemstack);
	}
	else if(slot == SLOT_INLET) {
		return Reactants.isWaste(itemstack);
	}

	return false;
}
 
Example #6
Source File: TileEntityReactorAccessPort.java    From BigReactors with MIT License 5 votes vote down vote up
@Override
public boolean isItemValidForSlot(int slot, ItemStack itemstack) {
	if(itemstack == null) { return true; }

	if(slot == SLOT_INLET) {
		return Reactants.isFuel(itemstack);
	}
	else if(slot == SLOT_OUTLET) {
		return Reactants.isWaste(itemstack);
	}
	else {
		return false;
	}
}
 
Example #7
Source File: TileEntityReactorAccessPort.java    From BigReactors with MIT License 5 votes vote down vote up
/**
 * Consume items from the input slot.
 * Returns the amount of reactant produced.
 * @param reactantDesired The amount of reactant desired, in reactant units (mB)
 * @return The amount of reactant actually produced, in reactant units (mB)
 */
public int consumeReactantItem(int reactantDesired) {
	ItemStack inputItem = getStackInSlot(SLOT_INLET);
	if(inputItem == null) { return 0; }
	
	SourceProductMapping mapping = Reactants.getSolidToReactant(inputItem);
	if(mapping == null) { return 0; }
	
	int sourceItemsToConsume = Math.min(inputItem.stackSize, mapping.getSourceAmount(reactantDesired));
	
	if(sourceItemsToConsume <= 0) { return 0; }

	decrStackSize(SLOT_INLET, sourceItemsToConsume);
	return mapping.getProductAmount(sourceItemsToConsume);
}
 
Example #8
Source File: TileEntityReactorAccessPort.java    From BigReactors with MIT License 5 votes vote down vote up
public int getInputReactantAmount() {
	ItemStack inputItem = getStackInSlot(SLOT_INLET);
	if(inputItem == null) { return 0; }

	SourceProductMapping mapping = Reactants.getSolidToReactant(inputItem);
	return mapping != null ? mapping.getProductAmount(inputItem.stackSize) : 0;
}
 
Example #9
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 #10
Source File: FuelContainer.java    From BigReactors with MIT License 5 votes vote down vote up
@Override
public boolean isReactantValidForStack(int idx, String name) {
	switch(idx) {
	case FUEL:
		return Reactants.isFuel(name);
	case WASTE:
		// Allow anything into our output slot, in case someone wants to do breeders or something
		return true;
	default:
		return false;
	}
}
 
Example #11
Source File: RecipeHandlerCyaniteReprocessor.java    From NEI-Integration with MIT License 5 votes vote down vote up
@Override
public void loadUsageRecipes(ItemStack ingred) {
    super.loadUsageRecipes(ingred);
    for (OreDictToReactantMapping o : solidToReactant.values()) {
        ReactantData data = Reactants.getReactant(o.getProduct());
        if (data.isWaste()) {
            for (ItemStack ore : OreDictionary.getOres(o.getSource())) {
                if (Utils.areStacksSameTypeCraftingSafe(ore, ingred)) {
                    this.arecipes.add(new CachedCyaniteReprocessorRecipe(ore, OreDictionary.getOres("ingotBlutonium").get(0)));
                }
            }
        }
    }
}
 
Example #12
Source File: MultiblockReactor.java    From BigReactors with MIT License 4 votes vote down vote up
protected void refuel() {
	// For now, we only need to check fuel ports when we have more space than can accomodate 1 ingot
	if(fuelContainer.getRemainingSpace() < Reactants.standardSolidReactantAmount) {
		return;
	}
	
	int amtAdded = 0;
	
	// Loop: Consume input reactants from all ports
	for(TileEntityReactorAccessPort port : attachedAccessPorts)
	{
		if(fuelContainer.getRemainingSpace() <= 0) { break; }

		if(!port.isConnected())	{ continue; }

		// See what type of reactant the port contains; if none, skip it.
		String portReactantType = port.getInputReactantType();
		int portReactantAmount = port.getInputReactantAmount();
		if(portReactantType == null || portReactantAmount <= 0) { continue; }
		
		if(!Reactants.isFuel(portReactantType)) { continue; } // Skip nonfuels

		// HACK; TEMPORARY
		// Alias blutonium to yellorium temporarily, until mixed fuels are implemented
		if(portReactantType.equals(StandardReactants.blutonium)) {
			portReactantType = StandardReactants.yellorium;
		}
		
		// How much fuel can we actually add from this type of reactant?
		int amountToAdd = fuelContainer.addFuel(portReactantType, portReactantAmount, false);
		if(amountToAdd <= 0) { continue; }
		
		int portCanAdd = port.consumeReactantItem(amountToAdd);
		if(portCanAdd <= 0) { continue; }
		
		amtAdded = fuelContainer.addFuel(portReactantType, portReactantAmount, true);
	}
	
	if(amtAdded > 0) {
		markReferenceCoordForUpdate();
		markReferenceCoordDirty();
	}
}
 
Example #13
Source File: RecipeHandlerCyaniteReprocessor.java    From NEI-Integration with MIT License 4 votes vote down vote up
@Override
public void prepare() {
    solidToReactant = ReflectionHelper.getPrivateValue(Reactants.class, null, "_solidToReactant");
    API.setGuiOffset(GuiCyaniteReprocessor.class, 8, 17);
}
 
Example #14
Source File: ReactantToFluidMapping.java    From BigReactors with MIT License 4 votes vote down vote up
public ReactantToFluidMapping(String reactantName, String fluidName, int fluidAmount) {
	super(reactantName, Reactants.standardFluidReactantAmount, fluidName, fluidAmount);
}
 
Example #15
Source File: ReactantToFluidMapping.java    From BigReactors with MIT License 4 votes vote down vote up
public ReactantToFluidMapping(String reactantName, Fluid fluid, int fluidAmount) {
	super(reactantName, Reactants.standardFluidReactantAmount, fluid.getName(), fluidAmount);
}
 
Example #16
Source File: ReactantToFluidMapping.java    From BigReactors with MIT License 4 votes vote down vote up
public ReactantToFluidMapping(String reactantName, FluidStack fluidStack) {
	super(reactantName, Reactants.standardFluidReactantAmount, fluidStack.getFluid().getName(), fluidStack.amount);
}
 
Example #17
Source File: ReactantToFluidMapping.java    From BigReactors with MIT License 4 votes vote down vote up
public ReactantToFluidMapping(String reactantName, String fluidName) {
	super(reactantName, Reactants.standardFluidReactantAmount, fluidName, Reactants.standardFluidReactantAmount);
}
 
Example #18
Source File: TileEntityReactorAccessPort.java    From BigReactors with MIT License 4 votes vote down vote up
public String getInputReactantType() {
	ItemStack inputItem = getStackInSlot(SLOT_INLET);
	if(inputItem == null) { return null; }
	SourceProductMapping mapping = Reactants.getSolidToReactant(inputItem);
	return mapping != null ? mapping.getProduct() : null;
}
 
Example #19
Source File: ReactantToFluidMapping.java    From BigReactors with MIT License 4 votes vote down vote up
public ReactantToFluidMapping(String reactantName, Fluid fluid) {
	super(reactantName, Reactants.standardFluidReactantAmount, fluid.getName(), Reactants.standardFluidReactantAmount);
}
 
Example #20
Source File: FluidToReactantMapping.java    From BigReactors with MIT License 4 votes vote down vote up
public FluidToReactantMapping(String fluidName, int fluidAmount, String reactantName) {
	super(fluidName, fluidAmount, reactantName, Reactants.standardFluidReactantAmount);
}
 
Example #21
Source File: OreDictToReactantMapping.java    From BigReactors with MIT License 4 votes vote down vote up
public OreDictToReactantMapping(String oreDictName, int oreAmount, String reactantName) {
	super(oreDictName, oreAmount, reactantName, Reactants.standardSolidReactantAmount);
}
 
Example #22
Source File: OreDictToReactantMapping.java    From BigReactors with MIT License 4 votes vote down vote up
public OreDictToReactantMapping(String oreDictName, String reactantName) {
	super(oreDictName, 1, reactantName, Reactants.standardSolidReactantAmount);
}
 
Example #23
Source File: StandardReactants.java    From BigReactors with MIT License 4 votes vote down vote up
public static void register() {
	Reactants.registerReactant(yellorium, 0, colorYellorium);
	Reactants.registerReactant(cyanite, 1, colorCyanite);
	Reactants.registerReactant(blutonium, 0, colorYellorium);
}
 
Example #24
Source File: FluidToReactantMapping.java    From BigReactors with MIT License 4 votes vote down vote up
public FluidToReactantMapping(Fluid fluid, String reactantName) {
	super(fluid.getName(), Reactants.standardFluidReactantAmount, reactantName, Reactants.standardFluidReactantAmount);
}
 
Example #25
Source File: FluidToReactantMapping.java    From BigReactors with MIT License 4 votes vote down vote up
public FluidToReactantMapping(String fluidName, String reactantName) {
	super(fluidName, Reactants.standardFluidReactantAmount, reactantName, Reactants.standardFluidReactantAmount);
}
 
Example #26
Source File: FluidToReactantMapping.java    From BigReactors with MIT License 4 votes vote down vote up
public FluidToReactantMapping(FluidStack fluidStack, String reactantName) {
	super(fluidStack.getFluid().getName(), fluidStack.amount, reactantName, Reactants.standardFluidReactantAmount);
}
 
Example #27
Source File: FluidToReactantMapping.java    From BigReactors with MIT License 4 votes vote down vote up
public FluidToReactantMapping(Fluid fluid, int fluidAmount, String reactantName) {
	super(fluid.getName(), fluidAmount, reactantName, Reactants.standardFluidReactantAmount);
}