Skip to content

Commit

Permalink
Merge pull request #112 from refinedmods/feat/GH-111/port
Browse files Browse the repository at this point in the history
feat: port to minecraft 1.20.4
  • Loading branch information
raoulvdberge authored Feb 16, 2024
2 parents a4c2d42 + e19e6b0 commit 5cb89b9
Show file tree
Hide file tree
Showing 24 changed files with 96 additions and 72 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ body:
options:
- Minecraft 1.19.2
- Minecraft 1.20.1
- Minecraft 1.20.4
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.7.1
uses: refinedmods/refinedarchitect/.github/workflows/build.yml@v0.11.4
with:
mutation-testing: false
sonarqube: false
Expand Down
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.7.1
uses: refinedmods/refinedarchitect/.github/workflows/draft-release.yml@v0.11.4
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.7.1
uses: refinedmods/refinedarchitect/.github/workflows/issue-for-unsupported-version.yml@v0.11.4
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.7.1
uses: refinedmods/refinedarchitect/.github/workflows/publish-release.yml@v0.11.4
secrets: inherit
with:
project-name: 'Refined Storage Addons'
Expand Down
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.7.1
uses: refinedmods/refinedarchitect/.github/workflows/resolved-issue-locking.yml@v0.11.4
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.7.1
uses: refinedmods/refinedarchitect/.github/workflows/validate-branch-name.yml@v0.11.4
2 changes: 1 addition & 1 deletion .github/workflows/validate-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ on:
types: [ opened, synchronize, reopened, ready_for_review, labeled, unlabeled ]
jobs:
validate-changelog:
uses: refinedmods/refinedarchitect/.github/workflows/validate-changelog.yml@v0.7.1
uses: refinedmods/refinedarchitect/.github/workflows/validate-changelog.yml@v0.11.4
with:
validation-level: 'warn'
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.7.1
uses: refinedmods/refinedarchitect/.github/workflows/validate-commit-messages.yml@v0.11.4
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ eclipse/
.nb-gradle-properties
.project
*.launch
run/
runs/
*.iml
*.ipr
*.iws
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed

- Ported to Minecraft 1.20.4.

## [0.10.0] - 2023-07-05

### Added
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 © 2017 - 2023 Refined Mods
Copyright © 2017 - 2024 Refined Mods

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apply from: "https://raw.githubusercontent.com/refinedmods/refinedarchitect/v0.7.1/helper.gradle"
apply from: "https://raw.githubusercontent.com/refinedmods/refinedarchitect/v0.11.4/helper.gradle"

