mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-28 03:56:59 -05:00
NeoForge 1.21.5 Port
This commit is contained in:
@@ -8,7 +8,7 @@ buildscript {
|
||||
|
||||
plugins {
|
||||
id "architectury-plugin" version "3.4-SNAPSHOT"
|
||||
id "dev.architectury.loom" version "1.9-SNAPSHOT" apply false
|
||||
id "dev.architectury.loom" version "1.10-SNAPSHOT" apply false
|
||||
id "org.cadixdev.licenser" version "0.6.1"
|
||||
id "me.shedaniel.unified-publishing" version "0.1.+" apply false
|
||||
id "maven-publish"
|
||||
|
||||
@@ -385,7 +385,7 @@ public final class BiomeHooks {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<MobCategory, List<MobSpawnSettings.SpawnerData>> getSpawners() {
|
||||
public Map<MobCategory, WeightedList.Builder<MobSpawnSettings.SpawnerData>> getSpawners() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,18 +19,18 @@
|
||||
|
||||
package dev.architectury.hooks.level.biome;
|
||||
|
||||
import net.minecraft.util.random.WeightedList;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiPredicate;
|
||||
|
||||
public interface SpawnProperties {
|
||||
float getCreatureProbability();
|
||||
|
||||
Map<MobCategory, List<MobSpawnSettings.SpawnerData>> getSpawners();
|
||||
Map<MobCategory, WeightedList.Builder<MobSpawnSettings.SpawnerData>> getSpawners();
|
||||
|
||||
Map<EntityType<?>, MobSpawnSettings.MobSpawnCost> getMobSpawnCosts();
|
||||
|
||||
|
||||
@@ -52,12 +52,18 @@ public class TradeRegistry {
|
||||
* Register a trade ({@link VillagerTrades.ItemListing}) to a wandering trader by its rarity.
|
||||
* When the mod loader is Forge, the {@code WandererTradesEvent} event is used.
|
||||
*
|
||||
* @param rare Whether this trade is "rare". Rare trades have a five times lower chance of being used.
|
||||
* @param type The type of trade to add to the wandering trader.
|
||||
* @param trades The trades to add to the wandering trader.
|
||||
*/
|
||||
@ExpectPlatform
|
||||
public static void registerTradeForWanderingTrader(boolean rare, VillagerTrades.ItemListing... trades) {
|
||||
public static void registerTradeForWanderingTrader(WandererTradeType type, VillagerTrades.ItemListing... trades) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
public enum WandererTradeType {
|
||||
BUYING_TRADES,
|
||||
GENERIC_TRADES,
|
||||
RARE_TRADES,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ unifiedPublishing {
|
||||
curseforge {
|
||||
token = CURSE_API_KEY
|
||||
id = rootProject.curseforge_id
|
||||
gameVersions.addAll "Java 21", "1.21.5-Snapshot" // , project.minecraft_version
|
||||
gameVersions.addAll "Java 21", "1.21.5-Snapshot", project.minecraft_version
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package dev.architectury.registry.level.entity.trade.fabric;
|
||||
|
||||
import dev.architectury.registry.level.entity.trade.TradeRegistry;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.entity.npc.VillagerProfession;
|
||||
@@ -31,7 +32,13 @@ public class TradeRegistryImpl {
|
||||
TradeOfferHelper.registerVillagerOffers(profession, level, allTradesList -> Collections.addAll(allTradesList, trades));
|
||||
}
|
||||
|
||||
public static void registerTradeForWanderingTrader(boolean rare, VillagerTrades.ItemListing... trades) {
|
||||
TradeOfferHelper.registerWanderingTraderOffers(rare ? 2 : 1, allTradesList -> Collections.addAll(allTradesList, trades));
|
||||
public static void registerTradeForWanderingTrader(TradeRegistry.WandererTradeType type, VillagerTrades.ItemListing... trades) {
|
||||
TradeOfferHelper.registerWanderingTraderOffers(builder -> {
|
||||
builder.addAll(switch (type) {
|
||||
case BUYING_TRADES -> TradeOfferHelper.WanderingTraderOffersBuilder.BUY_ITEMS_POOL;
|
||||
case GENERIC_TRADES -> TradeOfferHelper.WanderingTraderOffersBuilder.SELL_COMMON_ITEMS_POOL;
|
||||
case RARE_TRADES -> TradeOfferHelper.WanderingTraderOffersBuilder.SELL_SPECIAL_ITEMS_POOL;
|
||||
}, trades);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
org.gradle.jvmargs=-Xmx6G
|
||||
org.gradle.daemon=false
|
||||
|
||||
platforms=fabric
|
||||
platforms=fabric,neoforge
|
||||
|
||||
minecraft_version=1.21.5-rc1
|
||||
supported_version=1.21.5-rc1
|
||||
minecraft_version=1.21.5
|
||||
supported_version=1.21.5
|
||||
|
||||
artifact_type=beta
|
||||
artifact_type=release
|
||||
|
||||
archives_base_name=architectury
|
||||
archives_base_name_snapshot=architectury-snapshot
|
||||
@@ -15,11 +15,11 @@ maven_group=dev.architectury
|
||||
version_suffix=
|
||||
|
||||
fabric_loader_version=0.16.10
|
||||
fabric_api_version=0.119.3+1.21.5
|
||||
fabric_api_version=0.119.5+1.21.5
|
||||
mod_menu_version=11.0.1
|
||||
|
||||
forge_version=51.0.0
|
||||
neoforge_version=21.4.84-beta
|
||||
neoforge_version=21.5.1-beta
|
||||
|
||||
# Set to empty if not snapshots
|
||||
neoforge_pr=
|
||||
|
||||
@@ -121,7 +121,7 @@ unifiedPublishing {
|
||||
displayName = "[NeoForge $rootProject.supported_version] v$project.version"
|
||||
releaseType = "$rootProject.artifact_type"
|
||||
changelog = releaseChangelog()
|
||||
gameVersions = ["1.21.4"]
|
||||
gameVersions = ["1.21.5"]
|
||||
gameLoaders = ["neoforge"]
|
||||
mainPublication renameJarForPublication
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
@@ -262,7 +262,7 @@ class ArchitecturyFluidAttributesForge extends FluidType {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public SoundEvent getSound(@Nullable Player player, BlockGetter getter, BlockPos pos, SoundAction action) {
|
||||
public SoundEvent getSound(@Nullable LivingEntity entity, BlockGetter getter, BlockPos pos, SoundAction action) {
|
||||
if (getter instanceof BlockAndTintGetter level) {
|
||||
if (BUCKET_FILL.equals(action)) {
|
||||
return attributes.getFillSound(null, level, pos);
|
||||
|
||||
@@ -27,13 +27,13 @@ import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.util.TriState;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.neoforged.bus.api.EventPriority;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.neoforged.neoforge.common.util.TriState;
|
||||
import net.neoforged.neoforge.event.CommandEvent;
|
||||
import net.neoforged.neoforge.event.LootTableLoadEvent;
|
||||
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||
|
||||
@@ -111,7 +111,7 @@ public enum FluidStackImpl implements dev.architectury.fluid.FluidStack.FluidSta
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <D> D set(FluidStack value, DataComponentType<? super D> type, @Nullable D component) {
|
||||
public <D> D set(FluidStack value, DataComponentType<D> type, @Nullable D component) {
|
||||
return value.set(type, component);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import dev.architectury.extensions.ItemExtension;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Inventory.class)
|
||||
public class MixinInventory {
|
||||
@Shadow
|
||||
@Final
|
||||
public NonNullList<ItemStack> armor;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
public Player player;
|
||||
|
||||
@Inject(method = "tick", at = @At("RETURN"))
|
||||
private void updateItems(CallbackInfo ci) {
|
||||
for (var stack : armor) {
|
||||
Item item = stack.getItem();
|
||||
if (item instanceof ItemExtension extension) {
|
||||
extension.tickArmor(stack, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import dev.architectury.extensions.ItemExtension;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.neoforged.neoforge.common.extensions.IItemExtension;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(ItemExtension.class)
|
||||
public interface MixinItemExtension extends IItemExtension {
|
||||
@Nullable
|
||||
@Override
|
||||
default EquipmentSlot getEquipmentSlot(ItemStack stack) {
|
||||
return ((ItemExtension) this).getCustomEquipmentSlot(stack);
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.sounds.Music;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.util.random.SimpleWeightedRandomList;
|
||||
import net.minecraft.util.random.WeightedList;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.level.biome.*;
|
||||
@@ -237,7 +237,7 @@ public class BiomeModificationsImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<MobCategory, List<MobSpawnSettings.SpawnerData>> getSpawners() {
|
||||
public Map<MobCategory, WeightedList.Builder<MobSpawnSettings.SpawnerData>> getSpawners() {
|
||||
return builder.spawners;
|
||||
}
|
||||
|
||||
@@ -398,7 +398,7 @@ public class BiomeModificationsImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<SimpleWeightedRandomList<Music>> getBackgroundMusic() {
|
||||
public Optional<WeightedList<Music>> getBackgroundMusic() {
|
||||
return builder.backgroundMusic;
|
||||
}
|
||||
|
||||
@@ -469,7 +469,7 @@ public class BiomeModificationsImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mutable setBackgroundMusic(@Nullable SimpleWeightedRandomList<Music> music) {
|
||||
public Mutable setBackgroundMusic(@Nullable WeightedList<Music> music) {
|
||||
builder.backgroundMusic = Optional.ofNullable(music);
|
||||
return this;
|
||||
}
|
||||
@@ -551,8 +551,8 @@ public class BiomeModificationsImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mutable addSpawn(MobCategory category, MobSpawnSettings.SpawnerData data) {
|
||||
builder.addSpawn(category, data);
|
||||
public Mutable addSpawn(MobCategory category, MobSpawnSettings.SpawnerData data, int weight) {
|
||||
builder.addSpawn(category, weight, data);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -560,7 +560,9 @@ public class BiomeModificationsImpl {
|
||||
public boolean removeSpawns(BiPredicate<MobCategory, MobSpawnSettings.SpawnerData> predicate) {
|
||||
boolean removed = false;
|
||||
for (MobCategory type : builder.getSpawnerTypes()) {
|
||||
if (builder.getSpawner(type).removeIf(data -> predicate.test(type, data))) {
|
||||
int size = builder.getSpawner(type).getList().size();
|
||||
builder.getSpawner(type).removeIf(data -> predicate.test(type, data.value()));
|
||||
if (size != builder.getSpawner(type).getList().size()) {
|
||||
removed = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,11 @@
|
||||
|
||||
package dev.architectury.registry.level.entity.trade.forge;
|
||||
|
||||
import dev.architectury.registry.level.entity.trade.TradeRegistry;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.entity.npc.VillagerProfession;
|
||||
import net.minecraft.world.entity.npc.VillagerTrades;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
@@ -31,7 +33,8 @@ import net.neoforged.neoforge.event.village.WandererTradesEvent;
|
||||
import java.util.*;
|
||||
|
||||
public class TradeRegistryImpl {
|
||||
private static final Map<VillagerProfession, Int2ObjectMap<List<VillagerTrades.ItemListing>>> TRADES_TO_ADD = new HashMap<>();
|
||||
private static final Map<ResourceKey<VillagerProfession>, Int2ObjectMap<List<VillagerTrades.ItemListing>>> TRADES_TO_ADD = new HashMap<>();
|
||||
private static final List<VillagerTrades.ItemListing> WANDERER_TRADER_TRADES_BUYING = new ArrayList<>();
|
||||
private static final List<VillagerTrades.ItemListing> WANDERER_TRADER_TRADES_GENERIC = new ArrayList<>();
|
||||
private static final List<VillagerTrades.ItemListing> WANDERER_TRADER_TRADES_RARE = new ArrayList<>();
|
||||
|
||||
@@ -40,17 +43,19 @@ public class TradeRegistryImpl {
|
||||
NeoForge.EVENT_BUS.addListener(TradeRegistryImpl::onWanderingTradeRegistering);
|
||||
}
|
||||
|
||||
public static void registerVillagerTrade0(VillagerProfession profession, int level, VillagerTrades.ItemListing... trades) {
|
||||
public static void registerVillagerTrade0(ResourceKey<VillagerProfession> profession, int level, VillagerTrades.ItemListing... trades) {
|
||||
Int2ObjectMap<List<VillagerTrades.ItemListing>> tradesForProfession = TRADES_TO_ADD.computeIfAbsent(profession, $ -> new Int2ObjectOpenHashMap<>());
|
||||
List<VillagerTrades.ItemListing> tradesForLevel = tradesForProfession.computeIfAbsent(level, $ -> new ArrayList<>());
|
||||
Collections.addAll(tradesForLevel, trades);
|
||||
}
|
||||
|
||||
public static void registerTradeForWanderingTrader(boolean rare, VillagerTrades.ItemListing... trades) {
|
||||
if (rare) {
|
||||
public static void registerTradeForWanderingTrader(TradeRegistry.WandererTradeType type, VillagerTrades.ItemListing... trades) {
|
||||
if (type == TradeRegistry.WandererTradeType.RARE_TRADES) {
|
||||
Collections.addAll(WANDERER_TRADER_TRADES_RARE, trades);
|
||||
} else {
|
||||
} else if (type == TradeRegistry.WandererTradeType.GENERIC_TRADES) {
|
||||
Collections.addAll(WANDERER_TRADER_TRADES_GENERIC, trades);
|
||||
} else {
|
||||
Collections.addAll(WANDERER_TRADER_TRADES_BUYING, trades);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +70,9 @@ public class TradeRegistryImpl {
|
||||
}
|
||||
|
||||
public static void onWanderingTradeRegistering(WandererTradesEvent event) {
|
||||
if (!WANDERER_TRADER_TRADES_BUYING.isEmpty()) {
|
||||
event.getBuyingTrades().addAll(WANDERER_TRADER_TRADES_BUYING);
|
||||
}
|
||||
if (!WANDERER_TRADER_TRADES_GENERIC.isEmpty()) {
|
||||
event.getGenericTrades().addAll(WANDERER_TRADER_TRADES_GENERIC);
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
"neoforge.LiquidBlockAccessor",
|
||||
"neoforge.MixinChunkMap",
|
||||
"MixinFallingBlockEntity",
|
||||
"MixinInventory",
|
||||
"MixinItemExtension",
|
||||
"MixinLevelEvent"
|
||||
],
|
||||
"injectors": {
|
||||
|
||||
@@ -15,10 +15,10 @@ include("common")
|
||||
include("fabric")
|
||||
//include("forge")
|
||||
//include("minecraftforge")
|
||||
//include("neoforge")
|
||||
include("neoforge")
|
||||
include("testmod-common")
|
||||
include("testmod-fabric")
|
||||
//include("testmod-forge")
|
||||
//include("testmod-neoforge")
|
||||
include("testmod-neoforge")
|
||||
|
||||
rootProject.name = "architectury"
|
||||
|
||||
@@ -33,7 +33,7 @@ public class TestTrades {
|
||||
for (var villagerProfession : BuiltInRegistries.VILLAGER_PROFESSION.registryKeySet()) {
|
||||
TradeRegistry.registerVillagerTrade(villagerProfession, 1, TestTrades.createTrades());
|
||||
}
|
||||
TradeRegistry.registerTradeForWanderingTrader(false, TestTrades.createTrades());
|
||||
TradeRegistry.registerTradeForWanderingTrader(TradeRegistry.WandererTradeType.GENERIC_TRADES, TestTrades.createTrades());
|
||||
}
|
||||
|
||||
private static VillagerTrades.ItemListing[] createTrades() {
|
||||
|
||||
Reference in New Issue
Block a user