LootItemFunctionType now use LootItemFunctionType

This commit is contained in:
Davide Albiero
2022-06-08 22:52:21 +02:00
committed by Raoul
parent 726c3e3c25
commit d689c325d6
9 changed files with 30 additions and 34 deletions

View File

@@ -102,7 +102,7 @@ processResources {
}
dependencies {
minecraft 'net.minecraftforge:forge:1.18.2-40.0.32'
minecraft 'net.minecraftforge:forge:1.18.2-40.1.48'
compileOnly fg.deobf("mezz.jei:jei-1.18.2:9.5.4.171:api")
runtimeOnly fg.deobf("mezz.jei:jei-1.18.2:9.5.4.171")
@@ -122,7 +122,7 @@ jar {
"Specification-Vendor" : "refinedmods",
"Specification-Version" : "1",
"Implementation-Title" : project.name,
"Implementation-Version" : "${version}",
"Implementation-Version" : project.jar.archiveVersion,
"Implementation-Vendor" : "refinedmods",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])

View File

@@ -48,6 +48,7 @@ public final class RS {
RSBlocks.register();
RSItems.register();
RSLootFunctions.register();
FMLJavaModLoadingContext.get().getModEventBus().addListener(CommonSetup::onCommonSetup);
FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(BlockEntityType.class, CommonSetup::onRegisterBlockEntities);

View File

@@ -5,38 +5,30 @@ import com.refinedmods.refinedstorage.loottable.CrafterLootFunction;
import com.refinedmods.refinedstorage.loottable.PortableGridBlockLootFunction;
import com.refinedmods.refinedstorage.loottable.StorageBlockLootFunction;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.RegistryObject;
public final class RSLootFunctions {
private static LootItemFunctionType storageBlock;
private static LootItemFunctionType portableGrid;
private static LootItemFunctionType crafter;
private static LootItemFunctionType controller;
public static final RegistryObject<LootItemFunctionType> STORAGE_BLOCK;
public static final RegistryObject<LootItemFunctionType> PORTABLE_GRID;
public static final RegistryObject<LootItemFunctionType> CRAFTER;
public static final RegistryObject<LootItemFunctionType> CONTROLLER;
private static final DeferredRegister<LootItemFunctionType> LOOT_ITEM_FUNCTIONS = DeferredRegister.create(Registry.LOOT_FUNCTION_REGISTRY, RS.ID);
static {
STORAGE_BLOCK = LOOT_ITEM_FUNCTIONS.register("storage_block", () -> new LootItemFunctionType(new StorageBlockLootFunction.Serializer()));
PORTABLE_GRID = LOOT_ITEM_FUNCTIONS.register("portable_grid", () -> new LootItemFunctionType(new PortableGridBlockLootFunction.Serializer()));
CRAFTER = LOOT_ITEM_FUNCTIONS.register("crafter", () -> new LootItemFunctionType(new CrafterLootFunction.Serializer()));
CONTROLLER = LOOT_ITEM_FUNCTIONS.register("controller", () -> new LootItemFunctionType(new ControllerLootFunction.Serializer()));
}
private RSLootFunctions() {
}
public static void register() {
storageBlock = Registry.register(Registry.LOOT_FUNCTION_TYPE, new ResourceLocation(RS.ID, "storage_block"), new LootItemFunctionType(new StorageBlockLootFunction.Serializer()));
portableGrid = Registry.register(Registry.LOOT_FUNCTION_TYPE, new ResourceLocation(RS.ID, "portable_grid"), new LootItemFunctionType(new PortableGridBlockLootFunction.Serializer()));
crafter = Registry.register(Registry.LOOT_FUNCTION_TYPE, new ResourceLocation(RS.ID, "crafter"), new LootItemFunctionType(new CrafterLootFunction.Serializer()));
controller = Registry.register(Registry.LOOT_FUNCTION_TYPE, new ResourceLocation(RS.ID, "controller"), new LootItemFunctionType(new ControllerLootFunction.Serializer()));
}
public static LootItemFunctionType getStorageBlock() {
return storageBlock;
}
public static LootItemFunctionType getPortableGrid() {
return portableGrid;
}
public static LootItemFunctionType getCrafter() {
return crafter;
}
public static LootItemFunctionType getController() {
return controller;
LOOT_ITEM_FUNCTIONS.register(FMLJavaModLoadingContext.get().getModEventBus());
}
}

View File

@@ -38,7 +38,7 @@ public class ControllerLootFunction extends LootItemConditionalFunction {
@Override
public LootItemFunctionType getType() {
return RSLootFunctions.getController();
return RSLootFunctions.CONTROLLER.get();
}
public static class Serializer extends LootItemConditionalFunction.Serializer<ControllerLootFunction> {

View File

@@ -40,7 +40,7 @@ public class CrafterLootFunction extends LootItemConditionalFunction {
@Override
public LootItemFunctionType getType() {
return RSLootFunctions.getCrafter();
return RSLootFunctions.CRAFTER.get();
}
public static class Serializer extends LootItemConditionalFunction.Serializer<CrafterLootFunction> {

View File

@@ -30,7 +30,7 @@ public class PortableGridBlockLootFunction extends LootItemConditionalFunction {
@Override
public LootItemFunctionType getType() {
return RSLootFunctions.getPortableGrid();
return RSLootFunctions.PORTABLE_GRID.get();
}
public static class Serializer extends LootItemConditionalFunction.Serializer<PortableGridBlockLootFunction> {

View File

@@ -51,7 +51,7 @@ public class StorageBlockLootFunction extends LootItemConditionalFunction {
@Override
public LootItemFunctionType getType() {
return RSLootFunctions.getStorageBlock();
return RSLootFunctions.STORAGE_BLOCK.get();
}
public static class Serializer extends LootItemConditionalFunction.Serializer<StorageBlockLootFunction> {

View File

@@ -159,9 +159,6 @@ public final class CommonSetup {
@SubscribeEvent
public static void onRegisterBlockEntities(RegistryEvent.Register<BlockEntityType<?>> e) {
// Register here, there seems to be no specific register event for loot function types.
RSLootFunctions.register();
e.getRegistry().register(registerSynchronizationParameters(BlockEntityType.Builder.of((pos, state) -> new ControllerBlockEntity(NetworkType.NORMAL, pos, state), RSBlocks.CONTROLLER.getBlocks()).build(null).setRegistryName(RS.ID, "controller")));
e.getRegistry().register(registerSynchronizationParameters(BlockEntityType.Builder.of((pos, state) -> new ControllerBlockEntity(NetworkType.CREATIVE, pos, state), RSBlocks.CREATIVE_CONTROLLER.getBlocks()).build(null).setRegistryName(RS.ID, "creative_controller")));
e.getRegistry().register(BlockEntityType.Builder.of(CableBlockEntity::new, RSBlocks.CABLE.get()).build(null).setRegistryName(RS.ID, "cable"));

View File

@@ -12,3 +12,9 @@ authors = "Refined Mods"
description = '''
An elegant solution to your hoarding problem
'''
[[dependencies.refinedstorage]]
modId="forge"
mandatory=true
versionRange="[40.1,)"
ordering="NONE"
side="BOTH"