Created
February 6, 2023 20:20
-
-
Save falseresync/9c5f98c04bf36d6a2224b7e185f65281 to your computer and use it in GitHub Desktop.
a damn null
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final SimpleSingleVariantStorage<FluidVariant> fluidStorage = SimpleSingleVariantStorageBuilder.fluid() | |
.supportsExtraction(false) | |
.build(fluidVariant -> FluidConstants.BUCKET, () -> markDirty()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract sealed class SimpleSingleVariantStorageBuilder<T extends TransferVariant<?>> | |
permits SimpleSingleVariantStorageBuilder.ItemBuilder, SimpleSingleVariantStorageBuilder.FluidBuilder { | |
protected boolean supportsExtraction = true; | |
protected boolean supportsInsertion = true; | |
public static SimpleSingleVariantStorageBuilder<ItemVariant> item() { | |
return new ItemBuilder(); | |
} | |
public static SimpleSingleVariantStorageBuilder<FluidVariant> fluid() { | |
return new FluidBuilder(); | |
} | |
public SimpleSingleVariantStorageBuilder<T> supportsExtraction(boolean supportsExtraction) { | |
this.supportsExtraction = supportsExtraction; | |
return this; | |
} | |
public SimpleSingleVariantStorageBuilder<T> supportsInsertion(boolean supportsInsertion) { | |
this.supportsInsertion = supportsInsertion; | |
return this; | |
} | |
public SimpleSingleVariantStorageBuilder<T> readOnly() { | |
this.supportsExtraction = false; | |
this.supportsInsertion = false; | |
return this; | |
} | |
public abstract SimpleSingleVariantStorage<T> build(Function<T, Long> capacityForVariant, Runnable onChange); | |
protected static final class ItemBuilder extends SimpleSingleVariantStorageBuilder<ItemVariant> { | |
@Override | |
public SimpleSingleVariantStorage<ItemVariant> build(Function<ItemVariant, Long> capacityForVariant, Runnable onChange) { | |
return new SimpleSingleVariantStorage<>(ItemVariant::blank, supportsExtraction, supportsInsertion, capacityForVariant, onChange) { | |
@Override | |
public void readNbt(NbtCompound nbt) { | |
variant = ItemVariant.fromNbt(nbt.getCompound("variant")); | |
amount = nbt.getLong("amount"); | |
} | |
}; | |
} | |
} | |
protected static final class FluidBuilder extends SimpleSingleVariantStorageBuilder<FluidVariant> { | |
@Override | |
public SimpleSingleVariantStorage<FluidVariant> build(Function<FluidVariant, Long> capacityForVariant, Runnable onChange) { | |
return new SimpleSingleVariantStorage<>(FluidVariant::blank, supportsExtraction, supportsInsertion, capacityForVariant, onChange) { | |
@Override | |
public void readNbt(NbtCompound nbt) { | |
variant = FluidVariant.fromNbt(nbt.getCompound("variant")); | |
amount = nbt.getLong("amount"); | |
} | |
}; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment