mirror of
https://github.com/architectury/architectury-api.git
synced 2026-04-02 13:37:43 -05:00
Merge remote-tracking branch 'architectury/1.16' into 1.17
# Conflicts: # common/src/main/java/me/shedaniel/architectury/event/events/ChatEvent.java # common/src/main/java/me/shedaniel/architectury/registry/BlockEntityRenderers.java # common/src/main/java/me/shedaniel/architectury/utils/Fraction.java # fabric/src/main/java/me/shedaniel/architectury/registry/fabric/BlockEntityRenderersImpl.java # gradle.properties
This commit is contained in:
@@ -37,10 +37,11 @@ import javax.annotation.Nonnull;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PlatformImpl {
|
||||
private static final Map<String, Mod> mods = new HashMap<>();
|
||||
private static final Map<String, Mod> mods = new ConcurrentHashMap<>();
|
||||
|
||||
public static Path getGameFolder() {
|
||||
return FMLPaths.GAMEDIR.get();
|
||||
@@ -165,4 +166,4 @@ public class PlatformImpl {
|
||||
container.registerExtensionPoint(ExtensionPoint.CONFIGGUIFACTORY, () -> (minecraft, screen) -> configurationScreenProvider.provide(screen));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.entity.forge;
|
||||
|
||||
import me.shedaniel.architectury.forge.ArchitecturyForge;
|
||||
import me.shedaniel.architectury.platform.forge.EventBuses;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
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;
|
||||
|
||||
public class EntityAttributesImpl {
|
||||
private static final Map<Supplier<EntityType<? extends LivingEntity>>, Supplier<AttributeSupplier.Builder>> ATTRIBUTES = new ConcurrentHashMap<>();
|
||||
|
||||
public static void register(Supplier<EntityType<? extends LivingEntity>> type, Supplier<AttributeSupplier.Builder> attribute) {
|
||||
ATTRIBUTES.put(type, attribute);
|
||||
}
|
||||
|
||||
static {
|
||||
EventBuses.onRegistered(ArchitecturyForge.MOD_ID, bus -> {
|
||||
bus.register(EntityAttributesImpl.class);
|
||||
});
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void event(EntityAttributeCreationEvent event) {
|
||||
for (Map.Entry<Supplier<EntityType<? extends LivingEntity>>, Supplier<AttributeSupplier.Builder>> entry : ATTRIBUTES.entrySet()) {
|
||||
event.put(entry.getKey().get(), entry.getValue().get().build());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class BlockEntityRenderersImpl {
|
||||
public static <T extends BlockEntity> void registerRenderer(BlockEntityType<T> type, Function<BlockEntityRenderDispatcher, BlockEntityRenderer<T>> provider) {
|
||||
public static <T extends BlockEntity> void registerRenderer(BlockEntityType<T> type, Function<BlockEntityRenderDispatcher, BlockEntityRenderer<? super T>> provider) {
|
||||
ClientRegistry.bindTileEntityRenderer(type, provider);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,9 +200,9 @@ public class RegistriesImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull RegistrySupplier<T> registerSupplied(ResourceLocation id, Supplier<T> supplier) {
|
||||
public @NotNull <E extends T> RegistrySupplier<E> registerSupplied(ResourceLocation id, Supplier<E> supplier) {
|
||||
net.minecraft.core.Registry.register(delegate, id, supplier.get());
|
||||
return delegateSupplied(id);
|
||||
return (RegistrySupplier<E>) delegateSupplied(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -317,10 +317,10 @@ public class RegistriesImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull RegistrySupplier<T> registerSupplied(ResourceLocation id, Supplier<T> supplier) {
|
||||
public @NotNull <E extends T> RegistrySupplier<E> registerSupplied(ResourceLocation id, Supplier<E> supplier) {
|
||||
RegistryObject registryObject = RegistryObject.of(id, delegate);
|
||||
registry.put(delegate.getRegistrySuperType(), registryObject, () -> supplier.get().setRegistryName(id));
|
||||
return new RegistrySupplier<T>() {
|
||||
return new RegistrySupplier<E>() {
|
||||
@Override
|
||||
public @NotNull ResourceLocation getRegistryId() {
|
||||
return delegate.getRegistryName();
|
||||
@@ -337,8 +337,8 @@ public class RegistriesImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get() {
|
||||
return (T) registryObject.get();
|
||||
public E get() {
|
||||
return (E) registryObject.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.fuel.forge;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.furnace.FurnaceFuelBurnTimeEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
public class FuelRegistryImpl {
|
||||
private static final Object2IntMap<ItemLike> ITEMS = new Object2IntLinkedOpenHashMap<>();
|
||||
|
||||
static {
|
||||
MinecraftForge.EVENT_BUS.register(FuelRegistryImpl.class);
|
||||
}
|
||||
|
||||
public static void register(int time, ItemLike... items) {
|
||||
for (ItemLike item : items) {
|
||||
ITEMS.put(item, time);
|
||||
}
|
||||
}
|
||||
|
||||
public static int get(ItemStack stack) {
|
||||
return ForgeHooks.getBurnTime(stack);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void event(FurnaceFuelBurnTimeEvent event) {
|
||||
if (event.getItemStack().isEmpty()) return;
|
||||
int time = ITEMS.getOrDefault(event.getItemStack().getItem(), Integer.MIN_VALUE);
|
||||
if (time != Integer.MIN_VALUE) {
|
||||
event.setBurnTime(time);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user