Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v2.0.0-milestone.4.5 #634

Merged
merged 47 commits into from
Jul 26, 2024
Merged
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
450fe6c
Merge pull request #611 from refinedmods/main
raoulvdberge Jul 10, 2024
d607e38
feat: ability to extract resources other than item from the interface
raoulvdberge Jul 13, 2024
16bf161
ci: re-add sonar exclusions
raoulvdberge Jul 13, 2024
f461e49
Merge pull request #619 from refinedmods/feat/GH-616/iface-bucket-ext…
raoulvdberge Jul 13, 2024
22e08a9
fix: crash when trying to export fluids on Fabric
raoulvdberge Jul 13, 2024
285cfe5
Merge pull request #622 from refinedmods/fix/GH-621/exporter-crash
raoulvdberge Jul 13, 2024
3e02db0
style: cleanup
raoulvdberge Jul 13, 2024
13c41ea
Merge pull request #623 from refinedmods/fix/NO-ISSUE/cleanup
raoulvdberge Jul 14, 2024
611fb7a
refactor: cleanup duplication around storage types
raoulvdberge Jul 17, 2024
8d793d1
ci: store refined architect version for gradle in gradle.properties
raoulvdberge Jul 17, 2024
30e9191
Merge pull request #626 from refinedmods/refactor/NO-ISSUE/storage-types
raoulvdberge Jul 17, 2024
d961e5f
feat: stack upgrade gametest setup
starforcraft Jul 12, 2024
5842cfc
Merge pull request #615 from starforcraft/feat/GH-248/stacktests
raoulvdberge Jul 18, 2024
55f0ed7
feat: support for neoforge config screen
raoulvdberge Jul 20, 2024
d6756d0
fix: use neoforge safe saveddata saving
raoulvdberge Jul 20, 2024
8da072f
fix: crash in logs when trying to quick craft empty result slot
raoulvdberge Jul 20, 2024
ee0c73a
fix: remove comments using tooltip translations
raoulvdberge Jul 20, 2024
c58ec21
Merge pull request #628 from refinedmods/feat/NO-ISSUE/config-screen
raoulvdberge Jul 20, 2024
406f5a4
chore: update translation French from crowdin
raoulvdberge Jul 20, 2024
1ebca57
chore: update translation Spanish from crowdin
raoulvdberge Jul 20, 2024
030cbbd
chore: update translation German from crowdin
raoulvdberge Jul 20, 2024
7294971
chore: update translation Hungarian from crowdin
raoulvdberge Jul 20, 2024
162f365
chore: update translation Italian from crowdin
raoulvdberge Jul 20, 2024
86befeb
chore: update translation Japanese from crowdin
raoulvdberge Jul 20, 2024
4e80571
chore: update translation Korean from crowdin
raoulvdberge Jul 20, 2024
2cce584
chore: update translation Polish from crowdin
raoulvdberge Jul 20, 2024
5784ed8
chore: update translation Russian from crowdin
raoulvdberge Jul 20, 2024
adcc8dd
chore: update translation Chinese Simplified from crowdin
raoulvdberge Jul 20, 2024
fef643f
chore: update translation Chinese Traditional from crowdin
raoulvdberge Jul 20, 2024
6cb51c1
chore: update translation Portuguese, Brazilian from crowdin
raoulvdberge Jul 20, 2024
8374b72
chore: update translation Indonesian from crowdin
raoulvdberge Jul 20, 2024
a94bf00
chore: update translation Turkish from crowdin
raoulvdberge Jul 20, 2024
43e0aef
Merge pull request #629 from refinedmods/crowdin-translations
raoulvdberge Jul 20, 2024
328e1bf
refactor: remove platform prefix from modules, rename platform-api to…
raoulvdberge Jul 21, 2024
0e80e96
chore: update git-blame-ignore-revs
raoulvdberge Jul 22, 2024
3d7183b
Merge pull request #630 from refinedmods/refactor/NO-ISSUE/pkgrename
raoulvdberge Jul 22, 2024
82a6ace
refactor: minor renames for constructor / destructor strategies
raoulvdberge Jul 22, 2024
b5492b0
refactor: move amount override to support package
raoulvdberge Jul 22, 2024
14908e8
refactor: rename storage channel to root storage
raoulvdberge Jul 22, 2024
f286971
refactor: minor renames for network bound item
raoulvdberge Jul 23, 2024
77e867c
refactor: rename wireless transmitter api and make it part of network…
raoulvdberge Jul 23, 2024
1550061
feat: add neoforge block capability for network nodes
raoulvdberge Jul 23, 2024
89db325
feat: add fabric block capability for network nodes
raoulvdberge Jul 24, 2024
0f02a97
Merge pull request #632 from refinedmods/refactor/NO-ISSUE/platform-caps
raoulvdberge Jul 25, 2024
5f59e3d
fix: silicon tag missing and recipes not using silicon tag
raoulvdberge Jul 25, 2024
7d5db78
Merge pull request #633 from refinedmods/fix/GH-631/silicon
raoulvdberge Jul 25, 2024
d356f29
chore: prepare release v2.0.0-milestone.4.5
raoulvdberge Jul 26, 2024
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
Prev Previous commit
Next Next commit
feat: ability to extract resources other than item from the interface
  • Loading branch information