repositories {
maven {
Expand Down Expand Up @@ -28,8 +28,8 @@ enableModrinth("Z4Z5ccuT")
enableJavadoc()

dependencies {
compileOnly "com.refinedmods:refinedstorage:1.12.1"
runtimeOnly fg.deobf("com.refinedmods:refinedstorage:1.12.1") {
transitive false
compileOnly "com.refinedmods:refinedstorage:1.13.0-beta.2"
runtimeOnly("com.refinedmods:refinedstorage:1.13.0-beta.2") {
transitive = false
}
}
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
34 changes: 17 additions & 17 deletions src/main/java/com/refinedmods/refinedstorageaddons/RSAddons.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import com.refinedmods.refinedstorageaddons.config.ServerConfig;
import com.refinedmods.refinedstorageaddons.setup.ClientSetup;
import com.refinedmods.refinedstorageaddons.setup.CommonSetup;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.config.ModConfig;
import net.neoforged.fml.loading.FMLEnvironment;
import net.neoforged.neoforge.common.NeoForge;

@Mod(RSAddons.ID)
public final class RSAddons {
Expand All @@ -21,19 +21,19 @@ public final class RSAddons {
public static final String ID = "refinedstorageaddons";
public static final ServerConfig SERVER_CONFIG = new ServerConfig();

public RSAddons() {
//new ItemStack(RSAddonsItems.CREATIVE_WIRELESS_CRAFTING_GRID.get())
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> {
FMLJavaModLoadingContext.get().getModEventBus().addListener(ClientSetup::onClientSetup);
MinecraftForge.EVENT_BUS.addListener(ClientSetup::onKeyInput);
FMLJavaModLoadingContext.get().getModEventBus().addListener(ClientSetup::onRegisterKeymappings);
});
public RSAddons(IEventBus eventBus) {
if (FMLEnvironment.dist == Dist.CLIENT) {
eventBus.addListener(ClientSetup::onClientSetup);
eventBus.addListener(ClientSetup::onRegisterKeymappings);
NeoForge.EVENT_BUS.addListener(ClientSetup::onKeyInput);
}

RSAddonsItems.register();
RSAddonsItems.register(eventBus);

ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, SERVER_CONFIG.getSpec());

FMLJavaModLoadingContext.get().getModEventBus().addListener(CommonSetup::onCommonSetup);
FMLJavaModLoadingContext.get().getModEventBus().addListener(CommonSetup::onRegister);
eventBus.addListener(CommonSetup::onCommonSetup);
eventBus.addListener(CommonSetup::onRegisterCapabilities);
eventBus.addListener(CommonSetup::onRegister);
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
package com.refinedmods.refinedstorageaddons;

import com.refinedmods.refinedstorageaddons.item.WirelessCraftingGridItem;

import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.item.Item;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredRegister;

public final class RSAddonsItems {
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, RSAddons.ID);
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(BuiltInRegistries.ITEM, RSAddons.ID);

static {
WIRELESS_CRAFTING_GRID = ITEMS.register("wireless_crafting_grid", () -> new WirelessCraftingGridItem(WirelessCraftingGridItem.Type.NORMAL));
CREATIVE_WIRELESS_CRAFTING_GRID = ITEMS.register("creative_wireless_crafting_grid", () -> new WirelessCraftingGridItem(WirelessCraftingGridItem.Type.CREATIVE));
}

public static final RegistryObject<WirelessCraftingGridItem> WIRELESS_CRAFTING_GRID;
public static final RegistryObject<WirelessCraftingGridItem> CREATIVE_WIRELESS_CRAFTING_GRID;
public static final DeferredHolder<Item, WirelessCraftingGridItem> WIRELESS_CRAFTING_GRID;
public static final DeferredHolder<Item, WirelessCraftingGridItem> CREATIVE_WIRELESS_CRAFTING_GRID;

public static void register() {
ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());
public static void register(IEventBus eventBus) {
ITEMS.register(eventBus);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.mojang.blaze3d.platform.InputConstants;
import net.minecraft.client.KeyMapping;
import net.minecraftforge.client.settings.KeyConflictContext;
import net.minecraftforge.client.settings.KeyModifier;
import net.neoforged.neoforge.client.settings.KeyConflictContext;
import net.neoforged.neoforge.client.settings.KeyModifier;
import org.lwjgl.glfw.GLFW;

public final class RSAddonsKeyBindings {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.energy.IEnergyStorage;
import net.neoforged.neoforge.capabilities.Capabilities;
import net.neoforged.neoforge.energy.IEnergyStorage;

public class WirelessCraftingGridNetworkItem implements INetworkItem {
private final INetworkItemManager handler;
Expand All @@ -37,7 +37,7 @@ public Player getPlayer() {

@Override
public boolean onOpen(INetwork network) {
IEnergyStorage energy = stack.getCapability(ForgeCapabilities.ENERGY, null).orElse(null);
IEnergyStorage energy = stack.getCapability(Capabilities.EnergyStorage.ITEM);

if (RSAddons.SERVER_CONFIG.getWirelessCraftingGrid().getUseEnergy() &&
((WirelessCraftingGridItem) stack.getItem()).getType() != WirelessCraftingGridItem.Type.CREATIVE &&
Expand All @@ -64,7 +64,8 @@ public boolean onOpen(INetwork network) {
@Override
public void drainEnergy(int energy) {
if (RSAddons.SERVER_CONFIG.getWirelessCraftingGrid().getUseEnergy() && ((WirelessCraftingGridItem) stack.getItem()).getType() != WirelessCraftingGridItem.Type.CREATIVE) {
stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(energyStorage -> {
IEnergyStorage energyStorage = stack.getCapability(Capabilities.EnergyStorage.ITEM);
if (energyStorage != null) {
energyStorage.extractEnergy(energy, false);

if (energyStorage.getEnergyStored() <= 0) {
Expand All @@ -74,7 +75,7 @@ public void drainEnergy(int energy) {

sendOutOfEnergyMessage();
}
});
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.refinedmods.refinedstorageaddons.config;

import net.minecraftforge.common.ForgeConfigSpec;
import net.neoforged.neoforge.common.ModConfigSpec;

public class ServerConfig {
private ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
private ForgeConfigSpec spec;
private WirelessCraftingGrid wirelessCraftingGrid;
private final ModConfigSpec.Builder builder = new ModConfigSpec.Builder();
private final ModConfigSpec spec;
private final WirelessCraftingGrid wirelessCraftingGrid;

public ServerConfig() {
wirelessCraftingGrid = new WirelessCraftingGrid();
Expand All @@ -18,11 +18,11 @@ public WirelessCraftingGrid getWirelessCraftingGrid() {
}

public class WirelessCraftingGrid {
private final ForgeConfigSpec.BooleanValue useEnergy;
private final ForgeConfigSpec.IntValue capacity;
private final ForgeConfigSpec.IntValue openUsage;
private final ForgeConfigSpec.IntValue craftUsage;
private final ForgeConfigSpec.IntValue clearUsage;
private final ModConfigSpec.BooleanValue useEnergy;
private final ModConfigSpec.IntValue capacity;
private final ModConfigSpec.IntValue openUsage;
private final ModConfigSpec.IntValue craftUsage;
private final ModConfigSpec.IntValue clearUsage;

public WirelessCraftingGrid() {
builder.push("wirelessCraftingGrid");
Expand Down Expand Up @@ -57,7 +57,7 @@ public int getClearUsage() {
}
}

public ForgeConfigSpec getSpec() {
public ModConfigSpec getSpec() {
return spec;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import net.minecraft.world.inventory.TransientCraftingContainer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.CraftingRecipe;
import net.minecraft.world.item.crafting.RecipeHolder;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.Level;

Expand Down Expand Up @@ -108,7 +109,9 @@ public ResultContainer getCraftingResult() {
@Override
public void onCraftingMatrixChanged() {
if (currentRecipe == null || !currentRecipe.matches(craftingContainer, level)) {
currentRecipe = level.getRecipeManager().getRecipeFor(RecipeType.CRAFTING, craftingContainer, level).orElse(null);
currentRecipe = level.getRecipeManager().getRecipeFor(RecipeType.CRAFTING, craftingContainer, level)
.map(RecipeHolder::value)
.orElse(null);
}
if (currentRecipe == null) {
craftingResultContainer.setItem(0, ItemStack.EMPTY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
import net.neoforged.neoforge.client.event.InputEvent;
import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent;

public final class ClientSetup {
private ClientSetup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
import com.refinedmods.refinedstorageaddons.apiimpl.network.grid.WirelessCraftingGridGridFactory;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.registries.RegisterEvent;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
import net.neoforged.neoforge.capabilities.Capabilities;
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
import net.neoforged.neoforge.registries.RegisterEvent;

public final class CommonSetup {
private CommonSetup() {
Expand All @@ -20,10 +23,19 @@ public static void onCommonSetup(FMLCommonSetupEvent e) {
RSAddons.RSAPI.getGridManager().add(WirelessCraftingGridGridFactory.ID, new WirelessCraftingGridGridFactory());
}

@SubscribeEvent
public static void onRegisterCapabilities(RegisterCapabilitiesEvent e) {
e.registerItem(
Capabilities.EnergyStorage.ITEM,
(stack, ctx) -> RSAddonsItems.WIRELESS_CRAFTING_GRID.get().createEnergyStorage(stack),
RSAddonsItems.WIRELESS_CRAFTING_GRID.get()
);
}

@SubscribeEvent
public static void onRegister(RegisterEvent e) {
e.register(Registries.CREATIVE_MODE_TAB, helper -> {
helper.register("general", CreativeModeTab.builder()
helper.register(new ResourceLocation(RSAddons.ID, "general"), CreativeModeTab.builder()
.title(Component.translatable("itemGroup.refinedstorageaddons"))
.icon(() -> new ItemStack(RSAddonsItems.CREATIVE_WIRELESS_CRAFTING_GRID.get()))
.displayItems((params, output) -> {
Expand Down
Loading

0 comments on commit 5cb89b9

Please sign in to comment.