Skip to content

Commit

Permalink
Update to Botarium 2.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
CodexAdrian committed Jan 11, 2024
1 parent 7fc7195 commit 596d6b9
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 62 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ forge*changelog.txt
/.vscode/
/old.7z
/.architectury-transformer/
.DS_Store
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ subprojects {
minecraft "com.mojang:minecraft:$mc_version"
mappings loom.officialMojangMappings()

modApi "earth.terrarium:botarium-$name-1.20:$botarium_version"
modApi "earth.terrarium.botarium:botarium-$name-1.20.1:$botarium_version"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import com.teamresourceful.resourcefulbees.common.util.containers.SelectableFluidContainer;
import com.teamresourceful.resourcefullib.client.utils.ScreenUtils;
import com.teamresourceful.resourcefullib.common.collections.SelectableList;
import earth.terrarium.botarium.common.fluid.FluidConstants;
import earth.terrarium.botarium.common.fluid.base.FluidHolder;
import earth.terrarium.botarium.common.fluid.utils.ClientFluidHooks;
import earth.terrarium.botarium.common.fluid.utils.FluidHooks;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractWidget;
Expand Down Expand Up @@ -70,7 +70,7 @@ public void renderToolTip() {
line = Component.literal(" ○ ").withStyle(ChatFormatting.DARK_GRAY);
}
line = line.append(Component.empty().withStyle(ChatFormatting.RESET).append(ClientFluidHooks.getDisplayName(tankFluid)));
line = line.append(Component.literal(" " + FluidHooks.toMillibuckets(tankFluid.getFluidAmount()) + "mb").withStyle(ChatFormatting.RESET));
line = line.append(Component.literal(" " + FluidConstants.toMillibuckets(tankFluid.getFluidAmount()) + "mb").withStyle(ChatFormatting.RESET));
tooltip.add(line);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import com.teamresourceful.resourcefulbees.common.menus.EnderBeeconMenu;
import com.teamresourceful.resourcefulbees.common.networking.NetworkHandler;
import com.teamresourceful.resourcefulbees.common.networking.packets.client.BeeconChangePacket;
import earth.terrarium.botarium.common.fluid.FluidConstants;
import earth.terrarium.botarium.common.fluid.base.FluidHolder;
import earth.terrarium.botarium.common.fluid.utils.ClientFluidHooks;
import earth.terrarium.botarium.common.fluid.utils.FluidHooks;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractSliderButton;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
Expand Down Expand Up @@ -105,7 +105,7 @@ protected void renderLabels(@NotNull GuiGraphics graphics, int mouseX, int mouse
graphics.drawString(font, BeeconTranslations.FLUID_LABEL, 110, 56, 14737632);
graphics.drawString(font, holder.isEmpty() ? BeeconTranslations.NO_FLUID_LABEL : ClientFluidHooks.getDisplayName(holder), 137, 56, 16751628);
graphics.drawString(font, BeeconTranslations.FLUID_AMOUNT_LABEL, 110, 68, 14737632);
graphics.drawString(font, FluidHooks.toMillibuckets(holder.getFluidAmount()) +"mB", 148, 68, 47104);
graphics.drawString(font, FluidConstants.toMillibuckets(holder.getFluidAmount()) +"mB", 148, 68, 47104);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import com.teamresourceful.resourcefulbees.common.util.MathUtils;
import com.teamresourceful.resourcefullib.client.CloseablePoseStack;
import earth.terrarium.botarium.common.energy.base.EnergyContainer;
import earth.terrarium.botarium.common.fluid.FluidConstants;
import earth.terrarium.botarium.common.fluid.base.FluidHolder;
import earth.terrarium.botarium.common.fluid.utils.ClientFluidHooks;
import earth.terrarium.botarium.common.fluid.utils.FluidHooks;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
Expand Down Expand Up @@ -51,7 +51,7 @@ protected void renderBg(@NotNull GuiGraphics graphics, float partialTicks, int m
graphics.drawString(this.font, "Fluid: ", 57, 22, 0xffffff);
graphics.drawString(this.font, holder.isEmpty() ? GuiTranslations.NO_FLUID : ClientFluidHooks.getDisplayName(holder), 61, 32, 0xffffff);
graphics.drawString(this.font, "Amount: ", 57, 42, 0xffffff);
graphics.drawString(this.font, FluidHooks.toMillibuckets(holder.getFluidAmount()) + "mB", 61, 52, 0xffffff);
graphics.drawString(this.font, FluidConstants.toMillibuckets(holder.getFluidAmount()) + "mB", 61, 52, 0xffffff);
}
}
}
Expand Down Expand Up @@ -84,9 +84,9 @@ public void renderFluidTooltip(int mouseX, int mouseY) {
if (MathUtils.inRangeInclusive(mouseX, this.leftPos + 28, this.leftPos + 40) && MathUtils.inRangeInclusive(mouseY, this.topPos + 16, this.topPos + 70)) {
FluidHolder holder = this.menu.getEntity().getFluid();
if (Screen.hasShiftDown() || holder.getFluidAmount() < 500) {
setTooltipForNextRenderPass(Component.literal(FluidHooks.toMillibuckets(holder.getFluidAmount()) + " MB"));
setTooltipForNextRenderPass(Component.literal(FluidConstants.toMillibuckets(holder.getFluidAmount()) + " MB"));
} else {
setTooltipForNextRenderPass(Component.literal(TextUtils.NUMBER_FORMAT.format((double) holder.getFluidAmount() / FluidHooks.getBucketAmount()) + " Buckets"));
setTooltipForNextRenderPass(Component.literal(TextUtils.NUMBER_FORMAT.format((double) holder.getFluidAmount() / FluidConstants.getBucketAmount()) + " Buckets"));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import com.teamresourceful.resourcefulbees.common.lib.constants.translations.GuiTranslations;
import com.teamresourceful.resourcefulbees.common.menus.HoneyPotMenu;
import com.teamresourceful.resourcefulbees.common.util.MathUtils;
import earth.terrarium.botarium.common.fluid.FluidConstants;
import earth.terrarium.botarium.common.fluid.base.FluidHolder;
import earth.terrarium.botarium.common.fluid.utils.ClientFluidHooks;
import earth.terrarium.botarium.common.fluid.utils.FluidHooks;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
Expand Down Expand Up @@ -36,9 +36,9 @@ protected void renderBg(@NotNull GuiGraphics graphics, float partialTicks, int x
graphics.drawString(this.font, "Fluid: ",this.leftPos + 36, this.topPos + 17, 0xffffff);
graphics.drawString(this.font, holder.isEmpty() ? GuiTranslations.NO_FLUID : ClientFluidHooks.getDisplayName(holder), this.leftPos + 40, this.topPos + 27, 0xffffff);
graphics.drawString(this.font, "Amount: ",this.leftPos + 36, this.topPos + 37, 0xffffff);
graphics.drawString(this.font, FluidHooks.toMillibuckets(holder.getFluidAmount())+"mB",this.leftPos + 40, this.topPos + 47, 0xffffff);
graphics.drawString(this.font, FluidConstants.toMillibuckets(holder.getFluidAmount())+"mB",this.leftPos + 40, this.topPos + 47, 0xffffff);

int height = (int) ((holder.getFluidAmount() / FluidHooks.buckets(64)) * 54);
int height = (int) ((holder.getFluidAmount() / FluidConstants.fromMillibuckets(64000)) * 54);
ClientRenderUtils.drawFluid(graphics, height, 12, holder, this.leftPos+129, this.topPos+16);
}

Expand All @@ -64,10 +64,10 @@ public void render(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float


private Component getMillibuckets(long fluidAmount) {
return Component.literal(FluidHooks.toMillibuckets(fluidAmount) + "mB");
return Component.literal(FluidConstants.toMillibuckets(fluidAmount) + "mB");
}

private Component getBuckets(long fluidAmount) {
return Component.literal(((double) fluidAmount / FluidHooks.getBucketAmount()) + "B");
return Component.literal(((double) fluidAmount / FluidConstants.getBucketAmount()) + "B");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import com.teamresourceful.resourcefulbees.common.lib.constants.ModConstants;
import com.teamresourceful.resourcefulbees.common.menus.SolidificationChamberMenu;
import com.teamresourceful.resourcefulbees.common.util.MathUtils;
import earth.terrarium.botarium.common.fluid.FluidConstants;
import earth.terrarium.botarium.common.fluid.base.FluidHolder;
import earth.terrarium.botarium.common.fluid.utils.FluidHooks;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
Expand All @@ -33,7 +33,7 @@ protected void renderBg(@NotNull GuiGraphics graphics, float partialTicks, int m
int j = this.topPos;
graphics.blit(texture, i, j, 0, 0, this.imageWidth, this.imageHeight);
FluidHolder holder = tileEntity.getFluid();
int height = (int) ((holder.getFluidAmount() / FluidHooks.buckets(16)) * 62);
int height = (int) ((holder.getFluidAmount() / FluidConstants.fromMillibuckets(16000)) * 62);
ClientRenderUtils.drawFluid(graphics, height, 14, holder, i + 67, j + 12+(62-height));
}
}
Expand All @@ -60,10 +60,10 @@ public void render(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float
}

private Component getMillibuckets(long fluidAmount) {
return Component.literal(FluidHooks.toMillibuckets(fluidAmount) + "mB");
return Component.literal(FluidConstants.toMillibuckets(fluidAmount) + "mB");
}

private Component getBuckets(long fluidAmount) {
return Component.literal(((double) fluidAmount / FluidHooks.getBucketAmount()) + "B");
return Component.literal(((double) fluidAmount / FluidConstants.getBucketAmount()) + "B");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import com.teamresourceful.resourcefulbees.common.blocks.base.InstanceBlockEntityTicker;
import com.teamresourceful.resourcefulbees.common.registries.minecraft.ModBlockEntityTypes;
import earth.terrarium.botarium.common.energy.EnergyApi;
import earth.terrarium.botarium.common.energy.base.BotariumEnergyBlock;
import earth.terrarium.botarium.common.energy.impl.ExtractOnlyEnergyContainer;
import earth.terrarium.botarium.common.energy.impl.WrappedBlockEnergyContainer;
import earth.terrarium.botarium.common.energy.util.EnergyHooks;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
Expand All @@ -28,14 +28,14 @@ public Side getSide() {
public void serverTick(Level level, BlockPos pos, BlockState state) {
if (level != null) {
this.energy.setEnergy(Integer.MAX_VALUE);
EnergyHooks.distributeEnergyNearby(this);
EnergyApi.distributeEnergyNearby(this, Integer.MAX_VALUE);
}
}

@Override
public WrappedBlockEnergyContainer getEnergyStorage() {
if (energy == null) {
energy = new WrappedBlockEnergyContainer(this, new ExtractOnlyEnergyContainer(Integer.MAX_VALUE));
energy = new WrappedBlockEnergyContainer(this, new ExtractOnlyEnergyContainer(Integer.MAX_VALUE, Integer.MAX_VALUE));
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
import com.teamresourceful.resourcefulbees.common.registries.minecraft.ModBlockEntityTypes;
import com.teamresourceful.resourcefulbees.common.registries.minecraft.ModEffects;
import com.teamresourceful.resourcefullib.common.menu.ContentMenuProvider;
import earth.terrarium.botarium.common.fluid.FluidConstants;
import earth.terrarium.botarium.common.fluid.base.BotariumFluidBlock;
import earth.terrarium.botarium.common.fluid.base.FluidContainer;
import earth.terrarium.botarium.common.fluid.base.FluidHolder;
import earth.terrarium.botarium.common.fluid.impl.InsertOnlyFluidContainer;
import earth.terrarium.botarium.common.fluid.impl.WrappedBlockFluidContainer;
import earth.terrarium.botarium.common.fluid.utils.FluidHooks;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.registries.BuiltInRegistries;
Expand All @@ -40,7 +41,6 @@
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -173,20 +173,18 @@ private void startUpCheck(@NotNull Level level, BlockPos pos, BlockState state)

private void pullFluidFromBelow(@NotNull Level level, BlockPos pos) {
if (this.getFluid().getFluidAmount() >= this.tank.getTankCapacity(0)) return;
BlockEntity tileEntity = level.getBlockEntity(pos.below());
if (tileEntity == null) return;

FluidHooks.safeGetBlockFluidManager(tileEntity, Direction.UP).ifPresent(manager -> {
for (FluidHolder fluidTank : manager.getFluidTanks()) {
if (fluidTank.isEmpty()) continue;
FluidHolder holder = fluidTank.copyWithAmount(Math.min(fluidTank.getFluidAmount(), EnderBeeconConfig.beeconPullAmount));
FluidHolder extracted = manager.extractFluid(holder, true);
if (!extracted.isEmpty() && this.tank.internalInsert(extracted, true) > 0) {
manager.extractFluid(extracted, false);
this.tank.internalInsert(extracted, false);
}
FluidContainer container = FluidContainer.of(level, pos.below(), Direction.UP);
if (container == null) return;

for (FluidHolder fluidTank : container.getFluids()) {
if (fluidTank.isEmpty()) continue;
FluidHolder holder = fluidTank.copyWithAmount(Math.min(fluidTank.getFluidAmount(), EnderBeeconConfig.beeconPullAmount));
FluidHolder extracted = container.extractFluid(holder, true);
if (!extracted.isEmpty() && this.tank.internalInsert(extracted, true) > 0) {
container.extractFluid(extracted, false);
this.tank.internalInsert(extracted, false);
}
});
}
}

public FluidHolder getFluid() {
Expand Down Expand Up @@ -297,7 +295,7 @@ public void setChanged() {
@Override
public WrappedBlockFluidContainer getFluidContainer() {
if (tank == null) {
tank = new WrappedBlockFluidContainer(this, new InsertOnlyFluidContainer(i -> FluidHooks.buckets(16), 1, (amount, fluid) -> fluid.is(ModFluidTags.HONEY)));
tank = new WrappedBlockFluidContainer(this, new InsertOnlyFluidContainer(i -> FluidConstants.fromMillibuckets(16000), 1, (amount, fluid) -> fluid.is(ModFluidTags.HONEY)));
}
return this.tank;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
import com.teamresourceful.resourcefulbees.common.recipes.HoneyGenRecipe;
import com.teamresourceful.resourcefulbees.common.registries.minecraft.ModBlockEntityTypes;
import com.teamresourceful.resourcefulbees.common.util.containers.AutomationSensitiveContainer;
import earth.terrarium.botarium.common.energy.EnergyApi;
import earth.terrarium.botarium.common.energy.base.BotariumEnergyBlock;
import earth.terrarium.botarium.common.energy.impl.ExtractOnlyEnergyContainer;
import earth.terrarium.botarium.common.energy.impl.WrappedBlockEnergyContainer;
import earth.terrarium.botarium.common.energy.util.EnergyHooks;
import earth.terrarium.botarium.common.fluid.base.BotariumFluidBlock;
import earth.terrarium.botarium.common.fluid.base.FluidHolder;
import earth.terrarium.botarium.common.fluid.impl.InsertOnlyFluidContainer;
Expand Down Expand Up @@ -82,7 +82,7 @@ public void serverTick(Level level, BlockPos pos, BlockState state) {
else this.processCompleted(level);
}
if (hasEnergy()) {
EnergyHooks.distributeEnergyNearby(this, ENERGY_TRANSFER_AMOUNT);
EnergyApi.distributeEnergyNearby(this, ENERGY_TRANSFER_AMOUNT);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import com.teamresourceful.resourcefulbees.common.menus.content.PositionContent;
import com.teamresourceful.resourcefulbees.common.registries.minecraft.ModBlockEntityTypes;
import com.teamresourceful.resourcefullib.common.menu.ContentMenuProvider;
import earth.terrarium.botarium.common.fluid.FluidConstants;
import earth.terrarium.botarium.common.fluid.base.BotariumFluidBlock;
import earth.terrarium.botarium.common.fluid.base.FluidHolder;
import earth.terrarium.botarium.common.fluid.impl.SimpleFluidContainer;
import earth.terrarium.botarium.common.fluid.impl.WrappedBlockFluidContainer;
import earth.terrarium.botarium.common.fluid.utils.FluidHooks;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -80,7 +80,7 @@ public PositionContent createContent() {
private static class HoneyFluidContainer extends SimpleFluidContainer {

public HoneyFluidContainer() {
super(i -> FluidHooks.buckets(64), 1, (i, holder) -> holder.is(ModFluidTags.HONEY));
super(i -> FluidConstants.fromMillibuckets(64000), 1, (i, holder) -> holder.is(ModFluidTags.HONEY));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
import com.teamresourceful.resourcefulbees.common.recipes.SolidificationRecipe;
import com.teamresourceful.resourcefulbees.common.registries.minecraft.ModBlockEntityTypes;
import com.teamresourceful.resourcefulbees.common.util.containers.AutomationSensitiveContainer;
import earth.terrarium.botarium.common.fluid.FluidConstants;
import earth.terrarium.botarium.common.fluid.base.BotariumFluidBlock;
import earth.terrarium.botarium.common.fluid.base.FluidHolder;
import earth.terrarium.botarium.common.fluid.impl.InsertOnlyFluidContainer;
import earth.terrarium.botarium.common.fluid.impl.WrappedBlockFluidContainer;
import earth.terrarium.botarium.common.fluid.utils.FluidHooks;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -141,7 +141,7 @@ public void setChanged() {
@Override
public WrappedBlockFluidContainer getFluidContainer() {
if (tank == null) {
tank = new WrappedBlockFluidContainer(this, new InsertOnlyFluidContainer(i -> FluidHooks.buckets(16), 1, (amount, fluid) -> this.level != null && SolidificationRecipe.matches(level.getRecipeManager(), fluid.getFluid(), fluid.getCompound())));
tank = new WrappedBlockFluidContainer(this, new InsertOnlyFluidContainer(i -> FluidConstants.fromMillibuckets(16000), 1, (amount, fluid) -> this.level != null && SolidificationRecipe.matches(level.getRecipeManager(), fluid.getFluid(), fluid.getCompound())));
}
return this.tank;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.teamresourceful.resourcefulbees.common.lib.enums.HoneyPotState;
import com.teamresourceful.resourcefulbees.common.registries.minecraft.ModBlocks;
import com.teamresourceful.resourcefulbees.common.util.FluidUtils;
import earth.terrarium.botarium.common.fluid.utils.FluidHooks;
import earth.terrarium.botarium.common.fluid.base.FluidContainer;
import net.minecraft.Util;
import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand;
Expand Down Expand Up @@ -74,7 +74,7 @@ public void neighborChanged(@NotNull BlockState state, @NotNull Level level, @No

if (level.getBlockState(pos.above()).getBlock().equals(ModBlocks.ENDER_BEECON.get())) {
potState = HoneyPotState.BEECON;
} else if (blockEntityAbove != null && FluidHooks.safeGetBlockFluidManager(blockEntityAbove, null).isPresent()) {
} else if (blockEntityAbove != null && FluidContainer.holdsFluid(blockEntityAbove, null)) {
potState = HoneyPotState.OPEN;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.mojang.serialization.codecs.RecordCodecBuilder;
import com.teamresourceful.resourcefullib.common.codecs.CodecExtras;
import earth.terrarium.botarium.common.fluid.base.FluidHolder;
import earth.terrarium.botarium.common.fluid.utils.FluidHooks;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.ExtraCodecs;
Expand Down Expand Up @@ -67,6 +66,6 @@ public boolean isEmpty() {
}

public FluidHolder toHolder() {
return FluidHooks.newFluidHolder(fluid, amount, tag);
return FluidHolder.of(fluid, amount, tag);
}
}
Loading

0 comments on commit 596d6b9

Please sign in to comment.