[CHORE] Cleanup API's that's unused by any mod currently
This commit is contained in:
@@ -36,7 +36,6 @@ shadowJar {
|
||||
unimined.minecraft {
|
||||
fabric {
|
||||
loader fabric_loader
|
||||
accessWidener(project(":Common").file("src/main/resources/${mod_id}.aw"))
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,19 +1,9 @@
|
||||
package com.hypherionmc.craterlib.client;
|
||||
|
||||
import com.hypherionmc.craterlib.api.event.client.CraterClientTickEvent;
|
||||
import com.hypherionmc.craterlib.api.event.client.LateInitEvent;
|
||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
import com.hypherionmc.craterlib.core.event.annot.CraterEventListener;
|
||||
import com.hypherionmc.craterlib.core.systems.internal.CreativeTabRegistry;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public class CraterLibClientInitializer implements ClientModInitializer {
|
||||
|
||||
@@ -26,23 +16,4 @@ public class CraterLibClientInitializer implements ClientModInitializer {
|
||||
|
||||
CraterEventBus.INSTANCE.registerEventListener(CraterLibClientInitializer.class);
|
||||
}
|
||||
|
||||
@CraterEventListener
|
||||
public static void lateInitEvent(LateInitEvent event) {
|
||||
CreativeTabRegistry.getTabs().forEach(tab -> {
|
||||
CreativeModeTab finalTab = Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, tab.getResourceKey(), FabricItemGroup.builder()
|
||||
.title(Component.translatable("itemGroup." +
|
||||
tab.getResourceLocation().toString().replace(":", ".")
|
||||
))
|
||||
.icon(tab.getIcon())
|
||||
.build());
|
||||
|
||||
tab.setTab(finalTab);
|
||||
|
||||
ItemGroupEvents.modifyEntriesEvent(tab.getResourceKey()).register(entries -> CreativeTabRegistry
|
||||
.getTabItems()
|
||||
.stream().filter(t -> t.getLeft().get() == finalTab && t.getRight() != null)
|
||||
.map(Pair::getRight).forEach(itm -> entries.accept(itm.get())));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -1,43 +1,16 @@
|
||||
package com.hypherionmc.craterlib.client;
|
||||
|
||||
import com.hypherionmc.craterlib.common.item.BlockItemDyable;
|
||||
import com.hypherionmc.craterlib.core.platform.ClientPlatform;
|
||||
import com.hypherionmc.craterlib.util.ColorPropertyFunction;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
||||
import net.minecraft.client.renderer.item.ItemProperties;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
*/
|
||||
public class FabricClientPlatform implements ClientPlatform {
|
||||
|
||||
@Override
|
||||
public void registerItemProperty(@NotNull BlockItemDyable item, @NotNull String property) {
|
||||
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) {
|
||||
ItemProperties.register(item, new ResourceLocation(property), new ColorPropertyFunction(item));
|
||||
}
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public void registerCustomRenderTypes(Collection<RegistryObject<Block>> blocks) {
|
||||
blocks.forEach(blk -> {
|
||||
if (blk.get() instanceof CustomRenderType type) {
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(blk.get(), type.getCustomRenderType());
|
||||
}
|
||||
});
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public Minecraft getClientInstance() {
|
||||
return Minecraft.getInstance();
|
||||
@@ -57,9 +30,4 @@ public class FabricClientPlatform implements ClientPlatform {
|
||||
public Connection getClientConnection() {
|
||||
return Minecraft.getInstance().getConnection().getConnection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockEntityRenderer(@NotNull BlockEntityType<? extends BlockEntity> blockEntityType, @NotNull BlockEntityRendererProvider blockEntityRendererFactory) {
|
||||
BlockEntityRenderers.register(blockEntityType, blockEntityRendererFactory);
|
||||
}
|
||||
}
|
||||
|
@@ -1,94 +0,0 @@
|
||||
package com.hypherionmc.craterlib.client.gui.widgets;
|
||||
|
||||
import com.hypherionmc.craterlib.systems.fluid.FluidTank;
|
||||
import com.hypherionmc.craterlib.util.RenderUtils;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.fabricmc.fabric.api.transfer.v1.client.fluid.FluidVariantRendering;
|
||||
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Modified from <a href="https://github.com/SleepyTrousers/EnderIO-Rewrite/blob/dev/1.18.x/enderio-machines/src/main/java/com/enderio/machines/client/FluidStackWidget.java">...</a>
|
||||
*/
|
||||
public class FluidStackWidget extends AbstractWidget {
|
||||
|
||||
private final Screen displayOn;
|
||||
private final Supplier<FluidTank> getFluid;
|
||||
|
||||
private final String toolTipTitle;
|
||||
|
||||
public FluidStackWidget(Screen displayOn, Supplier<FluidTank> getFluid, int pX, int pY, int pWidth, int pHeight, String tooltipTitle) {
|
||||
super(pX, pY, pWidth, pHeight, Component.empty());
|
||||
this.displayOn = displayOn;
|
||||
this.getFluid = getFluid;
|
||||
this.toolTipTitle = tooltipTitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderWidget(@NotNull GuiGraphics matrices, int mouseX, int mouseY, float delta) {
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.defaultBlendFunc();
|
||||
RenderSystem.enableDepthTest();
|
||||
FluidTank fluidTank = getFluid.get();
|
||||
if (!fluidTank.getResource().isBlank()) {
|
||||
FluidVariant fluidStack = fluidTank.getResource();
|
||||
TextureAtlasSprite still = FluidVariantRendering.getSprite(fluidStack);
|
||||
if (still != null) {
|
||||
RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_BLOCKS);
|
||||
|
||||
int color = FluidVariantRendering.getColor(fluidStack);
|
||||
RenderSystem.setShaderColor(
|
||||
RenderUtils.ARGB32.red(color) / 255.0F,
|
||||
RenderUtils.ARGB32.green(color) / 255.0F,
|
||||
RenderUtils.ARGB32.blue(color) / 255.0F,
|
||||
RenderUtils.ARGB32.alpha(color) / 255.0F);
|
||||
RenderSystem.enableBlend();
|
||||
|
||||
long stored = fluidTank.getAmount();
|
||||
float capacity = fluidTank.getCapacity();
|
||||
float filledVolume = stored / capacity;
|
||||
int renderableHeight = (int) (filledVolume * height);
|
||||
|
||||
int atlasWidth = (int) (still.getX() / (still.getU1() - still.getU0()));
|
||||
int atlasHeight = (int) (still.getY() / (still.getV1() - still.getV0()));
|
||||
|
||||
matrices.pose().pushPose();
|
||||
matrices.pose().translate(0, height - 16, 0);
|
||||
for (int i = 0; i < Math.ceil(renderableHeight / 16f); i++) {
|
||||
int drawingHeight = Math.min(16, renderableHeight - 16 * i);
|
||||
int notDrawingHeight = 16 - drawingHeight;
|
||||
// TODO Double Check this
|
||||
matrices.blit(TextureAtlas.LOCATION_BLOCKS, getX(), getY() + notDrawingHeight, 0, still.getU0() * atlasWidth, still.getV0() * atlasHeight + notDrawingHeight, this.width, drawingHeight, atlasWidth, atlasHeight);
|
||||
matrices.pose().translate(0, -16, 0);
|
||||
}
|
||||
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
matrices.pose().popPose();
|
||||
}
|
||||
//renderToolTip(matrices, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Fix Tooltips
|
||||
/*@Override
|
||||
public void renderToolTip(PoseStack poseStack, int mouseX, int mouseY) {
|
||||
if (this.visible && this.isFocused() && isHoveredOrFocused()) {
|
||||
displayOn.renderTooltip(poseStack, Arrays.asList(LangUtils.getTooltipTitle(toolTipTitle), Component.literal((int) (((float) this.getFluid.get().getAmount() / this.getFluid.get().getCapacity()) * 100) + "%")), Optional.empty(), mouseX, mouseY);
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
protected void updateWidgetNarration(NarrationElementOutput narrationElementOutput) {
|
||||
|
||||
}
|
||||
}
|
@@ -1,29 +1,9 @@
|
||||
package com.hypherionmc.craterlib.common;
|
||||
|
||||
import com.hypherionmc.craterlib.api.blockentity.caps.CraterCapabilityHandler;
|
||||
import com.hypherionmc.craterlib.api.blockentity.caps.ICraterCapProvider;
|
||||
import com.hypherionmc.craterlib.core.network.CraterNetworkHandler;
|
||||
import com.hypherionmc.craterlib.core.platform.CommonPlatform;
|
||||
import com.hypherionmc.craterlib.network.FabricNetworkHandler;
|
||||
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory;
|
||||
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerType;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import org.apache.commons.lang3.function.TriFunction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
@@ -41,40 +21,4 @@ public class FabricCommonPlatform implements CommonPlatform {
|
||||
public MinecraftServer getMCServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openMenu(ServerPlayer player, MenuProvider menu, Consumer<FriendlyByteBuf> initialData) {
|
||||
ExtendedScreenHandlerFactory factory = new ExtendedScreenHandlerFactory() {
|
||||
@Override
|
||||
public void writeScreenOpeningData(ServerPlayer player, FriendlyByteBuf buf) {
|
||||
initialData.accept(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Component getDisplayName() {
|
||||
return menu.getDisplayName();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public AbstractContainerMenu createMenu(int i, @NotNull Inventory inventory, @NotNull Player player) {
|
||||
return menu.createMenu(i, inventory, player);
|
||||
}
|
||||
};
|
||||
|
||||
player.openMenu(factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends AbstractContainerMenu> MenuType<T> createMenuType(TriFunction<Integer, Inventory, FriendlyByteBuf, T> constructor) {
|
||||
return new ExtendedScreenHandlerType<>(constructor::apply);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Optional<T> getCapabilityHandler(BlockEntity entity, Direction side, CraterCapabilityHandler capability) {
|
||||
if (entity instanceof ICraterCapProvider capProvider) {
|
||||
return capProvider.getCapability(capability, side);
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
@@ -1,70 +0,0 @@
|
||||
package com.hypherionmc.craterlib.common;
|
||||
|
||||
import com.hypherionmc.craterlib.core.platform.CraterFluidHelper;
|
||||
import com.hypherionmc.craterlib.core.systems.fluid.CraterFluidTank;
|
||||
import com.hypherionmc.craterlib.core.systems.fluid.FluidHolder;
|
||||
import com.hypherionmc.craterlib.core.systems.fluid.ICraterFluidHandler;
|
||||
import com.hypherionmc.craterlib.systems.fluid.FabricFluidUtils;
|
||||
import com.hypherionmc.craterlib.systems.fluid.FluidTank;
|
||||
import net.fabricmc.fabric.api.transfer.v1.client.fluid.FluidVariantRendering;
|
||||
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
|
||||
import net.fabricmc.fabric.impl.transfer.fluid.FluidVariantImpl;
|
||||
import net.fabricmc.fabric.mixin.transfer.BucketItemAccessor;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.BucketItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class FabricFluidHelper implements CraterFluidHelper {
|
||||
|
||||
@Override
|
||||
public CraterFluidTank createFluidTank(int capacity) {
|
||||
return new FluidTank(capacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraterFluidTank createFluidTank(int capacity, Fluid... validFluids) {
|
||||
return new FluidTank(capacity, (variant) -> Arrays.stream(validFluids).allMatch(f -> f.isSame(variant.getFluid())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean interactWithFluidHandler(Player player, InteractionHand hand, ICraterFluidHandler fluidHandler) {
|
||||
ItemStack stack = player.getItemInHand(hand);
|
||||
if (stack.getItem() instanceof BucketItem bucketItem) {
|
||||
FluidVariant fluidVariant = new FluidVariantImpl(((BucketItemAccessor) bucketItem).fabric_getFluid(), stack.getTag());
|
||||
if (fluidVariant.isBlank())
|
||||
return false;
|
||||
if (fluidHandler.insert(new FluidHolder(fluidVariant.getFluid(), 1000), ICraterFluidHandler.FluidAction.EXECUTE) > 0) {
|
||||
player.level().playSound(null, player.getOnPos(), SoundEvents.BUCKET_EMPTY, SoundSource.BLOCKS, 1.0f, 1.0f);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean interactWithFluidHandler(@NotNull Player player, @NotNull InteractionHand hand, @NotNull Level level, @NotNull BlockPos pos, @Nullable Direction side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getFluidTexture(FluidHolder fluidHolder) {
|
||||
return FabricFluidUtils.getFluidTexture(FluidVariant.of(fluidHolder.getFluid()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFluidColor(Fluid fluid) {
|
||||
return FluidVariantRendering.getColor(FluidVariant.of(fluid));
|
||||
}
|
||||
}
|
@@ -35,6 +35,10 @@ public class FabricNetworkHandler implements CraterNetworkHandler {
|
||||
this.modid = modid;
|
||||
}
|
||||
|
||||
public synchronized static CraterNetworkHandler of(String modId) {
|
||||
return NETWORK_HANDLERS.computeIfAbsent(modId, FabricNetworkHandler::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends CraterPacket<T>> void registerPacket(Class<T> clazz, Supplier<T> supplier, PacketDirection packetDirection) {
|
||||
ResourceLocation channelName = this.nextId();
|
||||
@@ -43,8 +47,10 @@ public class FabricNetworkHandler implements CraterNetworkHandler {
|
||||
final Function<FriendlyByteBuf, CraterPacket<?>> decoder = buf -> Util.make(supplier.get(), message -> message.read(buf));
|
||||
|
||||
switch (packetDirection) {
|
||||
case TO_CLIENT -> FabricNetworkHelper.getForDist(FabricLoader.getInstance().getEnvironmentType()).registerClientReceiver(channelName, decoder);
|
||||
case TO_SERVER -> FabricNetworkHelper.getForDist(FabricLoader.getInstance().getEnvironmentType()).registerServerReceiver(channelName, decoder);
|
||||
case TO_CLIENT ->
|
||||
FabricNetworkHelper.getForDist(FabricLoader.getInstance().getEnvironmentType()).registerClientReceiver(channelName, decoder);
|
||||
case TO_SERVER ->
|
||||
FabricNetworkHelper.getForDist(FabricLoader.getInstance().getEnvironmentType()).registerServerReceiver(channelName, decoder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,13 +60,15 @@ public class FabricNetworkHandler implements CraterNetworkHandler {
|
||||
|
||||
@Override
|
||||
public Packet<?> toServerBound(CraterPacket<?> packet) {
|
||||
if (this.packets.get(packet.getClass()).direction() != PacketDirection.TO_SERVER) throw new IllegalStateException("Attempted sending message to wrong side, expected %s, was %s".formatted(PacketDirection.TO_SERVER, PacketDirection.TO_CLIENT));
|
||||
if (this.packets.get(packet.getClass()).direction() != PacketDirection.TO_SERVER)
|
||||
throw new IllegalStateException("Attempted sending message to wrong side, expected %s, was %s".formatted(PacketDirection.TO_SERVER, PacketDirection.TO_CLIENT));
|
||||
return this.toPacket(ClientPlayNetworking::createC2SPacket, packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet<?> toClientBound(CraterPacket<?> packet) {
|
||||
if (this.packets.get(packet.getClass()).direction() != PacketDirection.TO_CLIENT) throw new IllegalStateException("Attempted sending message to wrong side, expected %s, was %s".formatted(PacketDirection.TO_CLIENT, PacketDirection.TO_SERVER));
|
||||
if (this.packets.get(packet.getClass()).direction() != PacketDirection.TO_CLIENT)
|
||||
throw new IllegalStateException("Attempted sending message to wrong side, expected %s, was %s".formatted(PacketDirection.TO_CLIENT, PacketDirection.TO_SERVER));
|
||||
return this.toPacket(ServerPlayNetworking::createS2CPacket, packet);
|
||||
}
|
||||
|
||||
@@ -71,11 +79,8 @@ public class FabricNetworkHandler implements CraterNetworkHandler {
|
||||
return packetFactory.apply(identifier, byteBuf);
|
||||
}
|
||||
|
||||
public synchronized static CraterNetworkHandler of(String modId) {
|
||||
return NETWORK_HANDLERS.computeIfAbsent(modId, FabricNetworkHandler::new);
|
||||
}
|
||||
|
||||
private record PacketData(Class<? extends CraterPacket<?>> clazz, ResourceLocation identifier, PacketDirection direction) {
|
||||
private record PacketData(Class<? extends CraterPacket<?>> clazz, ResourceLocation identifier,
|
||||
PacketDirection direction) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -12,10 +12,6 @@ import java.util.function.Function;
|
||||
|
||||
public interface FabricNetworkHelper {
|
||||
|
||||
/* FABRIC ONLY */
|
||||
void registerClientReceiver(@NotNull ResourceLocation channelName, @NotNull Function<FriendlyByteBuf, @NotNull CraterPacket<?>> factory);
|
||||
void registerServerReceiver(ResourceLocation channelName, Function<FriendlyByteBuf, CraterPacket<?>> factory);
|
||||
|
||||
public static FabricNetworkHelper getForDist(EnvType dist) {
|
||||
switch (dist) {
|
||||
case CLIENT -> {
|
||||
@@ -28,4 +24,9 @@ public interface FabricNetworkHelper {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* FABRIC ONLY */
|
||||
void registerClientReceiver(@NotNull ResourceLocation channelName, @NotNull Function<FriendlyByteBuf, @NotNull CraterPacket<?>> factory);
|
||||
|
||||
void registerServerReceiver(ResourceLocation channelName, Function<FriendlyByteBuf, CraterPacket<?>> factory);
|
||||
|
||||
}
|
||||
|
@@ -1,13 +0,0 @@
|
||||
package com.hypherionmc.craterlib.systems.fluid;
|
||||
|
||||
import net.fabricmc.fabric.api.transfer.v1.client.fluid.FluidVariantRendering;
|
||||
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
|
||||
public class FabricFluidUtils {
|
||||
|
||||
public static TextureAtlasSprite getFluidTexture(FluidVariant fluidStack) {
|
||||
return FluidVariantRendering.getSprite(fluidStack);
|
||||
}
|
||||
|
||||
}
|
@@ -1,66 +0,0 @@
|
||||
package com.hypherionmc.craterlib.systems.fluid;
|
||||
|
||||
import com.hypherionmc.craterlib.core.systems.fluid.CraterFluidTank;
|
||||
import com.hypherionmc.craterlib.core.systems.fluid.FluidHolder;
|
||||
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
|
||||
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
|
||||
import net.fabricmc.fabric.api.transfer.v1.storage.StoragePreconditions;
|
||||
import net.fabricmc.fabric.api.transfer.v1.storage.StorageView;
|
||||
import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class FluidTank extends CraterFluidTank implements Storage<FluidVariant>, StorageView<FluidVariant> {
|
||||
|
||||
public FluidTank(long capacity) {
|
||||
this(capacity, e -> true);
|
||||
}
|
||||
|
||||
public FluidTank(long capacity, Predicate<FluidVariant> validFluid) {
|
||||
super((int) capacity, (p) -> validFluid.test(FluidVariant.of(p.getFluid())));
|
||||
}
|
||||
|
||||
public boolean isFluidValid(FluidVariant variant) {
|
||||
return isValidFluid(new FluidHolder(variant.getFluid(), 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long insert(FluidVariant resource, long maxAmount, TransactionContext transaction) {
|
||||
StoragePreconditions.notBlankNotNegative(resource, maxAmount);
|
||||
return insert(new FluidHolder(resource.getFluid(), (int) maxAmount), FluidAction.EXECUTE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long extract(FluidVariant resource, long maxAmount, TransactionContext transaction) {
|
||||
StoragePreconditions.notBlankNotNegative(resource, maxAmount);
|
||||
FluidHolder extracted = extract(new FluidHolder(resource.getFluid(), (int) maxAmount), FluidAction.EXECUTE);
|
||||
return extracted.getAmount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<StorageView<FluidVariant>> iterator() {
|
||||
// TODO: FIX THIS!
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResourceBlank() {
|
||||
return isTankEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidVariant getResource() {
|
||||
return FluidVariant.of(getFluidInTank().getFluid());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAmount() {
|
||||
return getTankLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCapacity() {
|
||||
return getTankCapacity();
|
||||
}
|
||||
}
|
@@ -1 +0,0 @@
|
||||
com.hypherionmc.craterlib.common.FabricFluidHelper
|
@@ -30,7 +30,6 @@
|
||||
"${mod_id}.mixins.json",
|
||||
"${mod_id}.fabric.mixins.json"
|
||||
],
|
||||
"accessWidener": "${mod_id}.aw",
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.21",
|
||||
"fabric-api": "*",
|
||||
|
Reference in New Issue
Block a user