Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Custom Leaf and Wood registry


ScottKillen
 Share

Recommended Posts

When writing a standard WorldGenerator for tree generation, or large structural or landscape features, we do a lot of checks for wood and leaf blocks. If we want to integrate with other mods, or have our trees grow in forest of custom trees,or have other's  trees grow in our forests, and if we want to support the decay of custom leaves on an equal basis with vanilla leaves, we need a registry for leaves and wood.

 

I have coded this in Extrabiomes and have the code ready to turn over to the forge team, but I'm unsure about who to talk to, or how to join the team as a coder. All that is required is two static sets and one interface. This works VERY well in practice with the mods that I have been able to support with Extrabiomes. Other developers play things more close to the vest and cannot be supported by our mod.

 

The results are difficult, for instance, our mod provides entire biomes of custom tree forests. Industrialcraft rubber will spawn in these biomes, but growth is often stifled because our leaves look like unknown block to that mod and so the tree grow fails. RedPower's volcanoes do not remove our leaves when the form, because the WorldGen can't identify our leaves as such and so the results look devastating.

 

I have done/am willing to do the work involved in making this small feature with a big impact available to all forge mods as a part of Forge. I would be grateful if someone could help me understand the process of adding this myself or donating the code to the project.

Link to comment
Share on other sites

Humm, someone actually bothered to make extra trees and think of how to make them interact with each other properly, nice.

Your best bet for getting something into forge, is to clean it up, and submit a Pull Request on Github.

 

Ideally submitting a small example mod to showcase what you're trying to do.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Patreon: http://www.patreon.com/lexmanos
Paypal: http://paypal.me/LexManos

BitCoin: 1Q8rWvUNMM2T1ZfDaFeeYQyVXtYoeT6tTn

Link to comment
Share on other sites

Thanks, LexManos and OvermindDL.

 

Github won't be a problem...I'll probably be needing help after I make my changes, because I am not familiar with the process.

 

I am curious abut what would be a good way to showcase this...I will prepare a mod, but in all honesty, the showcase mod would be about 20 times larger than the change itself...I suppose I could submit my test mod, but I fear that the subtleties of this might make it get lost.

 

I can very easily provide before and after screenshots as well as a save, with part of the terrain generated before the change and part after, to provide contrast in addition to the test mod.

 

What is the forge policy regarding vanilla changes? This feature would require one line changes to the wood block and several of the WorldGens as well as repairing a bug in the WorldGens for jungle trees where the wood block id is hardcoded...

 

If these are allowed, what tool do I use to make the patches to check in?

 

Thank you guys for being so receptive to this!

Link to comment
Share on other sites

Thanks, LexManos and OvermindDL.

 

Github won't be a problem...I'll probably be needing help after I make my changes, because I am not familiar with the process.

 

I am curious abut what would be a good way to showcase this...I will prepare a mod, but in all honesty, the showcase mod would be about 20 times larger than the change itself...I suppose I could submit my test mod, but I fear that the subtleties of this might make it get lost.

Just a basic tree mod would probably work, have new ones grow and use your api properly.

 

I can very easily provide before and after screenshots as well as a save, with part of the terrain generated before the change and part after, to provide contrast in addition to the test mod.

 

What is the forge policy regarding vanilla changes? This feature would require one line changes to the wood block and several of the WorldGens as well as repairing a bug in the WorldGens for jungle trees where the wood block id is hardcoded...

I cannot speak for Lex but vanilla hooks seem to be well accepted if they have a useful purpose, are minimized in code (keep about all the code you can 'elsewhere', like in ForgeHooks.java, with just a single line or two in the vanilla class), and cannot already be done via some other method, like reflection (which your API here fills something that reflection cannot fix).

 

 

If these are allowed, what tool do I use to make the patches to check in?

Forge actually already has a script to do that.

 

