Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[Solved] [1.9.4] Force block update at position


onVoid
 Share

Recommended Posts

I am using the code

        			worldIn.destroyBlock(pos.add(0, 0, i), false);

(i being a variable) to destroy multiple blocks at once. The blocks are being removed but aren't updating, still showing as what they were before until I relog. How can I force a block update at the location?

Link to comment
Share on other sites

I am using the code

        			worldIn.destroyBlock(pos.add(0, 0, i), false);

(i being a variable) to destroy multiple blocks at once. The blocks are being removed but aren't updating, still showing as what they were before until I relog. How can I force a block update at the location?

Link to comment
Share on other sites

Are you calling this ONLY (!world.isRemote) server side?

Yes, here is my whole code for the action.

    public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
    {
        if (!worldIn.isRemote) {
        	for (int i = 0; i < 2; i++){
        			if (worldIn.getBlockState(pos.add(0, 0, i)).getBlock().equals(Blocks.STONE) && playerIn.canPlayerEdit(pos.add(0, 0, i), facing, stack)){
        			worldIn.destroyBlock(pos.add(0, 0, i), false);
            			//worldIn.getBlockState(pos.add(0,0,i)).getBlock().removedByPlayer(worldIn.getBlockState(pos.add(0,0,i)),
            					//worldIn, pos.add(0,0,i), playerIn, true);
        			worldIn.scheduleBlockUpdate(pos, worldIn.getBlockState(pos.add(0,0,i)).getBlock(), 1, 100);
        			}
        	}
        }

The first block is the only one that actually gets updated and is shown breaking. The second one does not update.

Link to comment
Share on other sites

Are you calling this ONLY (!world.isRemote) server side?

Yes, here is my whole code for the action.

    public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
    {
        if (!worldIn.isRemote) {
        	for (int i = 0; i < 2; i++){
        			if (worldIn.getBlockState(pos.add(0, 0, i)).getBlock().equals(Blocks.STONE) && playerIn.canPlayerEdit(pos.add(0, 0, i), facing, stack)){
        			worldIn.destroyBlock(pos.add(0, 0, i), false);
            			//worldIn.getBlockState(pos.add(0,0,i)).getBlock().removedByPlayer(worldIn.getBlockState(pos.add(0,0,i)),
            					//worldIn, pos.add(0,0,i), playerIn, true);
        			worldIn.scheduleBlockUpdate(pos, worldIn.getBlockState(pos.add(0,0,i)).getBlock(), 1, 100);
        			}
        	}
        }

The first block is the only one that actually gets updated and is shown breaking. The second one does not update.

Link to comment
Share on other sites

Just tried it, works just fine with just

destroyBlock

:

 

Mine's done on right click, if that changes anything.

   
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
    {
        if (!worldIn.isRemote) {
        	int dir = MathHelper.floor_double((double)((playerIn.rotationYaw * 4F) / 360F) + 0.5D) & 3;
    		if (dir == 0){
        	for (int i = 0; i < 2; i++){
        			if (worldIn.getBlockState(pos.add(0, 0, i)).getBlock().equals(Blocks.STONE)){
        			worldIn.destroyBlock(pos.add(0, 0, i), false);
        			}
        			if (worldIn.getBlockState(pos.add(1, 0, i)).getBlock().equals(Blocks.STONE)){
        			worldIn.destroyBlock(pos.add(1, 0, i), false);
        			}        			if (worldIn.getBlockState(pos.add(-1, 0, i)).getBlock().equals(Blocks.STONE)){
        			worldIn.destroyBlock(pos.add(-1, 0, i), false);

        			}
        		}
    		}
        }
	return null;
    }

Full code

EDIT: Longer gif

Link to comment
Share on other sites

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

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • I did download the latest forge-1.18-38.0.6-installer and installed it correctly into the right place. Also downloaded  38.0.5 to test (didn't work) and downloaded 38.0.0 None of those worked.
    • Unknown module securejarhandler implies that some libraries were missed during the installation. I suggest you redownload the latest installer and run it again.
    • Forge Version: 38.0.6 Minecraft Version: 1.18 Downloads: Changelog: (Direct) Installer: (AdFocus) (Direct) MDK: (AdFocus) (Direct) However, as this is the start of a new version, it is recommended that you check the Downloads Page and use the latest version to receive any bug fixes. Intro: 1.17 was a stepping stone, and 1.18 is the real target. The culmination of the Caves & Cliffs update, with few real code changes from 1.17 except those required to plug in the new biome system. This is our new Latest version. As we had some time before the release, we handled some refactors beforehand. Those will be listed here. Changelog: Refactors (not comprehensive): 99% of the fmllegacy package. Most classes were simply moved from x.y.fmllegacy.z to x.y.z. All instances of Gui -> Screen (GuiOpenEvent -> ScreenOpenEvent, for example) GuiScreenEvent -> ScreenEvent, GuiOverlayDebugForge -> ForgeDebugScreenOverlay All instances of GameMode -> GameType (ClientPlayerChangeGameModeEvent -> ClientPlayerChangedGameTypeEvent, for example) All instances of MatrixStack -> PoseStack (DrawSelectionEvent.matrix -> DrawSelectionEvent.poseStack, for example All instances of KeyBinding -> KeyMapping (ClickInputEvent.keyBinding -> ClickInputEvent.keyMapping, for example All instances of World -> Level All instances of WorldType -> WorldPreset (ForgeHooksClient.getDefaultWorldType -> ForgeHooksClient.getDefaultWorldPreset, for example All instances of NBT -> Tag (BlockSnapshot.getNbt -> BlockSnapshot.getTag, for example) All instances of Container -> Menu (IForgeContainerType -> IForgeMenuType, for example) PlaySoundEvent.sound -> PlaySoundEvent.originalSound PlaySoundEvent.result -> PlaySoundEvent.sound SoundEvent.manager -> SoundEvent.engine SoundEvent.SoundSourceEvent.source -> SoundEvent.SoundSourceEvent.channel FOVUpdateEvent -> FOVModifierEvent EntityViewRenderEvent.FOVModiier -> EntityViewRenderEvent.FieldOfView InputUpdateEvent -> MovementInputUpdateEvent InitScreenEvent.{...Widget...} -> {...Listener...} ForgeItemTagsProvider.func_240521_a_Colored -> copyColored MobSpawnInfoBuilder -> MobSpawnSettingBuilder BasicTrade -> BasicItemListing ModelLoader -> ForgeModelBakery ForgeWorldTypeScreens -> ForgeWorldPresetEditors StackList -> MultItemValue Removals: Entire Animation API IForgeTextureAtlasSprite IForgeItem.{showDurabiityBar, getDurabilityForDisplay, getRGBDurabilityForDisplay} ForgeHooksClient.refreshResources ModelBuilder.gui3d BlockInfo.{updateShift, getShx, getShy, getShz} CapabilityInject CapabilityManager.register ConditionalAdvancement.processConditions IForgeItem.isShield IForgeStructureFeature.{getDefaultSpawnList, getDefaultCreatureSpawnList} Forge's Constants class VanillaResourceType ForgeHooksClient.worldRenderPass (+ accessor) ForgeHooksClient.{preDraw, postDraw, getColorIndex} ScrollPanel.drawBackground Screen.{RenderToolTip, RenderComponentToolTip} ResourceManager.getResourceType LootPool.bonusRolls ForgeConfig - selectiveResourceReload PotionEvent.PotionAddedEvent ClientHooks ModFileResourcePack ResourcePackLoader.getResourcePackFor ResourcePackLoader.IPackInfoFinder ServerLifecycleHooks.buildPackFinder IResourceType ReloadRequirements CommandSetDimension
    • This is the error that I'm getting. WARNING: Unknown module: cpw.mods.securejarhandler specified to --add-exports WARNING: Unknown module: cpw.mods.securejarhandler specified to --add-opens Exception in thread "main" java.lang.module.FindException: Module org.objectweb.asm.util not found, required by org.openjdk.nashorn at java.base/java.lang.module.Resolver.findFail(Resolver.java:893) at java.base/java.lang.module.Resolver.resolve(Resolver.java:192) at java.base/java.lang.module.Resolver.resolve(Resolver.java:141) at java.base/java.lang.module.Configuration.resolveAndBind(Configuration.java:492) at java.base/java.lang.module.Configuration.resolveAndBind(Configuration.java:298) at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:83)   Tried various java versions,   8 and 16 to no avail. even tried bellsoft liberica full jre  and openjre   No clue what is going on and why there are such problems with Java now, seems like Oracle took their ball and wants to go home with the Java project. So many issues with various versions of it.  Any advice? Thanks,.
    • Really old Minecraft versions are no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.