mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-28 20:06:59 -05:00
Testmod
Restore variance
This commit is contained in:
@@ -31,7 +31,7 @@ public final class FoodPropertiesHooks {
|
||||
|
||||
@ExpectPlatform
|
||||
public static void effect(FoodProperties.Builder builder,
|
||||
Supplier<MobEffectInstance> effectSupplier, float chance) {
|
||||
Supplier<? extends MobEffectInstance> effectSupplier, float chance) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.function.Supplier;
|
||||
|
||||
public class FoodPropertiesHooksImpl {
|
||||
public static void effect(FoodProperties.Builder builder,
|
||||
Supplier<MobEffectInstance> effectSupplier, float chance) {
|
||||
Supplier<? extends MobEffectInstance> effectSupplier, float chance) {
|
||||
// Fabric doesn't have deferred registration, so the mob effect should always be available anyway
|
||||
builder.effect(effectSupplier.get(), chance);
|
||||
}
|
||||
|
||||
@@ -25,8 +25,9 @@ import net.minecraft.world.food.FoodProperties;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class FoodPropertiesHooksImpl {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void effect(FoodProperties.Builder builder,
|
||||
Supplier<MobEffectInstance> effectSupplier, float chance) {
|
||||
builder.effect(effectSupplier, chance);
|
||||
Supplier<? extends MobEffectInstance> effectSupplier, float chance) {
|
||||
builder.effect((Supplier<MobEffectInstance>) effectSupplier, chance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package me.shedaniel.architectury.test.registry;
|
||||
|
||||
import me.shedaniel.architectury.hooks.EntityHooks;
|
||||
import me.shedaniel.architectury.hooks.FoodPropertiesHooks;
|
||||
import me.shedaniel.architectury.registry.BlockProperties;
|
||||
import me.shedaniel.architectury.registry.DeferredRegister;
|
||||
import me.shedaniel.architectury.registry.RegistrySupplier;
|
||||
@@ -29,7 +30,11 @@ import me.shedaniel.architectury.test.registry.objects.EquippableTickingItem;
|
||||
import me.shedaniel.architectury.test.tab.TestCreativeTabs;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffectCategory;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.food.FoodProperties;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
@@ -45,11 +50,20 @@ public class TestRegistries {
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(TestMod.MOD_ID, Registry.ITEM_REGISTRY);
|
||||
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(TestMod.MOD_ID, Registry.BLOCK_REGISTRY);
|
||||
public static final DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(TestMod.MOD_ID, Registry.ENTITY_TYPE_REGISTRY);
|
||||
public static final DeferredRegister<MobEffect> MOB_EFFECTS = DeferredRegister.create(TestMod.MOD_ID, Registry.MOB_EFFECT_REGISTRY);
|
||||
|
||||
public static final RegistrySupplier<MobEffect> TEST_EFFECT = MOB_EFFECTS.register("test_effect", () ->
|
||||
new MobEffect(MobEffectCategory.NEUTRAL, 0x123456) { });
|
||||
|
||||
public static final RegistrySupplier<Item> TEST_ITEM = ITEMS.register("test_item", () ->
|
||||
new Item(new Item.Properties().tab(TestCreativeTabs.TEST_TAB)));
|
||||
public static final RegistrySupplier<Item> TEST_EQUIPPABLE = ITEMS.register("test_eqippable", () ->
|
||||
new EquippableTickingItem(new Item.Properties().tab(TestCreativeTabs.TEST_TAB)));
|
||||
public static final RegistrySupplier<Item> TEST_EDIBLE = ITEMS.register("test_edible", () -> {
|
||||
FoodProperties.Builder fpBuilder = new FoodProperties.Builder().nutrition(8).saturationMod(0.8F).meat();
|
||||
FoodPropertiesHooks.effect(fpBuilder, () -> new MobEffectInstance(TEST_EFFECT.get(), 100), 1);
|
||||
return new Item(new Item.Properties().tab(TestCreativeTabs.TEST_TAB).food(fpBuilder.build()));
|
||||
});
|
||||
|
||||
public static final RegistrySupplier<Block> TEST_BLOCK = BLOCKS.register("test_block", () ->
|
||||
new Block(BlockProperties.copy(Blocks.STONE)));
|
||||
@@ -70,6 +84,7 @@ public class TestRegistries {
|
||||
public static final RegistrySupplier<EntityType<TestEntity>> TEST_ENTITY = ENTITY_TYPES.register("test_entity", () -> TestEntity.TYPE);
|
||||
|
||||
public static void initialize() {
|
||||
MOB_EFFECTS.register();
|
||||
BLOCKS.register();
|
||||
ITEMS.register();
|
||||
ENTITY_TYPES.register();
|
||||
|
||||
Reference in New Issue
Block a user