ChessMod

ChessMod

104k Downloads

Move move logic into ChessBoardEntity

ramou opened this issue ยท 0 comments

commented

Right now it's checked in GUI and done in the messages. The former is sub-par and the latter is all kinds of wrong:

char c = ((WoodChessboardTileEntity)tileEntity).getBoardState()[message.source.y][message.source.x];
char t = ((WoodChessboardTileEntity)tileEntity).getBoardState()[message.target.y][message.target.x];
((WoodChessboardTileEntity)tileEntity).getBoardState()[message.source.y][message.source.x]='.';
((WoodChessboardTileEntity)tileEntity).getBoardState()[message.target.y][message.target.x]=c;
if(c=='n' || c=='N') {
if(t=='.') {
world.playSound(null, pos, ModSounds.placePiece, SoundCategory.BLOCKS, 1F, 1F);
} else {
world.playSound(null, pos, ModSounds.placePieceTake, SoundCategory.BLOCKS, 1F, 1F);
}
} else {
if(t=='.') {
world.playSound(null, pos, ModSounds.slidePiece, SoundCategory.BLOCKS, 1F, 1F);
} else {
world.playSound(null, pos, ModSounds.slidePieceTake, SoundCategory.BLOCKS, 1F, 1F);
}
}
((WoodChessboardTileEntity)tileEntity).notifyClientOfMove();

This could more simply and sanely be done here, and polymorphsm would make the messages get to the correct implementation instead of what I'm about to do till I have the will to fix this ticket...