Jump to content

[1.7.10] How to would I add item drops from another mod?


beingben

Recommended Posts

I'm beginning my career in Computer Science and adventuring into Java with some simple minecraft modding. I'd like to be able to create just a simple mod for now allowing my to add an item to be dropped when breaking grass. Once i can figure this simple code out I'd like to expand it into an entire mod for editing what any item or block can drop when broken.

So any help at this early stage is much appreciated.

 

This is just a test for dropping 4 items from a random chance when breaking a grass block.

 

package com.beingben.tfcraft.addon;

import java.util.Random;

import com.bioxx.tfc.Blocks.Terrain.BlockGrass;
import com.bioxx.tfc.Core.TFCTabs;

import vazkii.botania.common.item.*;
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;

public class grassBreak extends BlockGrass
{
    
    public Item idDropped(int par1, Random par2Random, int par3)
    {

    double r = Math.random();

    if (r < 0.25){

    Item ItemFertilizer;
return ItemFertilizer;

    }else if (r < 0.5){

    return Items.wheat_seeds;

    }else if (r < 0.75){
    	
    }
    return Items.bone;
    
    }else{
        return Items.clay_ball;
    	}
}
}

Link to comment
Share on other sites

Alright, so MinecraftForge.addGrassSeed,

Is there a way to have a BlockEvent ? To allow me a random drop of different items as i tried with the previously informed event hook.

 

 

Here was my attempt from your earlier reply.

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 vazkii.botania.common.item.*;
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
{

@SubscribeEvent
public void onBlockDropItems(BlockEvent.HarvestDropsEvent event){

if (event.block == TFCBlocks.TallGrass){
	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));
}
}
    
}

Link to comment
Share on other sites

Figured I'd make a post since I'm not getting much further on my own. Below I will post both the TFC_Custom grass java and my GrassBreak Java. I'm currently unable to specify the block on which to call the event under line 35.

Any help, much appreciated.

 

My Java

package com.beingben.tfcraft.addon;

import java.util.Random;

import com.bioxx.tfc.Blocks.Vanilla.*;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IChatComponent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;

public class GrassBreak {

Random random;

@SubscribeEvent
public void onHarvestDrops(BlockEvent.HarvestDropsEvent event)
    {
        random = new Random();
    	Block block = event.block;
    	
        	EntityPlayer player = event.harvester;
        	if(player!=null)
        	{

        		[color=red]if (block == BlockCustomTallGrass) {[/color]
        			event.harvester.addChatMessage(new ChatComponentText("Test"));
        			
        			Random rnd = new Random();
        				int chance = rnd.nextInt(100); // can be float, but int should
										// testing simple vanilla drops
        					if (chance < 10) {
        						event.drops.add(new ItemStack(Items.clay_ball)); // 10 %
        					} else if (chance < 25) {
        						event.drops.add(new ItemStack(Items.painting));// 15 %
        					} else if (chance < 50) {
        						event.drops.add(new ItemStack(Items.bucket));// 25 %
        					} else if (chance < 75) {
        						event.drops.add(new ItemStack(Items.bone)); // 25 %
        					} else {
        						event.drops.add(new ItemStack(Items.string));// 25 %
        					}
        		}

        	}
    }
}

 

TFC_Custom_Grass

package com.bioxx.tfc.Blocks.Vanilla;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockTallGrass;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;

