Fix for machine tank drain. More luv to industrial grinder. (#1254)

* Fix for machine tank drain. More luv to grinder

Fix for empty cell drained from tank.
JEI should honor power units (FE\EU) used.
Fill\drain tank only two times per second in order to avoid game crash
due to ticking entity.
This commit is contained in:
drcrazy 2017-08-29 19:57:21 +03:00 committed by GitHub
parent 63be913878
commit ab1428eb12
3 changed files with 22 additions and 8 deletions

View file

@ -34,7 +34,7 @@ import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack;
import techreborn.api.recipe.machines.IndustrialGrinderRecipe;
import techreborn.compat.jei.BaseRecipeWrapper;
import reborncore.common.powerSystem.PowerSystem;
import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.List;
@ -86,6 +86,6 @@ public class IndustrialGrinderRecipeWrapper extends BaseRecipeWrapper<Industrial
int lineHeight = minecraft.fontRenderer.FONT_HEIGHT;
minecraft.fontRenderer.drawString("Time: " + baseRecipe.tickTime / 20 + " s", x, y, 0x444444);
minecraft.fontRenderer.drawString("EU: " + baseRecipe.euPerTick + " EU/t", x, y += lineHeight, 0x444444);
minecraft.fontRenderer.drawString("Energy: " + PowerSystem.getLocaliszedPowerFormattedNoSuffix(baseRecipe.euPerTick) + " " + PowerSystem.getDisplayPower().abbreviation + "/t", x, y += lineHeight, 0x444444);
}
}

View file

@ -226,7 +226,14 @@ public class DynamicCell extends Item {
@Override
public ItemStack getContainer() {
return new ItemStack(ModItems.CELL, 1);
ItemStack cell;
if (container.hasTagCompound() && container.getTagCompound().hasKey(FLUID_NBT_KEY)) {
cell = super.getContainer();
}
else {
cell = new ItemStack(ModItems.CELL, 1);
}
return cell;
}
}

View file

@ -60,6 +60,7 @@ public class TileIndustrialGrinder extends TilePowerAcceptor implements IWrencha
public Tank tank;
public RecipeCrafter crafter;
public MultiblockChecker multiblockChecker;
int ticksSinceLastChange;
public TileIndustrialGrinder() {
super();
@ -67,6 +68,7 @@ public class TileIndustrialGrinder extends TilePowerAcceptor implements IWrencha
tank = new Tank("TileIndustrialGrinder", TileIndustrialGrinder.TANK_CAPACITY, this);
inventory = new Inventory(7, "TileIndustrialGrinder", 64, this);
ticksSinceLastChange = 0;
final int[] inputs = new int[2];
inputs[0] = 0;
inputs[1] = 1;
@ -121,6 +123,8 @@ public class TileIndustrialGrinder extends TilePowerAcceptor implements IWrencha
@Override
public void update() {
ticksSinceLastChange++;
super.update();
if (this.multiblockChecker == null) {
@ -132,10 +136,13 @@ public class TileIndustrialGrinder extends TilePowerAcceptor implements IWrencha
this.crafter.updateEntity();
}
if (!this.inventory.getStackInSlot(1).isEmpty()){
FluidUtils.drainContainers(this.tank, this.inventory, 1, 6);
FluidUtils.fillContainers(this.tank, this.inventory, 1, 6, this.tank.getFluidType());
this.syncWithAll();
//Check cells input slot 2 time per second
if (ticksSinceLastChange >= 10){
if (!this.inventory.getStackInSlot(1).isEmpty()){
FluidUtils.drainContainers(this.tank, this.inventory, 1, 6);
FluidUtils.fillContainers(this.tank, this.inventory, 1, 6, this.tank.getFluidType());
}
ticksSinceLastChange = 0;
}
}