Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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

dont message the client about its motion. set it on the server, just like u have done for everythign else then player

  • Author

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

Hmm I might be wrong there.

If u are able to find out where the player gets knockbacked (from attacks etc) u will find ur solution for sure

  • Author

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

  • Author

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

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/

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.