mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-28 03:56:59 -05:00
Update for NeoForge 1.21.4
This commit is contained in:
@@ -7,7 +7,7 @@ on:
|
||||
- '**.properties'
|
||||
- '**/src/**'
|
||||
branches:
|
||||
- "1.21.2"
|
||||
- "1.21.4"
|
||||
types: [ opened, synchronize, reopened ]
|
||||
jobs:
|
||||
validate-gradle:
|
||||
@@ -8,7 +8,7 @@ on:
|
||||
- '**/src/**'
|
||||
- '.github/**'
|
||||
branches:
|
||||
- "1.21.2"
|
||||
- "1.21.4"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
norelease:
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* 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.core.item;
|
||||
|
||||
import dev.architectury.platform.Platform;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.item.MobBucketItem;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ArchitecturyMobBucketItem extends MobBucketItem {
|
||||
public ArchitecturyMobBucketItem(Supplier<? extends EntityType<?>> entity, Supplier<? extends Fluid> fluid, Supplier<? extends SoundEvent> sound, Properties properties) {
|
||||
super(checkPlatform(entity).get(), fluid.get(), sound.get(), properties);
|
||||
}
|
||||
|
||||
private static <T> T checkPlatform(T obj) {
|
||||
if (Platform.isForgeLike()) {
|
||||
throw new IllegalStateException("This class should've been replaced on Forge!");
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ package dev.architectury.core.item;
|
||||
|
||||
import dev.architectury.registry.registries.RegistrySupplier;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.dispenser.BlockSource;
|
||||
import net.minecraft.core.dispenser.DefaultDispenseItemBehavior;
|
||||
import net.minecraft.core.dispenser.DispenseItemBehavior;
|
||||
@@ -47,7 +48,7 @@ public class ArchitecturySpawnEggItem extends SpawnEggItem {
|
||||
@Override
|
||||
public ItemStack execute(BlockSource source, ItemStack stack) {
|
||||
Direction direction = source.state().getValue(DispenserBlock.FACING);
|
||||
EntityType<?> entityType = ((SpawnEggItem) stack.getItem()).getType(stack);
|
||||
EntityType<?> entityType = ((SpawnEggItem) stack.getItem()).getType(source.level().registryAccess(), stack);
|
||||
|
||||
try {
|
||||
entityType.spawn(source.level(), stack, null, source.pos().relative(direction), EntitySpawnReason.DISPENSER, direction != Direction.UP, false);
|
||||
@@ -63,13 +64,13 @@ public class ArchitecturySpawnEggItem extends SpawnEggItem {
|
||||
};
|
||||
}
|
||||
|
||||
public ArchitecturySpawnEggItem(RegistrySupplier<? extends EntityType<? extends Mob>> entityType, int backgroundColor, int highlightColor, Properties properties) {
|
||||
this(entityType, backgroundColor, highlightColor, properties, createDispenseItemBehavior());
|
||||
public ArchitecturySpawnEggItem(RegistrySupplier<? extends EntityType<? extends Mob>> entityType, Properties properties) {
|
||||
this(entityType, properties, createDispenseItemBehavior());
|
||||
}
|
||||
|
||||
public ArchitecturySpawnEggItem(RegistrySupplier<? extends EntityType<? extends Mob>> entityType, int backgroundColor, int highlightColor, Properties properties,
|
||||
public ArchitecturySpawnEggItem(RegistrySupplier<? extends EntityType<? extends Mob>> entityType, Properties properties,
|
||||
@Nullable DispenseItemBehavior dispenseItemBehavior) {
|
||||
super(null, backgroundColor, highlightColor, properties);
|
||||
super(null, properties);
|
||||
this.entityType = Objects.requireNonNull(entityType, "entityType");
|
||||
SpawnEggItem.BY_ID.remove(null);
|
||||
entityType.listen(type -> {
|
||||
@@ -85,8 +86,8 @@ public class ArchitecturySpawnEggItem extends SpawnEggItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType<?> getType(ItemStack itemStack) {
|
||||
EntityType<?> type = super.getType(itemStack);
|
||||
public EntityType<?> getType(HolderLookup.Provider provider, ItemStack itemStack) {
|
||||
EntityType<?> type = super.getType(provider, itemStack);
|
||||
return type == null ? entityType.get() : type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import dev.architectury.injectables.annotations.ExpectPlatform;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.sounds.Music;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.util.random.SimpleWeightedRandomList;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.level.biome.*;
|
||||
@@ -271,7 +272,7 @@ public final class BiomeHooks {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectsProperties.Mutable setBackgroundMusic(@Nullable Music music) {
|
||||
public EffectsProperties.Mutable setBackgroundMusic(@Nullable SimpleWeightedRandomList<Music> music) {
|
||||
effects.backgroundMusic = Optional.ofNullable(music);
|
||||
return this;
|
||||
}
|
||||
@@ -332,7 +333,7 @@ public final class BiomeHooks {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Music> getBackgroundMusic() {
|
||||
public Optional<SimpleWeightedRandomList<Music>> getBackgroundMusic() {
|
||||
return effects.backgroundMusic;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ package dev.architectury.hooks.level.biome;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.sounds.Music;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.util.random.SimpleWeightedRandomList;
|
||||
import net.minecraft.world.level.biome.AmbientAdditionsSettings;
|
||||
import net.minecraft.world.level.biome.AmbientMoodSettings;
|
||||
import net.minecraft.world.level.biome.AmbientParticleSettings;
|
||||
@@ -54,7 +55,7 @@ public interface EffectsProperties {
|
||||
|
||||
Optional<AmbientAdditionsSettings> getAmbientAdditionsSound();
|
||||
|
||||
Optional<Music> getBackgroundMusic();
|
||||
Optional<SimpleWeightedRandomList<Music>> getBackgroundMusic();
|
||||
|
||||
interface Mutable extends EffectsProperties {
|
||||
EffectsProperties.Mutable setFogColor(int color);
|
||||
@@ -79,6 +80,6 @@ public interface EffectsProperties {
|
||||
|
||||
EffectsProperties.Mutable setAmbientAdditionsSound(@Nullable AmbientAdditionsSettings settings);
|
||||
|
||||
EffectsProperties.Mutable setBackgroundMusic(@Nullable Music music);
|
||||
EffectsProperties.Mutable setBackgroundMusic(@Nullable SimpleWeightedRandomList<Music> music);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,6 @@ import dev.architectury.injectables.annotations.ExpectPlatform;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
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;
|
||||
|
||||
import java.util.Objects;
|
||||
@@ -35,15 +33,6 @@ public final class ColorHandlerRegistry {
|
||||
private ColorHandlerRegistry() {
|
||||
}
|
||||
|
||||
public static void registerItemColors(ItemColor color, ItemLike... items) {
|
||||
Supplier<ItemLike>[] array = new Supplier[items.length];
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var item = Objects.requireNonNull(items[i], "items[i] is null!");
|
||||
array[i] = () -> item;
|
||||
}
|
||||
registerItemColors(color, array);
|
||||
}
|
||||
|
||||
public static void registerBlockColors(BlockColor color, Block... blocks) {
|
||||
Supplier<Block>[] array = new Supplier[blocks.length];
|
||||
for (var i = 0; i < blocks.length; i++) {
|
||||
@@ -53,12 +42,6 @@ public final class ColorHandlerRegistry {
|
||||
registerBlockColors(color, array);
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
@ExpectPlatform
|
||||
public static void registerItemColors(ItemColor color, Supplier<? extends ItemLike>... items) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
@ExpectPlatform
|
||||
public static void registerBlockColors(BlockColor color, Supplier<? extends Block>... blocks) {
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* 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.registry.item;
|
||||
|
||||
import dev.architectury.injectables.annotations.ExpectPlatform;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.renderer.item.ClampedItemPropertyFunction;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
|
||||
/**
|
||||
* Registry for registering item properties used for model predicates.
|
||||
*
|
||||
* @see net.minecraft.client.renderer.item.ItemProperties
|
||||
*/
|
||||
@Environment(EnvType.CLIENT)
|
||||
public final class ItemPropertiesRegistry {
|
||||
private ItemPropertiesRegistry() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a generic item property function for all items.
|
||||
*
|
||||
* @param propertyId the id of the property
|
||||
* @param function the function to be registered
|
||||
* @return the function registered
|
||||
*/
|
||||
@ExpectPlatform
|
||||
public static ClampedItemPropertyFunction registerGeneric(ResourceLocation propertyId, ClampedItemPropertyFunction function) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a generic item property function for a specific item.
|
||||
*
|
||||
* @param item the item to be registered for
|
||||
* @param propertyId the id of the property
|
||||
* @param function the function to be registered
|
||||
* @return the function registered
|
||||
*/
|
||||
@ExpectPlatform
|
||||
public static ClampedItemPropertyFunction register(ItemLike item, ResourceLocation propertyId, ClampedItemPropertyFunction function) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ unifiedPublishing {
|
||||
curseforge {
|
||||
token = CURSE_API_KEY
|
||||
id = rootProject.curseforge_id
|
||||
gameVersions.addAll "Java 21", "1.21.2-Snapshot", project.minecraft_version
|
||||
gameVersions.addAll "Java 21", "1.21.4-Snapshot", project.minecraft_version
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,34 +21,18 @@ package dev.architectury.registry.client.rendering.fabric;
|
||||
|
||||
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;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ColorHandlerRegistryImpl {
|
||||
@SafeVarargs
|
||||
public static void registerItemColors(ItemColor itemColor, Supplier<? extends ItemLike>... items) {
|
||||
Objects.requireNonNull(itemColor, "color is null!");
|
||||
ColorProviderRegistry.ITEM.register(itemColor, unpackItems(items));
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public static void registerBlockColors(BlockColor blockColor, Supplier<? extends Block>... blocks) {
|
||||
Objects.requireNonNull(blockColor, "color is null!");
|
||||
ColorProviderRegistry.BLOCK.register(blockColor, unpackBlocks(blocks));
|
||||
}
|
||||
|
||||
private static ItemLike[] unpackItems(Supplier<? extends ItemLike>[] items) {
|
||||
var array = new ItemLike[items.length];
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
array[i] = Objects.requireNonNull(items[i].get());
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
private static Block[] unpackBlocks(Supplier<? extends Block>[] blocks) {
|
||||
var array = new Block[blocks.length];
|
||||
for (var i = 0; i < blocks.length; i++) {
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* 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.registry.item.fabric;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry;
|
||||
import net.minecraft.client.renderer.item.ClampedItemPropertyFunction;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
|
||||
public class ItemPropertiesRegistryImpl {
|
||||
public static ClampedItemPropertyFunction registerGeneric(ResourceLocation propertyId, ClampedItemPropertyFunction function) {
|
||||
FabricModelPredicateProviderRegistry.register(propertyId, function);
|
||||
return function;
|
||||
}
|
||||
|
||||
public static ClampedItemPropertyFunction register(ItemLike item, ResourceLocation propertyId, ClampedItemPropertyFunction function) {
|
||||
FabricModelPredicateProviderRegistry.register(item.asItem(), propertyId, function);
|
||||
return function;
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.Music;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.util.random.SimpleWeightedRandomList;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.level.biome.*;
|
||||
@@ -324,7 +325,7 @@ public class BiomeModificationsImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectsProperties.Mutable setBackgroundMusic(@Nullable Music music) {
|
||||
public EffectsProperties.Mutable setBackgroundMusic(@Nullable SimpleWeightedRandomList<Music> music) {
|
||||
context.setMusic(Optional.ofNullable(music));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
},
|
||||
"icon": "icon.png",
|
||||
"depends": {
|
||||
"minecraft": "~1.21.2-",
|
||||
"minecraft": "~1.21.4-",
|
||||
"fabricloader": ">=0.15.11",
|
||||
"fabric-api": ">=0.100.0"
|
||||
},
|
||||
|
||||
@@ -3,23 +3,23 @@ org.gradle.daemon=false
|
||||
|
||||
platforms=fabric,neoforge
|
||||
|
||||
minecraft_version=1.21.2
|
||||
supported_version=1.21.2
|
||||
minecraft_version=1.21.4
|
||||
supported_version=1.21.4
|
||||
|
||||
artifact_type=release
|
||||
|
||||
archives_base_name=architectury
|
||||
archives_base_name_snapshot=architectury-snapshot
|
||||
base_version=14.0
|
||||
base_version=15.0
|
||||
maven_group=dev.architectury
|
||||
version_suffix=
|
||||
|
||||
fabric_loader_version=0.16.7
|
||||
fabric_api_version=0.106.1+1.21.2
|
||||
fabric_loader_version=0.16.9
|
||||
fabric_api_version=0.110.5+1.21.4
|
||||
mod_menu_version=11.0.1
|
||||
|
||||
forge_version=51.0.0
|
||||
neoforge_version=21.2.0-beta
|
||||
neoforge_version=21.4.0-beta
|
||||
|
||||
# Set to empty if not snapshots
|
||||
neoforge_pr=
|
||||
|
||||
@@ -50,7 +50,6 @@ shadowJar {
|
||||
exclude 'dev/architectury/core/fluid/ArchitecturyFlowingFluid$Source.class'
|
||||
exclude 'dev/architectury/core/fluid/ArchitecturyFlowingFluid$Flowing.class'
|
||||
exclude 'dev/architectury/core/item/ArchitecturyBucketItem.class'
|
||||
exclude 'dev/architectury/core/item/ArchitecturyMobBucketItem.class'
|
||||
relocate "dev.architectury.core.block.forge.imitator", "dev.architectury.core.block"
|
||||
relocate "dev.architectury.core.fluid.forge.imitator", "dev.architectury.core.fluid"
|
||||
relocate "dev.architectury.core.item.forge.imitator", "dev.architectury.core.item"
|
||||
@@ -122,7 +121,7 @@ unifiedPublishing {
|
||||
displayName = "[NeoForge $rootProject.supported_version] v$project.version"
|
||||
releaseType = "$rootProject.artifact_type"
|
||||
changelog = releaseChangelog()
|
||||
gameVersions = ["1.21.2"]
|
||||
gameVersions = ["1.21.4"]
|
||||
gameLoaders = ["neoforge"]
|
||||
mainPublication renameJarForPublication
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* 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.core.item.forge.imitator;
|
||||
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.item.MobBucketItem;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ArchitecturyMobBucketItem extends MobBucketItem {
|
||||
public ArchitecturyMobBucketItem(Supplier<? extends EntityType<?>> entity, Supplier<? extends Fluid> fluid, Supplier<? extends SoundEvent> sound, Properties properties) {
|
||||
super(entity.get(), fluid.get(), sound.get(), properties);
|
||||
}
|
||||
}
|
||||
@@ -24,8 +24,6 @@ import dev.architectury.platform.hooks.EventBusesHooks;
|
||||
import dev.architectury.utils.ArchitecturyConstants;
|
||||
import net.minecraft.client.Minecraft;
|
||||
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;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent;
|
||||
@@ -36,7 +34,6 @@ import java.util.Objects;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ColorHandlerRegistryImpl {
|
||||
private static final List<Pair<ItemColor, Supplier<? extends ItemLike>[]>> ITEM_COLORS = Lists.newArrayList();
|
||||
private static final List<Pair<BlockColor, Supplier<? extends Block>[]>> BLOCK_COLORS = Lists.newArrayList();
|
||||
|
||||
static {
|
||||
@@ -45,13 +42,6 @@ public class ColorHandlerRegistryImpl {
|
||||
});
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onItemColorEvent(RegisterColorHandlersEvent.Item event) {
|
||||
for (Pair<ItemColor, Supplier<? extends ItemLike>[]> pair : ITEM_COLORS) {
|
||||
event.register(pair.getLeft(), unpackItems(pair.getRight()));
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onBlockColorEvent(RegisterColorHandlersEvent.Block event) {
|
||||
for (Pair<BlockColor, Supplier<? extends Block>[]> pair : BLOCK_COLORS) {
|
||||
@@ -59,16 +49,6 @@ public class ColorHandlerRegistryImpl {
|
||||
}
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public static void registerItemColors(ItemColor itemColor, Supplier<? extends ItemLike>... items) {
|
||||
Objects.requireNonNull(itemColor, "color is null!");
|
||||
if (Minecraft.getInstance().getItemColors() == null) {
|
||||
ITEM_COLORS.add(Pair.of(itemColor, items));
|
||||
} else {
|
||||
Minecraft.getInstance().getItemColors().register(itemColor, unpackItems(items));
|
||||
}
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public static void registerBlockColors(BlockColor blockColor, Supplier<? extends Block>... blocks) {
|
||||
Objects.requireNonNull(blockColor, "color is null!");
|
||||
@@ -79,14 +59,6 @@ public class ColorHandlerRegistryImpl {
|
||||
}
|
||||
}
|
||||
|
||||
private static ItemLike[] unpackItems(Supplier<? extends ItemLike>[] items) {
|
||||
ItemLike[] array = new ItemLike[items.length];
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
array[i] = Objects.requireNonNull(items[i].get());
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
private static Block[] unpackBlocks(Supplier<? extends Block>[] blocks) {
|
||||
Block[] array = new Block[blocks.length];
|
||||
for (int i = 0; i < blocks.length; i++) {
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* 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.registry.item.forge;
|
||||
|
||||
import net.minecraft.client.renderer.item.ClampedItemPropertyFunction;
|
||||
import net.minecraft.client.renderer.item.ItemProperties;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
|
||||
public class ItemPropertiesRegistryImpl {
|
||||
public static ClampedItemPropertyFunction registerGeneric(ResourceLocation propertyId, ClampedItemPropertyFunction function) {
|
||||
ItemProperties.registerGeneric(propertyId, function);
|
||||
return function;
|
||||
}
|
||||
|
||||
public static ClampedItemPropertyFunction register(ItemLike item, ResourceLocation propertyId, ClampedItemPropertyFunction function) {
|
||||
ItemProperties.register(item.asItem(), propertyId, function);
|
||||
return function;
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.sounds.Music;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.util.random.SimpleWeightedRandomList;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.level.biome.*;
|
||||
@@ -397,7 +398,7 @@ public class BiomeModificationsImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Music> getBackgroundMusic() {
|
||||
public Optional<SimpleWeightedRandomList<Music>> getBackgroundMusic() {
|
||||
return builder.backgroundMusic;
|
||||
}
|
||||
|
||||
@@ -468,7 +469,7 @@ public class BiomeModificationsImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mutable setBackgroundMusic(@Nullable Music music) {
|
||||
public Mutable setBackgroundMusic(@Nullable SimpleWeightedRandomList<Music> music) {
|
||||
builder.backgroundMusic = Optional.ofNullable(music);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ license = "LGPL-3"
|
||||
[[dependencies.architectury]]
|
||||
modId = "minecraft"
|
||||
type = "required"
|
||||
versionRange = "[1.21,)"
|
||||
versionRange = "[1.21.4,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven { url "https://maven.fabricmc.net/" }
|
||||
maven { url "https://maven.architectury.dev/" }
|
||||
maven { url "https://files.minecraftforge.net/maven/" }
|
||||
|
||||
@@ -25,11 +25,13 @@ import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.storage.loot.LootPool;
|
||||
import net.minecraft.world.level.storage.loot.entries.LootItem;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class TestLoot {
|
||||
public static void init() {
|
||||
LootEvent.MODIFY_LOOT_TABLE.register((key, context, builtin) -> {
|
||||
// Check that the loot table is dirt and built-in
|
||||
if (builtin && Blocks.DIRT.getLootTable().equals(key)) {
|
||||
if (builtin && Blocks.DIRT.getLootTable().equals(Optional.ofNullable(key))) {
|
||||
// Create a loot pool with a single item entry of Items.DIAMOND
|
||||
LootPool.Builder pool = LootPool.lootPool().add(LootItem.lootTableItem(Items.DIAMOND));
|
||||
context.addPool(pool);
|
||||
|
||||
@@ -127,10 +127,10 @@ public class TestRegistries {
|
||||
.setId(id(Registries.ITEM, "test_edible")));
|
||||
});
|
||||
public static final RegistrySupplier<Item> TEST_SPAWN_EGG = ITEMS.register("test_spawn_egg", () ->
|
||||
new ArchitecturySpawnEggItem(TestRegistries.TEST_ENTITY, 0xFF000000, 0xFFFFFFFF,
|
||||
new ArchitecturySpawnEggItem(TestRegistries.TEST_ENTITY,
|
||||
new Item.Properties().arch$tab(TestRegistries.TEST_TAB).setId(id(Registries.ITEM, "test_spawn_egg"))));
|
||||
public static final RegistrySupplier<Item> TEST_SPAWN_EGG_2 = ITEMS.register("test_spawn_egg_2", () ->
|
||||
new ArchitecturySpawnEggItem(TestRegistries.TEST_ENTITY_2, 0xFFFFFFFF, 0xFF000000,
|
||||
new ArchitecturySpawnEggItem(TestRegistries.TEST_ENTITY_2,
|
||||
new Item.Properties().arch$tab(TestRegistries.TEST_TAB).setId(id(Registries.ITEM, "test_spawn_egg_2"))));
|
||||
|
||||
public static final RegistrySupplier<Item> TEST_FLUID_BUCKET = ITEMS.register("test_fluid_bucket", () -> {
|
||||
|
||||
@@ -22,7 +22,6 @@ package dev.architectury.test.tags;
|
||||
import dev.architectury.event.EventResult;
|
||||
import dev.architectury.event.events.common.BlockEvent;
|
||||
import dev.architectury.test.TestMod;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
@@ -38,7 +37,7 @@ public class TestTags {
|
||||
|
||||
BlockEvent.BREAK.register((world, pos, state, player, xp) -> {
|
||||
if (player != null && !world.isClientSide() && (state.is(heartParticles) || state.is(heartParticles2))) {
|
||||
((ServerLevel) world).sendParticles(player, ParticleTypes.HEART, false, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 10, 0.0, 0.0, 0.0, 0.0);
|
||||
((ServerLevel) world).sendParticles(player, ParticleTypes.HEART, false, false, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 10, 0.0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
return EventResult.pass();
|
||||
|
||||
Reference in New Issue
Block a user