Guard against the same input calling fill multiple times per tick. *cough* GT output hatch *cough*

This commit is contained in:
Jason Mitchell committed 2021-11-13 15:35:04 -08:00
1 parent 8a5a84bb20
commit cdedddca2d
6 files changed
+30 -10

No files matched your search

@@ -26,9 +26,11 @@ import net.minecraftforge.fluids.FluidTankInfo;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
public abstract class AbstractEnderLiquidConduit extends AbstractLiquidConduit {
@@ -39,7 +41,8 @@ public abstract class AbstractEnderLiquidConduit extends AbstractLiquidConduit {
public static final String ICON_KEY_IN_OUT_IN = ItemConduit.ICON_KEY_IN_OUT_IN;
static final Map<String, IIcon> ICONS = new HashMap<String, IIcon>();
private final Set<BlockCoord> filledFromThisTick = new HashSet<>();
@SideOnly(Side.CLIENT)
public static void initIcons() {
IconUtil.addIconProvider(new IconUtil.IIconProvider() {
@@ -242,6 +245,7 @@ public abstract class AbstractEnderLiquidConduit extends AbstractLiquidConduit {
@Override
public void updateEntity(World world) {
super.updateEntity(world);
filledFromThisTick.clear();
if(world.isRemote) {
return;
}
@@ -281,6 +285,15 @@ public abstract class AbstractEnderLiquidConduit extends AbstractLiquidConduit {
if(network == null || !getConnectionMode(from).acceptsInput()) {
return 0;
}
// Guard against things that continuously call fill!
if(filledFromThisTick.contains(getLocation().getLocation(from))) {
return 0;
}
if(doFill) {
filledFromThisTick.add(getLocation().getLocation(from));
}
return network.fillFrom(this, from, resource, doFill);
}
@@ -1,6 +1,8 @@
package crazypants.enderio.conduit.liquid;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
@@ -31,6 +33,7 @@ public abstract class AbstractTankConduit extends AbstractLiquidConduit {
protected int numEmptyEvents = 0;
protected boolean fluidTypeLocked = false;
private int lastLightValue;
protected final Set<BlockCoord> filledFromThisTick = new HashSet<>();
@Override
public boolean onBlockActivated(EntityPlayer player, RaytraceResult res, List<RaytraceResult> all) {
@@ -191,6 +194,7 @@ public abstract class AbstractTankConduit extends AbstractLiquidConduit {
@Override
public void updateEntity(World world) {
filledFromThisTick.clear();
int lightValue = getLightValue();
if(lastLightValue != lightValue) {
BlockCoord bc = getLocation();
@@ -239,6 +239,15 @@ public class AdvancedLiquidConduit extends AbstractTankConduit {
if(network == null || !getConnectionMode(from).acceptsInput()) {
return 0;
}
// Guard against things that continuously call fill!
if(filledFromThisTick.contains(getLocation().getLocation(from))) {
return 0;
}
if(doFill) {
filledFromThisTick.add(getLocation().getLocation(from));
}
return network.fill(from, resource, doFill);
}
@@ -83,8 +83,6 @@ public class LiquidConduit extends AbstractTankConduit {
private ForgeDirection startPushDir = ForgeDirection.DOWN;
private final Set<BlockCoord> filledFromThisTick = new HashSet<BlockCoord>();
private long ticksSinceFailedExtract = 0;
@Override
@@ -170,9 +168,7 @@ public class LiquidConduit extends AbstractTankConduit {
return 0;
}
// Note: This is just a guard against mekansims pipes that will continuously
// call
// fill on us if we push liquid to them.
// Guard against things that continuously call fill!
if(filledFromThisTick.contains(getLocation().getLocation(from))) {
return 0;
}