protected void func_150124_c(World world, int x, int y, int z, int side, int meta)
{
double check = Math.random();
if (check < 0.30){
this.dropBlockAsItem(world, x, y, z, new ItemStack(MItems.Orange, 1, 0));
}
}
though it will be a 30% chance every time this code is called, and i haven't checked what the original statement was checking so 30% may be less often it may be more some trial and error may be involved. If after trial and error with that you still want more remove the if statement all together and it will simply drop every time its called with no chance, then if you still want more you have to either increase the stack size it drops or make your own tick counter and call if yourself using the tick counter (chance could be incorporated here too). though that last one is a little sloppy
yeah i only put 0.30 to illustrate it was a 30% chance
0.2 = 20%
0.35 = 35% and so on
here's a slightly more advanced example from one of my mods so you can see what it does
rand = Math.random();
if (rand>0.35D){
if (rand<0.55D){
event.entityLiving.dropItem(ModItems.pig_skin, 1);
}
}
if (rand<0.3D){
event.entityLiving.dropItem(Items.bone, 1);
}
if (rand>0.63D){
if (rand<0.7D){
event.entityLiving.dropItem(ModItems.pig_caught, 1);
}
}
Great! Now that that's out of the way, time for the other part to this thread. Custom cocoa beans.
Now I've seen tutorials on crops and I've seen tutorials on plants
But...
I've never seen a tutorial on custom Cocoa Beans.
Now I know I can't copy the vanilla code and work off that
And...
I know I have to extend BlockCocoa
But I've tried many ways and it always seems to crash or error or something bad happens to prevent it from working. I don't suppose anyone here knew how you could do this?
Ok I've gotten pretty far with this, its a lot more simpler than I thought, I just extended BlockCocoa and copied some of the stuff over from the BlockCocoa class and changed the drops and stuff, however there are a few thins wrong. You can place the bananas on any block (even cacti) and it faces the way you place it. Like shown in the attached images of this post.
My code is the same as BlockCocoa except it extends BlockCocoa and doesn't implement anything. (it was too big to post on here)
You should try them on water and fences because they count as blocks. Maybe that class doesn't have everything you need to know. Also, I don't thing copying that class is a good idea. They don't look shaped like a banana.
If you don't want them to be addable to any block there are a couple things you can do... 1 is canBlockStay referenced above in there you would us if statements
if (world.getBlock(x + 1, y, z) == Blocks.your trees log){
return true;}
else if (world.getBlock(x - 1, y, z) == Blocks.your trees log){
return true;}
else if (world.getBlock(x - 1, y, z + 1) == Blocks.your trees log){
return true;}
else if (world.getBlock(x, y, z - 1) == Blocks.your trees log){
return true;}
(world, x, y and z will be the p_numbers variables above unless you rename them like i do)
or you could delete the line setCreativeTabs() for your cocoa block have it not drop itself as an item but rather a subitem like watermelons dropping melon slices... and make it so the only way for your cocoa block to get into the game is onGenerated(whatever this method is actually called) by tree.
the return true in the statements are its return though you need to give it a return for if none of those statements are true.
so after the last else if statement just in the canBlockStay method add return false, if any of the above statements run it will never make it to the line return false.
as for your Log Block use the way you differentiated between them on registration there are a few ways you could have done this.
maybe they look different
if(world.getBlock(x + 1, y, z).getTextureName() == "Your SubBlock Textures Name"{
return true;
}
Or have Different Names, Slightly Diferent Materials, Different Hardness from one another... there are plently of options just work out which variable most easily differentiates between your Log Types
ok I don't know why, but every time after I added that return false statement I open a new world and get out the bananablock and minecraft crashes, ill send you my code:
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata
*/
public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_)
* Drops the block items with a specified chance of dropping the specified items
*/
public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_)
public Item getItemDropped(int par1, Random par2Random, int par3)
{
return null;
}
}
I want my banana to be the exact same as cocoa beans, you use a banana to plant them and you get bananas from them
(just like cocoa beans, you use brown dye to plant them and you get brown dye from them (not the actual block)
crash report please?? Having your code is somewhat helpful but unless i copy and try to run it myself i'm really just proof reading declarations without really knowing whats wrong
edit- If Can Block Stay is A Method from parent class add the @Override annotation above it,
---- Minecraft Crash Report ----
// I'm sorry, Dave.
Time: 27/03/15 6:42 PM
Description: There was a severe problem during mod loading that has caused the game to fail
cpw.mods.fml.common.LoaderException: java.lang.Error: Unresolved compilation problem:
The method setBlockName(String) is undefined for the type OrangeSapling
at cpw.mods.fml.common.LoadController.transition(LoadController.java:162)
at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:515)
at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:239)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:522)
at net.minecraft.client.Minecraft.run(Minecraft.java:931)
at net.minecraft.client.main.Main.main(Main.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
at GradleStart.main(Unknown Source)
Caused by: java.lang.Error: Unresolved compilation problem:
The method setBlockName(String) is undefined for the type OrangeSapling
at com.inyourpotato.blocks.MBlocks.initializeBlock(MBlocks.java:27)
at com.inyourpotato.blocks.MBlocks.mainRegitry(MBlocks.java:14)
at com.inyourpotato.Main.MainRegistry.PreLoad(MainRegistry.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:513)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:208)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118)
at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:513)
... 12 more
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 8.1 (amd64) version 6.3
Java Version: 1.8.0_11, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 897362192 bytes (855 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 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.1291 Minecraft Forge 10.13.2.1291 4 mods loaded, 4 mods active
mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized
FML{7.10.85.1291} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.2.1291.jar) Unloaded->Constructed->Pre-initialized
Forge{10.13.2.1291} [Minecraft Forge] (forgeSrc-1.7.10-10.13.2.1291.jar) Unloaded->Constructed->Pre-initialized
toomuchfood{0.1} [Too Much Food] (bin) Unloaded->Constructed->Errored
this will set the chance to 30%
protected void func_150124_c(World world, int x, int y, int z, int side, int meta)
{
double check = Math.random();
if (check < 0.30){
this.dropBlockAsItem(world, x, y, z, new ItemStack(MItems.Orange, 1, 0));
}
}
though it will be a 30% chance every time this code is called, and i haven't checked what the original statement was checking so 30% may be less often it may be more some trial and error may be involved. If after trial and error with that you still want more remove the if statement all together and it will simply drop every time its called with no chance, then if you still want more you have to either increase the stack size it drops or make your own tick counter and call if yourself using the tick counter (chance could be incorporated here too). though that last one is a little sloppy
Thanks so much! Works great! What you gave me is a 30% chance all the time!
can you use this line instead?
if (check < 0.3){
#savethezeros
#idontusesocialmedia
yeah i only put 0.30 to illustrate it was a 30% chance
0.2 = 20%
0.35 = 35% and so on
here's a slightly more advanced example from one of my mods so you can see what it does
rand = Math.random();
if (rand>0.35D){
if (rand<0.55D){
event.entityLiving.dropItem(ModItems.pig_skin, 1);
}
}
if (rand<0.3D){
event.entityLiving.dropItem(Items.bone, 1);
}
if (rand>0.63D){
if (rand<0.7D){
event.entityLiving.dropItem(ModItems.pig_caught, 1);
}
}
if
if
could be swapped to if &&
Great! Now that that's out of the way, time for the other part to this thread. Custom cocoa beans.
Now I've seen tutorials on crops and I've seen tutorials on plants
But...
I've never seen a tutorial on custom Cocoa Beans.
Now I know I can't copy the vanilla code and work off that
And...
I know I have to extend BlockCocoa
But I've tried many ways and it always seems to crash or error or something bad happens to prevent it from working. I don't suppose anyone here knew how you could do this?
Ok I've gotten pretty far with this, its a lot more simpler than I thought, I just extended BlockCocoa and copied some of the stuff over from the BlockCocoa class and changed the drops and stuff, however there are a few thins wrong. You can place the bananas on any block (even cacti) and it faces the way you place it. Like shown in the attached images of this post.
My code is the same as BlockCocoa except it extends BlockCocoa and doesn't implement anything. (it was too big to post on here)
Thanks!
Can you take a screenshot of the name?
Maybe this:
if (!this.canBlockStay(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_))
I know it looks like nothing, but it saids "canBlockStay" Whatever the p_149674_#'s are.
Did you test them on your bununu tree?
the p_149674's are this:
p_149674_1_ is world
p_149674_2_ is x
p_149674_3_ is y
p_149674_4_ is z
p_149674_5_is random
And yes, they work on every single block
Yes, it works on every block, the p_149674_'s are world x y z and random
You should try them on water and fences because they count as blocks. Maybe that class doesn't have everything you need to know. Also, I don't thing copying that class is a good idea. They don't look shaped like a banana.
If you don't want them to be addable to any block there are a couple things you can do... 1 is canBlockStay referenced above in there you would us if statements
if (world.getBlock(x + 1, y, z) == Blocks.your trees log){
return true;}
else if (world.getBlock(x - 1, y, z) == Blocks.your trees log){
return true;}
else if (world.getBlock(x - 1, y, z + 1) == Blocks.your trees log){
return true;}
else if (world.getBlock(x, y, z - 1) == Blocks.your trees log){
return true;}
(world, x, y and z will be the p_numbers variables above unless you rename them like i do)
or you could delete the line setCreativeTabs() for your cocoa block have it not drop itself as an item but rather a subitem like watermelons dropping melon slices... and make it so the only way for your cocoa block to get into the game is onGenerated(whatever this method is actually called) by tree.
Thanks, how would I choose my block.
I did MBlocks.BlockLog
but in block log there are multiple blocks (banana and orange)
I only want tem to be placed on a banana logs
Also I get an error on canblockstay saying it needs a return statement, what do I return the whole method as?
the return true in the statements are its return though you need to give it a return for if none of those statements are true.
so after the last else if statement just in the canBlockStay method add return false, if any of the above statements run it will never make it to the line return false.
as for your Log Block use the way you differentiated between them on registration there are a few ways you could have done this.
maybe they look different
if(world.getBlock(x + 1, y, z).getTextureName() == "Your SubBlock Textures Name"{
return true;
}
Or have Different Names, Slightly Diferent Materials, Different Hardness from one another... there are plently of options just work out which variable most easily differentiates between your Log Types
ok I don't know why, but every time after I added that return false statement I open a new world and get out the bananablock and minecraft crashes, ill send you my code:
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockCocoa;
import net.minecraft.block.BlockDirectional;
import net.minecraft.block.BlockLog;
import net.minecraft.block.IGrowable;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Direction;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BananaBlock extends BlockCocoa
{
@SideOnly(Side.CLIENT)
private IIcon[] field_149989_a;
private static final String __OBFID = "CL_00000216";
public BananaBlock()
{
this.setTickRandomly(true);
}
/**
* Gets the block's texture. Args: side, meta
*/
@SideOnly(Side.CLIENT)
public IIcon getIcon(int p_149691_1_, int p_149691_2_)
{
return this.field_149989_a[2];
}
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_)
{
if (!this.canBlockStay(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_))
{
this.dropBlockAsItem(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_), 0);
p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, getBlockById(0), 0, 2);
}
else if (p_149674_1_.rand.nextInt(5) == 0)
{
int l = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_);
int i1 = func_149987_c(l);
if (i1 < 2)
{
++i1;
p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, i1 << 2 | getDirection(l), 2);
}
}
}
@SideOnly(Side.CLIENT)
public IIcon getCocoaIcon(int p_149988_1_)
{
if (p_149988_1_ < 0 || p_149988_1_ >= this.field_149989_a.length)
{
p_149988_1_ = this.field_149989_a.length - 1;
}
return this.field_149989_a[p_149988_1_];
}
/**
* Can this block stay at this position. Similar to canPlaceBlockAt except gets checked often with plants.
*/
public boolean canBlockStay(World world, int x, int y, int z)
{
if (world.getBlock(x + 1, y, z) == MBlocks.BlockLog){
return true;}
else if (world.getBlock(x - 1, y, z) == MBlocks.BlockLog){
return true;}
else if (world.getBlock(x - 1, y, z + 1) == MBlocks.BlockLog){
return true;}
else if (world.getBlock(x, y, z - 1) == MBlocks.BlockLog){
return true;}
return false;
}
/**
* The type of render function that is called for this block
*/
public int getRenderType()
{
return 28;
}
/**
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
*/
public boolean renderAsNormalBlock()
{
return false;
}
/**
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
*/
public boolean isOpaqueCube()
{
return false;
}
/**
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
* cleared to be reused)
*/
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
{
this.setBlockBoundsBasedOnState(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_);
return super.getCollisionBoundingBoxFromPool(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_);
}
/**
* Updates the blocks bounds based on its current state. Args: world, x, y, z
*/
public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_)
{
int l = p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_);
int i1 = getDirection(l);
int j1 = func_149987_c(l);
int k1 = 4 + j1 * 2;
int l1 = 5 + j1 * 2;
float f = (float)k1 / 2.0F;
switch (i1)
{
case 0:
this.setBlockBounds((8.0F - f) / 16.0F, (12.0F - (float)l1) / 16.0F, (15.0F - (float)k1) / 16.0F, (8.0F + f) / 16.0F, 0.75F, 0.9375F);
break;
case 1:
this.setBlockBounds(0.0625F, (12.0F - (float)l1) / 16.0F, (8.0F - f) / 16.0F, (1.0F + (float)k1) / 16.0F, 0.75F, (8.0F + f) / 16.0F);
break;
case 2:
this.setBlockBounds((8.0F - f) / 16.0F, (12.0F - (float)l1) / 16.0F, 0.0625F, (8.0F + f) / 16.0F, 0.75F, (1.0F + (float)k1) / 16.0F);
break;
case 3:
this.setBlockBounds((15.0F - (float)k1) / 16.0F, (12.0F - (float)l1) / 16.0F, (8.0F - f) / 16.0F, 0.9375F, 0.75F, (8.0F + f) / 16.0F);
}
}
/**
* Called when the block is placed in the world.
*/
public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_)
{
int l = ((MathHelper.floor_double((double)(p_149689_5_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) + 0) % 4;
p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, l, 2);
}
/**
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata
*/
public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_)
{
if (p_149660_5_ == 1 || p_149660_5_ == 0)
{
p_149660_5_ = 2;
}
return Direction.rotateOpposite[Direction.facingToDirection[p_149660_5_]];
}
/**
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
* their own) Args: x, y, z, neighbor Block
*/
public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_)
{
if (!this.canBlockStay(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_))
{
this.dropBlockAsItem(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_), 0);
p_149695_1_.setBlock(p_149695_2_, p_149695_3_, p_149695_4_, getBlockById(0), 0, 2);
}
}
/**
* Returns the bounding box of the wired rectangular prism to render.
*/
@SideOnly(Side.CLIENT)
public AxisAlignedBB getSelectedBoundingBoxFromPool(World p_149633_1_, int p_149633_2_, int p_149633_3_, int p_149633_4_)
{
this.setBlockBoundsBasedOnState(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_);
return super.getSelectedBoundingBoxFromPool(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_);
}
public static int func_149987_c(int p_149987_0_)
{
return (p_149987_0_ & 12) >> 2;
}
/**
* Drops the block items with a specified chance of dropping the specified items
*/
public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_)
{
super.dropBlockAsItemWithChance(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_6_, p_149690_7_);
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int p_149690_5_, int fortune)
{
ArrayList<ItemStack> dropped = super.getDrops(world, x, y, z, p_149690_5_, fortune);
int j1 = func_149987_c(p_149690_5_);
byte b0 = 1;
if (j1 >= 2)
{
b0 = 3;
}
for (int k1 = 0; k1 < b0; ++k1)
{
dropped.add(new ItemStack(Items.dye, 1, 3));
}
return dropped;
}
/**
* Gets an item for the block being called on. Args: world, x, y, z
*/
@SideOnly(Side.CLIENT)
public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_)
{
return Items.dye;
}
/**
* Get the block's damage value (for use with pick block).
*/
public int getDamageValue(World p_149643_1_, int p_149643_2_, int p_149643_3_, int p_149643_4_)
{
return 3;
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister p_149651_1_)
{
this.field_149989_a = new IIcon[3];
for (int i = 0; i < this.field_149989_a.length; ++i)
{
this.field_149989_a = p_149651_1_.registerIcon(this.getTextureName() + "_stage_" + i);
}
}
public boolean func_149851_a(World p_149851_1_, int p_149851_2_, int p_149851_3_, int p_149851_4_, boolean p_149851_5_)
{
int l = p_149851_1_.getBlockMetadata(p_149851_2_, p_149851_3_, p_149851_4_);
int i1 = func_149987_c(l);
return i1 < 2;
}
public boolean func_149852_a(World p_149852_1_, Random p_149852_2_, int p_149852_3_, int p_149852_4_, int p_149852_5_)
{
return true;
}
public void func_149853_b(World p_149853_1_, Random p_149853_2_, int p_149853_3_, int p_149853_4_, int p_149853_5_)
{
int l = p_149853_1_.getBlockMetadata(p_149853_3_, p_149853_4_, p_149853_5_);
int i1 = BlockDirectional.getDirection(l);
int j1 = func_149987_c(l);
++j1;
p_149853_1_.setBlockMetadataWithNotify(p_149853_3_, p_149853_4_, p_149853_5_, j1 << 2 | i1, 2);
}
@Override
public Item getItemDropped(int par1, Random par2Random, int par3)
{
return null;
}
}
I want my banana to be the exact same as cocoa beans, you use a banana to plant them and you get bananas from them
(just like cocoa beans, you use brown dye to plant them and you get brown dye from them (not the actual block)
try changing return false to else{
return false;}
crash report please?? Having your code is somewhat helpful but unless i copy and try to run it myself i'm really just proof reading declarations without really knowing whats wrong
edit- If Can Block Stay is A Method from parent class add the @Override annotation above it,
Crash Report:
// I'm sorry, Dave. Time: 27/03/15 6:42 PM
Description: There was a severe problem during mod loading that has caused the game to fail cpw.mods.fml.common.LoaderException: java.lang.Error: Unresolved compilation problem:
The method setBlockName(String) is undefined for the type OrangeSapling at cpw.mods.fml.common.LoadController.transition(LoadController.java:162)
at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:515)
at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:239)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:522)
at net.minecraft.client.Minecraft.run(Minecraft.java:931)
at net.minecraft.client.main.Main.main(Main.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
at GradleStart.main(Unknown Source)
Caused by: java.lang.Error: Unresolved compilation problem:
The method setBlockName(String) is undefined for the type OrangeSapling at com.inyourpotato.blocks.MBlocks.initializeBlock(MBlocks.java:27)
at com.inyourpotato.blocks.MBlocks.mainRegitry(MBlocks.java:14)
at com.inyourpotato.Main.MainRegistry.PreLoad(MainRegistry.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:513)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:208)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118)
at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:513)
... 12 more 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 8.1 (amd64) version 6.3
Java Version: 1.8.0_11, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 897362192 bytes (855 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 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.1291 Minecraft Forge 10.13.2.1291 4 mods loaded, 4 mods active
mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized
FML{7.10.85.1291} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.2.1291.jar) Unloaded->Constructed->Pre-initialized
Forge{10.13.2.1291} [Minecraft Forge] (forgeSrc-1.7.10-10.13.2.1291.jar) Unloaded->Constructed->Pre-initialized
toomuchfood{0.1} [Too Much Food] (bin) Unloaded->Constructed->Errored
The method setBlockName(String) is undefined for the type OrangeSapling
at com.inyourpotato.blocks.MBlocks.initializeBlock(MBlocks.java:27)
at com.inyourpotato.blocks.MBlocks.mainRegitry(MBlocks.java:14)
What does this mean? It was working fine before?
Its ok I fixed that error, however I can still place it on any block...
ok I figured something out! I can place the bananablock on any block however on every block except my banana log, it eventually breaks.
Also if I break the block its on, it stays and it can be placed in different directions (like wood)