mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-28 03:56:59 -05:00
Fix compilation error
This commit is contained in:
@@ -36,19 +36,19 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface PlayerEvent {
|
||||
Event<PlayerJoin> PLAYER_JOIN = EventFactory.createLoop(PlayerJoin.class);
|
||||
Event<PlayerQuit> PLAYER_QUIT = EventFactory.createLoop(PlayerQuit.class);
|
||||
Event<PlayerRespawn> PLAYER_RESPAWN = EventFactory.createLoop(PlayerRespawn.class);
|
||||
Event<PlayerAdvancement> PLAYER_ADVANCEMENT = EventFactory.createLoop(PlayerAdvancement.class);
|
||||
Event<PlayerClone> PLAYER_CLONE = EventFactory.createLoop(PlayerClone.class);
|
||||
Event<CraftItem> CRAFT_ITEM = EventFactory.createLoop(CraftItem.class);
|
||||
Event<SmeltItem> SMELT_ITEM = EventFactory.createLoop(SmeltItem.class);
|
||||
Event<PickupItemPredicate> PICKUP_ITEM_PRE = EventFactory.createInteractionResult(PickupItemPredicate.class);
|
||||
Event<PickupItem> PICKUP_ITEM_POST = EventFactory.createLoop(PickupItem.class);
|
||||
Event<DropItem> DROP_ITEM = EventFactory.createLoop(DropItem.class);
|
||||
Event<OpenMenu> OPEN_MENU = EventFactory.createLoop(OpenMenu.class);
|
||||
Event<CloseMenu> CLOSE_MENU = EventFactory.createLoop(CloseMenu.class);
|
||||
Event<BreakBlock> BREAK_BLOCK = EventFactory.createInteractionResult(BreakBlock.class);
|
||||
Event<PlayerJoin> PLAYER_JOIN = EventFactory.createLoop();
|
||||
Event<PlayerQuit> PLAYER_QUIT = EventFactory.createLoop();
|
||||
Event<PlayerRespawn> PLAYER_RESPAWN = EventFactory.createLoop();
|
||||
Event<PlayerAdvancement> PLAYER_ADVANCEMENT = EventFactory.createLoop();
|
||||
Event<PlayerClone> PLAYER_CLONE = EventFactory.createLoop();
|
||||
Event<CraftItem> CRAFT_ITEM = EventFactory.createLoop();
|
||||
Event<SmeltItem> SMELT_ITEM = EventFactory.createLoop();
|
||||
Event<PickupItemPredicate> PICKUP_ITEM_PRE = EventFactory.createInteractionResult();
|
||||
Event<PickupItem> PICKUP_ITEM_POST = EventFactory.createLoop();
|
||||
Event<DropItem> DROP_ITEM = EventFactory.createLoop();
|
||||
Event<OpenMenu> OPEN_MENU = EventFactory.createLoop();
|
||||
Event<CloseMenu> CLOSE_MENU = EventFactory.createLoop();
|
||||
Event<BreakBlock> BREAK_BLOCK = EventFactory.createInteractionResult();
|
||||
|
||||
interface PlayerJoin {
|
||||
void join(ServerPlayer player);
|
||||
|
||||
@@ -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<ItemLike>) () -> item)
|
||||
.toArray(Supplier[]::new));
|
||||
Supplier<ItemLike>[] 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>) () -> block)
|
||||
.toArray(Supplier[]::new));
|
||||
Supplier<Block>[] array = new Supplier[blocks.length];
|
||||
for (int i = 0; i < blocks.length; i++) {
|
||||
Block block = blocks[i];
|
||||
array[i] = () -> block;
|
||||
}
|
||||
registerBlockColors(color, array);
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<ItemLike>... 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<Block>... 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<ItemLike>[] 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<Block>[] blocks) {
|
||||
Block[] array = new Block[blocks.length];
|
||||
for (int i = 0; i < blocks.length; i++) {
|
||||
array[i] = blocks[i].get();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.<ColorHandlerEvent.Item>addListener(event -> {
|
||||
for (Pair<ItemColor, Supplier<ItemLike>[]> 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.<ColorHandlerEvent.Block>addListener(event -> {
|
||||
for (Pair<BlockColor, Supplier<Block>[]> 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<ItemLike>[] 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<Block>[] blocks) {
|
||||
Block[] array = new Block[blocks.length];
|
||||
for (int i = 0; i < blocks.length; i++) {
|
||||
array[i] = blocks[i].get();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user