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

feat: port to minecraft 1.21 #583

Merged
merged 1 commit into from
Jul 3, 2024
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ body:
description: |
If your Minecraft version isn't listed here, it means that it isn't supported. In that case, don't create an issue.
options:
- Minecraft 1.20.4
- Minecraft 1.21
validations:
required: true
- type: input
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
types: [ opened, synchronize, reopened ]
jobs:
build:
uses: refinedmods/refinedarchitect/.github/workflows/build.yml@v0.13.4
uses: refinedmods/refinedarchitect/.github/workflows/build.yml@v0.14.3
with:
gametests: true
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/draft-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
type: string
jobs:
draft:
uses: refinedmods/refinedarchitect/.github/workflows/draft-release.yml@v0.13.4
uses: refinedmods/refinedarchitect/.github/workflows/draft-release.yml@v0.14.3
with:
release-type: ${{ inputs.release-type }}
version-number-override: ${{ inputs.version-number-override }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issue-for-unsupported-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ on:
types: [ labeled, unlabeled, reopened ]
jobs:
unsupported-labeler:
uses: refinedmods/refinedarchitect/.github/workflows/issue-for-unsupported-version.yml@v0.13.4
uses: refinedmods/refinedarchitect/.github/workflows/issue-for-unsupported-version.yml@v0.14.3
3 changes: 2 additions & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ on:
- closed
jobs:
publish-release:
uses: refinedmods/refinedarchitect/.github/workflows/publish-release.yml@v0.13.4
uses: refinedmods/refinedarchitect/.github/workflows/publish-release.yml@v0.14.3
secrets: inherit
with:
project-name: 'Refined Storage'
gametests: true
2 changes: 1 addition & 1 deletion .github/workflows/resolved-issue-locking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ on:
- cron: '0 0 * * *'
jobs:
lock:
uses: refinedmods/refinedarchitect/.github/workflows/resolved-issue-locking.yml@v0.13.4
uses: refinedmods/refinedarchitect/.github/workflows/resolved-issue-locking.yml@v0.14.3
2 changes: 1 addition & 1 deletion .github/workflows/validate-branch-name.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ name: Validate branch name
on: [ pull_request ]
jobs:
validate-branch-name:
uses: refinedmods/refinedarchitect/.github/workflows/validate-branch-name.yml@v0.13.4
uses: refinedmods/refinedarchitect/.github/workflows/validate-branch-name.yml@v0.14.3
2 changes: 1 addition & 1 deletion .github/workflows/validate-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ on:
types: [ opened, synchronize, reopened, ready_for_review, labeled, unlabeled ]
jobs:
validate-changelog:
uses: refinedmods/refinedarchitect/.github/workflows/validate-changelog.yml@v0.13.4
uses: refinedmods/refinedarchitect/.github/workflows/validate-changelog.yml@v0.14.3
2 changes: 1 addition & 1 deletion .github/workflows/validate-commit-messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ name: Validate commit messages
on: [ pull_request ]
jobs:
validate-commit-messages:
uses: refinedmods/refinedarchitect/.github/workflows/validate-commit-messages.yml@v0.13.4
uses: refinedmods/refinedarchitect/.github/workflows/validate-commit-messages.yml@v0.14.3
1 change: 1 addition & 0 deletions .idea/dictionaries/refinedstorage2.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Ported to Minecraft 1.21.
- More help information for items.

### Fixed

- Regulator Upgrade having wrong GUI title.
- Crafting Grid not dropping crafting matrix contents when broken.
- "+1" amount screen button not doing anything.

### Changed

- Internal data format for storages. Storages from milestone 3 are incompatible and will not be transferred.

## [2.0.0-milestone.3.14] - 2024-06-28

### Added
Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
noIndiumVersion=1.1.0+1.20.4
# Gradle
org.gradle.jvmargs=-Xmx1G
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import javax.annotation.Nullable;

import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
Expand All @@ -72,6 +71,8 @@ public interface PlatformApi {

PlatformRegistry<StorageType> getStorageTypeRegistry();

StorageRepository getClientStorageRepository();

StorageRepository getStorageRepository(Level level);

StorageContainerItemHelper getStorageContainerItemHelper();
Expand Down Expand Up @@ -106,8 +107,6 @@ public interface PlatformApi {

PlatformRegistry<GridSynchronizer> getGridSynchronizerRegistry();

void writeGridScreenOpeningData(Grid grid, FriendlyByteBuf buf);

UpgradeRegistry getUpgradeRegistry();

BuiltinUpgradeDestinations getBuiltinUpgradeDestinations();
Expand Down Expand Up @@ -189,10 +188,6 @@ EnergyStorage asBlockItemEnergyStorage(

PlatformRegistry<SlotReferenceFactory> getSlotReferenceFactoryRegistry();

void writeSlotReference(SlotReference slotReference, FriendlyByteBuf buf);

Optional<SlotReference> getSlotReference(FriendlyByteBuf buf);

void addSlotReferenceProvider(SlotReferenceProvider slotReferenceProvider);

SlotReference createInventorySlotReference(Player player, InteractionHand hand);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import javax.annotation.Nullable;

import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
Expand Down Expand Up @@ -81,6 +80,11 @@ public PlatformRegistry<StorageType> getStorageTypeRegistry() {
return ensureLoaded().getStorageTypeRegistry();
}

@Override
public StorageRepository getClientStorageRepository() {
return ensureLoaded().getClientStorageRepository();
}

@Override
public StorageRepository getStorageRepository(final Level level) {
return ensureLoaded().getStorageRepository(level);
Expand Down Expand Up @@ -166,11 +170,6 @@ public PlatformRegistry<GridSynchronizer> getGridSynchronizerRegistry() {
return ensureLoaded().getGridSynchronizerRegistry();
}

@Override
public void writeGridScreenOpeningData(final Grid grid, final FriendlyByteBuf buf) {
ensureLoaded().writeGridScreenOpeningData(grid, buf);
}

@Override
public UpgradeRegistry getUpgradeRegistry() {
return ensureLoaded().getUpgradeRegistry();
Expand Down Expand Up @@ -358,16 +357,6 @@ public PlatformRegistry<SlotReferenceFactory> getSlotReferenceFactoryRegistry()
return ensureLoaded().getSlotReferenceFactoryRegistry();
}

@Override
public void writeSlotReference(final SlotReference slotReference, final FriendlyByteBuf buf) {
ensureLoaded().writeSlotReference(slotReference, buf);
}

@Override
public Optional<SlotReference> getSlotReference(final FriendlyByteBuf buf) {
return ensureLoaded().getSlotReference(buf);
}

@Override
public void addSlotReferenceProvider(final SlotReferenceProvider slotReferenceProvider) {
ensureLoaded().addSlotReferenceProvider(slotReferenceProvider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Collections;
import java.util.List;

import net.minecraft.core.HolderLookup;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.item.Item;
import org.apiguardian.api.API;
Expand All @@ -12,9 +13,9 @@
*/
@API(status = API.Status.STABLE, since = "2.0.0-milestone.3.2")
public interface ConfigurationCardTarget {
void writeConfiguration(CompoundTag tag);
void writeConfiguration(CompoundTag tag, HolderLookup.Provider provider);

void readConfiguration(CompoundTag tag);
void readConfiguration(CompoundTag tag, HolderLookup.Provider provider);

default List<Item> getUpgradeItems() {
return Collections.emptyList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,12 @@ private void updateBlockEntityTag(final BlockPos pos,

@Override
public void appendHoverText(final ItemStack stack,
@Nullable final Level level,
final TooltipContext context,
final List<Component> tooltip,
final TooltipFlag context) {
super.appendHoverText(stack, level, tooltip, context);
if (level == null) {
return;
}
final StorageRepository storageRepository = PlatformApi.INSTANCE.getStorageRepository(level);
helper.appendToTooltip(stack, storageRepository, tooltip, context, this::formatAmount, hasCapacity());
final TooltipFlag flag) {
super.appendHoverText(stack, context, tooltip, flag);
final StorageRepository storageRepository = PlatformApi.INSTANCE.getClientStorageRepository();
helper.appendToTooltip(stack, storageRepository, tooltip, flag, this::formatAmount, hasCapacity());
}

protected abstract boolean hasCapacity();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.refinedmods.refinedstorage2.platform.api.storage;

import com.refinedmods.refinedstorage2.api.storage.Storage;
import com.refinedmods.refinedstorage2.platform.api.PlatformApi;

import java.util.List;
Expand Down Expand Up @@ -28,8 +27,8 @@ protected AbstractStorageContainerItem(final Properties properties, final Storag
}

@Override
public Optional<Storage> resolve(final StorageRepository storageRepository, final ItemStack stack) {
return helper.resolve(storageRepository, stack);
public Optional<SerializableStorage> resolve(final StorageRepository storageRepository, final ItemStack stack) {
return helper.resolveStorage(storageRepository, stack);
}

@Override
Expand All @@ -52,30 +51,27 @@ public void inventoryTick(final ItemStack stack,
final int slot,
final boolean selected) {
super.inventoryTick(stack, level, entity, slot, selected);
if (!level.isClientSide() && !stack.hasTag() && entity instanceof Player) {
if (!level.isClientSide() && !helper.hasStorage(stack) && entity instanceof Player) {
final StorageRepository storageRepository = PlatformApi.INSTANCE.getStorageRepository(level);
helper.set(storageRepository, stack, createStorage(storageRepository));
helper.setStorage(storageRepository, stack, createStorage(storageRepository));
}
}

@Override
public void appendHoverText(final ItemStack stack,
@Nullable final Level level,
final TooltipContext context,
final List<Component> tooltip,
final TooltipFlag context) {
super.appendHoverText(stack, level, tooltip, context);
if (level == null) {
return;
}
final StorageRepository storageRepository = PlatformApi.INSTANCE.getStorageRepository(level);
helper.appendToTooltip(stack, storageRepository, tooltip, context, this::formatAmount, hasCapacity());
final TooltipFlag flag) {
super.appendHoverText(stack, context, tooltip, flag);
final StorageRepository storageRepository = PlatformApi.INSTANCE.getClientStorageRepository();
helper.appendToTooltip(stack, storageRepository, tooltip, flag, this::formatAmount, hasCapacity());
}

protected abstract boolean hasCapacity();

protected abstract String formatAmount(long amount);

protected abstract Storage createStorage(StorageRepository storageRepository);
protected abstract SerializableStorage createStorage(StorageRepository storageRepository);

protected abstract ItemStack createPrimaryDisassemblyByproduct(int count);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
package com.refinedmods.refinedstorage2.platform.api.storage;

import com.refinedmods.refinedstorage2.api.storage.Storage;
import com.refinedmods.refinedstorage2.platform.api.PlatformApi;

import com.mojang.serialization.Codec;
import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.1.4")
public interface SerializableStorage {
public interface SerializableStorage extends Storage {
StorageType getType();

static Codec<SerializableStorage> getCodec(final Runnable listener) {
return PlatformApi.INSTANCE.getStorageTypeRegistry()
.codec()
.dispatch(SerializableStorage::getType, storage -> storage.getMapCodec(listener));
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.refinedmods.refinedstorage2.platform.api.storage;

import com.refinedmods.refinedstorage2.api.storage.Storage;

import java.util.Optional;
import java.util.function.Predicate;

Expand All @@ -10,7 +8,7 @@

@API(status = API.Status.STABLE, since = "2.0.0-milestone.1.0")
public interface StorageContainerItem {
Optional<Storage> resolve(StorageRepository storageRepository, ItemStack stack);
Optional<SerializableStorage> resolve(StorageRepository storageRepository, ItemStack stack);

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.refinedmods.refinedstorage2.platform.api.storage;

import com.refinedmods.refinedstorage2.api.storage.Storage;

import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand All @@ -21,9 +19,11 @@

@API(status = API.Status.STABLE, since = "2.0.0-milestone.2.5")
public interface StorageContainerItemHelper {
Optional<Storage> resolve(StorageRepository storageRepository, ItemStack stack);
Optional<SerializableStorage> resolveStorage(StorageRepository storageRepository, ItemStack stack);

void setStorage(StorageRepository storageRepository, ItemStack stack, SerializableStorage storage);

void set(StorageRepository storageRepository, ItemStack stack, Storage storage);
boolean hasStorage(ItemStack stack);

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.refinedmods.refinedstorage2.platform.api.storage;

import com.refinedmods.refinedstorage2.api.storage.Storage;

import java.util.Optional;
import java.util.UUID;

Expand All @@ -15,23 +13,23 @@ public interface StorageRepository {
* @param id the id
* @return the storage, if present
*/
Optional<Storage> get(UUID id);
Optional<SerializableStorage> get(UUID id);

/**
* Sets a storage by ID.
*
* @param id the id
* @param storage the storage
*/
void set(UUID id, Storage storage);
void set(UUID id, SerializableStorage storage);

/**
* If the storage exists, and is empty, it will remove the storage from the repository.
*
* @param id the id
* @return the removed storage, if it existed and was empty
*/
Optional<Storage> removeIfEmpty(UUID id);
Optional<SerializableStorage> removeIfEmpty(UUID id);

/**
* Retrieves info for a given storage ID.
Expand Down
Loading
Loading