You want to get Forge from github, not the source distribution.  The github version has a development set up for working on forge itself.  When set up, make your change, and there is a script that will auto generate patches and so forth.  Just run it, then push back to github as a pull request.  Lex has done an amazing job at keeping it very simple, and as such he can still explain it better.

 

Thank you guys for being so receptive to this!

This would be a very useful little hook, and one that *requires* vanilla changes, which is useful to have in Forge instead of 'other' mods editing base files.

 

It would also be useful if the API could be used to disallow blocks that trees overwrite.  Some mods have rather costly blocks that are often run in tree farm (think RedPower or BuildCraft), and being non-solid a growing tree can grow into and destroy the block, it would be nice to be able to mark a custom mod block as preventing tree growth as well.

Link to comment
Share on other sites

I think I must be doing something wrong...I never have a problem decompiling with the forge releases...but I do the following and I get tons of patch errors...

 

[*]Clone forge from github

[*]Extract mcp into my project directory

[*]Put server jar in jars and copy bin and resource directories there too

[*]install.cmd (Apparently, the install scripts crash when run from forge/install...they like to be up one in forge)

 

Logs are here: http://www.mediafire.com/?wwge0tlo9pmvpo0 Any help would be appreciated (I know I am missing something...I feel like a newb)

Link to comment
Share on other sites

It would also be useful if the API could be used to disallow blocks that trees overwrite.  Some mods have rather costly blocks that are often run in tree farm (think RedPower or BuildCraft), and being non-solid a growing tree can grow into and destroy the block, it would be nice to be able to mark a custom mod block as preventing tree growth as well.

 

I just saw this...I might as well add this while I'm in the code. It would be a nice feature.

Link to comment
Share on other sites

Lex,

 

I tried setup first last night, and I got some errors, so I then treid the process described above...

 

The process I followed tonight is this:

[*]Clone my branch of forge.

[*]Decompress mcp into the MinecraftForge directory (that contains the 'forge' directory.)

[*]Copy minecraft_server.jar and my clean vanilla bin and resource directories to the 'jars' directory.

[*]Run setup.bat

 

All looks fine, except that server recompilation chokes on a syntax error in BlockRedstoneRepeater.java and the application of patches looks good and then many multiple failures.

 

The set up script reports that all is well...but the server will not compile. It has MANY errors.

 

If this is the way it is supposed to be, I will continue, but it feels awkward with the server not compiling.

 

I appreciate your patience and understand that I sound like a complete noob...I just need to get my bearings in the build environment...

 

Once I get it, I'll be able to do get around pretty good.

 

So, is it ok that the server is not compiling?

Link to comment
Share on other sites

Make sure you've copied the conf folder from forge/conf to mcp/conf

The setup script does not automatically do that, {as it would be stupid}

No patches should fail, so thats probably your issue.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Patreon: http://www.patreon.com/lexmanos
Paypal: http://paypal.me/LexManos

BitCoin: 1Q8rWvUNMM2T1ZfDaFeeYQyVXtYoeT6tTn

Link to comment
Share on other sites

Pull request submitted.

 

Showcase mod source attached and at at http://www.mediafire.com/?8qjzvqa36281onq

 

I look forward to the feedback!

 

 

Mod illustrates custom trees (sandstone leaf texture) playing nicely with and behaving like vanilla trees. Also every chunk has a glass tower that leaves grow around, and not through, to illustrate that non-opaque blocks can be registered impervious to leaf growth.

TestMod.zip

Link to comment
Share on other sites

Humm, woke up to your pull request, Will need to look into it and see whats whats, but, you also forgot the server side :P

But, only a bit of a issue there, I would move those tree-lists to just plain Block methods. And make them all world/location {and therefor TileEntity/Metadata} sensitive.

 

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Patreon: http://www.patreon.com/lexmanos
Paypal: http://paypal.me/LexManos

BitCoin: 1Q8rWvUNMM2T1ZfDaFeeYQyVXtYoeT6tTn

Link to comment
Share on other sites

Thanks, Lex...

 

