diff --git a/common/src/main/java/me/shedaniel/architectury/event/events/PlayerEvent.java b/common/src/main/java/me/shedaniel/architectury/event/events/PlayerEvent.java index 982e572f..e426ca51 100644 --- a/common/src/main/java/me/shedaniel/architectury/event/events/PlayerEvent.java +++ b/common/src/main/java/me/shedaniel/architectury/event/events/PlayerEvent.java @@ -36,19 +36,19 @@ import net.minecraft.world.level.block.state.BlockState; import org.jetbrains.annotations.Nullable; public interface PlayerEvent { - Event PLAYER_JOIN = EventFactory.createLoop(PlayerJoin.class); - Event PLAYER_QUIT = EventFactory.createLoop(PlayerQuit.class); - Event PLAYER_RESPAWN = EventFactory.createLoop(PlayerRespawn.class); - Event PLAYER_ADVANCEMENT = EventFactory.createLoop(PlayerAdvancement.class); - Event PLAYER_CLONE = EventFactory.createLoop(PlayerClone.class); - Event CRAFT_ITEM = EventFactory.createLoop(CraftItem.class); - Event SMELT_ITEM = EventFactory.createLoop(SmeltItem.class); - Event PICKUP_ITEM_PRE = EventFactory.createInteractionResult(PickupItemPredicate.class); - Event PICKUP_ITEM_POST = EventFactory.createLoop(PickupItem.class); - Event DROP_ITEM = EventFactory.createLoop(DropItem.class); - Event OPEN_MENU = EventFactory.createLoop(OpenMenu.class); - Event CLOSE_MENU = EventFactory.createLoop(CloseMenu.class); - Event BREAK_BLOCK = EventFactory.createInteractionResult(BreakBlock.class); + Event PLAYER_JOIN = EventFactory.createLoop(); + Event PLAYER_QUIT = EventFactory.createLoop(); + Event PLAYER_RESPAWN = EventFactory.createLoop(); + Event PLAYER_ADVANCEMENT = EventFactory.createLoop(); + Event PLAYER_CLONE = EventFactory.createLoop(); + Event CRAFT_ITEM = EventFactory.createLoop(); + Event SMELT_ITEM = EventFactory.createLoop(); + Event PICKUP_ITEM_PRE = EventFactory.createInteractionResult(); + Event PICKUP_ITEM_POST = EventFactory.createLoop(); + Event DROP_ITEM = EventFactory.createLoop(); + Event OPEN_MENU = EventFactory.createLoop(); + Event CLOSE_MENU = EventFactory.createLoop(); + Event BREAK_BLOCK = EventFactory.createInteractionResult(); interface PlayerJoin { void join(ServerPlayer player); diff --git a/common/src/main/java/me/shedaniel/architectury/registry/ColorHandlers.java b/common/src/main/java/me/shedaniel/architectury/registry/ColorHandlers.java index e9c30d53..48432b29 100644 --- a/common/src/main/java/me/shedaniel/architectury/registry/ColorHandlers.java +++ b/common/src/main/java/me/shedaniel/architectury/registry/ColorHandlers.java @@ -35,15 +35,21 @@ public final class ColorHandlers { private ColorHandlers() {} public static void registerItemColors(ItemColor color, ItemLike... items) { - registerItemColors(color, Arrays.stream(items) - .map(item -> (Supplier) () -> item) - .toArray(Supplier[]::new)); + Supplier[] array = new Supplier[items.length]; + for (int i = 0; i < items.length; i++) { + ItemLike item = items[i]; + array[i] = () -> item; + } + registerItemColors(color, array); } public static void registerBlockColors(BlockColor color, Block... blocks) { - registerBlockColors(color, Arrays.stream(blocks) - .map(block -> (Supplier) () -> block) - .toArray(Supplier[]::new)); + Supplier[] array = new Supplier[blocks.length]; + for (int i = 0; i < blocks.length; i++) { + Block block = blocks[i]; + array[i] = () -> block; + } + registerBlockColors(color, array); } @SafeVarargs diff --git a/fabric/src/main/java/me/shedaniel/architectury/init/fabric/ArchitecturyClient.java b/fabric/src/main/java/me/shedaniel/architectury/init/fabric/ArchitecturyClient.java index 85aff307..4a050f16 100644 --- a/fabric/src/main/java/me/shedaniel/architectury/init/fabric/ArchitecturyClient.java +++ b/fabric/src/main/java/me/shedaniel/architectury/init/fabric/ArchitecturyClient.java @@ -1,3 +1,22 @@ +/* + * This file is part of architectury. + * Copyright (C) 2020, 2021 shedaniel + * + * 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.init.fabric; import me.shedaniel.architectury.event.events.client.ClientLifecycleEvent; diff --git a/fabric/src/main/java/me/shedaniel/architectury/registry/fabric/ColorHandlersImpl.java b/fabric/src/main/java/me/shedaniel/architectury/registry/fabric/ColorHandlersImpl.java index 6e09315b..12860dd0 100644 --- a/fabric/src/main/java/me/shedaniel/architectury/registry/fabric/ColorHandlersImpl.java +++ b/fabric/src/main/java/me/shedaniel/architectury/registry/fabric/ColorHandlersImpl.java @@ -25,21 +25,32 @@ import net.minecraft.client.color.item.ItemColor; import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.block.Block; -import java.util.Arrays; import java.util.function.Supplier; public class ColorHandlersImpl { @SafeVarargs public static void registerItemColors(ItemColor itemColor, Supplier... items) { - ColorProviderRegistry.ITEM.register(itemColor, Arrays.stream(items) - .map(Supplier::get) - .toArray(ItemLike[]::new)); + ColorProviderRegistry.ITEM.register(itemColor, unpackItems(items)); } @SafeVarargs public static void registerBlockColors(BlockColor blockColor, Supplier... blocks) { - ColorProviderRegistry.BLOCK.register(blockColor, Arrays.stream(blocks) - .map(Supplier::get) - .toArray(Block[]::new)); + ColorProviderRegistry.BLOCK.register(blockColor, unpackBlocks(blocks)); + } + + private static ItemLike[] unpackItems(Supplier[] items) { + ItemLike[] array = new ItemLike[items.length]; + for (int i = 0; i < items.length; i++) { + array[i] = items[i].get(); + } + return array; + } + + private static Block[] unpackBlocks(Supplier[] blocks) { + Block[] array = new Block[blocks.length]; + for (int i = 0; i < blocks.length; i++) { + array[i] = blocks[i].get(); + } + return array; } } diff --git a/forge/src/main/java/me/shedaniel/architectury/registry/forge/ColorHandlersImpl.java b/forge/src/main/java/me/shedaniel/architectury/registry/forge/ColorHandlersImpl.java index 7bb927c1..8ed2165c 100644 --- a/forge/src/main/java/me/shedaniel/architectury/registry/forge/ColorHandlersImpl.java +++ b/forge/src/main/java/me/shedaniel/architectury/registry/forge/ColorHandlersImpl.java @@ -29,7 +29,6 @@ import net.minecraftforge.client.event.ColorHandlerEvent; import net.minecraftforge.common.MinecraftForge; import org.apache.commons.lang3.tuple.Pair; -import java.util.Arrays; import java.util.List; import java.util.function.Supplier; @@ -40,16 +39,12 @@ public class ColorHandlersImpl { static { MinecraftForge.EVENT_BUS.addListener(event -> { for (Pair[]> pair : ITEM_COLORS) { - event.getItemColors().register(pair.getLeft(), Arrays.stream(pair.getRight()) - .map(Supplier::get) - .toArray(ItemLike[]::new)); + event.getItemColors().register(pair.getLeft(), unpackItems(pair.getRight())); } }); MinecraftForge.EVENT_BUS.addListener(event -> { for (Pair[]> pair : BLOCK_COLORS) { - event.getBlockColors().register(pair.getLeft(), Arrays.stream(pair.getRight()) - .map(Supplier::get) - .toArray(Block[]::new)); + event.getBlockColors().register(pair.getLeft(), unpackBlocks(pair.getRight())); } }); } @@ -59,9 +54,7 @@ public class ColorHandlersImpl { if (Minecraft.getInstance().getItemColors() == null) { ITEM_COLORS.add(Pair.of(itemColor, items)); } else { - Minecraft.getInstance().getItemColors().register(itemColor, Arrays.stream(items) - .map(Supplier::get) - .toArray(ItemLike[]::new)); + Minecraft.getInstance().getItemColors().register(itemColor, unpackItems(items)); } } @@ -70,9 +63,23 @@ public class ColorHandlersImpl { if (Minecraft.getInstance().getBlockColors() == null) { BLOCK_COLORS.add(Pair.of(blockColor, blocks)); } else { - Minecraft.getInstance().getBlockColors().register(blockColor, Arrays.stream(blocks) - .map(Supplier::get) - .toArray(Block[]::new)); + Minecraft.getInstance().getBlockColors().register(blockColor, unpackBlocks(blocks)); } } + + private static ItemLike[] unpackItems(Supplier[] items) { + ItemLike[] array = new ItemLike[items.length]; + for (int i = 0; i < items.length; i++) { + array[i] = items[i].get(); + } + return array; + } + + private static Block[] unpackBlocks(Supplier[] blocks) { + Block[] array = new Block[blocks.length]; + for (int i = 0; i < blocks.length; i++) { + array[i] = blocks[i].get(); + } + return array; + } } diff --git a/gradle.properties b/gradle.properties index a45ad75e..9370f5a0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false minecraft_version=1.16.4 -supported_version=1.16.4 +supported_version=1.16.4/5 archives_base_name=architectury mod_version=1.3