mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
new chemplant fluid and energy IO
This commit is contained in:
parent
50557e6d0a
commit
abb8c3aeba
@ -48,7 +48,7 @@ public class SILEXRecipeHandler extends TemplateRecipeHandler {
|
||||
this.outputs = new ArrayList<PositionedStack>();
|
||||
this.chances = new ArrayList<Double>();
|
||||
this.produced = recipe.fluidProduced / recipe.fluidConsumed;
|
||||
this.crystalStrength = EnumWavelengths.values()[recipe.laserStrength];
|
||||
this.crystalStrength = recipe.laserStrength;
|
||||
|
||||
double weight = 0;
|
||||
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
package com.hbm.interfaces;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.inventory.FluidTank;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
|
||||
public interface IFluidContainer {
|
||||
|
||||
@ -90,7 +90,7 @@ public class FluidTank {
|
||||
}
|
||||
|
||||
//Fills tank from canisters
|
||||
public void loadTank(int in, int out, ItemStack[] slots) {
|
||||
public boolean loadTank(int in, int out, ItemStack[] slots) {
|
||||
|
||||
FluidType inType = Fluids.NONE;
|
||||
if(slots[in] != null) {
|
||||
@ -101,27 +101,27 @@ public class FluidTank {
|
||||
|
||||
if(slots[in].getItem() == ModItems.fluid_barrel_infinite && type != Fluids.NONE) {
|
||||
this.fluid = this.maxFluid;
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if(slots[in].getItem() == ModItems.inf_water && this.type == Fluids.WATER) {
|
||||
this.fluid += 50;
|
||||
if(this.fluid > this.maxFluid)
|
||||
this.fluid = this.maxFluid;
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if(slots[in].getItem() == ModItems.inf_water_mk2 && this.type == Fluids.WATER) {
|
||||
this.fluid += 500;
|
||||
if(this.fluid > this.maxFluid)
|
||||
this.fluid = this.maxFluid;
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if(FluidContainerRegistry.getFluidContent(slots[in], type) <= 0)
|
||||
return;
|
||||
return false;
|
||||
} else {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(slots[in] != null && inType.getName().equals(type.getName()) && fluid + FluidContainerRegistry.getFluidContent(slots[in], type) <= maxFluid) {
|
||||
@ -141,7 +141,11 @@ public class FluidTank {
|
||||
if(slots[in].stackSize <= 0)
|
||||
slots[in] = null;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//Fills canisters from tank
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
package com.hbm.tileentity.machine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.interfaces.IFluidAcceptor;
|
||||
import com.hbm.interfaces.IFluidSource;
|
||||
import com.hbm.inventory.FluidTank;
|
||||
@ -13,12 +15,14 @@ import com.hbm.inventory.recipes.ChemplantRecipes;
|
||||
import com.hbm.inventory.recipes.ChemplantRecipes.ChemRecipe;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemMachineUpgrade.UpgradeType;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
import com.hbm.util.InventoryUtil;
|
||||
|
||||
import api.hbm.energy.IEnergyUser;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityMachineChemplantNew extends TileEntityMachineBase implements IEnergyUser, IFluidSource, IFluidAcceptor {
|
||||
|
||||
@ -63,6 +67,22 @@ public class TileEntityMachineChemplantNew extends TileEntityMachineBase impleme
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
this.power = Library.chargeTEFromItems(slots, 0, power, maxPower);
|
||||
|
||||
if(!tanks[0].loadTank(17, 19, slots)) tanks[0].unloadTank(17, 19, slots);
|
||||
if(!tanks[1].loadTank(18, 20, slots)) tanks[1].unloadTank(18, 20, slots);
|
||||
|
||||
tanks[2].unloadTank(9, 11, slots);
|
||||
tanks[3].unloadTank(10, 12, slots);
|
||||
|
||||
if(worldObj.getTotalWorldTime() % 10 == 0) {
|
||||
this.fillFluidInit(tanks[2].getTankType());
|
||||
this.fillFluidInit(tanks[3].getTankType());
|
||||
}
|
||||
if(worldObj.getTotalWorldTime() % 20 == 0) {
|
||||
this.updateConnections();
|
||||
}
|
||||
|
||||
UpgradeManager.eval(slots, 1, 3);
|
||||
|
||||
int speedLevel = Math.min(UpgradeManager.getLevel(UpgradeType.SPEED), 3);
|
||||
@ -104,6 +124,17 @@ public class TileEntityMachineChemplantNew extends TileEntityMachineBase impleme
|
||||
}
|
||||
}
|
||||
|
||||
private void updateConnections() {
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
|
||||
ForgeDirection rot = dir.getRotation(ForgeDirection.DOWN);
|
||||
|
||||
this.trySubscribe(worldObj, xCoord + rot.offsetX * 3, yCoord, zCoord + rot.offsetZ * 3, rot);
|
||||
this.trySubscribe(worldObj, xCoord - rot.offsetX * 2, yCoord, zCoord - rot.offsetZ * 2, rot.getOpposite());
|
||||
this.trySubscribe(worldObj, xCoord + rot.offsetX * 3 + dir.offsetX, yCoord, zCoord + rot.offsetZ * 3 + dir.offsetZ, rot);
|
||||
this.trySubscribe(worldObj, xCoord - rot.offsetX * 2 + dir.offsetX, yCoord, zCoord - rot.offsetZ * 2 + dir.offsetZ, rot.getOpposite());
|
||||
}
|
||||
|
||||
private boolean canProcess() {
|
||||
|
||||
if(slots[4] == null || slots[4].getItem() != ModItems.chemistry_template)
|
||||
@ -195,79 +226,116 @@ public class TileEntityMachineChemplantNew extends TileEntityMachineBase impleme
|
||||
|
||||
@Override
|
||||
public long getPower() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
return this.power;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPower(long power) {
|
||||
this.power = power;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxPower() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
return this.maxPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFillForSync(int fill, int index) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
if(index >= 0 && index < tanks.length) tanks[index].setFill(fill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFillForTransfer(int fill, FluidType type) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
for(FluidTank tank : tanks) {
|
||||
if(tank.getTankType() == type) {
|
||||
tank.setFill(fill);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTypeForSync(FluidType type, int index) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
if(index >= 0 && index < tanks.length) tanks[index].setTankType(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFluidFill(FluidType type) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
for(FluidTank tank : tanks) {
|
||||
if(tank.getTankType() == type) {
|
||||
return tank.getFill();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxFillForReceive(FluidType type) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
for(FluidTank tank : tanks) {
|
||||
if(tank.getTankType() == type) {
|
||||
return tank.getMaxFill();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillFluidInit(FluidType type) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
/*
|
||||
* ####
|
||||
* X####X
|
||||
* X##O#X
|
||||
* ####
|
||||
*/
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
|
||||
ForgeDirection rot = dir.getRotation(ForgeDirection.DOWN);
|
||||
|
||||
fillFluid(xCoord + rot.offsetX * 3, yCoord, zCoord + rot.offsetZ * 3, this.getTact(), type);
|
||||
fillFluid(xCoord - rot.offsetX * 2, yCoord, zCoord - rot.offsetZ * 2, this.getTact(), type);
|
||||
fillFluid(xCoord + rot.offsetX * 3 + dir.offsetX, yCoord, zCoord + rot.offsetZ * 3 + dir.offsetZ, this.getTact(), type);
|
||||
fillFluid(xCoord - rot.offsetX * 2 + dir.offsetX, yCoord, zCoord - rot.offsetZ * 2 + dir.offsetZ, this.getTact(), type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillFluid(int x, int y, int z, boolean newTact, FluidType type) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
Library.transmitFluid(x, y, z, newTact, this, worldObj, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getTact() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
return worldObj.getTotalWorldTime() % 20 < 10;
|
||||
}
|
||||
|
||||
List<IFluidAcceptor>[] lists = new List[] {
|
||||
new ArrayList(), new ArrayList(), new ArrayList(), new ArrayList()
|
||||
};
|
||||
|
||||
@Override
|
||||
public List<IFluidAcceptor> getFluidList(FluidType type) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
||||
for(int i = 0; i < tanks.length; i++) {
|
||||
if(tanks[i].getTankType() == type) {
|
||||
return lists[i];
|
||||
}
|
||||
}
|
||||
|
||||
return new ArrayList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearFluidList(FluidType type) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPower(long power) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
for(int i = 0; i < tanks.length; i++) {
|
||||
if(tanks[i].getTankType() == type) {
|
||||
lists[i].clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BIN
src/main/resources/assets/hbm/textures/gui/processing/gui_chemfac.png
Executable file
BIN
src/main/resources/assets/hbm/textures/gui/processing/gui_chemfac.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
Loading…
x
Reference in New Issue
Block a user