Jump to content

two blocks high crop


DrakusorU

Recommended Posts

Hi, first of all im new to java ( I know the basics, I can manage to solve myself most of the problems I encounter ).. for like 2 days im searching how to make a 2 blocks tall crop, i've been looking into other mods how they did it, i've been searching everywhere.. now i am at the stage where I created the crop, it grows, it drop the items I want, but I want to make it grow 1 more block like this http://i.imgur.com/dOAPPQ5.png for example.. exactly this mod ( flax mod from 1.7 ) I tried to recreate in 1.10 for myself.. I pretty much followed this tutorial http://shadowfacts.net/tutorials/forge-modding-1102/ to make my mod, so its almost indentical..

 

what I want exactly to do is once again, make it grow 2 blocks, when I break the top block to receive more items as its fully grown aswell if I break the buttom block when its fully grown, but if I break the bottom without being fully grown to receive only the seed back..

 

i've searched a lot how to do this for 1.10.. if there was already a topic about this, im sorry but I couldnt find it..

Link to comment
Share on other sites

I agree with comment above. In fact I learned how to create stuff simply by copying vanilla code.

 

Forge is very helpful in that it actually shows you how MC is coded something that would be hard to do normally since everything is obfuscated. So instead of just doing things after tutorial just actually look trough forge/mc vanilla code.

 

All blocks are registered in Block class

 

Search for reed or tall grass see how is done there

 

Ctrl + click on a class name to open it up in a new tab  in Eclipse. read trough try to do the same

Disclaimer:  I been told to keep my opinions to myself, to shut up and that I am spreading lies and misinformation or even that my methods are unorthodox and or too irregular. Here are my suggestions take it or leave it.

Link to comment
Share on other sites

Agreed. Knowing what you can pull from vanilla code is very useful.

But basically you're gonna have a block with states and say states 0-3 are 1 block tall, you're gonna check when you grow, that its the top block (bottom block with air above or top block) and then if its state 3, set the space above it to the block with state 4.

Link to comment
Share on other sites

Just make two separate blocks. You can make them drop separate things. Have the bottom block have a random tick and when it reaches a certain age the bottom block would have an if then statements saying, if there is air above me, then place this other block.

I don't optimize my code before it works.

Link to comment
Share on other sites

Oh, by the way.

 

Be aware of the BlockEvent.CropGrowEvent and its two sub events.  You should fire these at the appropriate times if you are not using subclassing a class that does, or not calling super.updateTick().  Look at BlockCrops, Reeds, Cactus, Netherwart, CocoPods, and a couple others for examples of useage.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I managed to make it grow 1 more block, but I have a problem with the function updateTick

 

I've got the function from another mod, but that mod was making the crop grow 3 blocks, so I tried to make it grow only 2 but it doesnt update corectly.. well.. it doesnt grow fully.. it looks like this http://prntscr.com/deb0g9 instead of http://i.imgur.com/dOAPPQ5.png

 

I was trying to recreate the flax mod from 1.7.10 so the assets are taken from that mod..

 

I know it is because of this function because I messed around for like 2 hours trying figure out what was wrong

 

the original code:

/*public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
    {
    	int j = ((Integer)state.getValue(AGE)).intValue();
    	if ((j != 9) && (j != 10) && (j != 11) && ((worldIn.getBlockState(pos.down()).getBlock() == this) || (canBlockStay(worldIn, pos, state)))) {
    		if ((worldIn.isAirBlock(pos.up())) || (j == 4) || (j == 7)) {
    			if (worldIn.getLightFromNeighbors(pos.up()) >= 9) {
    					if ((j == 0) || (j == 1) || (j == 2)) {
    						worldIn.setBlockState(pos, getStateFromMeta(j + 1));
    					}
		            if (j == 3) {
		                worldIn.setBlockState(pos, getStateFromMeta(4));
		           	}
    					if (j == 5) {
    						worldIn.setBlockState(pos, getStateFromMeta(6));
    					}
    					if (j == 6) {
    						worldIn.setBlockState(pos, getStateFromMeta(7));
    						worldIn.setBlockState(pos.up(), getStateFromMeta();
    					}
    					if (j ==  {
    						worldIn.setBlockState(pos, getStateFromMeta(10));
    						worldIn.setBlockState(pos.down(), getStateFromMeta(9));
    						worldIn.setBlockState(pos.down(2), getStateFromMeta(9));
    					}
    					if (((j == 4) || (j == 7)) && (worldIn.getBlockState(pos.up()).getBlock() == this)) {
    						int k = ((Integer)worldIn.getBlockState(pos.up()).getValue(AGE)).intValue();
    						if (k == 5) {
    							worldIn.setBlockState(pos.up(), getStateFromMeta(6));
    						}
    						if (k == 6) {
    							worldIn.setBlockState(pos.up(), getStateFromMeta(7));
    							worldIn.setBlockState(pos.up(2), getStateFromMeta();
    						}
    						if (k == 7) {
    							worldIn.setBlockState(pos.up(2), getStateFromMeta(11));
    							worldIn.setBlockState(pos.up(), getStateFromMeta(10));
    							worldIn.setBlockState(pos, getStateFromMeta(9));
    						}
    						if (k ==  {
    							worldIn.setBlockState(pos.up(), getStateFromMeta(11));
    							worldIn.setBlockState(pos, getStateFromMeta(10));
    							worldIn.setBlockState(pos.down(), getStateFromMeta(9));
    						}
    					}
    			}
    		}
    	}
    }*/

 

