some more chemfac work, expanded fluid acceptor interface

This commit is contained in:
Bob 2022-03-09 22:17:03 +01:00
parent 9477cf8b68
commit dbce273e03
5 changed files with 67 additions and 15 deletions

View File

@ -6,6 +6,7 @@ import com.hbm.tileentity.machine.TileEntityMachineChemfac;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@ -41,5 +42,24 @@ public class MachineChemfac extends BlockDummyable {
@Override
public void fillSpace(World world, int x, int y, int z, ForgeDirection dir, int o) {
super.fillSpace(world, x, y, z, dir, o);
x += dir.offsetX * o;
z += dir.offsetZ * o;
ForgeDirection rot = dir.getRotation(ForgeDirection.DOWN);
this.safeRem = true;
for(int i = -3; i < 3; i++) {
this.makeExtra(world, x + rot.offsetX * 2 + dir.offsetX * i, y + 3, z + rot.offsetZ * 2 + dir.offsetZ * i);
this.makeExtra(world, x - rot.offsetX * 3 + dir.offsetX * i, y + 3, z - rot.offsetZ * 3 + dir.offsetZ * i);
this.makeExtra(world, x + rot.offsetX * 3 + dir.offsetX * i, y + 1, z + rot.offsetZ * 3 + dir.offsetZ * i);
this.makeExtra(world, x + rot.offsetX * 3 + dir.offsetX * i, y + 2, z + rot.offsetZ * 3 + dir.offsetZ * i);
this.makeExtra(world, x - rot.offsetX * 4 + dir.offsetX * i, y + 1, z - rot.offsetZ * 4 + dir.offsetZ * i);
this.makeExtra(world, x - rot.offsetX * 4 + dir.offsetX * i, y + 2, z - rot.offsetZ * 4 + dir.offsetZ * i);
}
this.safeRem = false;
}
}

View File

@ -5,4 +5,16 @@ import com.hbm.inventory.fluid.FluidType;
public interface IFluidAcceptor extends IFluidContainer {
int getMaxFluidFill(FluidType type);
public default void setFluidFillForReceive(int fill, FluidType type) {
this.setFluidFill(fill, type);
}
public default int getFluidFillForReceive(FluidType type) {
return this.getFluidFill(type);
}
public default int getMaxFluidFillForReceive(FluidType type) {
return this.getMaxFluidFill(type);
}
}

View File

@ -611,28 +611,28 @@ public class Library {
}
}
if(tileentity instanceof IFluidAcceptor && newTact && ((IFluidAcceptor)tileentity).getMaxFluidFill(type) > 0 &&
((IFluidAcceptor)tileentity).getMaxFluidFill(type) - ((IFluidAcceptor)tileentity).getFluidFill(type) > 0) {
if(tileentity instanceof IFluidAcceptor && newTact && ((IFluidAcceptor)tileentity).getMaxFluidFillForReceive(type) > 0 &&
((IFluidAcceptor)tileentity).getMaxFluidFillForReceive(type) - ((IFluidAcceptor)tileentity).getFluidFillForReceive(type) > 0) {
that.getFluidList(type).add((IFluidAcceptor)tileentity);
}
if(!newTact)
{
if(!newTact) {
int size = that.getFluidList(type).size();
if(size > 0)
{
if(size > 0) {
int part = that.getFluidFill(type) / size;
for(IFluidAcceptor consume : that.getFluidList(type))
{
if(consume.getFluidFill(type) < consume.getMaxFluidFill(type))
{
if(consume.getMaxFluidFill(type) - consume.getFluidFill(type) >= part)
{
for(IFluidAcceptor consume : that.getFluidList(type)) {
if(consume.getFluidFillForReceive(type) < consume.getMaxFluidFillForReceive(type)) {
if(consume.getMaxFluidFillForReceive(type) - consume.getFluidFillForReceive(type) >= part) {
that.setFluidFill(that.getFluidFill(type) - part, type);
consume.setFluidFill(consume.getFluidFill(type) + part, type);
consume.setFluidFillForReceive(consume.getFluidFillForReceive(type) + part, type);
} else {
that.setFluidFill(that.getFluidFill(type) - (consume.getMaxFluidFill(type) - consume.getFluidFill(type)), type);
consume.setFluidFill(consume.getMaxFluidFill(type), type);
that.setFluidFill(that.getFluidFill(type) - (consume.getMaxFluidFillForReceive(type) - consume.getFluidFillForReceive(type)), type);
consume.setFluidFillForReceive(consume.getMaxFluidFillForReceive(type), type);
}
}
}

View File

@ -6,6 +6,7 @@ import java.util.List;
import com.hbm.interfaces.IFluidAcceptor;
import com.hbm.inventory.fluid.FluidType;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChunkCoordinates;
public class TileEntityMachineChemfac extends TileEntityMachineChemplantBase {
@ -78,4 +79,23 @@ public class TileEntityMachineChemfac extends TileEntityMachineChemplantBase {
public String getName() {
return "container.machineChemFac";
}
AxisAlignedBB bb = null;
@Override
public AxisAlignedBB getRenderBoundingBox() {
if(bb == null) {
bb = AxisAlignedBB.getBoundingBox(
xCoord - 5,
yCoord,
zCoord - 5,
xCoord + 5,
yCoord + 4,
zCoord + 5
);
}
return bb;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB