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 created my own goal, similar to the eat gras goal of the sheep. But my entity is a bit larger, so I used the entity.getLookVec(); to get the direction it is looking and multiplied by half of the width. But the entity always only picked one block, so I tracked everything and it seem that the look random goal only changes the looking of the Entity client side, but not server side. Am I right or am I doing something wrong. And is there a way to get it serverside? I tried the  entity.getLookController(), but this also didn't work. Anyone an Idea?

  • Author

I am not sure, but the entity model changed direction of look but the look vector didnt change... die he could only eat at one pos

 

  • Author
	public boolean shouldExecute() {
		if (eatTimer == 0 && entity.getIdleTime() > 100) {
			BlockPos pos = this.entity.getPosition();
			float width = this.entity.getWidth()/2;
			Vec3d look = this.entity.getLookVec();
			look = look.add(0, -look.y, 0);
			look = look.scale(width);
			pos = pos.add(round(look.x), 0, round(look.z));
			if (entity.world instanceof ServerWorld) {
				ServerWorld world = (ServerWorld) entity.world;
				for (int i = -1; i <= 1; i++) {
					if (blocks.contains(world.getBlockState(pos.add(0, i, 0)).getBlock())) {
						eatPos = pos.add(0, i, 0);
						eatWorld = world;
						entityPos = entity.getPosition();
						eatTimer = entityEatTime;
						entity.setIdleTime(0);
						return true;
					}
				}
			}
		}
		return false;
	}

This is the should executemethode of the goal. The look-vector always stays the same, so the entity couldn't find the block to eat.

  • Author

Maybe it was the hat and not the body or look vector from the LookRandomGoal. Now I used:

Vec3d look =Vec3d.fromPitchYaw((float) Math.PI/2, this.entity.getRotationYawHead());

and it worked. Thanks for help

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.