Jump to content

Recommended Posts

Posted

I am working on updating my Coffee & Tea Mod and I am trying to fix a bug that has been in it for a while. Basically whenever the farmland underneath my custom crop (technically a coffee bush) has a block update it turns to dirt. I have no idea how to fix this and it is really weird. Here is the code to my Coffee Bush.

 

package net.richardsprojects.teamod.main;

//Removed the imports to shorten the code here

public class BlockCoffeeBush extends BlockContainer implements IGrowable {

protected BlockCoffeeBush(Material mat) {
super(mat);

this.setTickRandomly(true);
float f = 0.5F;
    this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f);
    this.setCreativeTab((CreativeTabs)null);
    this.setHardness(0.0F);
    this.setStepSound(soundTypeGrass);
    this.disableStats();
}

public static void mainRegistry()
{
initializeBlock();
registerBlock();
}

//Used to handle crops growing
    public void updateTick(World world, int x, int y, int z, Random random)
    {
    if (world.getBlockLightValue(x, y + 1, z) >= 9)
    {
    int metadata = world.getBlockMetadata(x, y, z);

    if (metadata < 7)
    {
    if (random.nextInt(2) == 0)
    {
    metadata++;
    world.setBlockMetadataWithNotify(x, y, z, metadata, 2);
    }
    }
    }
    }

public static Block coffeeBush;

public static void initializeBlock()
{
coffeeBush = new BlockCoffeeBush(Material.grass).setBlockName("coffeeBush").setBlockTextureName("teamod:CoffeeStage1_4");
}

public static void registerBlock()
{
GameRegistry.registerBlock(coffeeBush, coffeeBush.getUnlocalizedName());
}

//Set the TileEntity
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_)
{
return new CoffeeBushEntity();
}

//Can be grown on farmland, dirt, or grass
protected boolean canPlaceBlockOn(Block block)
    {
        return block == Blocks.farmland;
    }

//Not a normal renderType
    @Override
    public int getRenderType() {
            return -1;
    }
 
    //It's not an opaque cube
    @Override
    public boolean isOpaqueCube() {
            return false;
    }
 
    //It's not a normal block
    public boolean renderAsNormalBlock() {
            return false;
    }

//Returns whether its fully grown?
@Override
public boolean func_149851_a(World world, int x, int y, int z, boolean flag)
{
return world.getBlockMetadata(x, y, z) != 7;
}

//I have no idea what this is for.
@Override
public boolean func_149852_a(World world, Random random, int x, int y, int z)
{
return true;
}

//Handles Bonemeal
@Override
public void func_149853_b(World world, Random random, int x, int y, int z)
{
int metadata = 0;
metadata = world.getBlockMetadata(x, y, z) + MathHelper.getRandomIntegerInRange(world.rand, 2, 5);

        if (metadata > 7)
        {
            metadata = 7;
        }

        world.setBlockMetadataWithNotify(x, y, z, metadata, 2);
}

    protected Item func_149865_P()
    {
    return null;
    }
   
    /**
    * 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 this.func_149866_i();
    }
   
    /**
    * Returns the quantity of items to drop on block destruction.
    */
    @Override
    public int quantityDropped(Random p_149745_1_)
    {
        return 0;
    }
   
/**
    * Gets an item for the block being called on. Args: world, x, y, z
    */
//TODO: Don't know if this needs to be only client side or not
    @SideOnly(Side.CLIENT)
    public Item getItemDropped(int p_149650_1_, Random rnd, int p_149650_3_)
    {
        return null;
    }
   
protected Item func_149866_i()
    {
        return ItemCoffeeBeans.unroastedBean;
    }

}[/Code]

 

It may seem a bit odd because it is also a TileEntity so that it can display different 3d models for each stage. Any help would be greatly appreciated. I am trying to get this update out as quickly as possible (everything else is finished). TIA :)

Creator of the Recipe Expansion Pack mod.

http://www.minecraftforum.net/topic/1983421-172-forge-recipe-expansion-pack-version-012/

Updated to 1.7.2!

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • You can check mod compatibility remove new mods and test them one by one.
    • @Tsuk1 Also, new note, you can use blockbench to make the custom item model for when it is not on the head.   EDIT: Funny story, I am making a mod similar to yours! Mine is called NorseMC.
    • @Nood_dev Could you send a screenshot of your weapon code? Here is the one I made (for a dagger): The specific UUID does not matter, just that it is the same every time, which is why UUID#randomUUID does not work public class DaggerItem extends TieredItem implements Vanishable { protected static final double REACH_MODIFIER = -1.5D; protected final Multimap<Attribute, AttributeModifier> defaultModifiers; protected final UUID BASE_ATTACK_REACH_UUID = UUID.fromString("6fe75b5c-9d1b-4e83-9eea-a1d5a94e8dd5") public DaggerItem(Tier pTier, int pAttackDamageModifier, float pAttackSpeedModifier, Properties pProperties) { super(pTier, pAttackDamageModifier, pAttackSpeedModifier, pProperties); this.attackDamage = (float) pAttackDamageModifier + pTier.getAttackDamageBonus(); ImmutableMultimap.Builder<Attribute, AttributeModifier> builder = ImmutableMultimap.builder(); builder.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(BASE_ATTACK_DAMAGE_UUID, "Weapon modifier", this.attackDamage, AttributeModifier.Operation.ADDITION)); builder.put(Attributes.ATTACK_SPEED, new AttributeModifier(BASE_ATTACK_SPEED_UUID, "Weapon modifier", pAttackSpeedModifier, AttributeModifier.Operation.ADDITION)); // THE ONE YOU WANT: builder.put(ForgeMod.ENTITY_REACH.get(), new AttributeModifier(BASE_ATTACK_REACH_UUID, "Weapon modifier", REACH_MODIFIER, AttributeModifier.Operation.ADDITION)); this.defaultModifiers = builder.build(); } @Override public Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(EquipmentSlot pEquipmentSlot) { return pEquipmentSlot == EquipmentSlot.MAINHAND ? this.defaultModifiers : super.getDefaultAttributeModifiers(pEquipmentSlot); } }
    • https://images.app.goo.gl/1PxFKdxByTgkxvSu6
    • That's what we'll try out. I could never figure out how to recreate the crash, so I'll just have to wait and see.
  • Topics

×
×
  • Create New...

Important Information

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