Jump to content

[Resolved]get were the player is looking 1.7.10


Recommended Posts

I want to make an item that spawns lightning were the player is looking. problem is I don't have the right code, I think its out dated because I cant find these things in the vec3 class. here is my code

 

package com.OlympiansMod.Item;

import com.OlympiansMod.entity.EntityThunderBolt;
import com.OlympiansMod.entity.EntityUndead;

import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;


public class ZThunderBolt extends Item{
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player){
	if(!player.capabilities.isCreativeMode){
		--itemstack.stackSize;
	}
	//world.playSoundAtEntity(player, "random.fizz", 0.7f, 0.8f);

	//if(!world.isRemote){
	 Vec3 posVec = world.getWorldVec3Pool().getVec3FromPool(player.posX, player.posY + player.getEyeHeight(), player.posZ);
	 Vec3 lookVec = player.getLookVec();
	 MovingObjectPosition mop = world.rayTraceBlocks(posVec, lookVec);

	 int x = mop.blockX;
	 int y = mop.blockY;
	 int z = mop.blockZ;


		EntityLightningBolt Bolt = new EntityLightningBolt(world, 5, 5, 5);
		Bolt.setPosition(player.posX = x , player.posY + y , player.posZ + z);;
		world.spawnEntityInWorld(Bolt);
	//}

	return itemstack;

}


}





 

so yeah what do I do to fix it? btw syntax error on world.getWorldVec3Pool().getVec3FromPool

Im serious don't look at it!!

Link to comment
Share on other sites

can someone just tell me how to do it because so far nothing is working.

 

public class ZThunderBolt extends Item{
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player){
	if(!player.capabilities.isCreativeMode){
		--itemstack.stackSize;
	}
	//world.playSoundAtEntity(player, "random.fizz", 0.7f, 0.8f);

	//if(!world.isRemote){
	@Override
	 Vec3 posVec = new Vec3(player.posX, player.posY, player.posZ); 
	 Vec3 lookVec = player.getLookVec();
	 MovingObjectPosition mop = world.rayTraceBlocks(posVec, lookVec);

	 int x = mop.blockX;
	 int y = mop.blockY;
	 int z = mop.blockZ;


		EntityLightningBolt Bolt = new EntityLightningBolt(world, 5, 5, 5);
		Bolt.setPosition(player.posX = x , player.posY + y , player.posZ + z);;
		world.spawnEntityInWorld(Bolt);
	//}

	return itemstack;

}


}

Im serious don't look at it!!

Link to comment
Share on other sites

You clearly dont understand how to override a method. You need to put @Override above onItemRightClick.

Not to be mean, but you clearly don't understand what @Override actually does - it is simply an extra layer of error-checking within the IDE - it has no effect whatsoever on the compiled code.

 

@OP You probably want to pay more attention to what you are writing in your code:

Bolt.setPosition(player.posX = x , player.posY + y , player.posZ + z);;

Surely you meant plus (+) and not equals (=) ?

 

Also, why are you adding them at all? The raytrace MovingObjectPosition returns the block position that was hit, as in real world block coordinates. If you add the player's position to that, you will get very bizarre numbers.

 

Example:

Player is at 100,64,100 looking east (+x axis); MOP returns a block at 100,64,115 (directly east). Now you add those together, and spawn lightning at 200, 128, 215. Do you really expect to see it?

Link to comment
Share on other sites

You clearly dont understand how to override a method. You need to put @Override above onItemRightClick.

Not to be mean, but you clearly don't understand what @Override actually does - it is simply an extra layer of error-checking within the IDE - it has no effect whatsoever on the compiled code.

 

I'm aware of this, just pointing out that thats not where override goes.

Link to comment
Share on other sites

okay guys but that's not the problem.  I did have a typo but im getting current errors in my code specifically on new Vec3. I don't exactly know how that works. and I do know that the override goes above the method. but at this point im desperate and new to java so.. anyway what else can I do. and I have the raytraceblocks so that it finds the block that the player is looking at and defines the other int.

Im serious don't look at it!!

Link to comment
Share on other sites

Yeah, that's the one: Vec3.createVectorHelper. Arguments are the coordinates of the vector you want to create. I don't know what you mean by 'defines the other int' - what int?

 

Listen, I understand you are "desperate" to get this working, but perhaps a time-out to learn about vectors would be helpful? That and going through some basic Java tutorials, of course.

Link to comment
Share on other sites

ok gotcha coolAlias

 

this isn't working for me in my craft.

package com.OlympiansMod.Item;

