Merge remote-tracking branch 'architectury/1.16' into 1.17

Signed-off-by: shedaniel <daniel@shedaniel.me>

# Conflicts:
#	.github/workflows/publish.yml
#	.github/workflows/snapshot.yml
#	build.gradle
#	common/src/main/resources/architectury-common.mixins.json
#	fabric/src/main/java/me/shedaniel/architectury/mixin/fabric/MixinLevelChunk.java
#	fabric/src/main/java/me/shedaniel/architectury/mixin/fabric/MixinServerGamePacketListenerImpl.java
#	fabric/src/main/java/me/shedaniel/architectury/mixin/fabric/MixinServerLevel.java
#	fabric/src/main/java/me/shedaniel/architectury/mixin/fabric/client/MixinMouseHandler.java
#	fabric/src/main/java/me/shedaniel/architectury/mixin/fabric/client/MixinScreen.java
#	forge/gradle.properties
#	gradle.properties
#	gradle/wrapper/gradle-wrapper.properties
#	testmod-fabric/build.gradle
#	testmod-forge/gradle.properties
This commit is contained in:
shedaniel
2021-05-19 22:25:49 +08:00
98 changed files with 1966 additions and 394 deletions

View File

@@ -68,7 +68,7 @@ publishing {
}
}
}
repositories {
if (System.getenv("MAVEN_PASS") != null) {
maven {

View File

@@ -1 +1 @@
loom.platform=forge
loom.platform=forge

View File

@@ -23,7 +23,8 @@ import me.shedaniel.architectury.fluid.FluidStack;
import me.shedaniel.architectury.utils.Fraction;
public final class FluidStackHooksForge {
private FluidStackHooksForge() {}
private FluidStackHooksForge() {
}
public static FluidStack fromForge(net.minecraftforge.fluids.FluidStack stack) {
return FluidStack.create(stack.getFluid().delegate, Fraction.ofWhole(stack.getAmount()), stack.getTag());

View File

@@ -33,7 +33,6 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.DistExecutor;

View File

@@ -25,7 +25,8 @@ import java.util.*;
import java.util.function.Consumer;
public final class EventBuses {
private EventBuses() {}
private EventBuses() {
}
private static final Map<String, IEventBus> EVENT_BUS_MAP = new HashMap<>();
private static final Map<String, List<Consumer<IEventBus>>> ON_REGISTERED = new HashMap<>();

View File

@@ -27,7 +27,6 @@ import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Supplier;

View File

@@ -157,7 +157,9 @@ public class BiomeModificationsImpl {
private static class GenerationSettingsBuilderWrapped implements GenerationProperties {
protected final BiomeGenerationSettingsBuilder generation;
public GenerationSettingsBuilderWrapped(BiomeGenerationSettingsBuilder generation) {this.generation = generation;}
public GenerationSettingsBuilderWrapped(BiomeGenerationSettingsBuilder generation) {
this.generation = generation;
}
@Override
public @NotNull Optional<Supplier<ConfiguredSurfaceBuilder<?>>> getSurfaceBuilder() {
@@ -184,7 +186,9 @@ public class BiomeModificationsImpl {
private static class SpawnSettingsBuilderWrapped implements SpawnProperties {
protected final MobSpawnInfoBuilder builder;
public SpawnSettingsBuilderWrapped(MobSpawnInfoBuilder builder) {this.builder = builder;}
public SpawnSettingsBuilderWrapped(MobSpawnInfoBuilder builder) {
this.builder = builder;
}
@Override
public float getCreatureProbability() {

View File

@@ -26,7 +26,8 @@ import net.minecraft.world.level.GameRules;
import java.util.function.BiConsumer;
public class GameRuleFactoryImpl {
private GameRuleFactoryImpl() {}
private GameRuleFactoryImpl() {
}
public static GameRules.Type<GameRules.BooleanValue> createBooleanRule(boolean defaultValue) {
return GameRulesAccessor.BooleanValueSimple.invokeCreateArchitectury(defaultValue);

View File

@@ -0,0 +1,75 @@
/*
* This file is part of architectury.
* Copyright (C) 2020, 2021 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 me.shedaniel.architectury.registry.trade.forge;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import me.shedaniel.architectury.forge.ArchitecturyForge;
import net.minecraft.core.NonNullList;
import net.minecraft.world.entity.npc.VillagerProfession;
import net.minecraft.world.entity.npc.VillagerTrades;
import net.minecraftforge.event.village.VillagerTradesEvent;
import net.minecraftforge.event.village.WandererTradesEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import java.util.*;
@Mod.EventBusSubscriber(modid = ArchitecturyForge.MOD_ID)
public class TradeRegistryImpl {
private static final Map<VillagerProfession, Int2ObjectMap<List<VillagerTrades.ItemListing>>> TRADES_TO_ADD = new HashMap<>();
private static final List<VillagerTrades.ItemListing> WANDERER_TRADER_TRADES_GENERIC = new ArrayList<>();
private static final List<VillagerTrades.ItemListing> WANDERER_TRADER_TRADES_RARE = new ArrayList<>();
public static void registerVillagerTrade0(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) {
Collections.addAll(WANDERER_TRADER_TRADES_RARE, trades);
} else {
Collections.addAll(WANDERER_TRADER_TRADES_GENERIC, trades);
}
}
@SubscribeEvent
public static void onTradeRegistering(VillagerTradesEvent event) {
Int2ObjectMap<List<VillagerTrades.ItemListing>> trades = TRADES_TO_ADD.get(event.getType());
if (trades != null) {
for (Int2ObjectMap.Entry<List<VillagerTrades.ItemListing>> entry : trades.int2ObjectEntrySet()) {
event.getTrades().computeIfAbsent(entry.getIntKey(), $ -> NonNullList.create()).addAll(entry.getValue());
}
}
}
@SubscribeEvent
public static void onWanderingTradeRegistering(WandererTradesEvent event) {
if (!WANDERER_TRADER_TRADES_GENERIC.isEmpty()) {
event.getGenericTrades().addAll(WANDERER_TRADER_TRADES_GENERIC);
}
if (!WANDERER_TRADER_TRADES_RARE.isEmpty()) {
event.getRareTrades().addAll(WANDERER_TRADER_TRADES_RARE);
}
}
}

View File

@@ -11,7 +11,7 @@ authors = "shedaniel"
description = '''
A intermediary api aimed to ease developing multiplatform mods.
'''
logoFile="icon.png"
logoFile = "icon.png"
license = "LGPL-3"
[[dependencies.architectury]]

View File

@@ -7,9 +7,17 @@
"client": [
],
"mixins": [
"BiomeGenerationSettingsBuilderAccessor", "GameRulesAccessor", "GameRulesAccessor$BooleanValue", "GameRulesAccessor$BooleanValueSimple",
"GameRulesAccessor$IntegerValue", "GameRulesAccessor$IntegerValueSimple", "MixinBlockEntity", "MixinBlockEntityExtension", "MixinItemExtension",
"MixinRegistryEntry", "MobSpawnSettingsBuilderAccessor"
"BiomeGenerationSettingsBuilderAccessor",
"GameRulesAccessor",
"GameRulesAccessor$BooleanValue",
"GameRulesAccessor$BooleanValueSimple",
"GameRulesAccessor$IntegerValue",
"GameRulesAccessor$IntegerValueSimple",
"MixinBlockEntity",
"MixinBlockEntityExtension",
"MixinItemExtension",
"MixinRegistryEntry",
"MobSpawnSettingsBuilderAccessor"
],
"injectors": {
"defaultRequire": 1