Jump to content

Choonster

Moderators
  • Posts

    5120
  • Joined

  • Last visited

  • Days Won

    75

Posts posted by Choonster

  1. 2 hours ago, oitsjustjose said:

    That makes sense. I had a hunch that it had something to do with priority / race condition, it I wasn’t sure and wondered if it was something else. Ok. 
     

    Is there a way to programmatically remove recipes? I’m aware of RecipeManager but I’m not sure in which context I can obtain an instance (or should I declare my own?), and either way I’ve had issues with not being able to remove from the list (I imagine by the time it becomes accessible it is immutable but I didn’t look too far into it as it felt like a hack).

     

    You can see how I remove recipes according to various conditions here. The recipe maps are immutable, but the fields storing them aren't final.

    • Thanks 1
  2. 8 minutes ago, Simon_kungen said:

    So, it seems like this thread died right when it was born. So let me reformulate: Read custom Json files in the data/ directory and do stuff with that. Does Minecraft have a static function to read the Json files and get the values inside that?

     

    It looks like Vanilla extends JsonReloadListener for recipes (RecipeManager), advancements (AdvancementManager) and loot tables (LootTableManager).

  3. You need to create a literal argument (Commands.literal) for "string" and call requires/then/execute on that as necessary and do the same for "player". In your main command registration (where you call CommandDispatcher#register), create a literal argument for "testcommand" and call then on it with the result of each literal method chain.

     

    If string and player are more like separate commands than modes of the same command, you can move each sub-command into its own class with a static method that returns an ArgumentBuilder<CommandSource, ?> (the result of the literal method chain) and call these methods in the then calls of the main command registration.

     

    See ForgeCommand or my TestMod3Command for examples of this.

  4. 1 hour ago, fanor said:

    Guys, have you an idea of remplace Natural_stone by other block ? like custom block ?

    Currently, you need to create your own Feature implementation that does the same thing as OreFeature but can be configured to replace your desired block.

     

    If/when this pull request is merged, all you'll need to do is create a new FillerBlockType that matches the block you want to replace.

    • Thanks 1
  5. I have a chunk capability that stores an energy value for each chunk. The Capability.IStorage implementation calls ChunkEnergy#setEnergy when reading from NBT, this in turn calls ChunkEnergy#onEnergyChanged which sends a packet to update all clients tracking the chunk with the new energy value.

     

    In 1.12.2, I used World#isBlockLoaded before getting the Chunk from the World to prevent an infinite recursion scenario where loading the chunk attempts to load the chunk.

     

    In 1.14.4, I'm using IWorld#chunkExists instead; but this returns true even when the chunk is being loaded. If I then call World#getChunk while the chunk is being loaded, this seems to result in a deadlock where the chunk loading never completes and the world never loads.

     

    The code on GitHub currently uses world.getChunk(x, z), but I've tried calling world.getChunk(x, z, ChunkStatus.EMPTY, false) just to see if it will return null or an empty chunk and this results in the same deadlock.

     

    It seems like I could use ChunkHolder#func_219299_i and ChunkHolder#func_219278_b to get the ChunkStatus of a chunk, but there don't seem to be any public methods to get a ChunkHolder and I'm reluctant to use internal APIs if there are public APIs available.

     

    Does anyone know if there's a way to determine whether a chunk is fully loaded without causing a deadlock if called during chunk loading?

  6. 20 hours ago, Draco18s said:

    What has world.markBlockRangeForRenderUpdate(pos, pos); been replaced by?

     

    The closest equivalents I can see are World#func_225319_b or WorldRenderer#markBlockRangeForRenderUpdate, though a lot of places that used to call World#markBlockRangeForRenderUpdate don't seem to call anything in its place now.

  7. Forge's fluid system (including the forge:fluid model) was removed in 1.13 due to large changes in the Vanilla fluid system. Forge's new fluid system is still being worked on, you can see some of the progress in this PR and KingLemming's fork.

     

    Until then, you could look at Vanilla's waterloggable blocks (IWaterLoggable) where the block can exist in the same space as a fluid (usually water).

     

    Extended states were replaced by the model data system in this PR.

  8. It looks like spawning conditions are handled by EntitySpawnPlacementRegistry in 1.14.

     

    You need to call EntitySpawnPlacementRegistry.register with your EntityType and a predicate that determines the conditions under which it can spawn. Zombies and other hostile mobs use MonsterEntity::func_223325_c for the predicate, this checks the difficulty and the light level.

    • Thanks 1
  9. It turns out that the constructor of the @Mod class is too early to call CapabilityManager#registerCapability as it uses the CapabilityManager#callbacks map, but this is only initialised between RegistryEvent.NewRegistry and RegistryEvent.Register being fired.

     

    Due to this, I kept the capability registration in FMLCommonSetupEvent and just added null protection to the IForgeItem#initCapabilities implementations. This fixed the crash.

     

    You can see the changes I made in this commit.

  10. Lex responded to the issue on GitHub and basically said to register the capabilities earlier and add null protection to the IForgeItem#createProvider implementation:

     

    Quote

    Register your cap in your constructor and hope it is called before anything anywhere creates a ItemStack.
    Since that's not feasible in a multithreaded world, better solution, add null protection to your createProvider code.

     

  11. ForgeConfigSpec implements UnmodifiableConfig, have you tried calling UnmodifiableConfig#getOrElse on your ForgeConfigSpec instance?

     

    Note that if you've followed Forge's example and made your ForgeConfigSpec fields private, you'll need to create a public method in your config class that calls UnmodifiableConfig#get(String) on the appropriate ForgeConfigSpec instance.

×
×
  • Create New...

Important Information

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