DjCtavia Posted April 2, 2017 Share Posted April 2, 2017 (edited) Hi guys, I searched for a method to sleep or wait in program for millis or second, I find "Thread.Sleep()" but, this method is not the good one, the game could crash. Then I tried to find an issue with "Tick" but I didn't found too... Then if someone could help me for find a method to sleep my program for a while I appreciate. Thank you ! Edited April 3, 2017 by DjCtavia [Solved] - Thank to everyone ;) Quote Link to comment Share on other sites More sharing options...
DjCtavia Posted April 2, 2017 Author Share Posted April 2, 2017 Hum, like re-use a block with right click. Cause in chat the block tell 2 times a message and it should tell just 1 time. I already do a "if (!worldIn.isRemote())" Here the code: if (!worldIn.isRemote) { if (buttonsFind) { if (!elevatorFind) { playerIn.addChatComponentMessage(new TextComponentString("No Elevator Block below your feet.")); } } else { if (!elevatorFind) { playerIn.addChatComponentMessage(new TextComponentString("No Buttons Elevator Block detected down, or Elevator Block below your feet.")); } else { playerIn.addChatComponentMessage(new TextComponentString("No Buttons Elevator Block detected down.")); } } } I think you don't need anything else, if needed I give the entire code Quote Link to comment Share on other sites More sharing options...
DjCtavia Posted April 2, 2017 Author Share Posted April 2, 2017 I hope it's clean for reading. @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { boolean buttonsFind = false; boolean elevatorFind = false; int elevatorBlockPos = 0; BlockPos finale; if (!worldIn.isRemote) { // Pour descendre en étant accroupi if (playerIn.isSneaking()) { for (int i = 2; i != 256; i++) { finale = new BlockPos(pos.getX(), pos.getY() - i, pos.getZ()); if (worldIn.getBlockState(finale).getBlock() == ModBlocks.elevatorButtonBlock) { buttonsFind = true; break; } } for (int y = 2; y != 256; y++) { finale = new BlockPos(MathHelper.floor_double(playerIn.getPosition().getX()), MathHelper.floor_double(playerIn.getPosition().getY()) - y, MathHelper.floor_double(playerIn.getPosition().getZ())); if (worldIn.getBlockState(finale).getBlock() == ModBlocks.elevatorBlock) { elevatorFind = true; elevatorBlockPos = MathHelper.floor_double(playerIn.getPosition().getY()) - y + 1; break; } } if (buttonsFind && elevatorFind) { playerIn.setPositionAndUpdate(playerIn.posX, (double) elevatorBlockPos, playerIn.posZ); return true; } if (buttonsFind) { if (!elevatorFind) { playerIn.addChatComponentMessage(new TextComponentString("No Elevator Block below your feet.")); } } else { if (!elevatorFind) { playerIn.addChatComponentMessage(new TextComponentString("No Buttons Elevator Block detected down, or Elevator Block below your feet.")); } else { playerIn.addChatComponentMessage(new TextComponentString("No Buttons Elevator Block detected down.")); } } } else { for (int i = 2; i != 256; i++) { finale = new BlockPos(pos.getX(), pos.getY() + i, pos.getZ()); if (worldIn.getBlockState(finale).getBlock() == ModBlocks.elevatorButtonBlock) { buttonsFind = true; break; } } for (int y = 2; y != 256; y++) { finale = new BlockPos(MathHelper.floor_double(playerIn.getPosition().getX()), playerIn.getPosition().getY() + y, MathHelper.floor_double(playerIn.getPosition().getZ())); if (worldIn.getBlockState(finale).getBlock() == ModBlocks.elevatorBlock) { elevatorFind = true; elevatorBlockPos = MathHelper.floor_double(playerIn.getPosition().getY()) + y + 1; break; } } if (buttonsFind && elevatorFind) { playerIn.setPositionAndUpdate(playerIn.posX, (double) elevatorBlockPos, playerIn.posZ); return true; } if (buttonsFind) { if (!elevatorFind) { playerIn.addChatComponentMessage(new TextComponentString("No elevator Block above your feet.")); } } else { if (!elevatorFind) { playerIn.addChatComponentMessage(new TextComponentString("No elevator buttons detect above, and no elevator block above your feet too.")); } else { playerIn.addChatComponentMessage(new TextComponentString("No elevator buttons detect above.")); } } } } return false; } Quote Link to comment Share on other sites More sharing options...
Matryoshika Posted April 2, 2017 Share Posted April 2, 2017 I believe the method is called once per side, per hand. Server, right-hand.... Client, left-hand. Add a check with the EnumHand parameter you get. Quote Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials. Link to comment Share on other sites More sharing options...
DjCtavia Posted April 2, 2017 Author Share Posted April 2, 2017 I don't see anything too do with EnumHand for my problem, I check the different purpose proposed but... I don't get it. Quote Link to comment Share on other sites More sharing options...
DjCtavia Posted April 3, 2017 Author Share Posted April 3, 2017 12 minutes ago, diesieben07 said: Not sure what's not to get. You will get 4 calls for every right-click: client-mainhand client-offhand server-mainhand server-offhand I don't get this, how call only "client", what way I need to use for it ? And I don't understand the notion of "mainhand" and "offhand", it is like "player start to touch block " ? Quote Link to comment Share on other sites More sharing options...
TheMasterGabriel Posted April 3, 2017 Share Posted April 3, 2017 (edited) You are playing on a recent version right? Duel wielding, no? As for client/server, this. Edited April 3, 2017 by TheMasterGabriel Quote Link to comment Share on other sites More sharing options...
DjCtavia Posted April 3, 2017 Author Share Posted April 3, 2017 (edited) I get this one, for side "client" and "server", but if I really understand (cause I could be wrong -> fact: I'm French). The problem only coming cause the player Right click on block, but there is 2 state of the right click, when he does the action, and when he stop, am I right ? EDIT : finaly I get the problem thank you guys, I get it. I change the primary condition like: if (!worldIn.isRemote && hand == enumHand.MAIN_HAND) { // Do stuff } Edited April 3, 2017 by DjCtavia EDIT - SOLVED Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.