import com.OlympiansMod.entity.EntityThunderBolt;
import com.OlympiansMod.entity.EntityUndead;

import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.monster.EntitySlime;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;


public class ZThunderBolt extends Item{
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player){
	if(!player.capabilities.isCreativeMode){
		--itemstack.stackSize;
	}
	//world.playSoundAtEntity(player, "random.fizz", 0.7f, 0.8f);

	if(!world.isRemote){
	 Vec3 posVec = Vec3.createVectorHelper(player.posX, player.posY + player.getEyeHeight(), player.posZ);
	 Vec3 lookVec = player.getLookVec();
	 MovingObjectPosition mop = world.rayTraceBlocks(posVec, lookVec);

	 int x = mop.blockX;
	 int y = mop.blockY;
	 int z = mop.blockZ;

	 System.out.println(x + ","+ y + ","+ z + " " + world.getBlock(x, y, z));

		EntitySlime Bolt = new EntitySlime(world);
		Bolt.setPosition(player.posX + x , player.posY + y , player.posZ + z);
		world.spawnEntityInWorld(Bolt);




}
	return itemstack;
}
}








 

is there anything you think I should change to make it work.

Im serious don't look at it!!

Link to comment
Share on other sites

To quote myself in answer to your question:

Also, why are you adding them at all? The raytrace MovingObjectPosition returns the block position that was hit, as in real world block coordinates. If you add the player's position to that, you will get very bizarre numbers.

 

Example:

Player is at 100,64,100 looking east (+x axis); MOP returns a block at 100,64,115 (directly east). Now you add those together, and spawn lightning at 200, 128, 215. Do you really expect to see it?

You didn't listen the first time, so perhaps the second?

Link to comment
Share on other sites

your quote is blank?

Not from my end, it isn't, but just in case, here it is, unquoted, again:

 

"Also, why are you adding them at all? The raytrace MovingObjectPosition returns the block position that was hit, as in real world block coordinates. If you add the player's position to that, you will get very bizarre numbers.

 

Example:

Player is at 100,64,100 looking east (+x axis); MOP returns a block at 100,64,115 (directly east). Now you add those together, and spawn lightning at 200, 128, 215. Do you really expect to see it?"

 

