Quantum board creation
riri404 opened this issue ยท 4 comments
Now that the board is registered in 1.20, I've started the implementation of the quantum board. I am using events for the mechanism, instead of creating a recipe of two quantum boards and an enderpearl. So far, the event is set up, but I have to start the linking process. I brainstormed a little yesterday and will start probably later this week.
Some issues when extending the GoldenChessBoardEntity:
- The super() takes fewer arguments when using the GoldenChessBoardEntity than if we extend ChessBoardEntity
- There is still some mirroring issues in chessPlay (the getLinkedBoards() needs to fetch the boards directly)
- The chess pieces do not render
Attempted solutions:
- Removed the blockEntityType argument to fit the GoldenChessBoardEntity constructor
- Will try fetching from the linkedChessboards hashMap in order for getLinkedBoards() to actually mirror
- I have not looked more into the rendering issue
Next steps:
- Ask for help for the rendering issue and if removing the blockEntityType argument might cause further issues
- Fix getLinkedBoards()
For rendering, the trick is to not subclass the GoldenChessBoardEntity. We just subclass ChessBoardBlockEntity and do it the old way. We may want to introduce an interface on entities for type-management in the events, but that's a relatively benign thing to do. The blockEntityType argument is needed to have things tie together behind the scenes, I believe.
Creating the following TODO
- EnderPearlEventHandler: override the right-click event for the enderpearl. When a player right-clicks on one chessboard with an enderpearl, store the chessboard's position.
- Linking Two Chessboards: If a player right-clicks on another chessboard with the same enderpearl (before throwing it), link the two chessboards. I will figure this out next week.
- Synchronize Moves: When a player makes a move on one chessboard, reflect the same move on its linked chessboard.
This can be done by sending custom packets between the client and the server(I am a networking genius now). The packet would contain info about the move (initial position, final position). When the server receives this packet, it will then update the linked board.
I will change some of these mechanism as I go. I will probably need to handle situations such as one board getting destroyed
After using synchronized block + nonce + debounce logic( stolen from hardware debounce logic), the event no longer fire twice.
- The event handler needs to be cleaned up it looks too gross to read, but hey its working
- make the enderpearl disappear after it has been used to link, this makes sense from a survival pov