Skip to content

Commit

Permalink
Merge pull request #657 from refinedmods/fix/GH-645/save-grid
Browse files Browse the repository at this point in the history
Save grid settings properly
  • Loading branch information
raoulvdberge authored Aug 10, 2024
2 parents 44182f2 + 8e3b1f2 commit a54f1f4
Show file tree
Hide file tree
Showing 117 changed files with 795 additions and 966 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### Changed

- Updated to Minecraft 1.21.1.
- The Network Transmitter and Wireless Transmitter GUI now has an inactive and active GUI animation.
- The Wireless Transmitter now shows whether it's inactive in GUI instead of always showing the range.

### Fixed

- Use new slimeballs convention tag for Processor Binding.
- Portable Grid search bar texture being positioned in the wrong way.
- External Storage screen unnecessarily showing upgrade slots.
- Grid setting changes not persisting after restarting Minecraft.

## [2.0.0-milestone.4.6] - 2024-08-08

Expand Down
6 changes: 0 additions & 6 deletions refinedstorage-common-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ plugins {

refinedarchitect {
common()
testing()
javadoc()
publishing {
maven = true
Expand All @@ -22,9 +21,4 @@ dependencies {
api(project(":refinedstorage-resource-api"))
api(project(":refinedstorage-network-api"))
api(project(":refinedstorage-grid-api"))
testImplementation(libs.junit.api)
testImplementation(libs.junit.params)
testImplementation(libs.assertj)
testImplementation(libs.equalsverifier)
testRuntimeOnly(libs.junit.engine)
}
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ GridScrollingStrategy createGridScrollingStrategy(AbstractContainerMenu containe

<T extends ResourceKey> void registerResourceRendering(Class<T> resourceClass, ResourceRendering rendering);

ResourceRendering getResourceRendering(ResourceKey resource);
<T extends ResourceKey> ResourceRendering getResourceRendering(Class<T> resourceClass);

void addIngredientConverter(RecipeModIngredientConverter converter);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ public <T extends ResourceKey> void registerResourceRendering(final Class<T> res
}

@Override
public ResourceRendering getResourceRendering(final ResourceKey resource) {
return ensureLoaded().getResourceRendering(resource);
public <T extends ResourceKey> ResourceRendering getResourceRendering(final Class<T> resourceClass) {
return ensureLoaded().getResourceRendering(resourceClass);
}

@Override
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@

@API(status = API.Status.STABLE, since = "2.0.0-milestone.2.13")
public interface ResourceRendering {
String getDisplayedAmount(long amount, boolean withUnits);
default String formatAmount(long amount) {
return formatAmount(amount, false);
}

String formatAmount(long amount, boolean withUnits);

Component getDisplayName(ResourceKey resource);

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.refinedmods.refinedstorage.common.importer.ImporterScreen;
import com.refinedmods.refinedstorage.common.networking.NetworkTransmitterScreen;
import com.refinedmods.refinedstorage.common.networking.RelayScreen;
import com.refinedmods.refinedstorage.common.networking.WirelessTransmitterScreen;
import com.refinedmods.refinedstorage.common.security.FallbackSecurityCardScreen;
import com.refinedmods.refinedstorage.common.security.SecurityCardScreen;
import com.refinedmods.refinedstorage.common.security.SecurityManagerScreen;
Expand All @@ -36,7 +37,6 @@
import com.refinedmods.refinedstorage.common.support.resource.ItemResource;
import com.refinedmods.refinedstorage.common.support.resource.ItemResourceRendering;
import com.refinedmods.refinedstorage.common.upgrade.RegulatorUpgradeScreen;
import com.refinedmods.refinedstorage.common.wirelesstransmitter.WirelessTransmitterScreen;

import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -87,7 +87,9 @@ protected static void registerAlternativeGridHints() {

protected static void registerResourceRendering() {
RefinedStorageApi.INSTANCE.registerResourceRendering(ItemResource.class, new ItemResourceRendering());
RefinedStorageApi.INSTANCE.registerResourceRendering(FluidResource.class, new FluidResourceRendering());
RefinedStorageApi.INSTANCE.registerResourceRendering(FluidResource.class, new FluidResourceRendering(
Platform.INSTANCE.getBucketAmount()
));
}

protected static void handleInputEvents() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,19 @@
import com.refinedmods.refinedstorage.common.importer.ImporterContainerMenu;
import com.refinedmods.refinedstorage.common.misc.ProcessorItem;
import com.refinedmods.refinedstorage.common.misc.WrenchItem;
import com.refinedmods.refinedstorage.common.networking.BaseWirelessTransmitterRangeModifier;
import com.refinedmods.refinedstorage.common.networking.CreativeRangeUpgradeWirelessTransmitterRangeModifier;
import com.refinedmods.refinedstorage.common.networking.NetworkCardItem;
import com.refinedmods.refinedstorage.common.networking.NetworkReceiverBlockEntity;
import com.refinedmods.refinedstorage.common.networking.NetworkTransmitterBlockEntity;
import com.refinedmods.refinedstorage.common.networking.NetworkTransmitterContainerMenu;
import com.refinedmods.refinedstorage.common.networking.NetworkTransmitterData;
import com.refinedmods.refinedstorage.common.networking.RangeUpgradeWirelessTransmitterRangeModifier;
import com.refinedmods.refinedstorage.common.networking.RelayBlockEntity;
import com.refinedmods.refinedstorage.common.networking.RelayContainerMenu;
import com.refinedmods.refinedstorage.common.networking.WirelessTransmitterBlockEntity;
import com.refinedmods.refinedstorage.common.networking.WirelessTransmitterContainerMenu;
import com.refinedmods.refinedstorage.common.networking.WirelessTransmitterData;
import com.refinedmods.refinedstorage.common.security.BuiltinPermission;
import com.refinedmods.refinedstorage.common.security.FallbackSecurityCardContainerMenu;
import com.refinedmods.refinedstorage.common.security.PlatformSecurityNetworkComponentImpl;
Expand Down Expand Up @@ -141,12 +147,6 @@
import com.refinedmods.refinedstorage.common.upgrade.SimpleUpgradeItem;
import com.refinedmods.refinedstorage.common.upgrade.UpgradeDestinations;
import com.refinedmods.refinedstorage.common.upgrade.UpgradeWithEnchantedBookRecipeSerializer;
import com.refinedmods.refinedstorage.common.wirelesstransmitter.BaseWirelessTransmitterRangeModifier;
import com.refinedmods.refinedstorage.common.wirelesstransmitter.CreativeRangeUpgradeWirelessTransmitterRangeModifier;
import com.refinedmods.refinedstorage.common.wirelesstransmitter.RangeUpgradeWirelessTransmitterRangeModifier;
import com.refinedmods.refinedstorage.common.wirelesstransmitter.WirelessTransmitterBlockEntity;
import com.refinedmods.refinedstorage.common.wirelesstransmitter.WirelessTransmitterContainerMenu;
import com.refinedmods.refinedstorage.common.wirelesstransmitter.WirelessTransmitterData;

import java.util.Optional;
import java.util.UUID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import com.refinedmods.refinedstorage.common.grid.strategy.CompositeGridExtractionStrategy;
import com.refinedmods.refinedstorage.common.grid.strategy.CompositeGridInsertionStrategy;
import com.refinedmods.refinedstorage.common.grid.strategy.CompositeGridScrollingStrategy;
import com.refinedmods.refinedstorage.common.networking.CompositeWirelessTransmitterRangeModifier;
import com.refinedmods.refinedstorage.common.storage.ClientStorageRepository;
import com.refinedmods.refinedstorage.common.storage.StorageContainerItemHelperImpl;
import com.refinedmods.refinedstorage.common.storage.StorageRepositoryImpl;
Expand All @@ -80,7 +81,6 @@
import com.refinedmods.refinedstorage.common.upgrade.UpgradeRegistryImpl;
import com.refinedmods.refinedstorage.common.util.IdentifierUtil;
import com.refinedmods.refinedstorage.common.util.ServerEventQueue;
import com.refinedmods.refinedstorage.common.wirelesstransmitter.CompositeWirelessTransmitterRangeModifier;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -456,8 +456,8 @@ public <T extends ResourceKey> void registerResourceRendering(final Class<T> res
}

@Override
public ResourceRendering getResourceRendering(final ResourceKey resource) {
return resourceRenderingMap.get(resource.getClass());
public <T extends ResourceKey> ResourceRendering getResourceRendering(final Class<T> resourceClass) {
return resourceRenderingMap.get(resourceClass);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private void renderInputSlot(final int x, final int y, final GuiGraphics graphic
if (!inputs.isEmpty()) {
final int idx = currentCycle % inputs.size();
final PlatformResourceKey resource = inputs.get(idx);
RefinedStorageApi.INSTANCE.getResourceRendering(resource).render(
RefinedStorageApi.INSTANCE.getResourceRendering(resource.getClass()).render(
resource,
graphics,
x + sx * 18 + 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.refinedmods.refinedstorage.common.content.Items;
import com.refinedmods.refinedstorage.common.support.RecipeMatrixContainer;
import com.refinedmods.refinedstorage.common.support.resource.ItemResource;
import com.refinedmods.refinedstorage.common.util.PlatformUtil;
import com.refinedmods.refinedstorage.common.util.ClientPlatformUtil;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -86,7 +86,7 @@ public Optional<TooltipComponent> getTooltipImage(final ItemStack stack) {
if (state == null) {
return Optional.of(new HelpTooltipComponent(HELP));
}
final Level level = PlatformUtil.getClientLevel();
final Level level = ClientPlatformUtil.getClientLevel();
return switch (state.type()) {
case CRAFTING -> {
final CraftingPatternState craftingState = stack.get(DataComponents.INSTANCE.getCraftingPatternState());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.refinedmods.refinedstorage.common.api.RefinedStorageApi;
import com.refinedmods.refinedstorage.common.api.autocrafting.PatternProviderItem;
import com.refinedmods.refinedstorage.common.support.resource.ItemResource;
import com.refinedmods.refinedstorage.common.util.PlatformUtil;
import com.refinedmods.refinedstorage.common.util.ClientPlatformUtil;

import java.util.Optional;

Expand Down Expand Up @@ -32,7 +32,7 @@ public static boolean canDisplayOutput(final ItemStack stack) {
}

public static Optional<ItemStack> getOutput(final ItemStack stack) {
final Level level = PlatformUtil.getClientLevel();
final Level level = ClientPlatformUtil.getClientLevel();
if (level == null) {
return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public static ClientTooltipComponent getComponent(final PatternItem.StonecutterP
CACHE.clear();
}
return CACHE.computeIfAbsent(key.id(), id -> new StonecutterPatternClientTooltipComponent(
key.stonecutterPattern().input(),
key.stonecutterPattern().output()
key.stonecutterPattern()
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void renderImage(final Font font, final int x, final int y, final GuiGrap
final PlatformResourceKey resource = alternative.resources().get(
currentCycle % alternative.resources().size()
);
final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(resource);
final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(resource.getClass());
rendering.render(resource, graphics, x, y + 9 + PADDING + i * 18);
graphics.drawString(
font,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,9 @@ private static List<Component> getOutputText(final ProcessingPatternState state)

private static Component getOutputText(final ResourceAmount resourceAmount) {
final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(
resourceAmount.resource()
);
final String displayAmount = rendering.getDisplayedAmount(
resourceAmount.amount(),
false
resourceAmount.resource().getClass()
);
final String displayAmount = rendering.formatAmount(resourceAmount.amount());
return Component.literal(String.format("%sx ", displayAmount))
.append(rendering.getDisplayName(resourceAmount.resource()))
.withStyle(ChatFormatting.GRAY);
Expand Down Expand Up @@ -152,10 +149,10 @@ private void renderMatrixSlot(
}
final ResourceAmount resourceAmount = possibilities.get(currentCycle % possibilities.size());
final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(
resourceAmount.resource()
resourceAmount.resource().getClass()
);
rendering.render(resourceAmount.resource(), graphics, slotX + 1, slotY + 1);
ResourceSlotRendering.render(graphics, slotX + 1, slotY + 1, resourceAmount.amount(), rendering);
ResourceSlotRendering.renderAmount(graphics, slotX + 1, slotY + 1, resourceAmount.amount(), rendering);
}

private void renderOutputText(final Font font, final int x, final int y, final GuiGraphics graphics) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.refinedmods.refinedstorage.common.autocrafting;

import com.refinedmods.refinedstorage.common.api.autocrafting.Pattern;
import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey;
import com.refinedmods.refinedstorage.common.support.resource.ItemResource;

record SmithingTablePattern(PlatformResourceKey template,
PlatformResourceKey base,
PlatformResourceKey addition,
PlatformResourceKey output) implements Pattern {
record SmithingTablePattern(ItemResource template, ItemResource base, ItemResource addition, ItemResource output)
implements Pattern {
}
Loading

0 comments on commit a54f1f4

Please sign in to comment.