In summary, use the coordinates from the MovingObjectPosition, and DO NOT ADD anything, certainly not the player's position. It makes no sense at all to do so, as you can see in the example provided.

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

    • Slot Deposit 1000: Slot Online Gacor Modal Receh Minimal Deposit 1000 1rb 2rb 3rb 5rb Tanpa Potongan Terbaru ▶️▶️DAFTAR◀️◀️ ▶️▶️DAFTAR◀️◀️ Bagi para penggemar slot online yang mencari pengalaman bermain yang mengasyikkan tanpa harus mengeluarkan modal besar, Lambo77 adalah tempat yang tepat. Dengan menawarkan slot deposit 1000, Lambo77 memungkinkan pemain untuk memulai petualangan mereka dengan modal yang terjangkau. Dengan minimal deposit hanya 1000, pemain dapat menikmati berbagai permainan slot favorit mereka tanpa perlu khawatir tentang kekurangan modal. Terlebih lagi, Lambo77 menawarkan berbagai pilihan nominal deposit, mulai dari 1rb hingga 5rb, sehingga pemain memiliki fleksibilitas dalam mengelola bankroll mereka. Salah satu keunggulan utama bermain di Lambo77 adalah tidak adanya potongan dalam setiap transaksi deposit. Hal ini memastikan bahwa pemain dapat menggunakan seluruh jumlah deposit mereka untuk bermain, tanpa harus kehilangan sebagian karena biaya tambahan. Dengan fitur-fitur seperti ini, Lambo77 menjadikan pengalaman bermain slot online semakin menghibur dan menguntungkan bagi para pemain. Jadi, jangan ragu untuk mencoba keberuntungan Anda dan mulai petualangan slot Anda di Lambo77 hari ini!  
    • Selamat datang di GACOR268 salah satu situs slot gacor gampang menang hari ini di Indonesia yang sangat menjajikan. Slot gacor adalah adalah suatu istilah yang digunakan untuk menjelaskan sebuah permainan slot gampang menang di situs slot online. Situs slot gacor GACOR268 ini bisa menjadi populer walaupun terbilang baru karena RTP slot online yang disajikan begitu tinggi. Seiring dengan perkembangan zaman situs slot gacor terbaru ini juga sudah update dari segi teknologi yang menggunakan HTML5, inilah yang membuat grafis permainan terlihat begitu modern, audio lebih jernih, dan user interface yang smooth. Tidak dipungkiri grafis yang kami memiliki sudah menarik banyak sekali pendatang baru yang ingin merasakan terbawa dalam suasana tema permainan mesin slot. Kehadiran slot gacor menjadi angin segar bagi para pecinta judi online, memberikan alternatif permainan yang seru dan menguntungkan. Tak heran jika popularitas slot gacor terus meningkat, menarik minat para pemain baru untuk mencoba peruntungan mereka di situs slot gacor hari ini GACOR268.
    • Slot BCA Lambo77 = Link Daftar Slot BCA Modal Receh Auto Jackpot Deposit bank BCA Tanpa Potongan 2024 ▶️▶️DAFTAR◀️◀️ ▶️▶️DAFTAR◀️◀️ Lambo77 telah menjadi tujuan utama bagi para penggemar slot online yang mencari pengalaman bermain yang aman dan terpercaya menggunakan Bank BCA. Sebagai salah satu situs slot online terkemuka di tahun 2024, Lambo77 menawarkan akses mudah dan cepat untuk melakukan deposit dan menikmati berbagai permainan slot berkualitas. Dengan layanan deposit menggunakan Bank BCA, pemain dapat dengan nyaman melakukan transaksi ke akun mereka tanpa khawatir tentang keamanan atau keandalan. Lambo77 menjamin proses transaksi yang lancar dan aman, sehingga pemain dapat fokus sepenuhnya pada pengalaman bermain mereka. Selain itu, Lambo77 juga menyediakan beragam permainan slot yang menarik dengan fitur-fitur bonus yang menggiurkan. Dari slot klasik hingga yang paling modern, pemain dapat menemukan berbagai pilihan permainan yang sesuai dengan selera dan preferensi mereka. Dengan reputasi yang solid dan komitmen untuk memberikan pengalaman bermain yang terbaik, Lambo77 terus menjadi pilihan utama bagi para penggemar slot online di tahun 2024. Jadi, jangan ragu untuk bergabung dengan Lambo77 dan rasakan sensasi menang yang tak terlupakan di setiap putaran!  
    • Selamat datang di Gacor88 salah satu situs slot gacor gampang menang hari ini di Indonesia yang sangat menjajikan. Slot gacor adalah adalah suatu istilah yang digunakan untuk menjelaskan sebuah permainan slot gampang menang di situs slot online. Situs slot gacor Gacor88 ini bisa menjadi populer walaupun terbilang baru karena RTP slot online yang disajikan begitu tinggi. Seiring dengan perkembangan zaman situs slot gacor terbaru ini juga sudah update dari segi teknologi yang menggunakan HTML5, inilah yang membuat grafis permainan terlihat begitu modern, audio lebih jernih, dan user interface yang smooth. Tidak dipungkiri grafis yang kami memiliki sudah menarik banyak sekali pendatang baru yang ingin merasakan terbawa dalam suasana tema permainan mesin slot. Kehadiran slot gacor menjadi angin segar bagi para pecinta judi online, memberikan alternatif permainan yang seru dan menguntungkan. Tak heran jika popularitas slot gacor terus meningkat, menarik minat para pemain baru untuk mencoba peruntungan mereka di situs slot gacor hari ini Gacor88.
    • Selamat datang di Casino88 salah satu situs slot gacor gampang menang hari ini di Indonesia yang sangat menjajikan. Slot gacor adalah adalah suatu istilah yang digunakan untuk menjelaskan sebuah permainan slot gampang menang di situs slot online. Situs slot gacor Casino88 ini bisa menjadi populer walaupun terbilang baru karena RTP slot online yang disajikan begitu tinggi. Seiring dengan perkembangan zaman situs slot gacor terbaru ini juga sudah update dari segi teknologi yang menggunakan HTML5, inilah yang membuat grafis permainan terlihat begitu modern, audio lebih jernih, dan user interface yang smooth. Tidak dipungkiri grafis yang kami memiliki sudah menarik banyak sekali pendatang baru yang ingin merasakan terbawa dalam suasana tema permainan mesin slot. Kehadiran slot gacor menjadi angin segar bagi para pecinta judi online, memberikan alternatif permainan yang seru dan menguntungkan. Tak heran jika popularitas slot gacor terus meningkat, menarik minat para pemain baru untuk mencoba peruntungan mereka di situs slot gacor hari ini Casino88.
  • Topics

×
×
  • Create New...

Important Information

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