Bug Fixes

- Snownee's basin render fix
- Fixed milk fluid exchange between vanilla items and the create fluid infrastructure
This commit is contained in:
simibubi 2020-12-17 23:29:33 +01:00
parent 493cad13d0
commit 68e7d3c34c
4 changed files with 25 additions and 8 deletions

View File

@ -23,6 +23,8 @@ public class GenericItemFilling {
public static boolean canItemBeFilled(World world, ItemStack stack) {
if (stack.getItem() == Items.GLASS_BOTTLE)
return true;
if (stack.getItem() == Items.MILK_BUCKET)
return false;
LazyOptional<IFluidHandlerItem> capability =
stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY);
@ -40,6 +42,8 @@ public class GenericItemFilling {
public static int getRequiredAmountForItem(World world, ItemStack stack, FluidStack availableFluid) {
if (stack.getItem() == Items.GLASS_BOTTLE && canFillGlassBottleInternally(availableFluid))
return PotionFluidHandler.getRequiredAmountForFilledBottle(stack, availableFluid);
if (stack.getItem() == Items.BUCKET && canFillBucketInternally(availableFluid))
return 1000;
LazyOptional<IFluidHandlerItem> capability =
stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY);
@ -51,6 +55,9 @@ public class GenericItemFilling {
.getFilledBucket();
if (filledBucket == null || filledBucket == Items.AIR)
return -1;
if (!((FluidBucketWrapper) tank).getFluid()
.isEmpty())
return -1;
return 1000;
}
@ -65,6 +72,11 @@ public class GenericItemFilling {
.isEquivalentTo(AllFluids.POTION.get());
}
private static boolean canFillBucketInternally(FluidStack availableFluid) {
return availableFluid.getFluid()
.isEquivalentTo(AllFluids.MILK.get().getFlowingFluid());
}
public static ItemStack fillItem(World world, int requiredAmount, ItemStack stack, FluidStack availableFluid) {
FluidStack toFill = availableFluid.copy();
toFill.setAmount(requiredAmount);
@ -79,7 +91,13 @@ public class GenericItemFilling {
stack.shrink(1);
return fillBottle;
}
if (stack.getItem() == Items.BUCKET && canFillBucketInternally(toFill)) {
ItemStack filledBucket = new ItemStack(Items.MILK_BUCKET);
stack.shrink(1);
return filledBucket;
}
ItemStack split = stack.copy();
split.setCount(1);
LazyOptional<IFluidHandlerItem> capability =

View File

@ -63,7 +63,7 @@ public class BasinFluidParticle extends FluidStackParticle {
TileEntity tileEntity = world.getTileEntity(basinPos);
if (tileEntity instanceof BasinTileEntity) {
float totalUnits = ((BasinTileEntity) tileEntity).getTotalFluidUnits();
float totalUnits = ((BasinTileEntity) tileEntity).getTotalFluidUnits(0);
if (totalUnits < 1)
totalUnits = 0;
float fluidLevel = MathHelper.clamp(totalUnits / 2000, 0, 1);

View File

@ -141,7 +141,7 @@ public class BasinRenderer extends SmartTileEntityRenderer<BasinTileEntity> {
SmartFluidTankBehaviour inputFluids = basin.getBehaviour(SmartFluidTankBehaviour.INPUT);
SmartFluidTankBehaviour outputFluids = basin.getBehaviour(SmartFluidTankBehaviour.OUTPUT);
SmartFluidTankBehaviour[] tanks = { inputFluids, outputFluids };
float totalUnits = basin.getTotalFluidUnits();
float totalUnits = basin.getTotalFluidUnits(partialTicks);
if (totalUnits < 1)
return 0;

View File

@ -39,7 +39,6 @@ import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.nbt.StringNBT;
import net.minecraft.particles.IParticleData;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
@ -62,7 +61,7 @@ import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemHandlerHelper;
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
public class BasinTileEntity extends SmartTileEntity implements ITickableTileEntity {
public class BasinTileEntity extends SmartTileEntity {
private boolean areFluidsMoving;
LerpedFloat ingredientRotationSpeed;
@ -285,7 +284,7 @@ public class BasinTileEntity extends SmartTileEntity implements ITickableTileEnt
}
}
public float getTotalFluidUnits() {
public float getTotalFluidUnits(float partialTicks) {
int renderedFluids = 0;
float totalUnits = 0;
@ -296,7 +295,7 @@ public class BasinTileEntity extends SmartTileEntity implements ITickableTileEnt
if (tankSegment.getRenderedFluid()
.isEmpty())
continue;
float units = tankSegment.getTotalUnits(0);
float units = tankSegment.getTotalUnits(partialTicks);
if (units < 1)
continue;
totalUnits += units;
@ -454,7 +453,7 @@ public class BasinTileEntity extends SmartTileEntity implements ITickableTileEnt
if (segments < 2)
return;
float totalUnits = getTotalFluidUnits();
float totalUnits = getTotalFluidUnits(0);
if (totalUnits == 0)
return;
float fluidLevel = MathHelper.clamp(totalUnits / 2000, 0, 1);