Skip to content

Commit

Permalink
feat: port to minecraft 1.20.4
Browse files Browse the repository at this point in the history
  • Loading branch information
raoulvdberge committed Jan 28, 2024
1 parent 4ff04c8 commit 39f97d5
Show file tree
Hide file tree
Showing 210 changed files with 2,207 additions and 2,556 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ on:
types: [ opened, synchronize, reopened ]
jobs:
build:
uses: refinedmods/refinedarchitect/.github/workflows/build.yml@v0.9.0
uses: refinedmods/refinedarchitect/.github/workflows/build.yml@v0.11.2
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.9.0
uses: refinedmods/refinedarchitect/.github/workflows/draft-release.yml@v0.11.2
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.9.0
uses: refinedmods/refinedarchitect/.github/workflows/issue-for-unsupported-version.yml@v0.11.2
2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- closed
jobs:
publish-release:
uses: refinedmods/refinedarchitect/.github/workflows/publish-release.yml@v0.9.0
uses: refinedmods/refinedarchitect/.github/workflows/publish-release.yml@v0.11.2
secrets: inherit
with:
project-name: 'Refined Storage'
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.9.0
uses: refinedmods/refinedarchitect/.github/workflows/resolved-issue-locking.yml@v0.11.2
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.9.0
uses: refinedmods/refinedarchitect/.github/workflows/validate-branch-name.yml@v0.11.2
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.9.0
uses: refinedmods/refinedarchitect/.github/workflows/validate-changelog.yml@v0.11.2
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.9.0
uses: refinedmods/refinedarchitect/.github/workflows/validate-commit-messages.yml@v0.11.2
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### Added

- Ported to Minecraft 1.20.4.
- Custom disk models. Fluid disks now have a different model.
- Portable Grid

Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The MIT License (MIT)