import com.bioxx.tfc.Reference;
import com.bioxx.tfc.TerraFirmaCraft;
import com.bioxx.tfc.Core.ColorizerFoliageTFC;
import com.bioxx.tfc.Core.ColorizerGrassTFC;
import com.bioxx.tfc.Core.Recipes;
import com.bioxx.tfc.Core.TFCTabs;
import com.bioxx.tfc.Core.TFC_Climate;
import com.bioxx.tfc.Core.TFC_Core;
import com.bioxx.tfc.Core.TFC_Sounds;
import com.bioxx.tfc.api.TFCItems;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class BlockCustomTallGrass extends BlockTallGrass implements IShearable
{
private static final String[] MetaNames = new String[] {"tallgrass", "fern", "shortgrass"};
@SideOnly(Side.CLIENT)
private IIcon[] icons;

public BlockCustomTallGrass()
{
	super();
	float var3 = 0.4F;
	this.setBlockBounds(0.5F - var3, 0.0F, 0.5F - var3, 0.5F + var3, 0.8F, 0.5F + var3);
	this.setCreativeTab(TFCTabs.TFCDecoration);
}

@Override
public void getSubBlocks(Item item, CreativeTabs tab, List list)
{
	for (int i = 0; i < MetaNames.length; ++i)
	{
		list.add(new ItemStack(item, 1, i));
	}
}

@Override
public int getBlockColor()
{
	double var1 = 0.5D;
	double var3 = 1.0D;
	return ColorizerGrassTFC.getGrassColor(var1, var3);
}

@Override
public int getRenderColor(int par1)
{
	return par1 == 0 ? 16777215 : ColorizerFoliageTFC.getFoliageColorBasic();
}

@Override
public int colorMultiplier(IBlockAccess bAccess, int x, int y, int z)
{
	return TerraFirmaCraft.proxy.grassColorMultiplier(bAccess, x, y, z);
}

@Override
public Item getItemDropped(int metadata, Random rand, int fortune)
{
	return null;
}

@Override
public int quantityDroppedWithBonus(int i, Random rand)
{
	return 1 + rand.nextInt(i * 2 + 1);
}

@Override
public void harvestBlock(World world, EntityPlayer player, int i, int j, int k, int l)
{
	super.harvestBlock(world, player, i, j, k, l);

	ItemStack is = player.inventory.getCurrentItem();
	for(int c = 0; c < Recipes.Knives.length && is != null; c++)
	{
		if(is.getItem() == Recipes.Knives[c])
		{
			createStraw(world, player, i, j, k);
			is.damageItem(1, player);
			break;
		}
	}

	for(int c = 0; c < Recipes.Scythes.length && is != null; c++)
	{
		if(is.getItem() == Recipes.Scythes[c])
		{
			//Spawn the straw for the block that we've already destroyed
			createStraw(world, player, i, j, k );
			//Now check each block around the destroyed block for AOE directions
			for(int x = -1; x < 2; x++)
			{
				for(int z = -1; z < 2; z++)
				{
					if(world.getBlock(i + x, j, k + z) == this)
					{
						createStraw(world, player, i + x, j, k + z);
						is.damageItem(1, player);
						world.setBlockToAir(i + x, j, k + z);
					}
				}
			}
			break;
		}
	}
}

private void createStraw(World world, EntityPlayer player, int i, int j, int k)
{
	EntityItem ei = new EntityItem(world, i+0.5F, j+0.5F, k+0.5F, new ItemStack(TFCItems.Straw, 1));
	world.spawnEntityInWorld(ei);
}

@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int meta, int fortune)
{
	ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
	//if (world.rand.nextInt( != 0) return ret;
	ItemStack item = GetSeeds(world.rand);
	if (item != null)
		ret.add(item);
	return ret;
}

@Override
public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int z)
{
	return true;
}

@Override
public ArrayList<ItemStack> onSheared(ItemStack item, IBlockAccess world, int x, int y, int z, int fortune)
{
	ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
	ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z)));
	return ret;
}

protected boolean canThisPlantGrowOnThisBlock(Block block)
{
	return TFC_Core.isSoil(block); // || par1 == Block.tilledField.blockID;
}

/**
 * Can this block stay at this position.  Similar to canPlaceBlockAt except gets checked often with plants.
 */
@Override
public boolean canBlockStay(World world, int x, int y, int z)
{
	return (world.getFullBlockLightValue(x, y, z) >= 8 || 
			world.canBlockSeeTheSky(x, y, z)) && 
			this.canThisPlantGrowOnThisBlock(world.getBlock(x, y - 1, z));
}

public static ItemStack GetSeeds(Random R)
{
	ItemStack is = null;
	/*if(R.nextInt(100) == 0)
	{
		int r = R.nextInt(19);
		switch(r)
		{
		case 0:
			is = new ItemStack(TFCItems.SeedsWheat,1); break;
		case 1:
			is = new ItemStack(TFCItems.SeedsMaize,1); break;
		case 2:
			is = new ItemStack(TFCItems.SeedsTomato,1); break;
		case 3:
			is = new ItemStack(TFCItems.SeedsBarley,1); break;
		case 4:
			is = new ItemStack(TFCItems.SeedsRye,1); break;
		case 5:
			is = new ItemStack(TFCItems.SeedsOat,1); break;
		case 6:
			is = new ItemStack(TFCItems.SeedsRice,1); break;
		case 7:
			is = new ItemStack(TFCItems.SeedsPotato,1); break;
		case 8:
			is = new ItemStack(TFCItems.SeedsOnion,1); break;
		case 9:
			is = new ItemStack(TFCItems.SeedsCabbage,1); break;
		case 10:
			is = new ItemStack(TFCItems.SeedsGarlic,1); break;
		case 11:
			is = new ItemStack(TFCItems.SeedsCarrot,1); break;
		case 12:
			is = new ItemStack(TFCItems.SeedsYellowBellPepper,1); break;
		case 13:
			is = new ItemStack(TFCItems.SeedsRedBellPepper,1); break;
		case 14:
			is = new ItemStack(TFCItems.SeedsSoybean,1); break;
		case 15:
			is = new ItemStack(TFCItems.SeedsGreenbean,1); break;
		case 16:
			is = new ItemStack(TFCItems.SeedsSquash,1); break;
		}
	}*/
	return is;
}

