Posted June 27, 201510 yr Greetings! When making a treecapitator axe, I ran across an issue which I can't seem to resolve on my own. When I call the method setBlock(x,y,z,Blocks.air) on the server world object, it doesn't update the client. It should, since that method calls setBlock(x,y,z,Blocks.air,0,3), in which the 3 stands for block update AND send change to client. I also tried calling the setBlock(x,y,z,Blocks.air,0,3) method directly, to no avail. I'm calling it on BlockOldLog and BLockLeaves objects, if that helps narrow the problem down. When I exit and re-enter the world, the blocks are gone, like it's supposed to be. I know one solution would be to just call markBlockForUpdate, but I'm not sure why the setblock method does not do what it tells me it should. Thanks in advance, Pancake
June 27, 201510 yr Show code and make sure you are calling setBlock only on server (!world.isRemote). Quote 1.7.10 is no longer supported by forge, you are on your own.
June 27, 201510 yr Author On 6/27/2015 at 2:35 AM, Ernio said: Show code and make sure you are calling setBlock only on server (!world.isRemote). Reveal hidden contents public boolean onItemUse(ItemStack stack,EntityPlayer player,World world,int x,int y, int z, int side, float hitX, float hitY, float hitZ) { if(world.isRemote){ return false; } if(player.isSneaking()){ return false; } System.out.println(world.getBlock(x,y,z)); if(!(world.getBlock(x,y,z) instanceof BlockOldLog)){ return false; } if(stack.stackTagCompound==null){ onCreated(stack,world,player); } if(!stack.stackTagCompound.getBoolean("hasLink")){ return false; } int[] linkLocation=stack.stackTagCompound.getIntArray("linkLocation"); TileEntityWirelessConnector link = (TileEntityWirelessConnector)Utils.getWorldByID(linkLocation[3]).getTileEntity(linkLocation[0],linkLocation[1],linkLocation[2]); TileEntityMainframeCore master = link.getMaster(); if(master==null){ return false; } ArrayList<int[]> list = new ArrayList(); ArrayList<int[]> templist = new ArrayList(); list.add(new int[]{x,y,z}); loop: while(list.size()!=0){ for(int i=0;i<list.size();i++){ if(!master.requestBlockBreak()){ break loop; } Block block = world.getBlock(list.get(i)[0],list.get(i)[1],list.get(i)[2]); ArrayList<ItemStack> drops = block.getDrops(world,list.get(i)[0],list.get(i)[1],list.get(i)[2],world.getBlockMetadata(list.get(i)[0],list.get(i)[1],list.get(i)[2]),0); for(ItemStack drop : drops){ master.addItem(drop,drop.stackSize); System.out.println("add drop: "+drop); } world.setBlock(list.get(i)[0],list.get(i)[1],list.get(i)[2],Blocks.air,0,3); for(int[] dir : Utils.DIRS){ Block block2 = world.getBlock(list.get(i)[0]+dir[0],list.get(i)[1]+dir[1],list.get(i)[2]+dir[2]); if(block instanceof BlockOldLog){ if(block2 instanceof BlockOldLog){ templist.add(new int[]{list.get(i)[0]+dir[0],list.get(i)[1]+dir[1],list.get(i)[2]+dir[2]}); } if(block2 instanceof BlockLeaves){ templist.add(new int[]{list.get(i)[0]+dir[0],list.get(i)[1]+dir[1],list.get(i)[2]+dir[2],Utils.LEAFBREAKRANGE}); } } if(block instanceof BlockLeaves){ if(block2 instanceof BlockLeaves && list.get(i)[3]>0){ templist.add(new int[]{list.get(i)[0]+dir[0],list.get(i)[1]+dir[1],list.get(i)[2]+dir[2],list.get(i)[3]-1}); } } } } list=(ArrayList<int[]>)templist.clone(); } return false; }
June 27, 201510 yr Author On 6/27/2015 at 2:58 AM, Failender said: Are you sure The code gets called? That ur statements are turning true The code gets called. That's why if I exit and re-enter the world the blocks are gone. I found a fix. I changed the last return to return true instead of false. All the blocks now dissapear correctly. Sweet.
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.