Jump to content

[Solved][1.15.2] Can't register Structure


Elsopeen

Recommended Posts

Hello,

I'm trying to add a structure to my mod, following this example, but the Registry.register function gives me an error. I know it's not the same forge version, but I kinda hoped it would still work.

I get 2 errors : first "String is not a functional interface" when I try to pass my Piece just like in the example, second I get "init\ModBusEvents.java:21: error: 'void' type not allowed here
                args.getRegistry().register(new Tower(NoFeatureConfig::deserialize) void type not authorized here"

 

Here's my repo, the important files are in the structures and init packages.

 

I hope you'll be able to help me,

thanks anyway,

Best regards,
Elsopéen

 

Nevermind, I failed to correctly match what's in the example...

Edited by Elsopeen
Found the problem
Link to comment
Share on other sites

Look closer at the registry event code, you've got 2 lines of code from my example smashed together into 1 line of code.

Mine:

@SubscribeEvent
public static void registerFeatures(RegistryEvent.Register<Feature<?>> args) {
	 StrucTest.BRICK_HOUSE_PIECE = Registry.register(Registry.STRUCTURE_PIECE, StrucTest.HOUSE_LOC, BrickHousePiece.Piece::new);
	 args.getRegistry().register(new BrickHouse(NoFeatureConfig::deserialize).setRegistryName(StrucTest.HOUSE_LOC));
}

 

Yours:

public static void registerFeatures(RegistryEvent.Register<Feature<?>> args) {
    ModStructurePieceTypes.TOWER_PIECE = Registry.register(Registry.STRUCTURE_PIECE,
            ModStructurePieceTypes.TOWER_LOC,
            TowerPiece.Piece::new,
            args.getRegistry().register(new Tower(NoFeatureConfig::deserialize)
                    .setRegistryName(ModStructurePieceTypes.TOWER_LOC)));
}

 

Also please post your debug.log (pref. as a github gist), it will provide more info than summarized error messages :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello, im kind of a newbie on creating mods, and i been trying to make simples mods so far, Right now, i'm creating a mod which detect an specific type of mob and kill it if reach a certain number, by far the mod is detecting the mob and counting them but at the time it reach the limit number, it don't do anything. The Game don't tweak, don't crash, just i't don't run the method i call, which is kill().   public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, InteractionHand pUsedHand) { final var TotalCows = pLevel.getNearbyEntities(Cow.class, TargetingConditions.forNonCombat(), pPlayer, pPlayer.getBoundingBox().inflate(5)); if(pLevel.isClientSide){ if(pPlayer.getItemInHand(InteractionHand.MAIN_HAND).getItem() == this.asItem()){ if(!TotalCows.isEmpty()){ if(TotalCows.get(0).isAlive()){ TotalCows.get(0).kill(); } }else{ pPlayer.sendSystemMessage(Component.literal("No hay vacas")); } } } The sendSystemMessage is get triggered, and when i change the method .kill() by any other like send a message it got called, can i get some tips, and a clue of what i'm missing
    • UPD: I DID IT   @Override public void applyEffectTick(LivingEntity livingEntity, int pAmplifier) { Level level = livingEntity.level(); if (!level.isClientSide()) { Holder<DamageType> entropyHolder = level .registryAccess() .registryOrThrow(Registries.DAMAGE_TYPE) .getHolderOrThrow(GTDamageTypes.ENTROPY_KEY); livingEntity.hurt(new DamageSource(entropyHolder), 1); } super.applyEffectTick(livingEntity, pAmplifier); }  
    • So I came to this public class ModDamageTypes{ public static void bootstrap(BootstapContext<DamageType> context) { context.register(GTDamageTypes.ENTROPY_KEY, new DamageType(GrimTales.MOD_ID + "_entropy", 0.1f)); } } public class GTDamageTypes implements DamageTypes { public static final ResourceKey<DamageType> ENTROPY_KEY = register("entropy"); private static ResourceKey<DamageType> register(String name) { return ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(GrimTales.MOD_ID, name)); } } public class ModWorldGenProvider extends DatapackBuiltinEntriesProvider { public static final RegistrySetBuilder BUILDER = new RegistrySetBuilder() .add(Registries.DAMAGE_TYPE, ModDamageTypes::bootstrap); public ModWorldGenProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> registries) { super(output, registries, BUILDER, Set.of(GrimTales.MOD_ID)); } But! I still have an issue that, I cannot just use Holder.direct, due to it will create error that "Required type:  Holder<DamageType>  Provided : Holder<ResourceKey<DamageType>>" And I still have no clue how to fix it
    • Yea, unless someone else sees this and has a solution in the next 4 or 5 hours, I’m just gonna reinstall the modpack. Thanks for trying to help me out.
    • Sadly, no it didn't work, although the window for minecraft startup stayed longer. do you have anymore recommendations?
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.