Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/content/Modpacks/Changes/v8.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,5 @@ A large number of machine feature interfaces have been removed, and have had the

- `BlastingRecipeBuilder`, `CampfireRecipeBuilder`, `SmeltingRecipeBuilder` and `SmokingRecipeBuilder` have been merged into `SimpleCookingRecipeBuilder`
- Example usage: `SimpleCookingRecipeBuilder.campfireCooking("cooking_chicken").input(new ItemStack(Items.CHICKEN)).output(new ItemStacks(Items.COOKED_CHICKEN)).cookingTime(100).experience(100).save(provider);`
- Item behaviors have been moved to `common/item/behavior`, and some items have been moved from `api/item` to `common/item`
- `GTFluidImpl` has been merged into `GTFluid`, use `GTFluid.Flowing` and `GTFluid.Source` instead of `GTFluidImpl.Flowing` and `GTFluidImpl.Source`.
- Item behaviors have been moved to `common/item/behavior`, and some items have been moved from `api/item` to `common/item`
61 changes: 57 additions & 4 deletions src/main/java/com/gregtechceu/gtceu/api/fluids/GTFluid.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
import net.minecraft.world.level.block.LiquidBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.material.FlowingFluid;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.Fluids;
import net.minecraftforge.common.extensions.IForgeFluid;
import net.minecraftforge.fluids.FluidType;

import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet;
import lombok.Getter;
Expand All @@ -32,7 +35,7 @@

