Jump to content

Recommended Posts

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?

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

Posted

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

×   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



×
×
  • Create New...

Important Information

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