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

Hello,

 

I notice that is inpossible rotate the yaw attribute of any entities setted always to 0:

 

I tried this code but doesn't works:

 

    			EntityCreeper Creeper = new EntityCreeper(player.worldObj);
	    		Creeper.setLocationAndAngles(event.x + 0.5D, event.y, event.z + 0.5D, fYaw, 0.0F);
		    	player.worldObj.spawnEntityInWorld(Creeper );
		    	Creeper.setPositionAndRotation(event.x + 0.5D, event.y, event.z + 0.5D, fYaw, 0.0F);
		    	Creeper.rotationYaw = fYaw;
		    	Creeper.setAngles(fYaw, 0.0F);

 

please help ...

We need to see more of your code. I see that you set the rotation yaw to fyaw but I don't know what fyaw is set to elsewhere in your code...

  • Author

We need to see more of your code. I see that you set the rotation yaw to fyaw but I don't know what fyaw is set to elsewhere in your code...

 

The Code into "onBreakBlock(BreakEvent event)" function (with "@SubscribeEvent" tag):

 

fYaw = 90.0F;
EntityCreeper Creeper = new EntityCreeper(player.worldObj);
Creeper.setLocationAndAngles(event.x + 0.5D, event.y, event.z + 0.5D, fYaw, 0.0F);
player.worldObj.spawnEntityInWorld(Creeper);
Creeper.setPositionAndRotation(event.x + 0.5D, event.y, event.z + 0.5D, fYaw, 0.0F);
Creeper.rotationYaw = fYaw;
Creeper.setAngles(fYaw, 0.0F);
//Creeper.setRotationYawHead(fYaw); <=== Works but rotate head only 

There should be a variable in your entity called rotationYaw try setting that to the value of fYaw and it should work.

  • Author

There should be a variable in your entity called rotationYaw try setting that to the value of fYaw and it should work.

 

maybe you haven't noticed, but it already does ...

 

Creeper.rotationYaw = fYaw;

Spawn the entity after you change all the variables. Make sure it only spawns serverside with if (!player.worldObj.isRemote).

The setAngles() method isn't doing what you think it is. Here is the text that the forge gives for what that method does.

 

Adds par1*0.15 to the entity's yaw, and *subtracts* par2*0.15 from the pitch. Clamps pitch from -90 to 90. Both arguments in degrees.

 

try removing that method and see if your entity rotates how you think it should. I tried a test using myself as the entity and when I changed the rotationYaw variable by itself it did work without any added code so try only changing that variable. Also try david's suggestion.

  • Author

Spawn the entity after you change all the variables. Make sure it only spawns serverside with if (!player.worldObj.isRemote).

 

Well, I tried this code in creative mode for watch better the creeper movements and not in "paceful" mode, obviously:

 

@SubscribeEvent
public void onBreakBlock(BreakEvent event) {
     		if (!player.worldObj.isRemote) {
                                fYaw = 90.0F; // or = 270.0F or = 180.0F
    			 EntityCreeper Logger = new EntityCreeper(player.worldObj);
	     		Logger.setLocationAndAngles(event.x + 0.5D, event.y, event.z + 0.5D, fYaw, 0.0F);
	     		Logger.rotationYaw = fYaw;            //   <===== Tried With and WithOut this line
		     	player.worldObj.spawnEntityInWorld(Logger);
                         }
           }

 

Results same problem: the Creeper spawn allways with the same Yaw direction (0.0F). :(

 

The setAngles() method isn't doing what you think it is. Here is the text that the forge gives for what that method does.

 

Adds par1*0.15 to the entity's yaw, and *subtracts* par2*0.15 from the pitch. Clamps pitch from -90 to 90. Both arguments in degrees.

 

try removing that method and see if your entity rotates how you think it should. I tried a test using myself as the entity and when I changed the rotationYaw variable by itself it did work without any added code so try only changing that variable. Also try david's suggestion.

 

Seriously, I tried all code combinations but nothing to do ... Can I see your testing code?

 

thank you so much ...

I just left the house for the day when I arrive back I can post the source code. If I forget pm me and I'll remember ;)

here is the code that worked for me...

@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack item){
	int yaw = ((int) player.rotationYaw)%360;
	if (yaw<0) yaw+=360;
	if (315<yaw || yaw<=45) world.setBlockMetadataWithNotify(x, y, z, 2, 3);
	if (45<yaw && yaw<=135) world.setBlockMetadataWithNotify(x, y, z, 5, 3);
	if (135<yaw && yaw<=225) world.setBlockMetadataWithNotify(x, y, z, 3, 3);
	if (225<yaw && yaw<=315) world.setBlockMetadataWithNotify(x, y, z, 4, 3);
	player.rotationYaw = 90;
}

the other code you see there just rotates the block depending on which direction you are facing which is unimportant in this case. What is important is the last line player.rotationYaw = 90; when run and I place the block my character is rotated to the position of 90 degrees so it is working for me.

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.