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

using a item i am placing some blocks on nearby entities using Level.setBlock(). but when doing so it only creates a ghost block which is not there to the client, when trying to place a block in the place where the block should be the block apears.

 

Show the code you are using to place the Blocks, due to the error i would say you are not syncing the block update with the client.

  • Author

Will do. Will be tomorrow because i had to go and it is pretty late now. So i will share the code tomorrow

 

 

  • Author
    @Override
    public void onUse(Level pLevel, ItemStack pWand, LivingEntity pPlayer) {
            List<Entity> list = pLevel.getEntities(pPlayer, AABB.ofSize(pPlayer.position(), this.getSize(), this.getSize(), this.getSize()));
            if (!pLevel.isClientSide) {
                if (pPlayer.getItemInHand(InteractionHand.OFF_HAND).getItem() instanceof SpellItem) {
                    SpellItem spellItem = (SpellItem) pPlayer.getItemInHand(InteractionHand.OFF_HAND).getItem();
                    spellItem.cooldown(pPlayer, this.getCooldown());
                }
                for (Entity entity : list) {
                    if (entity.isAlive()) {
                        if (!pLevel.isClientSide()) {
                            LivingEntity livingentity = (LivingEntity) entity;
                            livingentity.addEffect(new MobEffectInstance(MobEffects.WEAKNESS, 200, 1), entity);
                            livingentity.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 200, 5), entity);
                            BlockPos pos = new BlockPos(entity.position());
                            pLevel.setBlock(pos, Blocks.ICE.defaultBlockState(), 0);
                        }
                    }
                }
            }
            else {
                ParticleGen.spheremove(pPlayer.position().x, pPlayer.position().y+(pPlayer.getBbHeight()/2), pPlayer.position().z, 1, pLevel, ParticleTypes.SNOWFLAKE, 0, 0, 0, 1, 50, -3, true);
            }
            super.onUse(pLevel, pWand, pPlayer);
    }

 

Edited by Just_EmSee

Quote

pLevel.setBlock(pos, Blocks.ICE.defaultBlockState(), 0);

Passing 0 here means no updates are performed.

Using the value 2 will send updates to the client. See ServerLevel.markAndNotify() used by setBlock()

or you could just use setBlockAndUpdate() which passes the value 3 (so it also notifies neighbouring blocks of the change).

 

There is supposed to be a vanilla class somewhere that holds the values of these bits, but I don't know the name of it. 🙂

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

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.