mirror of
https://github.com/architectury/architectury-api.git
synced 2026-04-03 05:57:40 -05:00
Update for NeoForge 1.21.4
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user