mirror of
https://github.com/architectury/architectury-api.git
synced 2026-04-02 13:37:43 -05:00
Convert to @ExpectPlatform
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
package me.shedaniel.architectury.event.fabric;
|
||||
|
||||
import me.shedaniel.architectury.event.EventHandler;
|
||||
import me.shedaniel.architectury.event.events.*;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
@@ -31,9 +30,8 @@ import net.fabricmc.fabric.api.event.player.UseBlockCallback;
|
||||
import net.fabricmc.fabric.api.event.player.UseItemCallback;
|
||||
import net.minecraft.commands.Commands;
|
||||
|
||||
public class EventHandlerImpl implements EventHandler.Impl {
|
||||
@Override
|
||||
public void registerClient() {
|
||||
public class EventHandlerImpl {
|
||||
public static void registerClient() {
|
||||
ClientLifecycleEvents.CLIENT_STARTED.register(LifecycleEvent.CLIENT_STARTED.invoker()::stateChanged);
|
||||
ClientLifecycleEvents.CLIENT_STOPPING.register(LifecycleEvent.CLIENT_STOPPING.invoker()::stateChanged);
|
||||
|
||||
@@ -46,8 +44,7 @@ public class EventHandlerImpl implements EventHandler.Impl {
|
||||
HudRenderCallback.EVENT.register(GuiEvent.RENDER_HUD.invoker()::renderHud);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCommon() {
|
||||
public static void registerCommon() {
|
||||
ServerLifecycleEvents.SERVER_STARTING.register(LifecycleEvent.SERVER_STARTING.invoker()::stateChanged);
|
||||
ServerLifecycleEvents.SERVER_STARTED.register(LifecycleEvent.SERVER_STARTED.invoker()::stateChanged);
|
||||
ServerLifecycleEvents.SERVER_STOPPING.register(LifecycleEvent.SERVER_STOPPING.invoker()::stateChanged);
|
||||
@@ -68,8 +65,7 @@ public class EventHandlerImpl implements EventHandler.Impl {
|
||||
AttackBlockCallback.EVENT.register((player, world, hand, pos, face) -> InteractionEvent.LEFT_CLICK_BLOCK.invoker().click(player, hand, pos, face));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerServer() {
|
||||
public static void registerServer() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,10 @@
|
||||
|
||||
package me.shedaniel.architectury.hooks.fabric;
|
||||
|
||||
import me.shedaniel.architectury.hooks.DyeColorHooks;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
|
||||
public class DyeColorHooksImpl implements DyeColorHooks.Impl {
|
||||
@Override
|
||||
public int getColorValue(DyeColor color) {
|
||||
public class DyeColorHooksImpl {
|
||||
public static int getColorValue(DyeColor color) {
|
||||
return color.textureDiffuseColor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,10 @@
|
||||
|
||||
package me.shedaniel.architectury.hooks.fabric;
|
||||
|
||||
import me.shedaniel.architectury.hooks.EntityHooks;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
public class EntityHooksImpl implements EntityHooks.Impl {
|
||||
@Override
|
||||
public String getEncodeId(Entity entity) {
|
||||
public class EntityHooksImpl {
|
||||
public static String getEncodeId(Entity entity) {
|
||||
return entity.getEncodeId();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,29 +16,24 @@
|
||||
|
||||
package me.shedaniel.architectury.hooks.fabric;
|
||||
|
||||
import me.shedaniel.architectury.hooks.ExplosionHooks;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class ExplosionHooksImpl implements ExplosionHooks.Impl {
|
||||
@Override
|
||||
public Vec3 getPosition(Explosion explosion) {
|
||||
public class ExplosionHooksImpl {
|
||||
public static Vec3 getPosition(Explosion explosion) {
|
||||
return ((ExplosionExtensions) explosion).architectury_getPosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity getSource(Explosion explosion) {
|
||||
public static Entity getSource(Explosion explosion) {
|
||||
return ((ExplosionExtensions) explosion).architectury_getSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRadius(Explosion explosion) {
|
||||
public static float getRadius(Explosion explosion) {
|
||||
return ((ExplosionExtensions) explosion).architectury_getRadius();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRadius(Explosion explosion, float radius) {
|
||||
public static void setRadius(Explosion explosion, float radius) {
|
||||
((ExplosionExtensions) explosion).architectury_setRadius(radius);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,13 +16,11 @@
|
||||
|
||||
package me.shedaniel.architectury.hooks.fabric;
|
||||
|
||||
import me.shedaniel.architectury.hooks.ItemEntityHooks;
|
||||
import me.shedaniel.architectury.utils.IntValue;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
|
||||
public class ItemEntityHooksImpl implements ItemEntityHooks.Impl {
|
||||
@Override
|
||||
public IntValue lifespan(ItemEntity entity) {
|
||||
public class ItemEntityHooksImpl {
|
||||
public static IntValue lifespan(ItemEntity entity) {
|
||||
return new IntValue() {
|
||||
@Override
|
||||
public void accept(int value) {
|
||||
|
||||
@@ -17,16 +17,14 @@
|
||||
package me.shedaniel.architectury.hooks.fabric;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import me.shedaniel.architectury.hooks.PackRepositoryHooks;
|
||||
import net.minecraft.server.packs.repository.PackRepository;
|
||||
import net.minecraft.server.packs.repository.RepositorySource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PackRepositoryHooksImpl implements PackRepositoryHooks.Impl {
|
||||
@Override
|
||||
public void addSource(PackRepository repository, RepositorySource source) {
|
||||
public class PackRepositoryHooksImpl {
|
||||
public static void addSource(PackRepository repository, RepositorySource source) {
|
||||
List<RepositorySource> set = new ArrayList<>(repository.sources);
|
||||
set.add(source);
|
||||
repository.sources = ImmutableSet.copyOf(set);
|
||||
|
||||
@@ -16,17 +16,14 @@
|
||||
|
||||
package me.shedaniel.architectury.hooks.fabric;
|
||||
|
||||
import me.shedaniel.architectury.hooks.PlayerHooks;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
public class PlayerHooksImpl implements PlayerHooks.Impl {
|
||||
@Override
|
||||
public boolean isFake(Player player) {
|
||||
public class PlayerHooksImpl {
|
||||
public static boolean isFake(Player player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeContainer(Player player) {
|
||||
public static void closeContainer(Player player) {
|
||||
player.closeContainer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package me.shedaniel.architectury.hooks.fabric;
|
||||
|
||||
import me.shedaniel.architectury.hooks.ScreenHooks;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
@@ -26,19 +25,16 @@ import net.minecraft.client.gui.screens.Screen;
|
||||
import java.util.List;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class ScreenHooksImpl implements ScreenHooks.Impl {
|
||||
@Override
|
||||
public List<AbstractWidget> getButtons(Screen screen) {
|
||||
public class ScreenHooksImpl {
|
||||
public static List<AbstractWidget> getButtons(Screen screen) {
|
||||
return screen.buttons;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends AbstractWidget> T addButton(Screen screen, T widget) {
|
||||
public static <T extends AbstractWidget> T addButton(Screen screen, T widget) {
|
||||
return screen.addButton(widget);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends GuiEventListener> T addChild(Screen screen, T listener) {
|
||||
public static <T extends GuiEventListener> T addChild(Screen screen, T listener) {
|
||||
return screen.addWidget(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,8 @@ import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
public class NetworkManagerImpl implements NetworkManager.Impl {
|
||||
@Override
|
||||
public void registerReceiver(NetworkManager.Side side, ResourceLocation id, NetworkReceiver receiver) {
|
||||
public class NetworkManagerImpl {
|
||||
public static void registerReceiver(NetworkManager.Side side, ResourceLocation id, NetworkReceiver receiver) {
|
||||
if (side == NetworkManager.Side.C2S) {
|
||||
registerC2SReceiver(id, receiver);
|
||||
} else if (side == NetworkManager.Side.S2C) {
|
||||
@@ -39,16 +38,16 @@ public class NetworkManagerImpl implements NetworkManager.Impl {
|
||||
}
|
||||
}
|
||||
|
||||
private void registerC2SReceiver(ResourceLocation id, NetworkReceiver receiver) {
|
||||
private static void registerC2SReceiver(ResourceLocation id, NetworkReceiver receiver) {
|
||||
ServerSidePacketRegistry.INSTANCE.register(id, (packetContext, buf) -> receiver.receive(buf, to(packetContext)));
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
private void registerS2CReceiver(ResourceLocation id, NetworkReceiver receiver) {
|
||||
private static void registerS2CReceiver(ResourceLocation id, NetworkReceiver receiver) {
|
||||
ClientSidePacketRegistry.INSTANCE.register(id, (packetContext, buf) -> receiver.receive(buf, to(packetContext)));
|
||||
}
|
||||
|
||||
private NetworkManager.PacketContext to(PacketContext context) {
|
||||
private static NetworkManager.PacketContext to(PacketContext context) {
|
||||
return new NetworkManager.PacketContext() {
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
@@ -67,8 +66,7 @@ public class NetworkManagerImpl implements NetworkManager.Impl {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet<?> toPacket(NetworkManager.Side side, ResourceLocation id, FriendlyByteBuf buf) {
|
||||
public static Packet<?> toPacket(NetworkManager.Side side, ResourceLocation id, FriendlyByteBuf buf) {
|
||||
if (side == NetworkManager.Side.C2S) {
|
||||
return toC2SPacket(id, buf);
|
||||
} else if (side == NetworkManager.Side.S2C) {
|
||||
@@ -78,22 +76,20 @@ public class NetworkManagerImpl implements NetworkManager.Impl {
|
||||
throw new IllegalArgumentException("Invalid side: " + side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canServerReceive(ResourceLocation id) {
|
||||
public static boolean canServerReceive(ResourceLocation id) {
|
||||
return ClientSidePacketRegistry.INSTANCE.canServerReceive(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlayerReceive(ServerPlayer player, ResourceLocation id) {
|
||||
public static boolean canPlayerReceive(ServerPlayer player, ResourceLocation id) {
|
||||
return ServerSidePacketRegistry.INSTANCE.canPlayerReceive(player, id);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
private Packet<?> toC2SPacket(ResourceLocation id, FriendlyByteBuf buf) {
|
||||
private static Packet<?> toC2SPacket(ResourceLocation id, FriendlyByteBuf buf) {
|
||||
return ClientSidePacketRegistry.INSTANCE.toPacket(id, buf);
|
||||
}
|
||||
|
||||
private Packet<?> toS2CPacket(ResourceLocation id, FriendlyByteBuf buf) {
|
||||
private static Packet<?> toS2CPacket(ResourceLocation id, FriendlyByteBuf buf) {
|
||||
return ServerSidePacketRegistry.INSTANCE.toPacket(id, buf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package me.shedaniel.architectury.platform.fabric;
|
||||
|
||||
import me.shedaniel.architectury.platform.Mod;
|
||||
import me.shedaniel.architectury.platform.Platform;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
@@ -30,55 +29,46 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PlatformImpl implements Platform.Impl {
|
||||
public class PlatformImpl {
|
||||
public static final Map<String, Mod.ConfigurationScreenProvider> CONFIG_SCREENS = new HashMap<>();
|
||||
private final Map<String, Mod> mods = new HashMap<>();
|
||||
private static final Map<String, Mod> mods = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public Path getGameFolder() {
|
||||
public static Path getGameFolder() {
|
||||
return FabricLoader.getInstance().getGameDir();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getConfigFolder() {
|
||||
public static Path getConfigFolder() {
|
||||
return FabricLoader.getInstance().getConfigDir();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getModsFolder() {
|
||||
public static Path getModsFolder() {
|
||||
return getGameFolder().resolve("mods");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnvType getEnv() {
|
||||
public static EnvType getEnv() {
|
||||
return FabricLoader.getInstance().getEnvironmentType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModLoaded(String id) {
|
||||
public static boolean isModLoaded(String id) {
|
||||
return FabricLoader.getInstance().isModLoaded(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mod getMod(String id) {
|
||||
return this.mods.computeIfAbsent(id, ModImpl::new);
|
||||
public static Mod getMod(String id) {
|
||||
return mods.computeIfAbsent(id, ModImpl::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Mod> getMods() {
|
||||
public static Collection<Mod> getMods() {
|
||||
for (ModContainer mod : FabricLoader.getInstance().getAllMods()) {
|
||||
getMod(mod.getMetadata().getId());
|
||||
}
|
||||
return this.mods.values();
|
||||
return mods.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getModIds() {
|
||||
public static Collection<String> getModIds() {
|
||||
return FabricLoader.getInstance().getAllMods().stream().map(ModContainer::getMetadata).map(ModMetadata::getId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDevelopmentEnvironment() {
|
||||
public static boolean isDevelopmentEnvironment() {
|
||||
return FabricLoader.getInstance().isDevelopmentEnvironment();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package me.shedaniel.architectury.registry.fabric;
|
||||
|
||||
import me.shedaniel.architectury.registry.BlockEntityRenderers;
|
||||
import net.fabricmc.fabric.api.client.rendereregistry.v1.BlockEntityRendererRegistry;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
@@ -25,9 +24,8 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class BlockEntityRenderersImpl implements BlockEntityRenderers.Impl {
|
||||
@Override
|
||||
public <T extends BlockEntity> void registerRenderer(BlockEntityType<T> type, Function<BlockEntityRenderDispatcher, BlockEntityRenderer<T>> provider) {
|
||||
public class BlockEntityRenderersImpl {
|
||||
public static <T extends BlockEntity> void registerRenderer(BlockEntityType<T> type, Function<BlockEntityRenderDispatcher, BlockEntityRenderer<T>> provider) {
|
||||
BlockEntityRendererRegistry.INSTANCE.register(type, provider);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,24 +27,20 @@ import net.minecraft.world.level.material.MaterialColor;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class BlockPropertiesImpl implements BlockProperties.Impl {
|
||||
@Override
|
||||
public BlockProperties of(Material material, MaterialColor color) {
|
||||
public class BlockPropertiesImpl {
|
||||
public static BlockProperties of(Material material, MaterialColor color) {
|
||||
return new Impl(material, (state) -> color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockProperties of(Material material, Function<BlockState, MaterialColor> color) {
|
||||
public static BlockProperties of(Material material, Function<BlockState, MaterialColor> color) {
|
||||
return new Impl(material, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockProperties copy(BlockBehaviour old) {
|
||||
public static BlockProperties copy(BlockBehaviour old) {
|
||||
return copy(old.properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockProperties copy(BlockBehaviour.Properties old) {
|
||||
public static BlockProperties copy(BlockBehaviour.Properties old) {
|
||||
BlockProperties properties = of(old.material, old.materialColor);
|
||||
properties.material = old.material;
|
||||
properties.destroyTime = old.destroyTime;
|
||||
@@ -63,7 +59,7 @@ public class BlockPropertiesImpl implements BlockProperties.Impl {
|
||||
BlockSettingsInternals otherInternals = (BlockSettingsInternals) old;
|
||||
FabricBlockInternals.ExtraData extraData = otherInternals.getExtraData();
|
||||
if (extraData != null) {
|
||||
((BlockSettingsInternals) this).setExtraData(extraData);
|
||||
((BlockSettingsInternals) properties).setExtraData(extraData);
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
@@ -16,21 +16,18 @@
|
||||
|
||||
package me.shedaniel.architectury.registry.fabric;
|
||||
|
||||
import me.shedaniel.architectury.registry.ColorHandlers;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
|
||||
import net.minecraft.client.color.block.BlockColor;
|
||||
import net.minecraft.client.color.item.ItemColor;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
public class ColorHandlersImpl implements ColorHandlers.Impl {
|
||||
@Override
|
||||
public void registerItemColors(ItemColor color, ItemLike... items) {
|
||||
public class ColorHandlersImpl {
|
||||
public static void registerItemColors(ItemColor color, ItemLike... items) {
|
||||
ColorProviderRegistry.ITEM.register(color, items);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockColors(BlockColor color, Block... blocks) {
|
||||
public static void registerBlockColors(BlockColor color, Block... blocks) {
|
||||
ColorProviderRegistry.BLOCK.register(color, blocks);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package me.shedaniel.architectury.registry.fabric;
|
||||
|
||||
import me.shedaniel.architectury.registry.CreativeTabs;
|
||||
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
@@ -24,9 +23,8 @@ import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class CreativeTabsImpl implements CreativeTabs.Impl {
|
||||
@Override
|
||||
public CreativeModeTab create(ResourceLocation name, Supplier<ItemStack> icon) {
|
||||
public class CreativeTabsImpl {
|
||||
public static CreativeModeTab create(ResourceLocation name, Supplier<ItemStack> icon) {
|
||||
return FabricItemGroupBuilder.build(name, icon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,11 @@
|
||||
|
||||
package me.shedaniel.architectury.registry.fabric;
|
||||
|
||||
import me.shedaniel.architectury.registry.KeyBindings;
|
||||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
|
||||
public class KeyBindingsImpl implements KeyBindings.Impl {
|
||||
@Override
|
||||
public void registerKeyBinding(KeyMapping binding) {
|
||||
public class KeyBindingsImpl {
|
||||
public static void registerKeyBinding(KeyMapping binding) {
|
||||
KeyBindingHelper.registerKeyBinding(binding);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,21 +30,18 @@ import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class RegistriesImpl implements Registries.Impl {
|
||||
@Override
|
||||
public Registries.RegistryProvider get(String modId) {
|
||||
public class RegistriesImpl {
|
||||
public static Registries.RegistryProvider _get(String modId) {
|
||||
return RegistryProviderImpl.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> ResourceLocation getId(T object, ResourceKey<net.minecraft.core.Registry<T>> fallback) {
|
||||
public static <T> ResourceLocation getId(T object, ResourceKey<net.minecraft.core.Registry<T>> fallback) {
|
||||
if (fallback == null)
|
||||
return null;
|
||||
return RegistryProviderImpl.INSTANCE.get(fallback).getId(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> ResourceLocation getId(T object, net.minecraft.core.Registry<T> fallback) {
|
||||
public static <T> ResourceLocation getId(T object, net.minecraft.core.Registry<T> fallback) {
|
||||
if (fallback == null)
|
||||
return null;
|
||||
return RegistryProviderImpl.INSTANCE.get(fallback).getId(object);
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package me.shedaniel.architectury.registry.fabric;
|
||||
|
||||
import com.google.common.primitives.Longs;
|
||||
import me.shedaniel.architectury.registry.ReloadListeners;
|
||||
import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener;
|
||||
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
@@ -31,11 +30,10 @@ import java.security.SecureRandom;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
public class ReloadListenersImpl implements ReloadListeners.Impl {
|
||||
public class ReloadListenersImpl {
|
||||
private static final SecureRandom RANDOM = new SecureRandom();
|
||||
|
||||
@Override
|
||||
public void registerReloadListener(PackType type, PreparableReloadListener listener) {
|
||||
public static void registerReloadListener(PackType type, PreparableReloadListener listener) {
|
||||
byte[] bytes = new byte[8];
|
||||
RANDOM.nextBytes(bytes);
|
||||
ResourceLocation id = new ResourceLocation("architectury:reload_" + StringUtils.leftPad(Math.abs(Longs.fromByteArray(bytes)) + "", 19));
|
||||
@@ -44,12 +42,12 @@ public class ReloadListenersImpl implements ReloadListeners.Impl {
|
||||
public ResourceLocation getFabricId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return listener.getName();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> reload(PreparationBarrier preparationBarrier, ResourceManager resourceManager, ProfilerFiller profilerFiller, ProfilerFiller profilerFiller2, Executor executor, Executor executor2) {
|
||||
return listener.reload(preparationBarrier, resourceManager, profilerFiller, profilerFiller2, executor, executor2);
|
||||
|
||||
@@ -16,20 +16,17 @@
|
||||
|
||||
package me.shedaniel.architectury.registry.fabric;
|
||||
|
||||
import me.shedaniel.architectury.registry.RenderTypes;
|
||||
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
|
||||
public class RenderTypesImpl implements RenderTypes.Impl {
|
||||
@Override
|
||||
public void register(RenderType type, Block... blocks) {
|
||||
public class RenderTypesImpl {
|
||||
public static void register(RenderType type, Block... blocks) {
|
||||
BlockRenderLayerMap.INSTANCE.putBlocks(type, blocks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(RenderType type, Fluid... fluids) {
|
||||
public static void register(RenderType type, Fluid... fluids) {
|
||||
BlockRenderLayerMap.INSTANCE.putFluids(type, fluids);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,29 +16,24 @@
|
||||
|
||||
package me.shedaniel.architectury.registry.fabric;
|
||||
|
||||
import me.shedaniel.architectury.registry.ToolType;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
public class ToolTypeImpl implements ToolType.Impl {
|
||||
@Override
|
||||
public Tag<Item> pickaxeTag() {
|
||||
public class ToolTypeImpl {
|
||||
public static Tag<Item> pickaxeTag() {
|
||||
return FabricToolTags.PICKAXES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tag<Item> axeTag() {
|
||||
public static Tag<Item> axeTag() {
|
||||
return FabricToolTags.AXES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tag<Item> hoeTag() {
|
||||
public static Tag<Item> hoeTag() {
|
||||
return FabricToolTags.HOES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tag<Item> shovelTag() {
|
||||
public static Tag<Item> shovelTag() {
|
||||
return FabricToolTags.SHOVELS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,17 +19,15 @@ package me.shedaniel.architectury.utils.fabric;
|
||||
import me.shedaniel.architectury.event.EventHandler;
|
||||
import me.shedaniel.architectury.event.events.LifecycleEvent;
|
||||
import me.shedaniel.architectury.platform.Platform;
|
||||
import me.shedaniel.architectury.utils.GameInstance;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
public class GameInstanceImpl implements GameInstance.Impl {
|
||||
public class GameInstanceImpl {
|
||||
private static MinecraftServer server = null;
|
||||
|
||||
@Override
|
||||
public MinecraftServer getServer() {
|
||||
public static MinecraftServer getServer() {
|
||||
MinecraftServer server = null;
|
||||
if (GameInstanceImpl.server != null) server = GameInstanceImpl.server;
|
||||
if (Platform.getEnv() == EnvType.CLIENT) {
|
||||
|
||||
Reference in New Issue
Block a user