what I tried to do and have now:

 

public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
    {
    	int j = ((Integer)state.getValue(AGE)).intValue();
    	if (((worldIn.getBlockState(pos.down()).getBlock() == this) || (canBlockStay(worldIn, pos, state)))) {
    		if ((worldIn.isAirBlock(pos.up()))) {
    			if (worldIn.getLightFromNeighbors(pos.up()) >=  {
    				if ((j == 0) || (j == 1) || (j == 2)) {
					worldIn.setBlockState(pos, getStateFromMeta(j + 1));
				}
	            if (j == 3) {
	                worldIn.setBlockState(pos, getStateFromMeta(4));
	           	}
	            if (j == 4) {
					worldIn.setBlockState(pos, getStateFromMeta(5));
				}
				if (j == 5) {
					worldIn.setBlockState(pos, getStateFromMeta(6));
				}
				if (j == 6) {
					worldIn.setBlockState(pos, getStateFromMeta(7));
					worldIn.setBlockState(pos.up(), getStateFromMeta();
				}
				if ((j == 7) && (worldIn.getBlockState(pos.up()).getBlock() == this)) {
					int k = ((Integer)worldIn.getBlockState(pos.up()).getValue(AGE)).intValue();
					if (k ==  {
						worldIn.setBlockState(pos.up(), getStateFromMeta(9));
					}
					if (k == 9) {
						worldIn.setBlockState(pos.up(), getStateFromMeta(10));
					}
					if (k == 10) {
						worldIn.setBlockState(pos.up(), getStateFromMeta(11));
					}
					if (k == 11) {
						worldIn.setBlockState(pos.up(), getStateFromMeta(12));
					}
					if (k == 12) {
						worldIn.setBlockState(pos.up(), getStateFromMeta(13));
					}
					if (k == 13) {
						worldIn.setBlockState(pos.up(), getStateFromMeta(14));
					}
				}
    			}
    		}	
    	}
    }

 

the crop json:

 

{
    "forge_marker": 1,
    "defaults": {
        "model": "cross"
    },
    "variants": {
        "age": {
            "0": {
                "textures": {
                    "cross": "xcrops:blocks/flax/flaxBlock_stage_0"
                }
            },
            "1": {
                "textures": {
                    "cross": "xcrops:blocks/flax/flaxBlock_stage_1"
                }
            },
            "2": {
                "textures": {
                    "cross": "xcrops:blocks/flax/flaxBlock_stage_2"
                }
            },
            "3": {
                "textures": {
                    "cross": "xcrops:blocks/flax/flaxBlock_stage_3"
                }
            },
            "4": {
                "textures": {
                    "cross": "xcrops:blocks/flax/flaxBlock_stage_4"
                }
            },
            "5": {
                "textures": {
                    "cross": "xcrops:blocks/flax/flaxBlock_stage_5"
                }
            },
            "6": {
                "textures": {
                    "cross": "xcrops:blocks/flax/flaxBlock_stage_6"
                }
            },
            "7": {
                "textures": {
                    "cross": "xcrops:blocks/flax/flaxBlock_stage_7"
                }
            },
            "8": {
                "textures": {
                    "cross": "xcrops:blocks/flax/flaxBlock_stage_8"
                }
            },
            "9": {
                "textures": {
                    "cross": "xcrops:blocks/flax/flaxBlock_stage_9"
                }
            },
            "10": {
                "textures": {
                    "cross": "xcrops:blocks/flax/flaxBlock_stage_10"
                }
            },
            "11": {
                "textures": {
                    "cross": "xcrops:blocks/flax/flaxBlock_stage_11"
                }
            },
            "12": {
                "textures": {
                    "cross": "xcrops:blocks/flax/flaxBlock_stage_12"
                }
            },
            "13": {
                "textures": {
                    "cross": "xcrops:blocks/flax/flaxBlock_stage_13"
                }
            },
            "14": {
                "textures": {
                    "cross": "xcrops:blocks/flax/flaxBlock_stage_14"
                }
            }
        }
    }
}

 

what confuse me the most is the part where I add the second block and where I need to update it..

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



×
×
  • Create New...

Important Information

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