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.7 #663

Merged
merged 27 commits into from
Aug 11, 2024
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c1526e2
Merge pull request #653 from refinedmods/main
raoulvdberge Aug 8, 2024
12f1737
docs: add missing changelog entries for milestone 4.6
raoulvdberge Aug 8, 2024
e508ab8
feat: port to 1.21.1, use new slimeballs tag
raoulvdberge Aug 8, 2024
fdf2418
Merge pull request #654 from refinedmods/fix/GH-644/slimeballs
raoulvdberge Aug 8, 2024
9d52462
fix: move crafting matrix highlight to sprite
raoulvdberge Aug 8, 2024
332d0ea
chore: remove side button sprite sheet
raoulvdberge Aug 8, 2024
68552e6
fix: search bar being positioned wrongly on portable grid
raoulvdberge Aug 8, 2024
004bdac
fix: external storage screen showing upgrade slots
raoulvdberge Aug 8, 2024
44182f2
Merge pull request #655 from refinedmods/fix/GH-646/side-button-sprites
raoulvdberge Aug 8, 2024
cc70d44
fix: grid setting changes not persisting after restart
raoulvdberge Aug 8, 2024
f5f8322
refactor: fluid amount formatting is no longer static
raoulvdberge Aug 10, 2024
a78224c
refactor: move amount formatting from api to common
raoulvdberge Aug 10, 2024
400bd30
refactor: move security toast helper to client helper
raoulvdberge Aug 10, 2024
6a7783e
chore: remove useless test
raoulvdberge Aug 10, 2024
0b94698
fix: game tests should now detect duplicate resources
raoulvdberge Aug 10, 2024
42bd967
fix: regulator upgrade tooltip shouldn't use unit in tooltip
raoulvdberge Aug 10, 2024
50f3523
refactor: rename InMemoryStorageImpl to StorageImpl
raoulvdberge Aug 10, 2024
71d332b
build: manually update name as intellij failed to refactor
raoulvdberge Aug 10, 2024
8e3b1f2
feat: add transmitting icon for wireless transmitter and network tran…
raoulvdberge Aug 10, 2024
a54f1f4
Merge pull request #657 from refinedmods/fix/GH-645/save-grid
raoulvdberge Aug 10, 2024
6e76079
feat: upgrading storage disks and storage blocks
raoulvdberge Aug 10, 2024
504769b
Merge pull request #659 from refinedmods/feat/GH-658/storage-upgrading
raoulvdberge Aug 11, 2024
abff958
fix: can't extract fluids in grid if using an empty fluid container
starforcraft Jul 14, 2024
68798f4
Merge pull request #624 from starforcraft/fix/GH-617/draggingcontr
raoulvdberge Aug 11, 2024
4b18690
fix: retain and use custom names
raoulvdberge Aug 11, 2024
1e92b54
Merge pull request #662 from refinedmods/fix/GH-660/custom-name
raoulvdberge Aug 11, 2024
fcd24af
chore: prepare release v2.0.0-milestone.4.7
raoulvdberge Aug 11, 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: upgrading storage disks and storage blocks
raoulvdberge committed Aug 11, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 6e76079a4442925c71ddbaf4027f70d190b74e6e
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

- You can now upgrade Storage Disks and Storage Blocks to a higher tier by combining with a higher tier Storage Part. The original Storage Part will be returned.

### Changed

- Updated to Minecraft 1.21.1.
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
import net.minecraft.network.chat.Component;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack;
@@ -35,6 +36,16 @@ protected AbstractStorageContainerBlockItem(
this.helper = helper;
}

@Override
public void inventoryTick(final ItemStack stack,
final Level level,
final Entity entity,
final int slotId,
final boolean isSelected) {
super.inventoryTick(stack, level, entity, slotId, isSelected);
helper.transferStorageIfNecessary(stack, level, entity, this::createStorage);
}

