Skip to content

Commit

Permalink
Merge pull request #1220 from shartte/short-block-id-fix
Browse files Browse the repository at this point in the history
Fixes an issue with block changes (and 16-bit block ids), as well as som...
  • Loading branch information
immortius committed Sep 26, 2014
2 parents a90cc55 + 4a734a8 commit 22cbebc
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void setup() throws Exception {
solidBlock = new Block();
solidBlock.setDisplayName("Stone");
solidBlock.setUri(new BlockUri("engine:stone"));
solidBlock.setId((byte) 1);
solidBlock.setId((short) 1);
for (Side side : Side.values()) {
solidBlock.setFullSide(side, true);
}
Expand All @@ -66,7 +66,7 @@ public void setup() throws Exception {
fullLight = new Block();
fullLight.setDisplayName("Torch");
fullLight.setUri(new BlockUri("engine:torch"));
fullLight.setId((byte) 2);
fullLight.setId((short) 2);
fullLight.setLuminance(ChunkConstants.MAX_LIGHT);
blockManager.addBlockFamily(new SymmetricFamily(fullLight.getURI(), fullLight), true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void setup() throws Exception {
solid = new Block();
solid.setDisplayName("Solid");
solid.setUri(new BlockUri("engine:solid"));
solid.setId((byte) 5);
solid.setId((short) 5);
for (Side side : Side.values()) {
solid.setFullSide(side, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,28 +64,28 @@ public void setup() throws Exception {
fullLight = new Block();
fullLight.setDisplayName("Torch");
fullLight.setUri(new BlockUri("engine:torch"));
fullLight.setId((byte) 2);
fullLight.setId((short) 2);
fullLight.setLuminance(ChunkConstants.MAX_LIGHT);
blockManager.addBlockFamily(new SymmetricFamily(fullLight.getURI(), fullLight), true);

weakLight = new Block();
weakLight.setDisplayName("PartLight");
weakLight.setUri(new BlockUri("engine:weakLight"));
weakLight.setId((byte) 3);
weakLight.setId((short) 3);
weakLight.setLuminance((byte) 2);
blockManager.addBlockFamily(new SymmetricFamily(weakLight.getURI(), weakLight), true);

mediumLight = new Block();
mediumLight.setDisplayName("MediumLight");
mediumLight.setUri(new BlockUri("engine:mediumLight"));
mediumLight.setId((byte) 4);
mediumLight.setId((short) 4);
mediumLight.setLuminance((byte) 5);
blockManager.addBlockFamily(new SymmetricFamily(mediumLight.getURI(), mediumLight), true);

solid = new Block();
solid.setDisplayName("Solid");
solid.setUri(new BlockUri("engine:solid"));
solid.setId((byte) 5);
solid.setId((short) 5);
for (Side side : Side.values()) {
solid.setFullSide(side, true);
}
Expand All @@ -94,7 +94,7 @@ public void setup() throws Exception {
solidMediumLight = new Block();
solidMediumLight.setDisplayName("SolidMediumLight");
solidMediumLight.setUri(new BlockUri("engine:solidMediumLight"));
solidMediumLight.setId((byte) 6);
solidMediumLight.setId((short) 6);
solidMediumLight.setLuminance((byte) 5);
for (Side side : Side.values()) {
solidMediumLight.setFullSide(side, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void setup() throws Exception {
solid = new Block();
solid.setDisplayName("Solid");
solid.setUri(new BlockUri("engine:solid"));
solid.setId((byte) 5);
solid.setId((short) 5);
for (Side side : Side.values()) {
solid.setFullSide(side, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,12 @@ private void processRemoveEntities(NetData.NetMessage message) {

private void processBlockChanges(NetData.NetMessage message) {
for (NetData.BlockChangeMessage blockChange : message.getBlockChangeList()) {
logger.debug("Received block change to {}", blockManager.getBlock((byte) blockChange.getNewBlock()));
Block newBlock = blockManager.getBlock((short) blockChange.getNewBlock());
logger.debug("Received block change to {}", newBlock);
// TODO: Store changes to blocks that aren't ready to be modified (the surrounding chunks aren't available)
WorldProvider worldProvider = CoreRegistry.get(WorldProvider.class);
Vector3i pos = NetMessageUtil.convert(blockChange.getPos());
if (worldProvider.isBlockRelevant(pos)) {
Block newBlock = blockManager.getBlock((byte) blockChange.getNewBlock());
worldProvider.setBlock(pos, newBlock);
} else {
awaitingChunkReadyUpdates.put(TeraMath.calcChunkPos(pos), blockChange);
Expand Down Expand Up @@ -371,7 +371,7 @@ public void onChunkReady(Vector3i chunkPos) {
for (NetData.BlockChangeMessage message : updateMessages) {
WorldProvider worldProvider = CoreRegistry.get(WorldProvider.class);
Vector3i pos = NetMessageUtil.convert(message.getPos());
Block newBlock = blockManager.getBlock((byte) message.getNewBlock());
Block newBlock = blockManager.getBlock((short) message.getNewBlock());
worldProvider.setBlock(pos, newBlock);
}
}
Expand Down

0 comments on commit 22cbebc

Please sign in to comment.