Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I need help with placing a custom lily pad on top of water.

Ive looked in the original lilypad classes: BlockLilyPad/ItemLilyPad, but i cant seen to make it work.

This code seems interesting:

 

 

public class ItemLilyPad extends ItemColored

{

    private static final String __OBFID = "CL_00000074";

 

    public ItemLilyPad(Block block)

    {

        super(block, false);

    }

 

    public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)

    {

        MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, true);

 

        if (movingobjectposition == null)

        {

            return itemStackIn;

        }

        else

        {

            if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)

            {

                BlockPos blockpos = movingobjectposition.getBlockPos();

 

                if (!worldIn.isBlockModifiable(playerIn, blockpos))

                {

                    return itemStackIn;

                }

 

                if (!playerIn.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, itemStackIn))

                {

                    return itemStackIn;

                }

 

                BlockPos blockpos1 = blockpos.up();

                IBlockState iblockstate = worldIn.getBlockState(blockpos);

 

                if (iblockstate.getBlock().getMaterial() == Material.water && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0 && worldIn.isAirBlock(blockpos1))

                {

                    // special case for handling block placement with water lilies

                    net.minecraftforge.common.util.BlockSnapshot blocksnapshot = net.minecraftforge.common.util.BlockSnapshot.getBlockSnapshot(worldIn, blockpos1);

                    worldIn.setBlockState(blockpos1, Blocks.waterlily.getDefaultState());

                    if (net.minecraftforge.event.ForgeEventFactory.onPlayerBlockPlace(playerIn, blocksnapshot, net.minecraft.util.EnumFacing.UP).isCanceled())

                    {

                        blocksnapshot.restore(true, false);

                        return itemStackIn;

                    }

 

                    if (!playerIn.capabilities.isCreativeMode)

                    {

                        --itemStackIn.stackSize;

                    }

 

                    playerIn.triggerAchievement(StatList.objectUseStats[item.getIdFromItem(this)]);

                }

            }

 

            return itemStackIn;

        }

    }

 

 

Copied the code and made a ItemBlock but still can't make it work  :P

  • Author

I found out ;D

I had to add something from the BlockBush.class

 

BlockBush.class

 

 

    @Override

    public net.minecraftforge.common.EnumPlantType getPlantType(net.minecraft.world.IBlockAccess world, BlockPos pos)

    {

        if (this == Blocks.wheat)          return net.minecraftforge.common.EnumPlantType.Crop;

        if (this == Blocks.carrots)        return net.minecraftforge.common.EnumPlantType.Crop;

        if (this == Blocks.potatoes)      return net.minecraftforge.common.EnumPlantType.Crop;

        if (this == Blocks.melon_stem)    return net.minecraftforge.common.EnumPlantType.Crop;

        if (this == Blocks.pumpkin_stem)  return net.minecraftforge.common.EnumPlantType.Crop;

        if (this == Blocks.deadbush)      return net.minecraftforge.common.EnumPlantType.Desert;

        if (this == Blocks.waterlily)      return net.minecraftforge.common.EnumPlantType.Water;

        if (this == Blocks.red_mushroom)  return net.minecraftforge.common.EnumPlantType.Cave;

        if (this == Blocks.brown_mushroom) return net.minecraftforge.common.EnumPlantType.Cave;

        if (this == Blocks.nether_wart)    return net.minecraftforge.common.EnumPlantType.Nether;

        if (this == Blocks.sapling)        return net.minecraftforge.common.EnumPlantType.Plains;

        if (this == Blocks.tallgrass)      return net.minecraftforge.common.EnumPlantType.Plains;

        if (this == Blocks.double_plant)  return net.minecraftforge.common.EnumPlantType.Plains;

        if (this == Blocks.red_flower)    return net.minecraftforge.common.EnumPlantType.Plains;

        if (this == Blocks.yellow_flower)  return net.minecraftforge.common.EnumPlantType.Plains;

        return net.minecraftforge.common.EnumPlantType.Plains;

    }

 

 

 

MyBlock.class

 

 

    @Override

    public net.minecraftforge.common.EnumPlantType getPlantType(net.minecraft.world.IBlockAccess world, BlockPos pos)

    {

        if (this == BlockManager.BushLotus)      return net.minecraftforge.common.EnumPlantType.Water;

        return net.minecraftforge.common.EnumPlantType.Plains;

    }

 

 

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.