@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister register)
{
	this.icons = new IIcon[MetaNames.length];
	for (int i = 0; i < this.icons.length; ++i)
	{
		this.icons[i] = register.registerIcon((i > 1 ? Reference.ModID + ":plants/" : "") + MetaNames[i]);
	}
}

@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon(int side, int meta)
{
	if (meta >= this.icons.length) meta = 0;
	return this.icons[meta];
}

@Override
public void updateTick(World w, int x, int y, int z, Random rand)
{
	// Play cricket sound at night
	float temp = TFC_Climate.getHeightAdjustedTemp(w, x, y, z);
	/*Crickets typically don't mate below 55F and are nocturnal. We're being oddly accurate about this lol -B*/
	if(!w.isRemote && w.getBlockLightValue(x, y, z) < 7 && temp > 12.77)
	{
		if(w.rand.nextInt(Math.max(((int)((160)/(temp-4))),1)) < 2) //chirp intensity grows with higher temperature
		{
			float vol = 0.1f + (w.rand.nextFloat() * 0.20F); // keep the volume between 0 and 0.3
			float pitch = ((temp / 100) * 2) + 0.5F + vol; // the chirp frequency will change depending on the climate temperature
			w.playSoundEffect(x, y, z, TFC_Sounds.CRICKET, vol, pitch);
		}

		if(rand.nextInt(==0){
			w.scheduleBlockUpdate(x, y, z, this, 5);
		}
	}

	super.updateTick(w, x, y, z, rand);
}
}

Link to comment
Share on other sites

Alright, so after so much needed reading and trial an error of reading other source file mod addons I finally see some progress. I can launch the game, I can break a grass block and it successfully says "Test" in chat. Sadly, after I break a TallGrass the game crashes. Below is my simplified code and my crash report.

Any and All help is welcome.

 

MainPackage:

package com.beingben.tfcraft.addon;

import net.minecraft.init.Blocks;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;

@Mod(modid = TFCraftaddon.MODID, version = TFCraftaddon.VERSION)
public class TFCraftaddon{
public static final String MODID = "TFCraftAddon";
public static final String VERSION = "1.0";

TFCGrassDropsEvent events = new TFCGrassDropsEvent();

@EventHandler
public void init(FMLInitializationEvent event)
{
	FMLCommonHandler.instance().bus().register(events);
    	MinecraftForge.EVENT_BUS.register(events);		
}
}

 

 

GrassEvent:

package com.beingben.tfcraft.addon;

import net.minecraft.util.ChatComponentText;
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;

import com.bioxx.tfc.api.TFCBlocks;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;

public class TFCGrassDropsEvent {
@SubscribeEvent
public void blockHarvestEvent(HarvestDropsEvent event) {
	if (event.block == TFCBlocks.TallGrass) {
		event.harvester.addChatMessage(new ChatComponentText("Test"));
	}
}

}

 

 

 

Crash Log:

---- Minecraft Crash Report ----
// Why did you do that?

Time: 2/15/15 12:22 AM
Description: Exception while updating neighbours