@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
public abstract class GTFluid extends FlowingFluid implements IAttributedFluid {
public abstract class GTFluid extends FlowingFluid implements IAttributedFluid, IForgeFluid {

@Getter
private final Collection<FluidAttribute> attributes = new ObjectLinkedOpenHashSet<>();
Expand All @@ -44,21 +47,23 @@ public abstract class GTFluid extends FlowingFluid implements IAttributedFluid {
private final Supplier<? extends LiquidBlock> block;
@Getter
private final int burnTime;
private final Supplier<FluidType> fluidType;

public GTFluid(@NotNull FluidState state, Supplier<? extends Fluid> stillFluid,
public GTFluid(FluidState state, Supplier<? extends Fluid> stillFluid,
Supplier<? extends Fluid> flowingFluid, Supplier<? extends LiquidBlock> block,
Supplier<? extends Item> bucket, int burnTime) {
Supplier<? extends Item> bucket, int burnTime, Supplier<FluidType> fluidType) {
super();
this.state = state;
this.stillFluid = stillFluid;
this.flowingFluid = flowingFluid;
this.block = block;
this.bucketItem = bucket;
this.burnTime = burnTime;
this.fluidType = fluidType;
}

@Override
public void addAttribute(@NotNull FluidAttribute attribute) {
public void addAttribute(FluidAttribute attribute) {
attributes.add(attribute);
}

Expand Down Expand Up @@ -127,4 +132,52 @@ public boolean isSame(Fluid fluid) {
boolean flowing = this.getFlowing() == fluid;
return still || flowing;
}

public FluidType getFluidType() {
return fluidType.get();
}

public static class Source extends GTFluid {

public Source(FluidState state, Supplier<? extends Fluid> stillFluid,
Supplier<? extends Fluid> flowingFluid, Supplier<? extends LiquidBlock> block,
Supplier<? extends Item> bucket, int burnTime, Supplier<FluidType> fluidType) {
super(state, stillFluid, flowingFluid, block, bucket, burnTime, fluidType);
}

@Override
public int getAmount(net.minecraft.world.level.material.FluidState state) {
return 8;
}

@Override
public boolean isSource(net.minecraft.world.level.material.FluidState state) {
return true;
}
}

public static class Flowing extends GTFluid {

public Flowing(FluidState state, Supplier<? extends Fluid> stillFluid,
Supplier<? extends Fluid> flowingFluid, Supplier<? extends LiquidBlock> block,
Supplier<? extends Item> bucket, int burnTime, Supplier<FluidType> fluidType) {
super(state, stillFluid, flowingFluid, block, bucket, burnTime, fluidType);
// registerDefaultState(getStateDefinition().any().setValue(LEVEL, 7));
}

protected void createFluidStateDefinition(StateDefinition.@NotNull Builder<Fluid, net.minecraft.world.level.material.FluidState> builder) {
super.createFluidStateDefinition(builder);
builder.add(LEVEL);
}

@Override
public int getAmount(net.minecraft.world.level.material.FluidState state) {
return state.getValue(LEVEL);
}

@Override
public boolean isSource(net.minecraft.world.level.material.FluidState state) {
return false;
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.gregtechceu.gtceu.api.data.chemical.material.Material;
import com.gregtechceu.gtceu.api.fluids.FluidState;
import com.gregtechceu.gtceu.api.fluids.GTFluid;
import com.gregtechceu.gtceu.api.fluids.forge.GTFluidImpl;
import com.gregtechceu.gtceu.api.registry.registrate.IGTFluidBuilder;
import com.gregtechceu.gtceu.common.item.GTBucketItem;
import com.gregtechceu.gtceu.utils.GTUtil;
Expand Down Expand Up @@ -60,7 +59,7 @@
@Accessors(chain = true, fluent = true)
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
public class GTFluidBuilder<P> extends AbstractBuilder<Fluid, GTFluidImpl.Flowing, P, GTFluidBuilder<P>>
public class GTFluidBuilder<P> extends AbstractBuilder<Fluid, GTFluid.Flowing, P, GTFluidBuilder<P>>
implements IGTFluidBuilder {

@Setter
Expand Down Expand Up @@ -150,7 +149,7 @@ public GTFluidBuilder<P> renderType(Supplier<RenderType> layer) {
}

@SuppressWarnings("deprecation")
protected void registerRenderType(GTFluidImpl.Flowing entry) {
protected void registerRenderType(GTFluid.Flowing entry) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> {
OneTimeEventReceiver.addModListener(getOwner(), FMLClientSetupEvent.class, $ -> {
if (this.layer != null) {
Expand Down Expand Up @@ -188,11 +187,11 @@ public BlockBuilder<LiquidBlock, GTFluidBuilder<P>> block() {
return block(LiquidBlock::new);
}

public <B extends LiquidBlock> BlockBuilder<B, GTFluidBuilder<P>> block(NonNullBiFunction<NonNullSupplier<GTFluidImpl.Flowing>, BlockBehaviour.Properties, ? extends B> factory) {
public <B extends LiquidBlock> BlockBuilder<B, GTFluidBuilder<P>> block(NonNullBiFunction<NonNullSupplier<GTFluid.Flowing>, BlockBehaviour.Properties, ? extends B> factory) {
if (this.defaultBlock == Boolean.FALSE) {
throw new IllegalStateException("Only one call to block/noBlock per builder allowed");
}
NonNullSupplier<GTFluidImpl.Flowing> supplier = asSupplier();
NonNullSupplier<GTFluid.Flowing> supplier = asSupplier();

return getOwner().<B, GTFluidBuilder<P>>block(this, sourceName, p -> factory.apply(supplier, p))
.properties(p -> BlockBehaviour.Properties.copy(Blocks.WATER).noLootTable())
Expand Down Expand Up @@ -284,8 +283,8 @@ private FluidType.Properties makeTypeProperties() {
}

@Override
protected GTFluidImpl.Flowing createEntry() {
return new GTFluidImpl.Flowing(this.state, () -> this.source.get(), () -> this.get().get(),
protected GTFluid.Flowing createEntry() {
return new GTFluid.Flowing(this.state, () -> this.source.get(), () -> this.get().get(),
(() -> this.block != null ? this.block.get() : null),
(() -> this.bucket != null ? this.bucket.get() : null), this.burnTime, this.fluidType);
}
Expand Down Expand Up @@ -319,7 +318,7 @@ public IGTFluidBuilder onFluidRegister(Consumer<Fluid> fluidConsumer) {

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public RegistryEntry<GTFluidImpl.Flowing> register() {
public RegistryEntry<GTFluid.Flowing> register() {
// Check the fluid has a type.
if (this.fluidType != null) {
// Register the type.
Expand All @@ -331,7 +330,7 @@ public RegistryEntry<GTFluidImpl.Flowing> register() {
}

if (defaultSource == Boolean.TRUE) {
source(() -> new GTFluidImpl.Source(this.state, () -> this.source.get(), () -> this.get().get(),
source(() -> new GTFluid.Source(this.state, () -> this.source.get(), () -> this.get().get(),
(() -> this.block != null ? this.block.get() : null),
(() -> this.bucket != null ? this.bucket.get() : null), this.burnTime, this.fluidType));
}
Expand Down