Didn't forget the server side...hesitated because I have never done any server side programming and because of the minor (;D) issue that I cannot get the server's forge patches to apply cleanly...I know this is something I am doing...but I am not doing anything except browsing the code and running a build script...so I'm not sure what behavior to stop on my end...

 

Also, I know I'm going to have to gain experience on server side programming given the way future versions of Minecraft are headed.

 

You know the code better than me, so I will defer to however you feel this should be done. I will recommit with these functions relegated to the block.

 

Any help you, or anyone else can provide with regard to the server implementation would be appreciated.

 

Regarding the server build errors, I clone forge, extract mcp, copy in the binaries to jars, copy forge/conf to mcp/conf and run setup.bat...everything goes great until it tries to apply the patches to server then it goes nuts...unless I am missing a step, I don't know how to fix it. Like you said earlier, it is something on my end, but I don't know what.

Link to comment
Share on other sites

Hmmm...probably not in this case. I just tracked it to a PEBKAC error...  :-[ You'd be right to ban me for wasting your time.

 

Accounted for the idiot at my keyboard...and now it builds fine.

 

I'll revise my code and include the server this time.

Link to comment
Share on other sites

https://github.com/MinecraftForge/MinecraftForge/commit/3b523d57a9ceef4684442b45a787a4441df612ed

You now are rivaling RP for hooks, 26 base edits for just you.

Go! Make many good tutorials on how to use this.

Make mods take advantage of this.

Make RedPower take advantage of this!

Make it worth my while! :P

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Patreon: http://www.patreon.com/lexmanos
Paypal: http://paypal.me/LexManos

BitCoin: 1Q8rWvUNMM2T1ZfDaFeeYQyVXtYoeT6tTn

Link to comment
Share on other sites

Thanks! I always struggle with that...when to start supporting a newer version of forge...

 

We keep older versions of the mod available, and only add new features to the newest version.

 

Right now, some of the features we need are not available until SMP, so as soon as the new Recommended build of forge is out, we will release a new version of our mod. Lots of people are clamoring for SMP.

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.

Guest
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.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Hello all. I am trying to implement oil into my mod (I know I know, unoriginal). But I just can't seem to get it to work. (System/Minecraft information: Java 17, forge: 1.17.1-37.0.95, mappings: official) I am using DeferredRegisters. In the current configuration, the bucket doesn't do anything most of the time, the block doesn't appear and doesn't flow. I am extending "ForgeFlowingFluid". It seems in LiquidBlock there are two constructors, one deprecated taking in a Fluid, the other takes in a supplier/RegistryObject<Fluid>. Because I am using DeferredRegisters, I have to use the second one, because blocks are registered before fluids. But it seems that in the code, most of it relies on the LiquidBlock.fluid field, which never gets set in the second constructor. I tried hacking in a solution with a "Fixed" version of LiquidBlock: public class FixedLiquidBlock extends LiquidBlock { private static final List<FixedLiquidBlock> liquidBlocksNeedingFixing = new ArrayList<>(); // Check if the supplier is a registry object. If it is, and the value is not null, set the value of the fluid field, else mark it so that it gets set later. public FixedLiquidBlock(Supplier<? extends FlowingFluid> supplier, Properties properties) { super(supplier, properties); try { if (supplier instanceof RegistryObject registryObject && registryObject.get() != null) { try { Class<?> class_ = LiquidBlock.class; Field fluidField = ObfuscationReflectionHelper.findField(class_, "fluid"); fluidField.setAccessible(true); fluidField.set(this, supplier.get()); } catch (Exception e) { throw new RuntimeException(e); } } } catch (NullPointerException ignored) {} liquidBlocksNeedingFixing.add(this); } @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) private static class FixedLiquidBlockEvents { @SubscribeEvent(priority = EventPriority.LOWEST) // Force the event to be called last // After registration of fluids is finished, set the fluids field. public static void onFluidsRegister(RegistryEvent<Fluid> fluidRegistryEvent) { for (FixedLiquidBlock fixedLiquidBlock : liquidBlocksNeedingFixing) { try { Class<?> class_ = LiquidBlock.class; Field fluidField = ObfuscationReflectionHelper.findField(class_, "fluid"); fluidField.setAccessible(true); fluidField.set(fixedLiquidBlock, fixedLiquidBlock.getFluid()); } catch (Exception e) { throw new RuntimeException(e); } } } } } But clearly what I'm doing is stupid because it still doesn't work. I even tried without my hacky solution, and it still didn't work! Am I doing something wrong? Should I be extending something else? What else should I do?   Code for fluid, OilFluid.java:   public abstract class OilFluid extends ForgeFlowingFluid { protected OilFluid() { super(new ForgeFlowingFluid.Properties( Source::new, Flowing::new, FluidAttributes.builder( new ResourceLocation(MiniTech.MODID, "block/oil_still"), new ResourceLocation(MiniTech.MODID, "block/oil_flow") ).overlay(new ResourceLocation(MiniTech.MODID, "block/oil_overlay")) .translationKey("block." + MiniTech.MODID + ".oil") .color(0xffffff))); } public static class Flowing extends OilFluid { public Flowing() { registerDefaultState(getStateDefinition().any().setValue(LEVEL, 7)); } @Override protected void createFluidStateDefinition(StateDefinition.Builder<Fluid, FluidState> p_76476_) { super.createFluidStateDefinition(p_76476_); p_76476_.add(LEVEL); } @Override public int getAmount(FluidState p_76480_) { return p_76480_.getValue(LEVEL); } @Override public boolean isSource(FluidState p_76478_) { return false; } } public static class Source extends OilFluid { @Override public int getAmount(FluidState p_76485_) { return 8; } @Override public boolean isSource(FluidState p_76483_) { return true; } } } Code for ModBlocks.java:   public class ModBlocks { private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MiniTech.MODID); public static final RegistryObject<RefineryFurnaceBlock> REFINERY_FURNACE = BLOCKS.register("refinery_furnace", () -> new RefineryFurnaceBlock(BlockBehaviour.Properties.of(Material.STONE).requiresCorrectToolForDrops().strength(3.5F).lightLevel(litBlockEmission(13)))); // Fluids public static final RegistryObject<LiquidBlock> OIL = BLOCKS.register("oil", () -> new FixedLiquidBlock(ModFluids.OIL, BlockBehaviour.Properties.of(Material.WATER).noCollission().strength(100.0F).noDrops())); public static void register(IEventBus eventBus) { BLOCKS.register(eventBus); } private static ToIntFunction<BlockState> litBlockEmission(int lightLevel) { return (blockState) -> { return blockState.getValue(BlockStateProperties.LIT) ? lightLevel : 0; }; } }  
    • No, no and no. The server knows the sending player, so the UUID is unnecessary. If you really needed to send a player (or any entity) across, you'd send the entity ID, not the UUID. The button name is irrelevant, if anything you'd send an Enum that specifies the button (if multiple buttons needs to be sent). The block position is also known on the server, sending it again only allows for cheats (if you don't validate it on the server, at which point you might as well just not send it at all).
    • take a look at this thread: and then do not place Blocks in the Chunk (= Empty/Void Chunk)   via NBT Files (Note: one nbt file can store a Area of 45*48*48 Blocks, if the Structure is larger you need to divide into several NBT Files), you can take a look at the vanilla Structures like the Nether Bastions if the Structure is fixed you can place the Structure in the ChunkGenerator (but then you need a bit more logic, since with Strucure Generation distance) when you register the Structure you need set the min and max distance between two Structures, you can Simply set the min and max to a large value   not sure if this possible but you can try to remove the Chunks in which the structure was generated, since as you said it is a void dimension, then you could simply generate a new chunk at this point
    • you could re-invent the wheel and do exactly what you said.... or you could use world saved data (link). using it makes a dat file in saves/YourWorldName/data directory.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.