Jump to content

Recommended Posts

Posted

I have a question, it seems like you cant give a player any motion in this context, it works perfectly with a pig or something like that, but a player doen't want to fly away, thats weird

 

@Override
public void onLeftClick(World world, ItemStack stack, EntityLivingBase player) {
	NBTTagCompound nbt = stack.getTagCompound();
	if(!world.isRemote){
		Entity entity = null;
		if(nbt.getString("EntityID") != ""){
			WorldServer server = (WorldServer) world;
			entity = server.getEntityFromUuid(UUID.fromString(nbt.getString("EntityID")));
		}
		if(nbt.getBoolean("SomethingTaken")){
			if(entity != null){
				if(entity instanceof EntityNotFallingBlock){
					EntityBlock entityBlock = new EntityBlock(world, player, ((EntityNotFallingBlock) entity).getBlock());
					entityBlock.tileEntityData = ((EntityNotFallingBlock) entity).tileEntityData;
					entityBlock.posX = entity.posX;
					entityBlock.posY = entity.posY;
					entityBlock.posZ = entity.posZ;
					world.spawnEntityInWorld(entityBlock);
					stack.setTagCompound(new NBTTagCompound());
					entity.setDead();
				}else{
					stack.setTagCompound(new NBTTagCompound());
					float f = 2;
					if(entity instanceof EntityPlayer){
						double motionX = (double)(-MathHelper.sin(player.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float)Math.PI) * f);
						double motionZ = (double)(MathHelper.cos(player.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float)Math.PI) * f);
						double motionY = (double)(-MathHelper.sin((player.rotationPitch / 180.0F * (float)Math.PI) * f));
						MoreMinecraft.network.sendTo(new MessageToClient(1, motionX, motionY, motionZ), (EntityPlayerMP) player);
					}else{
						entity.motionX = (double)(-MathHelper.sin(player.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float)Math.PI) * f);
						entity.motionZ = (double)(MathHelper.cos(player.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float)Math.PI) * f);
						entity.motionY = (double)(-MathHelper.sin((player.rotationPitch / 180.0F * (float)Math.PI) * f));
					}
				}
			}
		}
	}
}

 

And yes the method gets called

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

Posted

Well I did, but it doesn't work

The player just dropps to ground, as I remember correctly, the motion handling is done by client?

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

Posted

Well I didn't find the solution so far, but what I also found out is, that you can't giva a player a potion effect only on server side, so you can only make the player move if the client agrees with that, thats why there can be a NoKnockBack hack, because the client doen't react on the motion change, but that doen't help me, my idea was, to give the player an Item, which makes him move, but that won't work if he has full inventory, so I don't have any idea what to do

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

Posted

Well, I think thats bad code of Mojang, because in a game like CSGO, everything has to be handled by server, otherways player would start hacking, but well, its not the time to dicuss why minecraft is coded bad. Anyone has an idea how to make the player knockback?

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

Posted

Minecraft, and CS:GO in that matter, get input on the client. If you send that to the server, move the player in there, and then notify the player, you get some stuttering on the client. To solve this, they let the client make predictions about the player movement, and then every once in a while the server notifys the client and changes his position the the correct one if the client is wrong. This way, player movement is so smooth, even when there is server lag. So, always do movement on both the client and server.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

Here a code from old versions of my mod.. see if this works for you. Used on leftClickEntity of an item...

 

 

    
    public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) 
    {
    	if(entity instanceof EntityLivingBase)
    		((EntityLivingBase) entity).knockBack(player, 30, player.posX - entity.posX, player.posZ - entity.posZ);
    	
    	return false;
    }

// BSc CIS, hardcore gamer and a big fan of Minecraft.

 

TmzOS ::..

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

    • @TileEntity it seemed to work, but do you know of a way i could get the two mods to play nicely with each other? Im just trying to add supplementary to a modpack (and most of the mods dont play nicely with neoforge) so i cant exactly remake the whole pack.
    • I did that and it says Error: Unable to access jarfile server.jar im assuming this is why you said make to sure they match? so I checked and following that same path then viewing the server folder, there is no .far file only a .dll file checking the modded server folder obviously has a server-1.20.1.jar file though completely different pathing so I don't think this is what you mean but let me know if im missing something. ALSO, was probably not what was needed but I reinstalled Java 17 in case it didnt fully download for some reason? still no such file.
    • Yes - Update 6 makes larger changes which is breaking these addons Most addons already have the update - some are still in the update process and will be released in the next days
    • So, as I understand it, at the moment it's not possible to update the modpack because too few addons are compatible with version 6 of Create?
    • Check the PC for the Java 17 installation The Oracle Java default path is C:\Program Files\Java\jdk-17\bin\javaw.exe   Open the bat file and replace the world java with the path and put it into quotation marks "C:\Program Files\Java\jdk-17\bin\javaw.exe" -Xmx4G -jar server.jar pause Make sure the java path is correct - the server jar file name also have to match
  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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