mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-28 03:56:59 -05:00
Merge remote-tracking branch 'architectury/1.18.2' into 1.19
# Conflicts: # gradle.properties
This commit is contained in:
@@ -21,11 +21,9 @@ package dev.architectury.core.fluid;
|
||||
|
||||
import com.google.common.base.Suppliers;
|
||||
import dev.architectury.fluid.FluidStack;
|
||||
import dev.architectury.registry.registries.Registries;
|
||||
import dev.architectury.registry.registries.RegistrySupplier;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
@@ -69,7 +67,7 @@ public class SimpleArchitecturyFluidAttributes implements ArchitecturyFluidAttri
|
||||
private SoundEvent fillSound = SoundEvents.BUCKET_FILL;
|
||||
@Nullable
|
||||
private SoundEvent emptySound = SoundEvents.BUCKET_EMPTY;
|
||||
private final Supplier<String> defaultTranslationKey = Suppliers.memoize(() -> Util.makeDescriptionId("fluid", Registries.getId(getSourceFluid(), Registry.FLUID_REGISTRY)));
|
||||
private final Supplier<String> defaultTranslationKey = Suppliers.memoize(() -> Util.makeDescriptionId("fluid", getSourceFluid().arch$registryName()));
|
||||
|
||||
public static SimpleArchitecturyFluidAttributes ofSupplier(Supplier<? extends Supplier<? extends Fluid>> flowingFluid, Supplier<? extends Supplier<? extends Fluid>> sourceFluid) {
|
||||
return of(() -> flowingFluid.get().get(), () -> sourceFluid.get().get());
|
||||
|
||||
@@ -19,11 +19,9 @@
|
||||
|
||||
package dev.architectury.core.item;
|
||||
|
||||
import dev.architectury.registry.registries.Registries;
|
||||
import dev.architectury.registry.registries.RegistrySupplier;
|
||||
import net.minecraft.core.BlockSource;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.dispenser.DefaultDispenseItemBehavior;
|
||||
import net.minecraft.core.dispenser.DispenseItemBehavior;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -76,8 +74,8 @@ public class ArchitecturySpawnEggItem extends SpawnEggItem {
|
||||
this.entityType = Objects.requireNonNull(entityType, "entityType");
|
||||
SpawnEggItem.BY_ID.remove(null);
|
||||
entityType.listen(type -> {
|
||||
LOGGER.debug("Registering spawn egg {} for {}", Objects.toString(Registries.getId(this, Registry.ITEM_REGISTRY)),
|
||||
Objects.toString(Registries.getId(type, Registry.ENTITY_TYPE_REGISTRY)));
|
||||
LOGGER.debug("Registering spawn egg {} for {}", toString(),
|
||||
Objects.toString(type.arch$registryName()));
|
||||
SpawnEggItem.BY_ID.put(type, this);
|
||||
this.defaultType = type;
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.extensions.injected;
|
||||
|
||||
import dev.architectury.registry.registries.Registries;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
public interface InjectedBlockExtension extends InjectedRegistryEntryExtension<Block> {
|
||||
@Override
|
||||
default Holder<Block> arch$holder() {
|
||||
return ((Block) this).builtInRegistryHolder();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package dev.architectury.extensions.injected;
|
||||
|
||||
import dev.architectury.hooks.fluid.FluidBucketHooks;
|
||||
import net.minecraft.world.item.BucketItem;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
|
||||
public interface InjectedBucketItemExtension {
|
||||
default Fluid arch$getFluid() {
|
||||
return FluidBucketHooks.getFluid((BucketItem) this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.extensions.injected;
|
||||
|
||||
import dev.architectury.registry.registries.Registries;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
|
||||
public interface InjectedEntityTypeExtension extends InjectedRegistryEntryExtension<EntityType<?>> {
|
||||
@Override
|
||||
default Holder<EntityType<?>> arch$holder() {
|
||||
return ((EntityType<?>) this).builtInRegistryHolder();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.extensions.injected;
|
||||
|
||||
import dev.architectury.registry.registries.Registries;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
|
||||
public interface InjectedFluidExtension extends InjectedRegistryEntryExtension<Fluid> {
|
||||
@Override
|
||||
default Holder<Fluid> arch$holder() {
|
||||
return ((Fluid) this).builtInRegistryHolder();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.extensions.injected;
|
||||
|
||||
import dev.architectury.hooks.item.food.FoodPropertiesHooks;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.food.FoodProperties;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public interface InjectedFoodPropertiesBuilderExtension {
|
||||
default FoodProperties.Builder arch$effect(Supplier<? extends MobEffectInstance> effectSupplier, float chance) {
|
||||
FoodPropertiesHooks.effect((FoodProperties.Builder) this, effectSupplier, chance);
|
||||
return (FoodProperties.Builder) this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.extensions.injected;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
|
||||
public interface InjectedGameEventExtension extends InjectedRegistryEntryExtension<GameEvent> {
|
||||
@Override
|
||||
default Holder<GameEvent> arch$holder() {
|
||||
return ((GameEvent) this).builtInRegistryHolder();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.extensions.injected;
|
||||
|
||||
import dev.architectury.registry.registries.Registries;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
public interface InjectedItemExtension extends InjectedRegistryEntryExtension<Item> {
|
||||
@Override
|
||||
default Holder<Item> arch$holder() {
|
||||
return ((Item) this).builtInRegistryHolder();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.extensions.injected;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface InjectedRegistryEntryExtension<T> {
|
||||
Holder<T> arch$holder();
|
||||
|
||||
@Nullable
|
||||
default ResourceLocation arch$registryName() {
|
||||
return arch$holder().unwrapKey().map(ResourceKey::location).orElse(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package dev.architectury.mixin.inject;
|
||||
|
||||
import dev.architectury.extensions.injected.InjectedBlockExtension;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(Block.class)
|
||||
public class MixinBlock implements InjectedBlockExtension {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package dev.architectury.mixin.inject;
|
||||
|
||||
import dev.architectury.extensions.injected.InjectedGameEventExtension;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(BlockEntityType.class)
|
||||
public class MixinBlockEntityType implements InjectedGameEventExtension {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package dev.architectury.mixin.inject;
|
||||
|
||||
import dev.architectury.extensions.injected.InjectedBucketItemExtension;
|
||||
import net.minecraft.world.item.BucketItem;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(BucketItem.class)
|
||||
public class MixinBucketItem implements InjectedBucketItemExtension {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package dev.architectury.mixin.inject;
|
||||
|
||||
import dev.architectury.extensions.injected.InjectedEntityTypeExtension;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(EntityType.class)
|
||||
public class MixinEntityType implements InjectedEntityTypeExtension {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package dev.architectury.mixin.inject;
|
||||
|
||||
import dev.architectury.extensions.injected.InjectedFluidExtension;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(Fluid.class)
|
||||
public class MixinFluid implements InjectedFluidExtension {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package dev.architectury.mixin.inject;
|
||||
|
||||
import dev.architectury.extensions.injected.InjectedItemExtension;
|
||||
import net.minecraft.world.item.Item;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(Item.class)
|
||||
public class MixinItem implements InjectedItemExtension {
|
||||
}
|
||||
@@ -6,6 +6,12 @@
|
||||
"client": [
|
||||
],
|
||||
"mixins": [
|
||||
"inject.MixinBlock",
|
||||
"inject.MixinBlockEntityType",
|
||||
"inject.MixinBucketItem",
|
||||
"inject.MixinEntityType",
|
||||
"inject.MixinFluid",
|
||||
"inject.MixinItem",
|
||||
"MixinLightningBolt"
|
||||
],
|
||||
"injectors": {
|
||||
|
||||
@@ -1,3 +1,26 @@
|
||||
{
|
||||
"accessWidener": "architectury.accessWidener"
|
||||
"accessWidener": "architectury.accessWidener",
|
||||
"injected_interfaces": {
|
||||
"net/minecraft/class_1792": [
|
||||
"dev/architectury/extensions/injected/InjectedItemExtension"
|
||||
],
|
||||
"net/minecraft/class_2248": [
|
||||
"dev/architectury/extensions/injected/InjectedBlockExtension"
|
||||
],
|
||||
"net/minecraft/class_3611": [
|
||||
"dev/architectury/extensions/injected/InjectedFluidExtension"
|
||||
],
|
||||
"net/minecraft/class_1299": [
|
||||
"dev/architectury/extensions/injected/InjectedEntityTypeExtension"
|
||||
],
|
||||
"net/minecraft/class_2591": [
|
||||
"dev/architectury/extensions/injected/InjectedBlockEntityTypeExtension"
|
||||
],
|
||||
"net/minecraft/class_1755": [
|
||||
"dev/architectury/extensions/injected/InjectedBucketItemExtension"
|
||||
],
|
||||
"net/minecraft/class_4174$class_4175": [
|
||||
"dev/architectury/extensions/injected/InjectedFoodPropertiesBuilderExtension"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package dev.architectury.networking.fabric;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
import dev.architectury.networking.NetworkManager;
|
||||
import dev.architectury.networking.NetworkManager.NetworkReceiver;
|
||||
import dev.architectury.networking.transformers.PacketSink;
|
||||
@@ -38,10 +39,12 @@ import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.util.thread.BlockableEventLoop;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class NetworkManagerImpl {
|
||||
private static final Map<ResourceLocation, NetworkReceiver> C2S_RECEIVER = new HashMap<>();
|
||||
@@ -49,7 +52,12 @@ public class NetworkManagerImpl {
|
||||
private static final Map<ResourceLocation, PacketTransformer> C2S_TRANSFORMERS = new HashMap<>();
|
||||
private static final Map<ResourceLocation, PacketTransformer> S2C_TRANSFORMERS = new HashMap<>();
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
|
||||
public static void registerReceiver(NetworkManager.Side side, ResourceLocation id, List<PacketTransformer> packetTransformers, NetworkReceiver receiver) {
|
||||
Objects.requireNonNull(id, "Cannot register receiver with a null ID!");
|
||||
packetTransformers = Objects.requireNonNullElse(packetTransformers, List.of());
|
||||
Objects.requireNonNull(receiver, "Cannot register a null receiver!");
|
||||
if (side == NetworkManager.Side.C2S) {
|
||||
registerC2SReceiver(id, packetTransformers, receiver);
|
||||
} else if (side == NetworkManager.Side.S2C) {
|
||||
@@ -58,6 +66,7 @@ public class NetworkManagerImpl {
|
||||
}
|
||||
|
||||
private static void registerC2SReceiver(ResourceLocation id, List<PacketTransformer> packetTransformers, NetworkReceiver receiver) {
|
||||
LOGGER.info("Registering C2S receiver with id {}", id);
|
||||
C2S_RECEIVER.put(id, receiver);
|
||||
PacketTransformer transformer = PacketTransformer.concat(packetTransformers);
|
||||
ServerPlayNetworking.registerGlobalReceiver(id, (server, player, handler, buf, sender) -> {
|
||||
@@ -76,6 +85,7 @@ public class NetworkManagerImpl {
|
||||
@SuppressWarnings("Convert2Lambda")
|
||||
@Environment(EnvType.CLIENT)
|
||||
private static void registerS2CReceiver(ResourceLocation id, List<PacketTransformer> packetTransformers, NetworkReceiver receiver) {
|
||||
LOGGER.info("Registering S2C receiver with id {}", id);
|
||||
S2C_RECEIVER.put(id, receiver);
|
||||
PacketTransformer transformer = PacketTransformer.concat(packetTransformers);
|
||||
ClientPlayNetworking.registerGlobalReceiver(id, new ClientPlayNetworking.PlayChannelHandler() {
|
||||
|
||||
@@ -21,6 +21,7 @@ package dev.architectury.networking.forge;
|
||||
|
||||
|
||||
import com.google.common.collect.*;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import dev.architectury.forge.ArchitecturyForge;
|
||||
import dev.architectury.networking.NetworkManager;
|
||||
import dev.architectury.networking.NetworkManager.NetworkReceiver;
|
||||
@@ -47,18 +48,17 @@ import net.minecraftforge.network.NetworkHooks;
|
||||
import net.minecraftforge.network.NetworkRegistry;
|
||||
import net.minecraftforge.network.event.EventNetworkChannel;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = ArchitecturyForge.MOD_ID)
|
||||
public class NetworkManagerImpl {
|
||||
public static void registerReceiver(NetworkManager.Side side, ResourceLocation id, List<PacketTransformer> packetTransformers, NetworkReceiver receiver) {
|
||||
Objects.requireNonNull(id, "Cannot register receiver with a null ID!");
|
||||
packetTransformers = Objects.requireNonNullElse(packetTransformers, List.of());
|
||||
Objects.requireNonNull(receiver, "Cannot register a null receiver!");
|
||||
if (side == NetworkManager.Side.C2S) {
|
||||
registerC2SReceiver(id, packetTransformers, receiver);
|
||||
} else if (side == NetworkManager.Side.S2C) {
|
||||
@@ -84,7 +84,7 @@ public class NetworkManagerImpl {
|
||||
}
|
||||
}
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static final ResourceLocation CHANNEL_ID = new ResourceLocation("architectury:network");
|
||||
static final ResourceLocation SYNC_IDS = new ResourceLocation("architectury:sync_ids");
|
||||
static final EventNetworkChannel CHANNEL = NetworkRegistry.newEventChannel(CHANNEL_ID, () -> "1", version -> true, version -> true);
|
||||
@@ -159,12 +159,14 @@ public class NetworkManagerImpl {
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void registerS2CReceiver(ResourceLocation id, List<PacketTransformer> packetTransformers, NetworkReceiver receiver) {
|
||||
LOGGER.info("Registering S2C receiver with id {}", id);
|
||||
S2C.put(id, receiver);
|
||||
PacketTransformer transformer = PacketTransformer.concat(packetTransformers);
|
||||
S2C_TRANSFORMERS.put(id, transformer);
|
||||
}
|
||||
|
||||
public static void registerC2SReceiver(ResourceLocation id, List<PacketTransformer> packetTransformers, NetworkReceiver receiver) {
|
||||
LOGGER.info("Registering C2S receiver with id {}", id);
|
||||
C2S.put(id, receiver);
|
||||
PacketTransformer transformer = PacketTransformer.concat(packetTransformers);
|
||||
C2S_TRANSFORMERS.put(id, transformer);
|
||||
|
||||
@@ -100,26 +100,10 @@ public class RegistriesImpl {
|
||||
}
|
||||
}
|
||||
|
||||
public static class RegistryEntryId<T> {
|
||||
private final ResourceKey<T> registryKey;
|
||||
private final ResourceLocation id;
|
||||
|
||||
public RegistryEntryId(ResourceKey<T> registryKey, ResourceLocation id) {
|
||||
this.registryKey = registryKey;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public record RegistryEntryId<T>(ResourceKey<T> registryKey, ResourceLocation id) {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof RegistryEntryId)) return false;
|
||||
RegistryEntryId<?> that = (RegistryEntryId<?>) o;
|
||||
return java.util.Objects.equals(registryKey, that.registryKey) && java.util.Objects.equals(id, that.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return java.util.Objects.hash(registryKey, id);
|
||||
public String toString() {
|
||||
return "Registry Entry [%s / %s]".formatted(registryKey.location(), id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ artifact_type=release
|
||||
|
||||
archives_base_name=architectury
|
||||
archives_base_name_snapshot=architectury-snapshot
|
||||
base_version=5.10
|
||||
base_version=5.11
|
||||
maven_group=dev.architectury
|
||||
|
||||
fabric_loader_version=0.14.6
|
||||
|
||||
Reference in New Issue
Block a user