Posted August 4, 20223 yr 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.
August 4, 20223 yr 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.
August 4, 20223 yr Author Will do. Will be tomorrow because i had to go and it is pretty late now. So i will share the code tomorrow
August 5, 20223 yr 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 August 5, 20223 yr by Just_EmSee
August 5, 20223 yr 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.