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 want to detect when a player left clicks on a block, but onBlockClicked does nothing...

Here's my current code:

package com.nulldev.extremeskyblock.blocks;

import com.nulldev.extremeskyblock.util.RegistryHandler;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.client.particle.ParticleManager;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;

public class CompactStoneBlock extends Block {
    public CompactStoneBlock(Material material, Float hardness, Float resistance, SoundType soundType, int harvestLevel, ToolType toolType) {
        super(Properties.create(material)
                .hardnessAndResistance(hardness, resistance)
                .sound(soundType)
                .harvestLevel(harvestLevel)
                .harvestTool(toolType));
    }

    @Override
    public void onBlockClicked(BlockState state, World worldIn, BlockPos pos, PlayerEntity player) {
        ItemEntity stonePebble = new ItemEntity(worldIn, pos.getX(), pos.getY() + 2, pos.getZ(), new ItemStack(RegistryHandler.STONE_PEBBLE.get(), 1));
    }
}

But placing the block and clicking on it does nothing, and Intellij says that its deprecated but I cannot find anywhere what to use instead.

1 hour ago, NullDev said:

Intellij says that its deprecated

You can override it.

1 hour ago, NullDev said:

But placing the block and clicking on it does nothing

You are creating the ItemEntity but aren't spawning it.

Edited by Danebi

  • Author
On 12/7/2020 at 4:10 PM, Danebi said:

You can override it.

You are creating the ItemEntity but aren't spawning it.

Thanks that worked!

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.