raoulvdberge committed Jul 13, 2024
commit d607e386855e0d52a2344b88985f001bfb497f2b
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Ability to extract fluids from the Interface using an empty bucket or other empty fluid container.

## [2.0.0-milestone.4.4] - 2024-07-10

## [2.0.0-milestone.4.3] - 2024-07-06
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@
import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.NetworkBoundItemHelper;
import com.refinedmods.refinedstorage.platform.api.support.registry.PlatformRegistry;
import com.refinedmods.refinedstorage.platform.api.support.resource.RecipeModIngredientConverter;
import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceContainerInsertStrategy;
import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceFactory;
import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceRendering;
import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceType;
@@ -132,6 +133,10 @@ GridInsertionStrategy createGridInsertionStrategy(AbstractContainerMenu containe

void addGridInsertionStrategyFactory(GridInsertionStrategyFactory insertionStrategyFactory);

void addResourceContainerInsertStrategy(ResourceContainerInsertStrategy strategy);

Collection<ResourceContainerInsertStrategy> getResourceContainerInsertStrategies();

void addAlternativeGridInsertionHint(GridInsertionHint hint);

GridInsertionHints getGridInsertionHints();
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@
import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.NetworkBoundItemHelper;
import com.refinedmods.refinedstorage.platform.api.support.registry.PlatformRegistry;
import com.refinedmods.refinedstorage.platform.api.support.resource.RecipeModIngredientConverter;
import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceContainerInsertStrategy;
import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceFactory;
import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceRendering;
import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceType;
@@ -230,6 +231,16 @@ public void addGridInsertionStrategyFactory(final GridInsertionStrategyFactory i
ensureLoaded().addGridInsertionStrategyFactory(insertionStrategyFactory);
}

@Override
public void addResourceContainerInsertStrategy(final ResourceContainerInsertStrategy strategy) {
ensureLoaded().addResourceContainerInsertStrategy(strategy);
}

@Override
public Collection<ResourceContainerInsertStrategy> getResourceContainerInsertStrategies() {
return ensureLoaded().getResourceContainerInsertStrategies();
}

@Override
public void addAlternativeGridInsertionHint(final GridInsertionHint hint) {
ensureLoaded().addAlternativeGridInsertionHint(hint);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.refinedmods.refinedstorage.platform.api.support.resource;

import net.minecraft.world.item.ItemStack;
import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.4.5")
public record FluidOperationResult(ItemStack container, PlatformResourceKey fluid, long amount) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.refinedmods.refinedstorage.platform.api.support.resource;

import com.refinedmods.refinedstorage.api.resource.ResourceAmount;
import com.refinedmods.refinedstorage.api.resource.ResourceKey;

import java.util.Optional;

import net.minecraft.world.item.ItemStack;
import org.apiguardian.api.API;

/**
* Defines how a resource can be extracted from a resource slot into a container.
* For fluids, this maps to how a fluid is inserted into a fluid container like a bucket.
*/
@API(status = API.Status.STABLE, since = "2.0.0-milestone.4.5")
public interface ResourceContainerInsertStrategy {
/**
* @param container the container to insert the resource into
* @param resourceAmount the resource to insert into the container
* @return the result of the insertion, if any. If no result is present, the next insertion strategy will be tried.
*/
Optional<InsertResult> insert(ItemStack container, ResourceAmount resourceAmount);

Optional<ConversionInfo> getConversionInfo(ResourceKey resource);

record InsertResult(ItemStack container, long inserted) {
}

record ConversionInfo(ItemStack from, ItemStack to) {
}
}
Original file line number Diff line number Diff line change
@@ -120,6 +120,7 @@
import com.refinedmods.refinedstorage.platform.common.support.energy.EnergyLootItemFunction;
import com.refinedmods.refinedstorage.platform.common.support.network.BaseNetworkNodeContainerBlockEntity;
import com.refinedmods.refinedstorage.platform.common.support.network.component.PlatformStorageNetworkComponent;
import com.refinedmods.refinedstorage.platform.common.support.resource.FluidResourceContainerInsertStrategy;
import com.refinedmods.refinedstorage.platform.common.support.resource.FluidResourceFactory;
import com.refinedmods.refinedstorage.platform.common.support.resource.ResourceContainerData;
import com.refinedmods.refinedstorage.platform.common.support.resource.ResourceTypes;
@@ -218,6 +219,7 @@ protected final void initializePlatformApi() {
registerStorageTypes();
registerResourceTypes();
registerAdditionalResourceFactories();
registerResourceContainerInsertStrategies();
registerDestructorStrategyFactories();
registerConstructorStrategyFactories();
registerStorageMonitorInsertionStrategies();
@@ -254,6 +256,10 @@ private void registerAdditionalResourceFactories() {
PlatformApi.INSTANCE.addResourceFactory(new FluidResourceFactory());
}

private void registerResourceContainerInsertStrategies() {
PlatformApi.INSTANCE.addResourceContainerInsertStrategy(new FluidResourceContainerInsertStrategy());
}

private void registerDestructorStrategyFactories() {
PlatformApi.INSTANCE.addDestructorStrategyFactory(new BlockBreakDestructorStrategyFactory());
PlatformApi.INSTANCE.addDestructorStrategyFactory(new FluidBreakDestructorStrategyFactory());
Original file line number Diff line number Diff line change
@@ -3,7 +3,9 @@
import com.refinedmods.refinedstorage.api.core.Action;
import com.refinedmods.refinedstorage.api.grid.view.GridResourceFactory;
import com.refinedmods.refinedstorage.api.network.energy.EnergyStorage;
import com.refinedmods.refinedstorage.api.resource.ResourceAmount;
import com.refinedmods.refinedstorage.platform.api.grid.strategy.GridInsertionStrategyFactory;
import com.refinedmods.refinedstorage.platform.api.support.resource.FluidOperationResult;
import com.refinedmods.refinedstorage.platform.common.support.containermenu.MenuOpener;
import com.refinedmods.refinedstorage.platform.common.support.containermenu.TransferManager;
import com.refinedmods.refinedstorage.platform.common.support.render.FluidRenderer;
@@ -63,9 +65,11 @@ public interface Platform {

FluidRenderer getFluidRenderer();

Optional<ContainedFluid> getContainedFluid(ItemStack stack);
Optional<FluidOperationResult> drainContainer(ItemStack container);

Optional<ItemStack> convertToBucket(FluidResource fluidResource);
Optional<FluidOperationResult> fillContainer(ItemStack container, ResourceAmount resourceAmount);

Optional<ItemStack> getFilledBucket(FluidResource fluidResource);

TransferManager createTransferManager(AbstractContainerMenu containerMenu);

@@ -111,7 +115,4 @@ List<ClientTooltipComponent> processTooltipComponents(
<T extends CustomPacketPayload> void sendPacketToServer(T packet);

<T extends CustomPacketPayload> void sendPacketToClient(ServerPlayer player, T packet);

record ContainedFluid(ItemStack remainderContainer, FluidResource fluid, long amount) {
}
}
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@
import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.NetworkBoundItemHelper;
import com.refinedmods.refinedstorage.platform.api.support.registry.PlatformRegistry;
import com.refinedmods.refinedstorage.platform.api.support.resource.RecipeModIngredientConverter;
import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceContainerInsertStrategy;
import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceFactory;
import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceRendering;
import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceType;
@@ -85,6 +86,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
@@ -169,6 +171,7 @@ public class PlatformApiImpl implements PlatformApi {
private final PlatformRegistry<SlotReferenceFactory> slotReferenceFactoryRegistry = new PlatformRegistryImpl<>();
private final CompositeSlotReferenceProvider slotReferenceProvider = new CompositeSlotReferenceProvider();
private final PlatformRegistry<PlatformPermission> permissionRegistry = new PlatformRegistryImpl<>();
private final List<ResourceContainerInsertStrategy> resourceExtractStrategies = new ArrayList<>();

public PlatformApiImpl() {
gridSynchronizerRegistry.register(createIdentifier("off"), NoopGridSynchronizer.INSTANCE);
@@ -372,6 +375,16 @@ public void addGridInsertionStrategyFactory(final GridInsertionStrategyFactory i
gridInsertionStrategyFactories.add(insertionStrategyFactory);
}

@Override
public void addResourceContainerInsertStrategy(final ResourceContainerInsertStrategy strategy) {
resourceExtractStrategies.add(strategy);
}

@Override
public Collection<ResourceContainerInsertStrategy> getResourceContainerInsertStrategies() {
return Collections.unmodifiableList(resourceExtractStrategies);
}

@Override
public void addAlternativeGridInsertionHint(final GridInsertionHint hint) {
gridInsertionHints.addAlternativeHint(hint);
Original file line number Diff line number Diff line change
@@ -3,7 +3,9 @@
import com.refinedmods.refinedstorage.api.core.Action;
import com.refinedmods.refinedstorage.api.grid.view.GridResourceFactory;
import com.refinedmods.refinedstorage.api.network.energy.EnergyStorage;
import com.refinedmods.refinedstorage.api.resource.ResourceAmount;
import com.refinedmods.refinedstorage.platform.api.grid.strategy.GridInsertionStrategyFactory;
import com.refinedmods.refinedstorage.platform.api.support.resource.FluidOperationResult;
import com.refinedmods.refinedstorage.platform.common.support.containermenu.MenuOpener;
import com.refinedmods.refinedstorage.platform.common.support.containermenu.TransferManager;
import com.refinedmods.refinedstorage.platform.common.support.render.FluidRenderer;
@@ -100,13 +102,19 @@ public FluidRenderer getFluidRenderer() {
}

@Override
public Optional<ContainedFluid> getContainedFluid(final ItemStack stack) {
return ensureLoaded().getContainedFluid(stack);
public Optional<FluidOperationResult> drainContainer(final ItemStack container) {
return ensureLoaded().drainContainer(container);
}

@Override
public Optional<ItemStack> convertToBucket(final FluidResource fluidResource) {
return ensureLoaded().convertToBucket(fluidResource);
public Optional<FluidOperationResult> fillContainer(final ItemStack container,
final ResourceAmount resourceAmount) {
return ensureLoaded().fillContainer(container, resourceAmount);
}

@Override
public Optional<ItemStack> getFilledBucket(final FluidResource fluidResource) {
return ensureLoaded().getFilledBucket(fluidResource);
}

@Override
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.refinedmods.refinedstorage.platform.common.grid.screen.hint;

import com.refinedmods.refinedstorage.platform.api.grid.GridInsertionHint;
import com.refinedmods.refinedstorage.platform.api.support.resource.FluidOperationResult;
import com.refinedmods.refinedstorage.platform.common.Platform;
import com.refinedmods.refinedstorage.platform.common.support.resource.FluidResource;
import com.refinedmods.refinedstorage.platform.common.support.resource.FluidResourceRendering;
import com.refinedmods.refinedstorage.platform.common.support.tooltip.MouseWithIconClientTooltipComponent;
import com.refinedmods.refinedstorage.platform.common.support.tooltip.MouseClientTooltipComponent;

import java.util.Optional;

@@ -13,18 +15,13 @@
public class FluidGridInsertionHint implements GridInsertionHint {
@Override
public Optional<ClientTooltipComponent> getHint(final ItemStack carried) {
return Platform.INSTANCE.getContainedFluid(carried).map(this::createComponent);
return Platform.INSTANCE.drainContainer(carried).map(this::createComponent);
}

private MouseWithIconClientTooltipComponent createComponent(final Platform.ContainedFluid result) {
return new MouseWithIconClientTooltipComponent(
MouseWithIconClientTooltipComponent.Type.RIGHT,
(graphics, x, y) -> Platform.INSTANCE.getFluidRenderer().render(
graphics.pose(),
x,
y,
result.fluid()
),
private ClientTooltipComponent createComponent(final FluidOperationResult result) {
return MouseClientTooltipComponent.fluid(
MouseClientTooltipComponent.Type.RIGHT,
(FluidResource) result.fluid(),
result.amount() == Platform.INSTANCE.getBucketAmount()
? null
: FluidResourceRendering.format(result.amount())
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

import com.refinedmods.refinedstorage.platform.api.grid.GridInsertionHint;
import com.refinedmods.refinedstorage.platform.api.support.AmountFormatting;
import com.refinedmods.refinedstorage.platform.common.support.tooltip.MouseWithIconClientTooltipComponent;
import com.refinedmods.refinedstorage.platform.common.support.tooltip.MouseClientTooltipComponent;

import java.util.Optional;

@@ -12,9 +12,9 @@
public class ItemGridInsertionHint implements GridInsertionHint {
@Override
public Optional<ClientTooltipComponent> getHint(final ItemStack carried) {
return Optional.of(new MouseWithIconClientTooltipComponent(
MouseWithIconClientTooltipComponent.Type.LEFT,
(graphics, x, y) -> graphics.renderItem(carried, x, y),
return Optional.of(MouseClientTooltipComponent.item(
MouseClientTooltipComponent.Type.LEFT,
carried,
carried.getCount() == 1 ? null : AmountFormatting.format(carried.getCount())
));
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.refinedmods.refinedstorage.platform.common.grid.screen.hint;

import com.refinedmods.refinedstorage.platform.api.grid.GridInsertionHint;
import com.refinedmods.refinedstorage.platform.common.support.tooltip.MouseWithIconClientTooltipComponent;
import com.refinedmods.refinedstorage.platform.common.support.tooltip.MouseClientTooltipComponent;

import java.util.Optional;

@@ -11,9 +11,9 @@
public class SingleItemGridInsertionHint implements GridInsertionHint {
@Override
public Optional<ClientTooltipComponent> getHint(final ItemStack carried) {
return Optional.of(new MouseWithIconClientTooltipComponent(
MouseWithIconClientTooltipComponent.Type.RIGHT,
(graphics, x, y) -> graphics.renderItem(carried, x, y),
return Optional.of(MouseClientTooltipComponent.item(
MouseClientTooltipComponent.Type.RIGHT,
carried,
null
));
}
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
import com.refinedmods.refinedstorage.platform.common.Platform;
import com.refinedmods.refinedstorage.platform.common.support.resource.FluidResource;
import com.refinedmods.refinedstorage.platform.common.support.resource.FluidResourceRendering;
import com.refinedmods.refinedstorage.platform.common.support.tooltip.MouseWithIconClientTooltipComponent;
import com.refinedmods.refinedstorage.platform.common.support.tooltip.MouseClientTooltipComponent;

import java.util.List;
import java.util.Map;
@@ -52,13 +52,11 @@ public int getRegistryId() {

@Override
public List<ClientTooltipComponent> getExtractionHints() {
return Platform.INSTANCE.convertToBucket(fluidResource).map(
bucket -> (ClientTooltipComponent) new MouseWithIconClientTooltipComponent(
MouseWithIconClientTooltipComponent.Type.LEFT,
(graphics, x, y) -> graphics.renderItem(bucket, x, y),
null
)
).stream().toList();
return Platform.INSTANCE.getFilledBucket(fluidResource).map(bucket -> MouseClientTooltipComponent.item(
MouseClientTooltipComponent.Type.LEFT,
bucket,
null
)).stream().toList();
}

@Nullable
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
import com.refinedmods.refinedstorage.platform.api.support.AmountFormatting;
import com.refinedmods.refinedstorage.platform.api.support.resource.PlatformResourceKey;
import com.refinedmods.refinedstorage.platform.common.support.resource.ItemResource;
import com.refinedmods.refinedstorage.platform.common.support.tooltip.MouseWithIconClientTooltipComponent;
import com.refinedmods.refinedstorage.platform.common.support.tooltip.MouseClientTooltipComponent;

import java.util.List;
import java.util.Map;
@@ -71,14 +71,14 @@ public List<ClientTooltipComponent> getExtractionHints() {
final long extractableAmount = Math.min(getAmount(), itemStack.getMaxStackSize());
final long halfExtractionAmount = extractableAmount == 1 ? 1 : extractableAmount / 2;
return List.of(
new MouseWithIconClientTooltipComponent(
MouseWithIconClientTooltipComponent.Type.LEFT,
this::render,
MouseClientTooltipComponent.itemWithDecorations(
MouseClientTooltipComponent.Type.LEFT,
itemStack,
extractableAmount == 1 ? null : AmountFormatting.format(extractableAmount)
),
new MouseWithIconClientTooltipComponent(
MouseWithIconClientTooltipComponent.Type.RIGHT,
this::render,
MouseClientTooltipComponent.itemWithDecorations(
MouseClientTooltipComponent.Type.RIGHT,
itemStack,
halfExtractionAmount == 1 ? null : AmountFormatting.format(halfExtractionAmount)
)
);
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ public long insert(final ResourceKey resource, final long amount, final Action a
if (amount != Platform.INSTANCE.getBucketAmount()) {
return 0;
}
return Platform.INSTANCE.convertToBucket(fluidResource).map(
return Platform.INSTANCE.getFilledBucket(fluidResource).map(
filledBucketStack -> insert(filledBucketStack, amount, action, actor)
).orElse(0L);
}
Loading