Jump to content

[1.12.2] Apple Tree help


Christof18

Recommended Posts

I'm trying to make a mod about apple trees. the idea started when I was looking for a lightweight mod that adds apple trees. There was only one good mod... but it was 1.11, a few updates too old. I have had a decent amount of experience with Java, not great but still decent; with little experience modding Minecraft. I also want to code it myself and know how to do it again, something simple copy/pasting can't do. I'm also trying to follow the rules I set for myself as outlined. If anyone can help, thank you. 

 

The only real problems I feel like I'm going to have are with the apples themselves (that hang from the bottommost layer of leaves and can be picked with a right-click with varying success rates, again, as outlined in the rules)

Link to comment
Share on other sites

Cool.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

By that I mean I don't know what you need help with, as you haven't showed your code nor your question.

Are you having trouble implementing the apple tree?

Are you not sure how to make a custom tree?

Please elaborate.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

Pretty much the portion with the apples in the trees, I'm going to send an example of a tree that I'm using as a sort of reference soon, it's going to be implementing it as code that is going to be difficult, the rest shouldn't be too hard for me to do.

Link to comment
Share on other sites

Whenever you ask for help it’s good to include what you’re trying to do (from a player’s perspective), what you’ve tried and the problem your having (and logs if applicable)

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

My main problem is that I understand Java, just not applying it to Minecraft.

I want to have it so every now and then, an apple or two will form similarly to the berries of the tree pictured below (this tree is from the Pokecube mod). While you can try to pick them immediately (via RMB), you have increasingly lower chances to get an apple than if you were to wait. It's that setup that I feel like I'm going to struggle with.

 

The tree itself, notice the berries hanging from it?:

934483561_Minecraft1_12.26_12_201910_03_06AM.thumb.png.fdf7d5db9bef449cb8e5767e193836e6.png

Right-clicking one of these berries would drop one. This is mostly what I'm trying to replicate with the exception being that my apple trees would have 3 growth stages with chances of getting an apple increasing each stage (0% for the 1st stage, 50% for the 2nd, 100% 3rd). It would (similarly to this tree) also grow similarly to a crop until it finishes growing (at which point, it becomes a tree).

Link to comment
Share on other sites

Do you have the code used for the berry tree? That might be useful.

 

I'd probably make an apple Block (with the appropriate model/texture). Then, add these abilities to it:

  • When right clicked, the apple Block should disappear, and an apple Item should be added to the player's inventory.
  • Every [whatever] seconds/minutes, an apple Block should have the chance to generate underneath oak (for now) leaves, provided they are connected to a tree and there's not already something there.

To create a Block, see the documentation here. You'll want to extend the Block class and override the necessary methods. Then, register it. Here's an example of registering something:

@ObjectHolder(MAINMODCLASS.MODID)
public static Block APPLE_BLOCK; // This is a placeholder for when you register it later. This is the object you'll access whenever you want to reference/use the apple Block.

and

@SubscribeEvent
public static void registerBlocks(final RegistryEvent.Register<Block> event)
{
	IForgeRegistry<Block> blockRegistry = event.getRegistry();
	blockRegistry.register(new BlockApple(Block.Properties.from(Blocks.OAK_LEAVES))); // This creates it with the same properties as Oak Leaves. 
}

(This is for 1.13.2, but I think it should still be similar if not the same for 1.12.2.)

 

Since you have the Block you can do other stuff with it now. Here's the documentation on player interaction.

 

As to generating it on leaves; you'd probably want to look into Capabilities (if using an already existing tree/leaves) or adding it directly to your custom leaf block. I don't have experience with that so don't know what the best practice for it is. For the specifics, maybe take a look at the BlockCrops class, which implements/extends a couple of other classes that might be useful. You could probably extend the BlockCrops class if it fits your needs.

Link to comment
Share on other sites

I have the mod that uses it... to be honest, I was mostly thinking about getting it (somehow) and transferring it over. Then all I needed was the apple growth (as this tree simply had the berries appear).

 

there are three problems, which are:

  1. Actually accessing the mod file... no idea how to do that
    1. Apple growth... slightly clueless
  2. Modeling the apples, which happens to be my biggest weakness
Link to comment
Share on other sites

 
 
 
 
 
 
42 minutes ago, Christof18 said:

1. Actually accessing the mod file... no idea how to do that

If the mod isn't open source, which (as far as I can tell) it isn't, it's going to be tough to get the code. You'll probably have to implement it from scratch!

 

 
 
 
43 minutes ago, Christof18 said:

2. Apple growth... slightly clueless

Earlier I recommended looking at the BlockCrops class, but I'm not sure that's actually the best base to build off of, since you just want one type of apple that appears, not one that grows over time. Instead, you probably want to look at dirt and dirt with grass, since dirt can turn into dirt with grass in Vanilla Minecraft. It looks like the class BlockDirtSnowySpreadable will be what you want. It may look complicated at first, but if you really take some time to understand how the vanilla code works it will help.

 

 
 
 
45 minutes ago, Christof18 said:

3. Modeling the apples, which happens to be my biggest weakness

I'd recommend getting the code working before you worry about aesthetics. Use a normal, solid block model (like Stone) with a simple texture (like completely red). Then, once it's working, you can worry about modeling it (which I'm not sure how to do, I'm sure somewhere on these forums or elsewhere online there's a good explanation).

Link to comment
Share on other sites

6 hours ago, TheKingElessar said:

@ObjectHolder(MAINMODCLASS.MODID) public static Block APPLE_BLOCK; 

Objectholders need to public static final and null.

  • Like 1

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

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.