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'm trying to use IEntityAdditionalSpawnData for my projectile but I'm not really sure how to use the packet methods. 

I have a capped arrow entity with an IItemTier field that get's written to in writeSpawnData and that gets read from in readSpawnData, I can see from the console (debugging I did) that writeSpawnData is getting called, but readSpawnData isn't. 

Here's what my overrides look like

@Override
	public void writeSpawnData(PacketBuffer buffer) {
		Two.LOGGER.info("writing...");
		buffer.setCharSequence(0, (CharSequence) this.tier.toString(), Charset.defaultCharset());
		Two.LOGGER.info("wrote spawn data {}", this.tier.toString());
	}
	@Override
	public void readSpawnData(PacketBuffer additionalData) {
		Two.LOGGER.info("reading...");
		String t = additionalData.readCharSequence(0, Charset.defaultCharset()).toString();
		Two.LOGGER.info("read spawn data {}", t);
		try {
			this.tier = ItemTier.valueOf(t);
		} catch(Exception exception) {
			try {
				this.tier = ItemTierTwo.valueOf(t);
			} catch(Exception exception2) {
				Two.LOGGER.warn(exception2);
			}
		}
	}

 

I don't know how to use the PacketBuffer, what would I do if I wanted to write a String to one? 

I'm also getting these error messages

[m[1;31m[11:11:04] [Render thread/ERROR] [ne.mi.fm.ne.si.IndexedMessageCodec/SIMPLENET]: Received invalid discriminator byte 71 on channel fml:play
[m[33m[11:11:04] [Render thread/WARN] [minecraft/ClientPlayNetHandler]: Unknown custom packet identifier: fml:play

I used to have this done with the datamanager, but I read in the documentation that some things can be done without it. (like the color property of a tipped arrow) (it also reset the itemtier value whenever the world was reopened)
 

at first i tried it with data,

then i tried it without data and with nbts (with writeAdditional and readAdditional)

then I tried it without data or nbts and with packet buffers (writeSpawnData and readSpawnData)

 

here are some of the files I'm using

CappedArrowEntity.java CappedArrowRenderer.java CappedArrowItem.java latest.log

  • Author
8 hours ago, diesieben07 said:

Only use the write*** and read*** methods.

For strings use writeString(String) and readString(int).

thanks... I'm not sure how i missed those, for some reason I thought there were only char versions

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.