Jump to content

[Solved] Double text while right click on block


DjCtavia

Recommended Posts

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 by DjCtavia
[Solved] - Thank to everyone ;)
Link to comment
Share on other sites

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 ^_^

Link to comment
Share on other sites

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;
    }

 

Link to comment
Share on other sites

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.

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

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 " ?

Link to comment
Share on other sites

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 by DjCtavia
EDIT - SOLVED
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Perjudian online telah menjadi tren yang populer di kalangan penggemar permainan kasino. Salah satu permainan yang paling diminati adalah mesin slot online. Mesin slot online menawarkan kesenangan dan kegembiraan yang tak tertandingi, serta peluang untuk memenangkan hadiah besar. Salah satu situs slot online resmi yang menarik perhatian banyak pemain adalah Tuyul Slot. Kenapa Memilih Tuyul Slot? Tuyul Slot adalah situs slot online resmi yang menawarkan berbagai keuntungan bagi para pemainnya. Berikut adalah beberapa alasan mengapa Anda harus memilih Tuyul Slot: 1. Keamanan dan Kepercayaan Tuyul Slot adalah situs slot online resmi yang terpercaya dan memiliki reputasi yang baik di kalangan pemain judi online. Situs ini menggunakan teknologi keamanan terkini untuk melindungi data pribadi dan transaksi keuangan pemain. Anda dapat bermain dengan tenang dan yakin bahwa informasi Anda aman. 2. Pilihan Permainan yang Beragam Tuyul Slot menawarkan berbagai macam permainan slot online yang menarik. Anda dapat memilih dari ratusan judul permainan yang berbeda, dengan tema dan fitur yang beragam. Setiap permainan memiliki tampilan grafis yang menarik dan suara yang menghibur, memberikan pengalaman bermain yang tak terlupakan. 3. Kemudahan Menang Salah satu keunggulan utama dari Tuyul Slot adalah kemudahan untuk memenangkan hadiah. Situs ini menyediakan mesin slot online dengan tingkat pengembalian yang tinggi, sehingga peluang Anda untuk memenangkan hadiah besar lebih tinggi. Selain itu, Tuyul Slot juga menawarkan berbagai bonus dan promosi menarik yang dapat meningkatkan peluang Anda untuk menang. Cara Memulai Bermain di Tuyul Slot Untuk memulai bermain di Tuyul Slot, Anda perlu mengikuti langkah-langkah berikut: 1. Daftar Akun Kunjungi situs Tuyul Slot dan klik tombol "Daftar" untuk membuat akun baru. Isi formulir pendaftaran dengan informasi pribadi yang valid dan lengkap. Pastikan untuk memberikan data yang akurat dan jaga kerahasiaan informasi Anda. 2. Deposit Dana Setelah mendaftar, Anda perlu melakukan deposit dana ke akun Anda. Tuyul Slot menyediakan berbagai metode pembayaran yang aman dan terpercaya. Pilih metode yang paling nyaman untuk Anda dan ikuti petunjuk untuk melakukan deposit. 3. Pilih Permainan Setelah memiliki dana di akun Anda, Anda dapat memilih permainan slot online yang ingin Anda mainkan. Telusuri koleksi permainan yang tersedia dan pilih yang paling menarik bagi Anda. Anda juga dapat mencoba permainan secara gratis sebelum memasang taruhan uang sungguhan. 4. Mulai Bermain Saat Anda sudah memilih permainan, klik tombol "Main" untuk memulai permainan. Anda dapat mengatur jumlah taruhan dan jumlah garis pembayaran sesuai dengan preferensi Anda. Setelah itu, tekan tombol "Putar" dan lihat apakah Anda beruntung untuk memenangkan hadiah. Promosi dan Bonus Tuyul Slot menawarkan berbagai promosi dan bonus menarik kepada para pemainnya. Beberapa jenis promosi yang tersedia termasuk bonus deposit, cashback, dan turnamen slot. Pastikan untuk memanfaatkan promosi ini untuk meningkatkan peluang Anda memenangkan hadiah besar. Kesimpulan Tuyul Slot adalah situs slot online resmi yang menawarkan pengalaman bermain yang seru dan peluang menang yang tinggi. Dengan keamanan dan kepercayaan yang terjamin, berbagai pilihan permainan yang menarik, serta bonus dan promosi yang menguntungkan, Tuyul Slot menjadi pilihan yang tepat bagi para penggemar mesin slot online. Segera daftar akun dan mulai bermain di Tuyul Slot untuk kesempatan memenangkan hadiah besar!
    • I have been having a problem with minecraft forge. Any version. Everytime I try to launch it it always comes back with error code 1. I have tried launching from curseforge, from the minecraft launcher. I have also tried resetting my computer to see if that would help. It works on my other computer but that one is too old to run it properly. I have tried with and without mods aswell. Fabric works, optifine works, and MultiMC works aswell but i want to use forge. If you can help with this issue please DM on discord my # is Haole_Dawg#6676
    • Add the latest.log (logs-folder) with sites like https://paste.ee/ and paste the link to it here  
    • I have no idea how a UI mod crashed a whole world but HUGE props to you man, just saved me +2 months of progress!  
    • So i know for a fact this has been asked before but Render stuff troubles me a little and i didnt find any answer for recent version. I have a custom nausea effect. Currently i add both my nausea effect and the vanilla one for the effect. But the problem is that when I open the inventory, both are listed, while I'd only want mine to show up (both in the inv and on the GUI)   I've arrived to the GameRender (on joined/net/minecraft/client) and also found shaders on client-extra/assets/minecraft/shaders/post and client-extra/assets/minecraft/shaders/program but I'm lost. I understand that its like a regular screen, where I'd render stuff "over" the game depending on data on the server, but If someone could point to the right client and server classes that i can read to see how i can manage this or any tip would be apreciated
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.