Copyright © 2020 - 2023 Refined Mods
Copyright © 2020 - 2024 Refined Mods

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the “Software”), to deal in the Software without restriction, including without limitation the
Expand Down
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.3.1")
public abstract class AbstractEnergyBlockItem extends BlockItem implements EnergyItem {
public abstract class AbstractEnergyBlockItem extends BlockItem {
private final EnergyItemHelper helper;

protected AbstractEnergyBlockItem(final Block block, final Properties properties, final EnergyItemHelper helper) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.3.1")
public abstract class AbstractEnergyItem extends Item implements EnergyItem {
public abstract class AbstractEnergyItem extends Item {
private final EnergyItemHelper helper;

protected AbstractEnergyItem(final Properties properties, final EnergyItemHelper helper) {
Expand Down

This file was deleted.

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

import org.apiguardian.api.API;

/**
* Implement this on block entities that can contain energy.
* At runtime, Refined Storage will attach an energy storage adapter for the platform.
*/
@API(status = API.Status.STABLE, since = "2.0.0-milestone.3.1")
public interface EnergyBlockEntity {
public interface TransferableBlockEntityEnergy {
EnergyStorage getEnergyStorage();
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public FluidResource normalize() {
return new FluidResource(fluid, null);
}

@SuppressWarnings({"deprecation", "RedundantSuppression"}) // forge deprecates Registry access
public static CompoundTag toTag(final FluidResource fluidResource) {
final CompoundTag tag = new CompoundTag();
if (fluidResource.tag() != null) {
Expand All @@ -45,7 +44,6 @@ public static CompoundTag toTagWithAmount(final ResourceAmount<FluidResource> re
return tag;
}

@SuppressWarnings({"deprecation", "RedundantSuppression"}) // forge deprecates Registry access
public static Optional<FluidResource> fromTag(final CompoundTag tag) {
final ResourceLocation id = new ResourceLocation(tag.getString(TAG_ID));
final Fluid fluid = BuiltInRegistries.FLUID.get(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public static ItemResource ofItemStack(final ItemStack itemStack) {
return new ItemResource(itemStack.getItem(), itemStack.getTag());
}

@SuppressWarnings({"deprecation", "RedundantSuppression"}) // forge deprecates Registry access
public static CompoundTag toTag(final ItemResource itemResource) {
final CompoundTag tag = new CompoundTag();
if (itemResource.tag() != null) {
Expand All @@ -69,7 +68,6 @@ public static CompoundTag toTagWithAmount(final ResourceAmount<ItemResource> res
return tag;
}

@SuppressWarnings({"deprecation", "RedundantSuppression"}) // forge deprecates Registry access
public static Optional<ItemResource> fromTag(final CompoundTag tag) {
final ResourceLocation id = new ResourceLocation(tag.getString(TAG_ID));
final Item item = BuiltInRegistries.ITEM.get(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
import com.refinedmods.refinedstorage2.platform.common.storage.portablegrid.PortableGridBlock;
import com.refinedmods.refinedstorage2.platform.common.storage.portablegrid.PortableGridContainerMenu;
import com.refinedmods.refinedstorage2.platform.common.storage.portablegrid.PortableGridItem;
import com.refinedmods.refinedstorage2.platform.common.storage.portablegrid.PortableGridLootItemFunctionSerializer;
import com.refinedmods.refinedstorage2.platform.common.storage.portablegrid.PortableGridLootItemFunction;
import com.refinedmods.refinedstorage2.platform.common.storage.portablegrid.PortableGridType;
import com.refinedmods.refinedstorage2.platform.common.storage.storageblock.FluidStorageBlock;
import com.refinedmods.refinedstorage2.platform.common.storage.storageblock.FluidStorageBlockBlockEntity;
Expand All @@ -78,7 +78,7 @@
import com.refinedmods.refinedstorage2.platform.common.storage.storageblock.ItemStorageBlockBlockEntity;
import com.refinedmods.refinedstorage2.platform.common.storage.storageblock.ItemStorageBlockBlockItem;
import com.refinedmods.refinedstorage2.platform.common.storage.storageblock.ItemStorageBlockContainerMenu;
import com.refinedmods.refinedstorage2.platform.common.storage.storageblock.StorageBlockLootItemFunctionSerializer;
import com.refinedmods.refinedstorage2.platform.common.storage.storageblock.StorageBlockLootItemFunction;
import com.refinedmods.refinedstorage2.platform.common.storage.storagedisk.FluidStorageDiskItem;
import com.refinedmods.refinedstorage2.platform.common.storage.storagedisk.ItemStorageDiskItem;
import com.refinedmods.refinedstorage2.platform.common.storagemonitor.FluidStorageMonitorExtractionStrategy;
Expand All @@ -91,7 +91,7 @@
import com.refinedmods.refinedstorage2.platform.common.support.SimpleBlock;
import com.refinedmods.refinedstorage2.platform.common.support.SimpleBlockItem;
import com.refinedmods.refinedstorage2.platform.common.support.SimpleItem;
import com.refinedmods.refinedstorage2.platform.common.support.energy.EnergyLootItemFunctionSerializer;
import com.refinedmods.refinedstorage2.platform.common.support.energy.EnergyLootItemFunction;
import com.refinedmods.refinedstorage2.platform.common.support.network.NetworkNodeContainerBlockEntityImpl;
import com.refinedmods.refinedstorage2.platform.common.support.resource.FluidResourceFactory;
import com.refinedmods.refinedstorage2.platform.common.upgrade.FortuneUpgradeItem;
Expand All @@ -111,6 +111,7 @@
import java.util.function.BiFunction;
import java.util.function.Supplier;

import com.mojang.serialization.Codec;
import net.minecraft.core.BlockPos;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.inventory.MenuType;
Expand Down Expand Up @@ -714,15 +715,15 @@ protected final void registerMenus(final RegistryCallback<MenuType<?>> callback,
protected final void registerLootFunctions(final RegistryCallback<LootItemFunctionType> callback) {
LootFunctions.INSTANCE.setStorageBlock(callback.register(
STORAGE_BLOCK,
() -> new LootItemFunctionType(new StorageBlockLootItemFunctionSerializer())
() -> new LootItemFunctionType(Codec.unit(new StorageBlockLootItemFunction()))
));
LootFunctions.INSTANCE.setPortableGrid(callback.register(
PORTABLE_GRID,
() -> new LootItemFunctionType(new PortableGridLootItemFunctionSerializer())
() -> new LootItemFunctionType(Codec.unit(new PortableGridLootItemFunction()))
));
LootFunctions.INSTANCE.setEnergy(callback.register(
createIdentifier("energy"),
() -> new LootItemFunctionType(new EnergyLootItemFunctionSerializer())
() -> new LootItemFunctionType(Codec.unit(new EnergyLootItemFunction()))
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.CraftingRecipe;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.LiquidBlock;
import net.minecraft.world.level.block.state.BlockState;
Expand Down Expand Up @@ -100,7 +100,7 @@ NonNullList<ItemStack> getRemainingCraftingItems(Player player,
ItemStack getBlockAsItemStack(Block block,
BlockState state,
Direction direction,
BlockGetter level,
LevelReader level,
BlockPos pos,
Player player);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
import com.refinedmods.refinedstorage2.platform.api.upgrade.BuiltinUpgradeDestinations;
import com.refinedmods.refinedstorage2.platform.api.upgrade.UpgradeRegistry;
import com.refinedmods.refinedstorage2.platform.api.wirelesstransmitter.WirelessTransmitterRangeModifier;
import com.refinedmods.refinedstorage2.platform.common.grid.AbstractGridContainerMenu;
import com.refinedmods.refinedstorage2.platform.common.grid.NoopGridSynchronizer;
import com.refinedmods.refinedstorage2.platform.common.grid.screen.AbstractGridScreen;
import com.refinedmods.refinedstorage2.platform.common.grid.screen.hint.GridInsertionHintsImpl;
import com.refinedmods.refinedstorage2.platform.common.grid.screen.hint.ItemGridInsertionHint;
import com.refinedmods.refinedstorage2.platform.common.grid.screen.hint.SingleItemGridInsertionHint;
Expand Down Expand Up @@ -101,6 +101,7 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.saveddata.SavedData;

import static com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil.createIdentifier;

Expand Down Expand Up @@ -168,19 +169,18 @@ public PlatformRegistry<StorageType<?>> getStorageTypeRegistry() {
return storageTypeRegistry;
}

@SuppressWarnings("DataFlowIssue") // NeoForge makes null datafixer safe
@Override
public StorageRepository getStorageRepository(final Level level) {
if (level.getServer() == null) {
return clientStorageRepository;
}
final ServerLevel serverLevel = Objects.requireNonNull(level.getServer().getLevel(Level.OVERWORLD));
return serverLevel
.getDataStorage()
.computeIfAbsent(
this::createStorageRepository,
this::createStorageRepository,
StorageRepositoryImpl.NAME
);
return serverLevel.getDataStorage().computeIfAbsent(new SavedData.Factory<>(
this::createStorageRepository,
this::createStorageRepository,
null
), StorageRepositoryImpl.NAME);
}

@Override
Expand Down Expand Up @@ -280,7 +280,7 @@ public PlatformRegistry<GridSynchronizer> getGridSynchronizerRegistry() {

@Override
public void writeGridScreenOpeningData(final Grid grid, final FriendlyByteBuf buf) {
AbstractGridScreen.writeScreenOpeningData(storageChannelTypeRegistry, grid, buf);
AbstractGridContainerMenu.writeScreenOpeningData(storageChannelTypeRegistry, grid, buf);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.CraftingRecipe;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.LiquidBlock;
import net.minecraft.world.level.block.state.BlockState;
Expand Down Expand Up @@ -195,7 +195,7 @@ public boolean placeFluid(final Level level,
public ItemStack getBlockAsItemStack(final Block block,
final BlockState state,
final Direction direction,
final BlockGetter level,
final LevelReader level,
final BlockPos pos,
final Player player) {
return ensureLoaded().getBlockAsItemStack(block, state, direction, level, pos, player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ private InteractionResult applyConfiguration(
return InteractionResult.SUCCESS;
}

@SuppressWarnings("deprecation") // Forge deprecates registry access this way
private void tryTransferUpgrades(final Player player, final ConfigurationCardTarget target, final CompoundTag tag) {
final ListTag upgradesTag = tag.getList(TAG_UPGRADES, Tag.TAG_STRING);
for (final Tag upgradeItemTag : upgradesTag) {
Expand Down Expand Up @@ -111,7 +110,6 @@ private InteractionResult configurationCardIsConfiguredForDifferentType(
return InteractionResult.CONSUME;
}

@SuppressWarnings("deprecation") // Forge deprecates registry access this way
private void writeConfiguration(final ItemStack stack,
final Player player,
final ConfigurationCardTarget target,
Expand All @@ -130,7 +128,6 @@ private CompoundTag createConfigTag(final ConfigurationCardTarget target) {
return tag;
}

@SuppressWarnings("deprecation") // Forge deprecates registry access this way
private ListTag createUpgradesTag(final ConfigurationCardTarget target) {
final ListTag tag = new ListTag();
target.getUpgradeItems().forEach(item -> {
Expand Down Expand Up @@ -184,13 +181,11 @@ public void appendHoverText(final ItemStack stack,
}

@Nullable
@SuppressWarnings("deprecation") // Forge deprecates registry access this way
private BlockEntityType<?> getConfiguredType(final CompoundTag tag) {
final ResourceLocation type = new ResourceLocation(tag.getString(TAG_TYPE));
return BuiltInRegistries.BLOCK_ENTITY_TYPE.get(type);
}

@SuppressWarnings("deprecation") // Forge deprecates registry access this way
private MutableComponent getConfiguredTypeTranslation(final BlockEntityType<?> type) {
final ResourceLocation typeId = BuiltInRegistries.BLOCK_ENTITY_TYPE.getKey(type);
if (typeId == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import net.minecraft.core.Direction;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
Expand All @@ -24,9 +25,10 @@
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.phys.shapes.VoxelShape;

public abstract class AbstractConstructorDestructorBlock<T extends Block & BlockItemProvider, B extends BlockEntity>
public abstract class AbstractConstructorDestructorBlock<T extends Block & BlockItemProvider<I>,
B extends BlockEntity, I extends BlockItem>
extends AbstractDirectionalCableBlock
implements ColorableBlock<T>, EntityBlock {
implements ColorableBlock<T, I>, EntityBlock {
public static final BooleanProperty ACTIVE = BooleanProperty.create("active");

private static final Map<DirectionalCacheShapeCacheKey, VoxelShape> SHAPE_CACHE = new HashMap<>();
Expand Down Expand Up @@ -79,9 +81,9 @@ public MutableComponent getName() {

@Nullable
@Override
public <I extends BlockEntity> BlockEntityTicker<I> getTicker(final Level level,
public <E extends BlockEntity> BlockEntityTicker<E> getTicker(final Level level,
final BlockState blockState,
final BlockEntityType<I> type) {
final BlockEntityType<E> type) {
return ticker.get(level, type);
}
}
Loading

0 comments on commit 39f97d5

Please sign in to comment.