mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-28 07:55:41 +00:00
#311 Cannot connect an empty fluid conduit to a full one.
This commit is contained in:
1 parent
97472a7fb8
commit
56e166c0aa
2 files changed
+58
-30
No files matched your search
@@ -397,36 +397,11 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
}
|
||||
|
||||
if(breakBlock) {
|
||||
RaytraceResult rt = doRayTrace(world, x, y, z, player);
|
||||
if(rt != null && rt.component != null) {
|
||||
Class<? extends IConduit> type = rt.component.conduitType;
|
||||
if(type == null) {
|
||||
// broke a conector so drop any conduits with no connections as there
|
||||
// is no other way to remove these
|
||||
List<IConduit> cons = new ArrayList<IConduit>(te.getConduits());
|
||||
boolean droppedUnconected = false;
|
||||
for (IConduit con : cons) {
|
||||
if(con.getConduitConnections().isEmpty() &&
|
||||
con.getExternalConnections().isEmpty()) {
|
||||
te.removeConduit(con);
|
||||
drop.add(con.createItem());
|
||||
droppedUnconected = true;
|
||||
}
|
||||
}
|
||||
// If there isn't, then drop em all
|
||||
if(!droppedUnconected) {
|
||||
for (IConduit con : cons) {
|
||||
te.removeConduit(con);
|
||||
drop.add(con.createItem());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
IConduit con = te.getConduit(type);
|
||||
if(con != null) {
|
||||
te.removeConduit(con);
|
||||
drop.add(con.createItem());
|
||||
}
|
||||
|
||||
List<RaytraceResult> results = doRayTraceAll(world, x, y, z, player);
|
||||
RaytraceResult.sort(getEyePosition(world, player), results);
|
||||
for (RaytraceResult rt : results) {
|
||||
if(breakConduit(te, drop, rt, player)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -447,6 +422,48 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider, IC
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean breakConduit(IConduitBundle te, List<ItemStack> drop, RaytraceResult rt, EntityPlayer player) {
|
||||
if(rt == null || rt.component == null) {
|
||||
return false;
|
||||
}
|
||||
Class<? extends IConduit> type = rt.component.conduitType;
|
||||
if(!ConduitUtil.renderConduit(player, type)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(type == null) {
|
||||
// broke a conector so drop any conduits with no connections as there
|
||||
// is no other way to remove these
|
||||
List<IConduit> cons = new ArrayList<IConduit>(te.getConduits());
|
||||
boolean droppedUnconected = false;
|
||||
for (IConduit con : cons) {
|
||||
if(con.getConduitConnections().isEmpty() &&
|
||||
con.getExternalConnections().isEmpty() && ConduitUtil.renderConduit(player, con)) {
|
||||
te.removeConduit(con);
|
||||
drop.add(con.createItem());
|
||||
droppedUnconected = true;
|
||||
}
|
||||
}
|
||||
// If there isn't, then drop em all
|
||||
if(!droppedUnconected) {
|
||||
for (IConduit con : cons) {
|
||||
if(ConduitUtil.renderConduit(player, con)) {
|
||||
te.removeConduit(con);
|
||||
drop.add(con.createItem());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
IConduit con = te.getConduit(type);
|
||||
if(con != null) {
|
||||
te.removeConduit(con);
|
||||
drop.add(con.createItem());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, int par5, int
|
||||
par6) {
|
||||
|
||||
@@ -103,6 +103,17 @@ public class LiquidConduit extends AbstractConduit implements ILiquidConduit {
|
||||
ForgeDirection faceHit = ForgeDirection.getOrientation(res.movingObjectPosition.sideHit);
|
||||
|
||||
if(connDir == ForgeDirection.UNKNOWN || connDir == faceHit) {
|
||||
BlockCoord loc = getLocation().getLocation(faceHit);
|
||||
ILiquidConduit neighbour = ConduitUtil.getConduit(getBundle().getEntity().worldObj, loc.x, loc.y, loc.z, ILiquidConduit.class);
|
||||
if(neighbour == null) {
|
||||
return false;
|
||||
}
|
||||
if(neighbour.getFluidType() == null || getFluidType() == null) {
|
||||
FluidStack type = getFluidType();
|
||||
type = type != null ? type : neighbour.getFluidType();
|
||||
neighbour.setFluidType(type);
|
||||
setFluidType(type);
|
||||
}
|
||||
return ConduitUtil.joinConduits(this, faceHit);
|
||||
} else if(containsExternalConnection(connDir)) {
|
||||
// Toggle extraction mode
|
||||
|
||||
Reference in new issue
Block a user