java.lang.NullPointerException: Exception while updating neighbours
at com.beingben.tfcraft.addon.TFCGrassDropsEvent.blockHarvestEvent(TFCGrassDropsEvent.java:14)
at cpw.mods.fml.common.eventhandler.ASMEventHandler_21_TFCGrassDropsEvent_blockHarvestEvent_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.dropBlockAsItemWithChance(Block.java:806)
at net.minecraft.block.Block.dropBlockAsItem(Block.java:795)
at net.minecraft.block.BlockBush.checkAndDropBlock(BlockBush.java:74)
at net.minecraft.block.BlockBush.onNeighborBlockChange(BlockBush.java:56)
at net.minecraft.world.World.notifyBlockOfNeighborChange(World.java:787)
at net.minecraft.world.World.notifyBlocksOfNeighborChange(World.java:738)
at net.minecraft.world.World.notifyBlockChange(World.java:697)
at net.minecraft.world.World.markAndNotifyBlock(World.java:556)
at net.minecraft.world.World.setBlock(World.java:534)
at net.minecraft.world.World.setBlockToAir(World.java:651)
at com.bioxx.tfc.Blocks.Terrain.BlockDirt.updateTick(BlockDirt.java:228)
at net.minecraft.world.WorldServer.func_147456_g(WorldServer.java:408)
at net.minecraft.world.WorldServer.tick(WorldServer.java:191)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:692)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at com.beingben.tfcraft.addon.TFCGrassDropsEvent.blockHarvestEvent(TFCGrassDropsEvent.java:14)
at cpw.mods.fml.common.eventhandler.ASMEventHandler_21_TFCGrassDropsEvent_blockHarvestEvent_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.dropBlockAsItemWithChance(Block.java:806)
at net.minecraft.block.Block.dropBlockAsItem(Block.java:795)
at net.minecraft.block.BlockBush.checkAndDropBlock(BlockBush.java:74)
at net.minecraft.block.BlockBush.onNeighborBlockChange(BlockBush.java:56)

-- Block being updated --
Details:
Source block type: ID #190 (tile.dirt // com.bioxx.tfc.Blocks.Terrain.BlockDirt)
Block type: ID #204 (tile.TallGrass // com.bioxx.tfc.Blocks.Vanilla.BlockCustomTallGrass)
Block data value: 0 / 0x0 / 0b0000
Block location: World: (-157,146,-6395), Chunk: (at 3,9,5 in -10,-400; contains blocks -160,0,-6400 to -145,255,-6385), Region: (-1,-13; contains chunks -32,-416 to -1,-385, blocks -512,0,-6656 to -1,255,-6145)
Stacktrace:
at net.minecraft.world.World.notifyBlockOfNeighborChange(World.java:787)
at net.minecraft.world.World.notifyBlocksOfNeighborChange(World.java:738)
at net.minecraft.world.World.notifyBlockChange(World.java:697)
at net.minecraft.world.World.markAndNotifyBlock(World.java:556)
at net.minecraft.world.World.setBlock(World.java:534)
at net.minecraft.world.World.setBlockToAir(World.java:651)
at com.bioxx.tfc.Blocks.Terrain.BlockDirt.updateTick(BlockDirt.java:228)
at net.minecraft.world.WorldServer.func_147456_g(WorldServer.java:408)
at net.minecraft.world.WorldServer.tick(WorldServer.java:191)

-- Affected level --
Details:
Level name: grassTest
All players: 1 total; [EntityPlayerMP['Player106'/202, l='grassTest', x=-82.63, y=148.00, z=-6366.98]]
Chunk stats: ServerChunkCache: 698 Drop: 0
Level seed: -5379282275939727980
Level generator: ID 00 - TFCDefault, ver 0. Features enabled: true
Level generator options: 
Level spawn location: World: (-64,147,-6364), Chunk: (at 0,9,4 in -4,-398; contains blocks -64,0,-6368 to -49,255,-6353), Region: (-1,-13; contains chunks -32,-416 to -1,-385, blocks -512,0,-6656 to -1,255,-6145)
Level time: 576992 game time, 576992 day time
Level dimension: 0
Level storage version: 0x04ABD - Anvil
Level weather: Rain time: 76936 (now: false), thunder time: 118390 (now: false)
Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false
Stacktrace:
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:692)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)

-- System Details --
Details:
Minecraft Version: 1.7.10
Operating System: Windows 7 (amd64) version 6.1
Java Version: 1.7.0_75, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 638044792 bytes (608 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
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 6 mods loaded, 6 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] (forgeSrc-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] (forgeSrc-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
TFCraftAddon{1.0} [TFCraftAddon] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
terrafirmacraft{0.79.15} [TerraFirmaCraft] (bin) 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['Player106'/202, l='grassTest', x=-82.63, y=148.00, z=-6366.98]]
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to 'fml,forge'

Link to comment
Share on other sites

When should or would it be null??

 

[me=Draco18s]pours a bucket of water on the ground.[/me]

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've corrected the code and manage to get it working. Now the problem seems to be it won't compile...I first posted the question on the mod-Owners website but they do not reply.

 

After running gradlew build the following error occurs:

 

BUILD FAILED

Total time: 5.82 secs