@Override
public InteractionResultHolder<ItemStack> use(final Level level, final Player player, final InteractionHand hand) {
final ItemStack stack = player.getItemInHand(hand);
@@ -76,13 +87,16 @@ public void appendHoverText(final ItemStack stack,
final TooltipFlag flag) {
super.appendHoverText(stack, context, tooltip, flag);
final StorageRepository storageRepository = RefinedStorageApi.INSTANCE.getClientStorageRepository();
helper.appendToTooltip(stack, storageRepository, tooltip, flag, this::formatAmount, hasCapacity());
helper.appendToTooltip(stack, storageRepository, tooltip, flag, this::formatAmount, getCapacity());
}

protected abstract boolean hasCapacity();
@Nullable
protected abstract Long getCapacity();

protected abstract String formatAmount(long amount);

protected abstract SerializableStorage createStorage(StorageRepository storageRepository);

protected abstract ItemStack createPrimaryDisassemblyByproduct(int count);

@Nullable
Original file line number Diff line number Diff line change
@@ -51,10 +51,8 @@ public void inventoryTick(final ItemStack stack,
final int slot,
final boolean selected) {
super.inventoryTick(stack, level, entity, slot, selected);
if (!level.isClientSide() && !helper.hasStorage(stack) && entity instanceof Player) {
final StorageRepository storageRepository = RefinedStorageApi.INSTANCE.getStorageRepository(level);
helper.setStorage(storageRepository, stack, createStorage(storageRepository));
}
helper.transferStorageIfNecessary(stack, level, entity, this::createStorage);
helper.loadStorageIfNecessary(stack, level, entity, this::createStorage);
}

@Override
@@ -64,10 +62,11 @@ public void appendHoverText(final ItemStack stack,
final TooltipFlag flag) {
super.appendHoverText(stack, context, tooltip, flag);
final StorageRepository storageRepository = RefinedStorageApi.INSTANCE.getClientStorageRepository();
helper.appendToTooltip(stack, storageRepository, tooltip, flag, this::formatAmount, hasCapacity());
helper.appendToTooltip(stack, storageRepository, tooltip, flag, this::formatAmount, getCapacity());
}

protected abstract boolean hasCapacity();
@Nullable
protected abstract Long getCapacity();

protected abstract String formatAmount(long amount);

Original file line number Diff line number Diff line change
@@ -4,12 +4,14 @@
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import java.util.function.LongFunction;
import javax.annotation.Nullable;

import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
@@ -21,9 +23,15 @@
public interface StorageContainerItemHelper {
Optional<SerializableStorage> resolveStorage(StorageRepository storageRepository, ItemStack stack);

void setStorage(StorageRepository storageRepository, ItemStack stack, SerializableStorage storage);
void loadStorageIfNecessary(ItemStack stack,
Level level,
Entity entity,
Function<StorageRepository, SerializableStorage> factory);

boolean hasStorage(ItemStack stack);
void transferStorageIfNecessary(ItemStack stack,
Level level,
Entity entity,
Function<StorageRepository, SerializableStorage> factory);

Optional<StorageInfo> getInfo(StorageRepository storageRepository, ItemStack stack);

@@ -38,7 +46,7 @@ void appendToTooltip(ItemStack stack,
List<Component> tooltip,
TooltipFlag context,
LongFunction<String> amountFormatter,
boolean hasCapacity);
@Nullable Long capacity);

void transferToBlockEntity(ItemStack stack, StorageBlockEntity blockEntity);

@@ -49,4 +57,6 @@ void appendToTooltip(ItemStack stack,
Set<ResourceLocation> getDiskModels();

Map<Item, ResourceLocation> getDiskModelsByItem();

void markAsToTransfer(ItemStack from, ItemStack to);
}
Original file line number Diff line number Diff line change
@@ -31,6 +31,13 @@ public interface StorageRepository {
*/
Optional<SerializableStorage> removeIfEmpty(UUID id);

/**
* Removes a storage by ID.
*
* @param id the id
*/
void remove(UUID id);

/**
* Retrieves info for a given storage ID.
*
Original file line number Diff line number Diff line change
@@ -95,6 +95,8 @@
import com.refinedmods.refinedstorage.common.security.SecurityManagerContainerMenu;
import com.refinedmods.refinedstorage.common.storage.FluidStorageVariant;
import com.refinedmods.refinedstorage.common.storage.ItemStorageVariant;
import com.refinedmods.refinedstorage.common.storage.StorageContainerUpgradeRecipe;
import com.refinedmods.refinedstorage.common.storage.StorageContainerUpgradeRecipeSerializer;
import com.refinedmods.refinedstorage.common.storage.StorageTypes;
import com.refinedmods.refinedstorage.common.storage.diskdrive.AbstractDiskDriveBlockEntity;
import com.refinedmods.refinedstorage.common.storage.diskdrive.DiskDriveBlock;
@@ -815,6 +817,42 @@ protected final void registerRecipeSerializers(final RegistryCallback<RecipeSeri
createIdentifier("upgrade_with_enchanted_book"),
UpgradeWithEnchantedBookRecipeSerializer::new
);
callback.register(
createIdentifier("storage_disk_upgrade"),
() -> new StorageContainerUpgradeRecipeSerializer<>(
ItemStorageVariant.values(),
to -> new StorageContainerUpgradeRecipe<>(
ItemStorageVariant.values(), to, Items.INSTANCE::getItemStorageDisk
)
)
);
callback.register(
createIdentifier("fluid_storage_disk_upgrade"),
() -> new StorageContainerUpgradeRecipeSerializer<>(
FluidStorageVariant.values(),
to -> new StorageContainerUpgradeRecipe<>(
FluidStorageVariant.values(), to, Items.INSTANCE::getFluidStorageDisk
)
)
);
callback.register(
createIdentifier("storage_block_upgrade"),
() -> new StorageContainerUpgradeRecipeSerializer<>(
ItemStorageVariant.values(),
to -> new StorageContainerUpgradeRecipe<>(
ItemStorageVariant.values(), to, Blocks.INSTANCE::getItemStorageBlock
)
)
);
callback.register(
createIdentifier("fluid_storage_block_upgrade"),
() -> new StorageContainerUpgradeRecipeSerializer<>(
FluidStorageVariant.values(),
to -> new StorageContainerUpgradeRecipe<>(
FluidStorageVariant.values(), to, Blocks.INSTANCE::getFluidStorageBlock
)
)
);
}

protected final void registerDataComponents(final RegistryCallback<DataComponentType<?>> callback) {
@@ -833,6 +871,12 @@ protected final void registerDataComponents(final RegistryCallback<DataComponent
.persistent(UUIDUtil.CODEC)
.networkSynchronized(UUIDUtil.STREAM_CODEC)
.build()));
DataComponents.INSTANCE.setStorageReferenceToBeTransferred(
callback.register(createIdentifier("storage_reference_to_be_transferred"),
() -> DataComponentType.<UUID>builder()
.persistent(UUIDUtil.CODEC)
.networkSynchronized(UUIDUtil.STREAM_CODEC)
.build()));
DataComponents.INSTANCE.setRegulatorUpgradeState(
callback.register(createIdentifier("regulator_upgrade_state"),
() -> DataComponentType.<RegulatorUpgradeState>builder()
Original file line number Diff line number Diff line change
@@ -29,6 +29,8 @@ public final class DataComponents {
@Nullable
private Supplier<DataComponentType<UUID>> storageReference;
@Nullable
private Supplier<DataComponentType<UUID>> storageReferenceToBeTransferred;
@Nullable
private Supplier<DataComponentType<RegulatorUpgradeState>> regulatorUpgradeState;
@Nullable
private Supplier<DataComponentType<SecurityCardBoundPlayer>> securityCardBoundPlayer;
@@ -74,6 +76,14 @@ public void setStorageReference(@Nullable final Supplier<DataComponentType<UUID>
this.storageReference = supplier;
}

public DataComponentType<UUID> getStorageReferenceToBeTransferred() {
return requireNonNull(storageReferenceToBeTransferred).get();
}

public void setStorageReferenceToBeTransferred(@Nullable final Supplier<DataComponentType<UUID>> supplier) {
this.storageReferenceToBeTransferred = supplier;
}

public DataComponentType<RegulatorUpgradeState> getRegulatorUpgradeState() {
return requireNonNull(regulatorUpgradeState).get();
}
Original file line number Diff line number Diff line change
@@ -44,6 +44,11 @@ public Optional<SerializableStorage> removeIfEmpty(final UUID id) {
throw new UnsupportedOperationException();
}

@Override
public void remove(final UUID id) {
throw new UnsupportedOperationException();
}

public void setInfo(final UUID id, final long stored, final long capacity) {
info.put(id, new StorageInfo(stored, capacity));
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package com.refinedmods.refinedstorage.common.storage;

import com.refinedmods.refinedstorage.common.Platform;
import com.refinedmods.refinedstorage.common.content.Items;

import javax.annotation.Nullable;

public enum FluidStorageVariant {
import net.minecraft.util.StringRepresentable;
import net.minecraft.world.item.Item;

public enum FluidStorageVariant implements StringRepresentable, StorageVariant {
SIXTY_FOUR_B("64b", 64L),
TWO_HUNDRED_FIFTY_SIX_B("256b", 256L),
THOUSAND_TWENTY_FOUR_B("1024b", 1024L),
@@ -29,6 +33,7 @@ public Long getCapacityInBuckets() {
return capacityInBuckets;
}

@Override
@Nullable
public Long getCapacity() {
if (capacityInBuckets == null) {
@@ -37,7 +42,17 @@ public Long getCapacity() {
return capacityInBuckets * Platform.INSTANCE.getBucketAmount();
}

public boolean hasCapacity() {
return capacityInBuckets != null;
@Nullable
@Override
public Item getStoragePart() {
if (this == CREATIVE) {
return null;
}
return Items.INSTANCE.getFluidStoragePart(this);
}

@Override
public String getSerializedName() {
return name;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package com.refinedmods.refinedstorage.common.storage;

import com.refinedmods.refinedstorage.common.content.Items;

import javax.annotation.Nullable;

public enum ItemStorageVariant {
import net.minecraft.util.StringRepresentable;
import net.minecraft.world.item.Item;

public enum ItemStorageVariant implements StringRepresentable, StorageVariant {
ONE_K("1k", 1024L),
FOUR_K("4k", 1024 * 4L),
SIXTEEN_K("16k", 1024 * 4 * 4L),
@@ -22,12 +27,23 @@ public String getName() {
return name;
}

@Override
@Nullable
public Long getCapacity() {
return capacity;
}

public boolean hasCapacity() {
return capacity != null;
@Nullable
@Override
public Item getStoragePart() {
if (this == CREATIVE) {
return null;
}
return Items.INSTANCE.getItemStoragePart(this);
}

@Override
public String getSerializedName() {
return name;
}
}
Loading
Loading