Content: Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Background: Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Pattern: Blank Waves Notes Sharp Wood Rockface Leather Honey Vertical Triangles
Welcome to TerraFirmaCraft Forums

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

  • Announcements

    • Dries007

      ATTENTION Forum Database Breach   03/04/2019

      There has been a breach of our database. Please make sure you change your password (use a password manager, like Lastpass).
      If you used this password anywhere else, change that too! The passwords themselves are stored hashed, but may old accounts still had old, insecure (by today's standards) hashes from back when they where created. This means they can be "cracked" more easily. Other leaked information includes: email, IP, account name.
      I'm trying my best to find out more and keep everyone up to date. Discord (http://invite.gg/TerraFirmaCraft) is the best option for up to date news and questions. I'm sorry for this, but the damage has been done. All I can do is try to make sure it doesn't happen again.
    • Claycorp

      This forum is now READ ONLY!   01/20/2020

      As of this post and forever into the future this forum has been put into READ ONLY MODE. There will be no new posts! A replacement is coming SoonTM . If you wish to stay up-to-date on whats going on or post your content. Please use the Discord or Sub-Reddit until the new forums are running.

      Any questions or comments can be directed to Claycorp on either platform.
Sign in to follow this  
Followers 0
beingben

Mod Addon Assistance

16 posts in this topic

Hello again, I've been attempting to write a small mod that lets me add items to be dropped when breaking grass *not the block*. I've gotten this far, but I think i am referencing the wrong class in my addon. The println was to see if it was even registering that I was breaking the TallGrass...it never displayed such text in the console.

 

Any help would be greatly appreciated.

package com.beingben.tfcraft.addon;import java.util.Random;import com.bioxx.tfc.TFCBlocks;import com.bioxx.tfc.Blocks.Terrain.BlockGrass;import com.bioxx.tfc.Core.TFCTabs;import net.minecraft.block.Block;import net.minecraft.block.material.Material;import net.minecraft.creativetab.CreativeTabs;import net.minecraft.init.Items;import net.minecraft.item.Item;import net.minecraft.item.ItemStack;import cpw.mods.fml.common.eventhandler.SubscribeEvent;import net.minecraftforge.event.world.BlockEvent;public class grassBreak extends BlockGrass{	@SubscribeEventpublic void onBlockDropItems(BlockEvent.HarvestDropsEvent event){	if (event.block == TFCBlocks.TallGrass){		System.out.println("Break!");		Random rnd =new Random();			if (rnd.nextFloat() <= 0.10f)			event.drops.add(new ItemStack(Items.bone));		if (rnd.nextFloat() > 0.10f && rnd.nextFloat() <= .025f);	event.drops.add(new ItemStack(Items.wheat_seeds));		if (rnd.nextFloat() > 0.10f && rnd.nextFloat() <= .050f);	event.drops.add(new ItemStack(Items.apple));		if (rnd.nextFloat() > 0.10f && rnd.nextFloat() <= .075f);	event.drops.add(new ItemStack(Items.stick));	}}    }
0

Share this post


Link to post
Share on other sites

Did you register the grassBreak class in your FMLInitializationEvent method?

 

-->  MinecraftForge.EVENT_BUS.register(new grassBreak ());

0

Share this post


Link to post
Share on other sites

just some points I noted:

- must grassBreak extend BlockGrass?

- do you really want do call nextFloat (twice) for every if?

it generates a new number each call, so testing if it is greater than 0.1f doesn't make sense (IMHO). The way it is done you could get all four items at once...

- really test against 0.025 (0.05, 0.075), shouldn't it be 0.25 (0.50, 0.75)

- (detail) by convention class names start with an uppercase letter

- (detail) the indentation is not consistent, a bit confusing

Suggestion for the random part (assuming only one item drop):

int chance = rnd.nextInt(100);  // can be float, but int should sufficeif (chance < 10) {   ... // 10 %} else if (chance < 25) {   ...  // 15 %} else if (chance < 50) {   ... // 25 %} else if (chance < 75) {   ... // 25 %} else {   ... // 25 %}
0

Share this post


Link to post
Share on other sites

I will look at this and try attempt a fix after classes today.

I'm attempting to drop one item but it has a chance at dropping different items.

0

Share this post


Link to post
Share on other sites

If you're looking for tall grass, you've got the wrong class. BlockGrass is for the block that drops dirt when you break it. I think what you're looking for is BlockCustomTallGrass.

0

Share this post


Link to post
Share on other sites

And as CHeuberger pointed out, you do not have to extend any class. Forge returns everything you need in the event.

0

Share this post


Link to post
Share on other sites

Code works inside of eclipse, outside when compiled into the mod it crashes with the following error.

---- Minecraft Crash Report ----// Hey, that tickles! Hehehe!Time: 2/17/15 11:43 PMDescription: Exception in server tick loopjava.lang.NoClassDefFoundError: com/bioxx/tfc/api/TFCBlocks	at com.beingben.TFCraft_Addon.TFCGrassDropsEvent.onBlockBreak(TFCGrassDropsEvent.java:21)	at cpw.mods.fml.common.eventhandler.ASMEventHandler_139_TFCGrassDropsEvent_onBlockBreak_HarvestDropsEvent.invoke(.dynamic)	at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54)	at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138)	at net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(ForgeEventFactory.java:155)	at net.minecraft.block.Block.func_149690_a(Block.java:656)	at net.minecraft.block.Block.func_149697_b(Block.java:648)	at net.minecraft.block.Block.func_149636_a(Block.java:974)	at net.minecraft.block.BlockTallGrass.func_149636_a(BlockTallGrass.java:88)	at com.bioxx.tfc.Blocks.Vanilla.BlockCustomTallGrass.func_149636_a(BlockCustomTallGrass.java:92)	at net.minecraft.server.management.ItemInWorldManager.func_73084_b(ItemInWorldManager.java:299)	at net.minecraft.server.management.ItemInWorldManager.func_73074_a(ItemInWorldManager.java:186)	at net.minecraft.network.NetHandlerPlayServer.func_147345_a(NetHandlerPlayServer.java:489)	at net.minecraft.network.play.client.C07PacketPlayerDigging.func_148833_a(SourceFile:53)	at net.minecraft.network.play.client.C07PacketPlayerDigging.func_148833_a(SourceFile:8)	at net.minecraft.network.NetworkManager.func_74428_b(NetworkManager.java:212)	at net.minecraft.network.NetworkSystem.func_151269_c(NetworkSystem.java:165)	at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:659)	at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:547)	at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:111)	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:427)	at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685)Caused by: java.lang.ClassNotFoundException: com.bioxx.tfc.api.TFCBlocks	at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191)	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)	... 22 moreCaused by: java.lang.NullPointerExceptionA detailed walkthrough of the error, its code path and all known details is as follows:----------------------------------------------------------------------------------------- System Details --Details:	Minecraft Version: 1.7.10	Operating System: Windows 7 (amd64) version 6.1	Java Version: 1.8.0_25, Oracle Corporation	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation	Memory: 126601248 bytes (120 MB) / 880279552 bytes (839 MB) up to 1908932608 bytes (1820 MB)	JVM Flags: 2 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx2G	AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0	FML: MCP v9.05 FML v7.10.85.1272 Minecraft Forge 10.13.2.1272 15 mods loaded, 15 mods active	mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available	FML{7.10.85.1272} [Forge Mod Loader] (forge-1.7.10-10.13.2.1272.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available	Forge{10.13.2.1272} [Minecraft Forge] (forge-1.7.10-10.13.2.1272.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available	tfc_coremod{0.79.15} [TFC[coremod]] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available	CodeChickenCore{1.0.4.29} [CodeChicken Core] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available	NotEnoughItems{1.0.3.65} [Not Enough Items] (NotEnoughItems-1.7.10-1.0.3.65-universal.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available	terrafirmacraft{0.79.15} [TerraFirmaCraft] ([1.7.10]TerraFirmaCraft-0.79.15.538.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available	Baubles{1.0.1.10} [Baubles] (Baubles-1.7.10-1.0.1.10.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available	Botania{r1.4-155} [Botania] (Botania r1.4-155.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available	ChickenChunks{1.3.4.16} [ChickenChunks] (ChickenChunks-1.7.10-1.3.4.16-universal.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available	FastCraft{1.16} [FastCraft] (fastcraft-1.16.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available	magicalcrops{1.7.2 - 0.1 ALPHA} [Magical Crops] (magicalcrops-1.7.10_0.1.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available	MineTweaker3{3.0.9B} [MineTweaker 3] (MineTweaker3-1.7.10-3.0.9C.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available	ModTweaker{0.6} [ModTweaker] (ModTweaker-1.7.X-0.6-0.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available	TFCraftAddon{1.0} [TFCraftAddon] (TFCraftaddon-1.0.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available	Profiler Position: N/A (disabled)	Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used	Player Count: 1 / 8; [EntityPlayerMP['beingben'/215, l='New World', x=8845.72, y=148.00, z=-7700.95]]	Type: Integrated Server (map_client.txt)	Is Modded: Definitely; Client brand changed to 'fml,forge'
0

Share this post


Link to post
Share on other sites

Without having any information on how you've setup your projects dev env, there is almost no way to give you any useful info.

 

Although it probably has nothing to do with your problem, i would update Java, if i remember correctly, forge had some issues with version _25. I think _31 is the latest now. Or use jdk1.7.0_75.

0

Share this post


Link to post
Share on other sites

Here is a link to my project which I just finished uploading to GitHub, maybe this can shed some light on my problem.

 

 

https://github.com/WhiteShadoh/TFCraft-Addon

 

 

Like Emris said, it may be something with your dev environment. I just built and ran it it without any problems. 

 

By the way, your first and last items will never drop. You've got the logic backwards, (chance <= 1 && chance >= 3) can never be true.

0

Share this post


Link to post
Share on other sites

I wish I knew how to fix my environment than. Plus all the items do drop, they are just testing percentages. I do gradlew build and it crashes once I break a grass within MineCraft.

0

Share this post


Link to post
Share on other sites

Ah, I just remembered, the blocks weren't in the API in 79.15. It works fine against the most recent TFC codebase, but not against any released version. I was able to replicate the crash by downgrading.

 

 

Plus all the items do drop, they are just testing percentages. 

 

I realize you're just testing for now, but "less than or equal to 1 and greater than or equal to 3" can NEVER be true, therefore the wheat seeds can't drop. Same is true for the bones. The two in the middle are fine.

0

Share this post


Link to post
Share on other sites

Downgrading How do I find the most recent TFC codebase? I downloaded mine directly from GitHub. Thanks for the info on my drops, it took me a second to realize what you were saying. :D

0

Share this post


Link to post
Share on other sites

By downgrading I meant I used the latest release, which is 79.15.538 available from http://terrafirmacraft.com/download.html. That version does not have the API you are using, but what you got from github does. Did you build the source you got from github and use that when running outside of eclipse? 

0

Share this post


Link to post
Share on other sites

Son of a Monkey's Uncle. If i could I would kiss you while kicking myself. I feel like a real moron trying to fix this over the past week. Well glad to see my code was written and working this time.

 

Thanks again silentrob.

0

Share this post


Link to post
Share on other sites

No worries... At least you know it'll work once .16 comes out. :)

0

Share this post


Link to post
Share on other sites
Sign in to follow this  
Followers 0