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'm trying to create a new crafting table but i always get the same error while trying to open the container:

[m[33m[20:11:54] [Render thread/WARN] [minecraft/ClientPlayNetHandler]: Unknown custom packet identifier: professionsmod:main

My Crafting Table Block Code:

public class SmithCraftingTableBlock extends Block{

	public SmithCraftingTableBlock(Properties properties) {
		super(properties);
	}
	
	@Override
	public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
		ActionResultType type[] = { ActionResultType.PASS };
		if (worldIn.isRemote) {
			player.getCapability(CapabilityProfession.PROFESSION, null).ifPresent(iProfession -> {
				if(iProfession.getProfession() == profession.SMITH) {
					type[0] = ActionResultType.SUCCESS;
				}
            });
			return type[0];
		} else {
			player.getCapability(CapabilityProfession.PROFESSION, null).ifPresent(iProfession -> {
				if(iProfession.getProfession() == profession.SMITH) {
    				type[0] = ActionResultType.SUCCESS;
                	NetworkHooks.openGui((ServerPlayerEntity) player, new SmithContainerProvider(pos));
                }
            });
			return type[0];
		}
	}
}

 

ContainerProvider:

public class SmithContainerProvider implements INamedContainerProvider{
	//private BlockPos pos;
	private static final ITextComponent name = new TranslationTextComponent("container.smithcrafting");
	
	//public SmithContainerProvider(BlockPos pos) {
	//	this.pos = pos;
	//}
	
	@Override
	public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity p_createMenu_3_) {
		return new SmithCraftingContainer(windowId, playerInventory/*, new PacketBuffer(Unpooled.buffer(8, 8)).writeBlockPos(pos)*/);
	}

	@Override
	public ITextComponent getDisplayName() {
		return name;
	}

}

 

I believe the problem is caused by NetworkHooks.openGui because i'm probably not sending the PacketBuffer the right way. I tried it in many different ways and i suspect that the error was sent from handleCustomPayload in ClientPlayNetHandler, however, i can't figure out a possible solution. If i do this with TileEntity, then there is no such problem. Everything else works fine.

Your help would be greatly appreciated.

 

PS: This is my first time ever using a forum. Some parts of the code are really ugly in my opinion but i'm only a beginner. Atleast i understand most Java and OOP concepts.

 

Edited by Thorius
solved

  • Author

I was aware that my array solution is not the best, thanks for the tip.

 

The error only shows up if i call NetworkHooks.openGui.

Edited by Thorius

  • Author

Weridly after changing some things the problem is gone. Right now after joining a world i get this error message only once. Does SimpleImpl have something to do with it? If so, then i think i can manage it by myself by researching and looking up other codes.

 

If you still want to see the code:

https://github.com/Thoriuslight/Professionsmod

I could only copy the files manually, so only the code and resources were uploaded.

Also it's a big mess and needs a serious cleanup. Right now i'm experimenting with many features and it cannot be said that i mastered practices for code readability or defensive programming.

 

Anyway, thanks for the help.

 

Edited by Thorius

  • Author

After playing around with my code i noticed that i left out a ctx.enqueueWork() in my Packet, which caused the error after joining a world and probably also the error in the crafting table. Though i'm sure i tested them sepparately.

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.