Merge branch 'mc1.15/dev' into mc1.16/dev

This commit is contained in:
simibubi 2020-12-17 23:32:11 +01:00
commit 6660718aff
6 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);
@ -80,6 +92,12 @@ public class GenericItemFilling {
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

@ -143,7 +143,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

@ -40,7 +40,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;
@ -63,7 +62,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;
@ -286,7 +285,7 @@ public class BasinTileEntity extends SmartTileEntity implements ITickableTileEnt
}
}
public float getTotalFluidUnits() {
public float getTotalFluidUnits(float partialTicks) {
int renderedFluids = 0;
float totalUnits = 0;
@ -297,7 +296,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;
@ -455,7 +454,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);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 394 B

After

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 444 B