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

    • Time: 12/3/21 11:33 PM Description: Ticking entity java.lang.BootstrapMethodError: java.lang.LinkageError: loader constraint violation: loader (instance of sun/misc/Launcher$AppClassLoader) previously initiated loading for a different type with name "org/apache/logging/log4j/util/MessageSupplier"     at net.minecraftforge.eventbus.EventBus.handleException(EventBus.java:316) ~[eventbus-4.0.0.jar:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:307) ~[eventbus-4.0.0.jar:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283) ~[eventbus-4.0.0.jar:?] {}     at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:597) ~[?:?] {re:mixin,re:classloading}     at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:591) ~[?:?] {re:mixin,re:classloading}     at net.minecraftforge.common.capabilities.CapabilityProvider.doGatherCapabilities(CapabilityProvider.java:83) ~[?:?] {re:computing_frames,re:mixin,re:classloading}     at net.minecraftforge.common.capabilities.CapabilityProvider.getCapabilities(CapabilityProvider.java:91) ~[?:?] {re:computing_frames,re:mixin,re:classloading}     at net.minecraftforge.common.capabilities.CapabilityProvider.areCapsCompatible(CapabilityProvider.java:103) ~[?:?] {re:computing_frames,re:mixin,re:classloading}     at net.minecraft.item.ItemStack.func_77959_d(ItemStack.java:387) ~[?:?] {re:mixin,xf:fml:forge:filled_map.4,xf:fml:forge:itemstack,re:classloading,xf:fml:forge:filled_map.4,xf:fml:forge:itemstack,pl:mixin:APP:performant.mixins.json:item.ItemStackMixin,pl:mixin:APP:itemfilters-common.mixins.json:ItemStackMixin,pl:mixin:APP:epicfight.mixins.json:MixinItemStack,pl:mixin:A}     at net.minecraft.item.ItemStack.func_77989_b(ItemStack.java:375) ~[?:?] {re:mixin,xf:fml:forge:filled_map.4,xf:fml:forge:itemstack,re:classloading,xf:fml:forge:filled_map.4,xf:fml:forge:itemstack,pl:mixin:APP:performant.mixins.json:item.ItemStackMixin,pl:mixin:APP:itemfilters-common.mixins.json:ItemStackMixin,pl:mixin:APP:epicfight.mixins.json:MixinItemStack,pl:mixin:A}     at net.minecraft.entity.LivingEntity.func_241354_r_(LivingEntity.java:2267) ~[?:?] {re:mixin,pl:accesstransformer:B,re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:performant.mixins.json:entity.LivingEntityMixin,pl:mixin:APP:citadel.mixins.json:LivingEntityMixin,pl:mixin:APP:environmental.mixins.json:LivingEntityMixin,pl:mixin:APP:allurement.mixins.json:LivingEntityAccessor,pl:mixin:APP:allurement.mixins.json:LivingEntityMixin,pl:mixin:APP:ars_nouveau.mixins.json:ExpInvokerMixin,pl:mixin:APP:ars_nouveau.mixins.json:MixinLivingEntity,pl:mixin:APP:personality.mixins.json:LivingEntityMixin,pl:mixin:APP:assets/botania/botania.mixins.json:AccessorLivingEntity,pl:mixin:A}     at net.minecraft.entity.LivingEntity.func_241353_q_(LivingEntity.java:2239) ~[?:?] {re:mixin,pl:accesstransformer:B,re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:performant.mixins.json:entity.LivingEntityMixin,pl:mixin:APP:citadel.mixins.json:LivingEntityMixin,pl:mixin:APP:environmental.mixins.json:LivingEntityMixin,pl:mixin:APP:allurement.mixins.json:LivingEntityAccessor,pl:mixin:APP:allurement.mixins.json:LivingEntityMixin,pl:mixin:APP:ars_nouveau.mixins.json:ExpInvokerMixin,pl:mixin:APP:ars_nouveau.mixins.json:MixinLivingEntity,pl:mixin:APP:personality.mixins.json:LivingEntityMixin,pl:mixin:APP:assets/botania/botania.mixins.json:AccessorLivingEntity,pl:mixin:A}     at net.minecraft.entity.LivingEntity.func_70071_h_(LivingEntity.java:2141) ~[?:?] {re:mixin,pl:accesstransformer:B,re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:performant.mixins.json:entity.LivingEntityMixin,pl:mixin:APP:citadel.mixins.json:LivingEntityMixin,pl:mixin:APP:environmental.mixins.json:LivingEntityMixin,pl:mixin:APP:allurement.mixins.json:LivingEntityAccessor,pl:mixin:APP:allurement.mixins.json:LivingEntityMixin,pl:mixin:APP:ars_nouveau.mixins.json:ExpInvokerMixin,pl:mixin:APP:ars_nouveau.mixins.json:MixinLivingEntity,pl:mixin:APP:personality.mixins.json:LivingEntityMixin,pl:mixin:APP:assets/botania/botania.mixins.json:AccessorLivingEntity,pl:mixin:A}     at net.minecraft.entity.MobEntity.func_70071_h_(MobEntity.java:431) ~[?:?] {re:mixin,pl:accesstransformer:B,xf:OptiFine:default,re:classloading,pl:accesstransformer:B,xf:OptiFine:default,pl:mixin:APP:environmental.mixins.json:MobEntityMixin,pl:mixin:APP:assets/botania/botania.mixins.json:AccessorMobEntity,pl:mixin:APP:performant.mixins.json:entity.MobEntityDespawnMixin,pl:mixin:APP:performant.mixins.json:entity.MobEntityMixin,pl:mixin:A}     at net.minecraft.world.server.ServerWorld.func_217479_a(ServerWorld.java:611) ~[?:?] {re:mixin,pl:accesstransformer:B,re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:performant.mixins.json:world.ServerWorldBlockUpdateMixin,pl:mixin:APP:abnormals_core.mixins.json:ServerWorldMixin,pl:mixin:APP:performant.mixins.json:world.ServerWorldMixin,pl:mixin:APP:performant.mixins.json:entity.MobServerWorldMixin,pl:mixin:A}     at net.minecraft.world.server.ServerWorld$$Lambda$16565/514282080.accept(Unknown Source) ~[?:?] {}     at net.minecraft.world.World.func_217390_a(World.java:554) ~[?:?] {re:computing_frames,pl:accesstransformer:B,xf:fml:observerlib:coremodmethod,re:mixin,pl:accesstransformer:B,xf:fml:observerlib:coremodmethod,re:classloading,pl:accesstransformer:B,xf:fml:observerlib:coremodmethod,pl:mixin:APP:sereneseasons.mixins.json:MixinWorld,pl:mixin:APP:flywheel.mixins.json:TileWorldHookMixin,pl:mixin:A}     at net.minecraft.world.server.ServerWorld.func_72835_b(ServerWorld.java:404) ~[?:?] {re:mixin,pl:accesstransformer:B,re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:performant.mixins.json:world.ServerWorldBlockUpdateMixin,pl:mixin:APP:abnormals_core.mixins.json:ServerWorldMixin,pl:mixin:APP:performant.mixins.json:world.ServerWorldMixin,pl:mixin:APP:performant.mixins.json:entity.MobServerWorldMixin,pl:mixin:A}     at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:851) ~[?:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:structure_gel.mixins.json:MinecraftServerMixin,pl:mixin:APP:byg.mixins.json:server.MixinMinecraftServer,pl:mixin:APP:marg.mixins.json:MinecraftServerMixin,pl:mixin:A}     at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:787) ~[?:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:structure_gel.mixins.json:MinecraftServerMixin,pl:mixin:APP:byg.mixins.json:server.MixinMinecraftServer,pl:mixin:APP:marg.mixins.json:MinecraftServerMixin,pl:mixin:A}     at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:118) ~[?:?] {re:mixin,xf:OptiFine:default,re:classloading,xf:OptiFine:default,pl:mixin:APP:smoothboot.mixins.json:client.IntegratedServerMixin,pl:mixin:A}     at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:642) [?:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:structure_gel.mixins.json:MinecraftServerMixin,pl:mixin:APP:byg.mixins.json:server.MixinMinecraftServer,pl:mixin:APP:marg.mixins.json:MinecraftServerMixin,pl:mixin:A}     at net.minecraft.server.MinecraftServer.func_240783_a_(MinecraftServer.java:232) [?:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:structure_gel.mixins.json:MinecraftServerMixin,pl:mixin:APP:byg.mixins.json:server.MixinMinecraftServer,pl:mixin:APP:marg.mixins.json:MinecraftServerMixin,pl:mixin:A}     at net.minecraft.server.MinecraftServer$$Lambda$15673/85323444.run(Unknown Source) [?:?] {}     at java.lang.Thread.run(Thread.java:745) [?:1.8.0_51] {} Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of sun/misc/Launcher$AppClassLoader) previously initiated loading for a different type with name "org/apache/logging/log4j/util/MessageSupplier"     at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_51] {}     at java.lang.ClassLoader.defineClass(ClassLoader.java:760) ~[?:1.8.0_51] {}     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[?:1.8.0_51] {}     at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) ~[?:1.8.0_51] {}     at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[?:1.8.0_51] {}     at java.net.URLClassLoader$1.run(URLClassLoader.java:368) ~[?:1.8.0_51] {}     at java.net.URLClassLoader$1.run(URLClassLoader.java:362) ~[?:1.8.0_51] {}     at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_51] {}     at java.net.URLClassLoader.findClass(URLClassLoader.java:361) ~[?:1.8.0_51] {}     at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_51] {}     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[?:1.8.0_51] {}     at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_51] {}     ... 25 more for full report https://pastebin.com/Did3vHvR    
    • you need to create a new ForgeSpawnEggItem and not a SpawnEggItem!
    • this is at the moment not implemented, since vanilla changed the Biome generation, and the old Forge patch doesn't work anymore you need to wait till it's will be added back
    • Please can you HELP instead of posting learn java learn java, PLEASE
    • Please learn basic Java. Do not use SpawnEggItem.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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