Skip to content

Commit

Permalink
Port to 1.20.6 (#494)
Browse files Browse the repository at this point in the history
* Begin port to 1.20.6

* Port to 1.20.6

* decrease diff

* Fix Creative Tab Ordering

* add test for creative tab ordering

* change up test

* add github actions build for 1.20.6

* fix some outdated things in the github actions

* use the mod bus instead of the neoforge bus when registering menu screens

* update versions in `build.gradle`

* change to 20.6.70-beta

* require 20.6.70

* this doesn't need fabric

Signed-off-by: shedaniel <[email protected]>

---------

Signed-off-by: shedaniel <[email protected]>
Co-authored-by: shedaniel <[email protected]>
  • Loading branch information
Jab125 and shedaniel authored May 18, 2024
1 parent 26bf197 commit ba78f46
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build PR snapshot (1.19)
name: Build PR snapshot (1.20.6)

on:
pull_request:
Expand All @@ -7,7 +7,7 @@ on:
- '**.properties'
- '**/src/**'
branches:
- "1.20.4"
- "1.20.6"
types: [ opened, synchronize, reopened ]
jobs:
validate-gradle:
Expand All @@ -25,10 +25,10 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v2
with:
java-version: 17
java-version: 21
distribution: 'temurin'

- name: Setup Gradle and verify license using Licenser
Expand All @@ -44,10 +44,10 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v2
with:
java-version: 17
java-version: 21
distribution: 'temurin'

- name: Setup and Build with Gradle
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Release (1.19)
name: Build and Release (1.20.6)

on:
push:
Expand All @@ -8,7 +8,7 @@ on:
- '**/src/**'
- '.github/**'
branches:
- "1.20.5"
- "1.20.6"
workflow_dispatch:
inputs:
norelease:
Expand Down
4 changes: 2 additions & 2 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
},
"icon": "icon.png",
"depends": {
"minecraft": "~1.20.5-",
"minecraft": "~1.20.6-",
"fabricloader": ">=0.15.6",
"fabric-api": ">=0.97.6"
"fabric-api": ">=0.98.0"
},
"breaks": {
"optifabric": "<1.13.0"
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ org.gradle.daemon=false

platforms=fabric,neoforge

minecraft_version=1.20.5
supported_version=1.20.5
minecraft_version=1.20.6
supported_version=1.20.6

artifact_type=release

Expand All @@ -15,11 +15,11 @@ maven_group=dev.architectury
version_suffix=

fabric_loader_version=0.15.10
fabric_api_version=0.97.6+1.20.5
fabric_api_version=0.98.0+1.20.6
mod_menu_version=10.0.0-beta.1

forge_version=50.0.0
neoforge_version=20.5.20-beta
neoforge_version=20.6.70-beta

# Set to empty if not snapshots
neoforge_pr=
Expand Down
2 changes: 1 addition & 1 deletion minecraftforge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ unifiedPublishing {
displayName = "[MinecraftForge $rootProject.supported_version] v$project.version"
releaseType = "$rootProject.artifact_type"
changelog = releaseChangelog()
gameVersions = ["1.20.4"]
gameVersions = ["1.20.6"]
gameLoaders = ["forge"]
mainPublication renameJarForPublication

Expand Down
2 changes: 1 addition & 1 deletion neoforge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ unifiedPublishing {
displayName = "[NeoForge $rootProject.supported_version] v$project.version"
releaseType = "$rootProject.artifact_type"
changelog = releaseChangelog()
gameVersions = ["1.20.5"]
gameVersions = ["1.20.6"]
gameLoaders = ["neoforge"]
mainPublication renameJarForPublication

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package dev.architectury.core.item.forge.imitator;

import dev.architectury.hooks.fluid.FluidBucketHooks;
import dev.architectury.platform.hooks.EventBusesHooks;
import dev.architectury.utils.ArchitecturyConstants;
import net.minecraft.core.registries.BuiltInRegistries;
Expand Down Expand Up @@ -49,6 +50,6 @@ public ArchitecturyBucketItem(Supplier<? extends Fluid> fluid, Properties proper
}

public final Fluid getContainedFluid() {
return getFluid();
return FluidBucketHooks.getFluid(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent;
import net.neoforged.neoforge.event.entity.item.ItemTossEvent;
import net.neoforged.neoforge.event.entity.living.AnimalTameEvent;
import net.neoforged.neoforge.event.entity.living.FinalizeSpawnEvent;
import net.neoforged.neoforge.event.entity.living.LivingAttackEvent;
import net.neoforged.neoforge.event.entity.living.LivingDeathEvent;
import net.neoforged.neoforge.event.entity.living.MobSpawnEvent;
import net.neoforged.neoforge.event.entity.player.*;
import net.neoforged.neoforge.event.entity.player.PlayerEvent.*;
import net.neoforged.neoforge.event.level.BlockEvent.BreakEvent;
Expand Down Expand Up @@ -268,8 +268,8 @@ public static void event(FillBucketEvent event) {
// }

@SubscribeEvent(priority = EventPriority.HIGH)
public static void eventLivingSpawnEvent(MobSpawnEvent.FinalizeSpawn event) {
EventResult result = EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(event.getEntity(), event.getLevel(), event.getX(), event.getY(), event.getZ(), event.getSpawnType(), event.getSpawner());
public static void eventLivingSpawnEvent(FinalizeSpawnEvent event) {
EventResult result = EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(event.getEntity(), event.getLevel(), event.getX(), event.getY(), event.getZ(), event.getSpawnType(), null);//TODO FIX: , event.getSpawner());
if (result.interruptsFurtherEvaluation()) {
if (!result.isEmpty()) {
event.setSpawnCancelled(result.value());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@

package dev.architectury.hooks.fluid.forge;

import dev.architectury.mixin.forge.neoforge.BucketItemAccessor;
import net.minecraft.world.item.BucketItem;
import net.minecraft.world.level.material.Fluid;

public class FluidBucketHooksImpl {
public static Fluid getFluid(BucketItem item) {
return item.getFluid();
return ((BucketItemAccessor) item).getContent();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* This file is part of architectury.
* Copyright (C) 2020, 2021, 2022 architectury
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

package dev.architectury.mixin.forge.neoforge;

import net.minecraft.world.item.BucketItem;
import net.minecraft.world.level.material.Fluid;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(BucketItem.class)
public interface BucketItemAccessor {
@Accessor("content")
Fluid getContent();
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ public void acceptAfter(ItemStack after, ItemStack stack, CreativeModeTab.TabVis
if (after.isEmpty()) {
entries.put(stack, visibility);
} else {
for (Map.Entry<ItemStack, CreativeModeTab.TabVisibility> entry : entries) {
if (ItemStack.isSameItemSameComponents(entry.getKey(), after)) {
after = entry.getKey();
break;
}
}
entries.putAfter(after, stack, visibility);
}
}
Expand All @@ -185,6 +191,12 @@ public void acceptBefore(ItemStack before, ItemStack stack, CreativeModeTab.TabV
if (before.isEmpty()) {
entries.put(stack, visibility);
} else {
for (Map.Entry<ItemStack, CreativeModeTab.TabVisibility> entry : entries) {
if (ItemStack.isSameItemSameComponents(entry.getKey(), before)) {
before = entry.getKey();
break;
}
}
entries.putBefore(before, stack, visibility);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@

package dev.architectury.registry.menu.forge;

import dev.architectury.platform.hooks.EventBusesHooks;
import dev.architectury.registry.menu.ExtendedMenuProvider;
import dev.architectury.registry.menu.MenuRegistry.ExtendedMenuTypeFactory;
import dev.architectury.registry.menu.MenuRegistry.ScreenFactory;
import dev.architectury.registry.menu.MenuRegistry.SimpleMenuTypeFactory;
import dev.architectury.utils.ArchitecturyConstants;
import net.minecraft.client.gui.screens.MenuScreens;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.MenuAccess;
Expand All @@ -32,6 +34,8 @@
import net.minecraft.world.inventory.MenuType;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.common.extensions.IMenuTypeExtension;

public class MenuRegistryImpl {
Expand All @@ -48,8 +52,11 @@ public static <T extends AbstractContainerMenu> MenuType<T> ofExtended(ExtendedM
return IMenuTypeExtension.create(factory::create);
}

@SuppressWarnings("CodeBlock2Expr") // It's neater this way
@OnlyIn(Dist.CLIENT)
public static <H extends AbstractContainerMenu, S extends Screen & MenuAccess<H>> void registerScreenFactory(MenuType<? extends H> type, ScreenFactory<H, S> factory) {
MenuScreens.register(type, factory::create);
EventBusesHooks.whenAvailable(ArchitecturyConstants.MOD_ID, bus -> {
bus.addListener(RegisterMenuScreensEvent.class, event -> event.register(type, factory::create));
});
}
}
4 changes: 2 additions & 2 deletions neoforge/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ license = "LGPL-3"
[[dependencies.architectury]]
modId = "minecraft"
type = "required"
versionRange = "[1.20.5,)"
versionRange = "[1.20.6,)"
ordering = "NONE"
side = "BOTH"

[[dependencies.architectury]]
modId = "neoforge"
type = "required"
versionRange = "[20.5.0-beta,)"
versionRange = "[20.6.70-beta,)"
ordering = "NONE"
side = "BOTH"

Expand Down
1 change: 1 addition & 0 deletions neoforge/src/main/resources/architectury.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"MixinMinecraft"
],
"mixins": [
"neoforge.BucketItemAccessor",
"neoforge.LiquidBlockAccessor",
"neoforge.MixinChunkSerializer",
"MixinFallingBlockEntity",
Expand Down
20 changes: 20 additions & 0 deletions testmod-common/src/main/java/dev/architectury/test/TestMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.mojang.brigadier.arguments.StringArgumentType;
import dev.architectury.event.events.client.ClientCommandRegistrationEvent;
import dev.architectury.event.events.client.ClientLifecycleEvent;
import dev.architectury.registry.CreativeTabRegistry;
import dev.architectury.registry.client.gui.ClientTooltipComponentRegistry;
import dev.architectury.registry.client.level.entity.EntityRendererRegistry;
import dev.architectury.test.debug.ConsoleMessageSink;
Expand All @@ -44,6 +45,17 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.renderer.entity.CowRenderer;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.item.enchantment.ItemEnchantments;
import net.minecraft.world.level.block.Blocks;

import java.util.Collections;
import java.util.List;

public class TestMod {
public static final MessageSink SINK = EnvExecutor.getEnvSpecific(() -> ClientOverlayMessageSink::new, () -> ConsoleMessageSink::new);
Expand All @@ -61,6 +73,14 @@ public static void initialize() {
TestLoot.init();
TestWorldGeneration.initialize();
EnvExecutor.runInEnv(Env.CLIENT, () -> TestMod.Client::initializeClient);
CreativeTabRegistry.modifyBuiltin(BuiltInRegistries.CREATIVE_MODE_TAB.get(CreativeModeTabs.BUILDING_BLOCKS), (flags, output, canUseGameMasterBlocks) -> {
ItemStack sword = Items.DIAMOND_SWORD.getDefaultInstance();
ItemEnchantments.Mutable mutable = new ItemEnchantments.Mutable(ItemEnchantments.EMPTY);
mutable.set(Enchantments.SHARPNESS, 10);
sword.set(DataComponents.ENCHANTMENTS, mutable.toImmutable());
output.acceptBefore(new ItemStack(Items.OAK_WOOD), sword);
output.acceptAfter(Blocks.STRIPPED_OAK_LOG, Items.BEDROCK);
});
}

@Environment(EnvType.CLIENT)
Expand Down

0 comments on commit ba78f46

Please sign in to comment.