C:\Users\beingben\Desktop\Forge Folder>gradlew build
****************************
Powered By MCP:
http://mcp.ocean-labs.de/
Searge, ProfMobius, Fesh0r,
R4wk, ZeuX, IngisKahn, bspkrs
MCP Data version : unknown
****************************
:compileApiJava UP-TO-DATE
:processApiResources UP-TO-DATE
:apiClasses UP-TO-DATE
:sourceMainJava UP-TO-DATE
:compileJava
warning: [options] bootstrap class path not set in conjunction with -source 1.6
C:\Users\beingben\Desktop\Forge Folder\build\sources\java\com\beingben\tfcraftad
don\TFCGrassDropsEvent.java:5: error: package com.bioxx.tfc.api does not exist
import com.bioxx.tfc.api.TFCBlocks;
                        ^
C:\Users\beingben\Desktop\Forge Folder\build\sources\java\com\beingben\tfcraftad
don\TFCGrassDropsEvent.java:20: error: cannot find symbol
                                if (event.block == TFCBlocks.TallGrass) {
                                                   ^
  symbol:   variable TFCBlocks
  location: class TFCGrassDropsEvent
2 errors
1 warning
:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

BUILD FAILED

Total time: 8.687 secs

C:\Users\beingben\Desktop\Forge Folder>

 

The referenced file and import does exist...otherwise I wouldn't see it and I wouldn't be able to launch the game within eclipse and test the code with success.

 

 

Link to comment
Share on other sites

Below is  quoted reply from the TFC-Forum, I followed these directions.

 

 

Get TFC sources from github, unzip them. Lets call this folder "TFCraft-master". Now run theses commands in the unzipped folder :

 

gradlew setupDecompWorkspace

gradlew eclipse

Grab the forge sources, unzip them in a separate folder and run the sames commands as above. This is the folder where you make your mod. I will call it the "forge folder".

Open eclipse and set your workspace to the eclipse folder located in the forge folder. You should see the project Minecraft.

Now you need to link TFC sources in your project :

Right-click on the project in the package explorer, select new>folder

Type "TFC_sources" in Folder name

Click on advanced and select "Link to alternate location (Linked Folder)"

Browse to the TFCraft-master folder and select the "src" folder

Now you should see a TFC_sources folder in your project with 4 sub folders (API, ASM, Common and Resources)

Right click on each of theses sub folder and select Build Path > use as source folder

You should have 10 errors showing up. To fix theses, you need to replace the forge source jar by the one in TFCraft-master :

Right click on your project, select  build path > configure build path

Go in the tab libraries and remove the forgeSrc-[a version number].jar

Click on Add external JARs and select the forgeSrc-[a version number].jar located in the folder TFCraft-master>build>dirtyArtifacts

 

You are done, now you should be able to import/code your mod in src/main/java and to compile it alone.

 

Hope it helps

Link to comment
Share on other sites

I have, sadly after three days all I could get was a moderator to delete my triple post.

 

--Edit-- With some expierimenting i was able to get it to compile. Launches and I'm able to interact with the world. Once I interact with grass it crashes. Can anyone tell me what is causing this within my code?

 

---- Minecraft Crash Report ----

// Uh... Did I do that?

 

Time: 2/17/15 9:50 PM

Description: Exception in server tick loop

 

java.lang.NoClassDefFoundError: com/bioxx/tfc/api/TFCBlocks

at com.beingben.tfcraftaddon.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 more

Caused by: java.lang.NullPointerException

 

 

A 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 64-Bit Server VM (mixed mode), Oracle Corporation

Memory: 156617808 bytes (149 MB) / 879230976 bytes (838 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: 12, 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.7.10-10.13.2.1272-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'/36, 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'

Link to comment
Share on other sites

I have, sadly after three days all I could get was a moderator to delete my triple post.

 

--Edit-- With some expierimenting i was able to get it to compile. Launches and I'm able to interact with the world. Once I interact with grass it crashes. Can anyone tell me what is causing this within my code?

 

---- Minecraft Crash Report ----

// Uh... Did I do that?

 

Time: 2/17/15 9:50 PM

Description: Exception in server tick loop

 

java.lang.NoClassDefFoundError: com/bioxx/tfc/api/TFCBlocks

at com.beingben.tfcraftaddon.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 more

Caused by: java.lang.NullPointerException

 

 

A 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 64-Bit Server VM (mixed mode), Oracle Corporation

Memory: 156617808 bytes (149 MB) / 879230976 bytes (838 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: 12, 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.7.10-10.13.2.1272-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'/36, 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'

 

It can't find the TFC block apparently.

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

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.



×
×
  • Create New...

Important Information

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