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 can spawn a cow, but it seems only on the client side.  The cow disappears after a moment, which is my clue that it is only happening on client side.

 

I figured the best approach was to send a message to the server, and then spawn the cow within that context.  I was able to send the message successfully, and verified that the "side" is "SERVER", but when I attempt to spawn the cow, it again appears to spawn on the client instead.

 

Apologies in advance.  Long time programmer, but this minecraft modding has me back to the "hello world" stage apparently.

 

Here's the code (in my message handler class) that receives the message from client side:

 

	@Override
	public IMessage onMessage(MoshMessage message, MessageContext ctx) {

		// this works as expected, indicating (I think) that I have received a message from client-side.
		System.out.println("I got a message [" + message.msg + "] from " + ctx.getServerHandler().playerEntity.getDisplayName());

		// this says "SERVER" as expected
		System.out.println("side: " + ctx.side.toString());

		// this works as expected, time is set to 0
		ctx.getServerHandler().playerEntity.worldObj.setWorldTime(0);

		// This DOESN'T work as expected.  The cow is spawned client-side and disappears soon after.
		// I want it to spawn on server-side.
		Entity e = new EntityCow(ctx.getServerHandler().playerEntity.worldObj);
		e.posX = ctx.getServerHandler().playerEntity.posX;
		e.posY = ctx.getServerHandler().playerEntity.posY;
		e.posZ = ctx.getServerHandler().playerEntity.posZ;			
		ctx.getServerHandler().playerEntity.worldObj.spawnEntityInWorld(e);

		return null;
	}

 

I'm probably overlooking a simple concept here so I would appreciate any guidance.

 

Thanks,

John

I've run into a problem similar to this before, and it's definitely not your fault. :P

 

You need to set the entity's angles too.

e.setLocationAndAngles(player.posX, player.posY, player.posZ, 0, 0);

Kain

  • Author

Did the trick.  Thank you much!  Odd that the pitch and yaw aren't set to 0 by default - oh well.

 

Follow up, if I can trouble you a bit more: 

 

My end goal is to be able to spawn a player model (as an NPC) and assign arbitrary AI to it.  EntityPlayerMP seems too heavy for this purpose, because it contains a lot of logic for an actual "player", and I just want the NPC version of it. 

 

Is this something I need to put together manually (model/texture -> class extended from EntityLivingBase)?  If so, no worries, I'll figure it out.

 

I was looking at extending from EntityVillager perhaps?  But I want to use the player model, so maybe a custom binding - not sure still exploring.

 

Thanks again,

John

 

You can use ModelBiped for the model, as that's the standard player model.

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/

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.