Jump to content

[1.8] Change melon_block / BlockStem.java


DancyMC

Recommended Posts

I have now employed quite a few "days" with Java. Now I am working on Minecraft mods. My first mods are now finished and work fine with no errors. (many new items, blocks, crafting recipes ....)

 

My next idea is the melons blocks on "Hopper" grow.

Since I still have difficulties in implementing how to begin there.

 

Can I use "Forge" simply override the melons class, or change it? If so, how?

 

 

BlockStem.java:

 

[....]
/**
     * is the block grass, dirt or farmland
     */
    protected boolean canPlaceBlockOn(Block ground)
    {
        return ground == Blocks.farmland;
    }
[....]

 

 

The search API was not really helped (and also in the forum or google).

Maybe I've also just looking for the wrong, who knows.

 

Thanks for the help.

Greetings from Germany

 

PS: Sorry for the bad english ... Google's fault: D :o:P

Link to comment
Share on other sites

You can't directly replace whole class without using ASM.

You can replace registry, but them you will create huge incompatybility.

 

Best way is to utilize events.

In your case you might want to use "PlaceEvent". Google on how to use Forge events.

 

Write what exacly do you need for more help.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

Okay it works.. it was a fail in eclipse..

 

Now, the discription of the event ist:

 

 

net.minecraftforge.event.world.BlockEvent.PlaceEvent

@Cancelable

Called when a block is placed by a player. If a Block Place event is cancelled, the block will not be placed.

 

Player? melon_block is set by melon_stam ? or not?

 

Link to comment
Share on other sites

@Ernio He wants to change the way melons blocks behave, which is not necessarily only when placed by players, but when they grow from stems.

 

@OP I'm not sure if this will work, but you could try BlockEvent.NeighborNotifyEvent - it fires whenever a block notifies its neighbors that it has changed, and may fire for stems when they set the melon block, or perhaps for the melon block when it is first set in the world.

 

I'll leave digging around in the code / testing it up to you, but that's where I'd start.

Link to comment
Share on other sites

Well there are many ways to do it, replace melons, replace pistons, replace hoppers, etc..

Probably your best bet would be to create a new block that acts like a hopper that allows melons to grow on them.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

Hey,

 

okay thx i will test it..

I thought it is the stem that prevents the melon block to set it on the top of the hopper... on creativ i can manualy place a melon block on the top of the hopper... only in surrival the stem dont place the melon block on a hopper...

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

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