refactor Block to Blocks, sign support

This commit is contained in:
bixilon 2020-06-15 21:36:39 +02:00
parent 96fc0aa0d3
commit af9d75e764
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
13 changed files with 162 additions and 50 deletions

View File

@ -16,7 +16,7 @@ package de.bixilon.minosoft.game.datatypes.blocks;
import de.bixilon.minosoft.game.datatypes.Color; import de.bixilon.minosoft.game.datatypes.Color;
import de.bixilon.minosoft.game.datatypes.Identifier; import de.bixilon.minosoft.game.datatypes.Identifier;
public enum Block { public enum Blocks {
UNKNOWN(null, -1), // the buggy pink black block UNKNOWN(null, -1), // the buggy pink black block
AIR(new Identifier("air"), 0), AIR(new Identifier("air"), 0),
STONE(new Identifier("stone"), 1), STONE(new Identifier("stone"), 1),
@ -52,6 +52,26 @@ public enum Block {
RED_WOOL(new Identifier("wool", "red_wool"), 35, Color.RED.getColor()), RED_WOOL(new Identifier("wool", "red_wool"), 35, Color.RED.getColor()),
BLACK_WOOL(new Identifier("wool", "black_wool"), 35, Color.BLACK.getColor()), BLACK_WOOL(new Identifier("wool", "black_wool"), 35, Color.BLACK.getColor()),
TNT(new Identifier("tnt"), 46), TNT(new Identifier("tnt"), 46),
STANDING_SIGN_SOUTH(new Identifier("standing_sign"), 63, 0),
STANDING_SIGN_SOUTH_SOUTH_WEST(new Identifier("standing_sign"), 63, 1),
STANDING_SIGN_SOUTH_WEST(new Identifier("standing_sign"), 63, 2),
STANDING_SIGN_WEST_SOUTH_WEST(new Identifier("standing_sign"), 63, 3),
STANDING_SIGN_WEST(new Identifier("standing_sign"), 63, 4),
STANDING_SIGN_WEST_NORTH_WEST(new Identifier("standing_sign"), 63, 5),
STANDING_SIGN_NORTH_WEST(new Identifier("standing_sign"), 63, 6),
STANDING_SIGN_NORTH_NORTH_WEST(new Identifier("standing_sign"), 63, 7),
STANDING_SIGN_NORTH(new Identifier("standing_sign"), 63, 8),
STANDING_SIGN_NORTH_NORTH_EAST(new Identifier("standing_sign"), 63, 9),
STANDING_SIGN_NORTH_EAST(new Identifier("standing_sign"), 63, 10),
STANDING_SIGN_EAST_NORTH_EAST(new Identifier("standing_sign"), 63, 11),
STANDING_SIGN_EAST(new Identifier("standing_sign"), 63, 12),
STANDING_SIGN_EAST_SOUTH_EAST(new Identifier("standing_sign"), 63, 13),
STANDING_SIGN_SOUTH_EAST(new Identifier("standing_sign"), 63, 14),
STANDING_SIGN_SOUTH_SOUTH_EAST(new Identifier("standing_sign"), 63, 15),
WALL_SIGN_EAST(new Identifier("wall_sign"), 68, 0),
WALL_SIGN_NORTH(new Identifier("wall_sign"), 68, 1),
WALL_SIGN_SOUTH(new Identifier("wall_sign"), 68, 2),
WALL_SIGN_WEST(new Identifier("wall_sign"), 68, 3),
DROPPER_DOWN(new Identifier("dropper"), 158, 0), DROPPER_DOWN(new Identifier("dropper"), 158, 0),
DROPPER_EAST(new Identifier("dropper"), 158, 1), DROPPER_EAST(new Identifier("dropper"), 158, 1),
DROPPER_NORTH(new Identifier("dropper"), 158, 2), DROPPER_NORTH(new Identifier("dropper"), 158, 2),
@ -66,19 +86,19 @@ public enum Block {
final int legacyId; final int legacyId;
int legacyData; int legacyData;
Block(Identifier identifier, int legacyId, int legacyData) { Blocks(Identifier identifier, int legacyId, int legacyData) {
this.identifier = identifier; this.identifier = identifier;
this.legacyId = legacyId; this.legacyId = legacyId;
this.legacyData = legacyData; this.legacyData = legacyData;
} }
Block(Identifier identifier, int legacyId) { Blocks(Identifier identifier, int legacyId) {
this.identifier = identifier; this.identifier = identifier;
this.legacyId = legacyId; this.legacyId = legacyId;
} }
public static Block byIdentifier(Identifier identifier) { public static Blocks byIdentifier(Identifier identifier) {
for (Block b : values()) { for (Blocks b : values()) {
if (b.getIdentifier().equals(identifier)) { if (b.getIdentifier().equals(identifier)) {
return b; return b;
} }
@ -86,8 +106,8 @@ public enum Block {
return UNKNOWN; return UNKNOWN;
} }
public static Block byLegacy(int id, int data) { public static Blocks byLegacy(int id, int data) {
for (Block b : values()) { for (Blocks b : values()) {
if (b.getLegacyId() == id && b.getLegacyData() == data) { if (b.getLegacyId() == id && b.getLegacyData() == data) {
return b; return b;
} }
@ -95,7 +115,7 @@ public enum Block {
return UNKNOWN; return UNKNOWN;
} }
public static Block byLegacy(int id) { public static Blocks byLegacy(int id) {
return byLegacy(id, 0); return byLegacy(id, 0);
} }

View File

@ -13,7 +13,7 @@
package de.bixilon.minosoft.game.datatypes.entities.meta; package de.bixilon.minosoft.game.datatypes.entities.meta;
import de.bixilon.minosoft.game.datatypes.blocks.Block; import de.bixilon.minosoft.game.datatypes.blocks.Blocks;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer; import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
@ -24,12 +24,12 @@ public class EndermanMetaData extends MobMetaData {
} }
public Block getCarriedBlock() { public Blocks getCarriedBlock() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
return Block.byLegacy((short) sets.get(16).getData(), (byte) sets.get(17).getData()); return Blocks.byLegacy((short) sets.get(16).getData(), (byte) sets.get(17).getData());
} }
return Block.AIR; return Blocks.AIR;
} }
public boolean isScreaming() { public boolean isScreaming() {

View File

@ -13,7 +13,7 @@
package de.bixilon.minosoft.game.datatypes.entities.meta; package de.bixilon.minosoft.game.datatypes.entities.meta;
import de.bixilon.minosoft.game.datatypes.blocks.Block; import de.bixilon.minosoft.game.datatypes.blocks.Blocks;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer; import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
@ -47,12 +47,12 @@ public class MinecartMetaData extends EntityMetaData {
return 0; return 0;
} }
public Block getBlock() { public Blocks getBlock() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
return Block.byLegacy((int) sets.get(20).getData() & 0xFF, (int) sets.get(20).getData() & 0xFF00); return Blocks.byLegacy((int) sets.get(20).getData() & 0xFF, (int) sets.get(20).getData() & 0xFF00);
} }
return Block.AIR; return Blocks.AIR;
} }
} }

View File

@ -13,7 +13,7 @@
package de.bixilon.minosoft.game.datatypes.entities.objects; package de.bixilon.minosoft.game.datatypes.entities.objects;
import de.bixilon.minosoft.game.datatypes.blocks.Block; import de.bixilon.minosoft.game.datatypes.blocks.Blocks;
import de.bixilon.minosoft.game.datatypes.entities.EntityObject; import de.bixilon.minosoft.game.datatypes.entities.EntityObject;
import de.bixilon.minosoft.game.datatypes.entities.Location; import de.bixilon.minosoft.game.datatypes.entities.Location;
import de.bixilon.minosoft.game.datatypes.entities.ObjectInterface; import de.bixilon.minosoft.game.datatypes.entities.ObjectInterface;
@ -23,13 +23,13 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class FallingBlock extends EntityObject implements ObjectInterface { public class FallingBlock extends EntityObject implements ObjectInterface {
EntityMetaData metaData; EntityMetaData metaData;
Block block; Blocks block;
public FallingBlock(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) { public FallingBlock(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null); super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int // objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info // tnt does not have any additional info
block = Block.byLegacy(additionalInt & 0xFFF, additionalInt >> 12); block = Blocks.byLegacy(additionalInt & 0xFFF, additionalInt >> 12);
} }
@Override @Override
@ -62,7 +62,7 @@ public class FallingBlock extends EntityObject implements ObjectInterface {
return EntityMetaData.class; return EntityMetaData.class;
} }
public Block getBlock() { public Blocks getBlock() {
return block; return block;
} }
} }

View File

@ -13,7 +13,7 @@
package de.bixilon.minosoft.game.datatypes.world; package de.bixilon.minosoft.game.datatypes.world;
import de.bixilon.minosoft.game.datatypes.blocks.Block; import de.bixilon.minosoft.game.datatypes.blocks.Blocks;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -28,7 +28,7 @@ public class Chunk {
this.nibbles = chunks; this.nibbles = chunks;
} }
public Block getBlock(int x, int y, int z) { public Blocks getBlock(int x, int y, int z) {
if (x > 16 || y > 255 || z > 16 || x < 0 || y < 0 || z < 0) { if (x > 16 || y > 255 || z > 16 || x < 0 || y < 0 || z < 0) {
throw new IllegalArgumentException(String.format("Invalid chunk location %s %s %s", x, y, z)); throw new IllegalArgumentException(String.format("Invalid chunk location %s %s %s", x, y, z));
} }
@ -36,13 +36,13 @@ public class Chunk {
return nibbles.get(section).getBlock(x, y % 16, z); return nibbles.get(section).getBlock(x, y % 16, z);
} }
public void setBlock(int x, int y, int z, Block block) { public void setBlock(int x, int y, int z, Blocks block) {
byte section = (byte) (y / 16); byte section = (byte) (y / 16);
createSection(section); createSection(section);
nibbles.get(section).setBlock(x, y % 16, z, block); nibbles.get(section).setBlock(x, y % 16, z, block);
} }
public void setBlock(InChunkLocation location, Block block) { public void setBlock(InChunkLocation location, Blocks block) {
byte section = (byte) (location.getY() / 16); byte section = (byte) (location.getY() / 16);
createSection(section); createSection(section);
nibbles.get(section).setBlock(location.getChunkNibbleLocation(), block); nibbles.get(section).setBlock(location.getChunkNibbleLocation(), block);
@ -55,9 +55,20 @@ public class Chunk {
} }
} }
public void setBlocks(HashMap<InChunkLocation, Block> blocks) { public void setBlocks(HashMap<InChunkLocation, Blocks> blocks) {
for (Map.Entry<InChunkLocation, Block> set : blocks.entrySet()) { for (Map.Entry<InChunkLocation, Blocks> set : blocks.entrySet()) {
setBlock(set.getKey(), set.getValue()); setBlock(set.getKey(), set.getValue());
} }
} }
public void updateSign(BlockPosition position, String[] lines) {
ChunkNibble nibble = nibbles.get((byte) (position.getY() / 16));
nibble.updateSign(new ChunkNibbleLocation(position.getX() % 16, position.getY() % 16, position.getZ() % 16), lines);
}
public String[] getSignText(BlockPosition position) {
ChunkNibble nibble = nibbles.get((byte) (position.getY() / 16));
return nibble.getSignText(new ChunkNibbleLocation(position.getX() % 16, position.getY() / 16, position.getZ() % 16));
}
} }

View File

@ -13,7 +13,7 @@
package de.bixilon.minosoft.game.datatypes.world; package de.bixilon.minosoft.game.datatypes.world;
import de.bixilon.minosoft.game.datatypes.blocks.Block; import de.bixilon.minosoft.game.datatypes.blocks.Blocks;
import java.util.HashMap; import java.util.HashMap;
@ -21,30 +21,41 @@ import java.util.HashMap;
* Collection of 16x16x16 blocks * Collection of 16x16x16 blocks
*/ */
public class ChunkNibble { public class ChunkNibble {
private final HashMap<ChunkNibbleLocation, Block> blocks; private final HashMap<ChunkNibbleLocation, Blocks> blocks;
private final HashMap<ChunkNibbleLocation, String[]> signs;
public ChunkNibble(HashMap<ChunkNibbleLocation, Block> blocks) { public ChunkNibble(HashMap<ChunkNibbleLocation, Blocks> blocks) {
this.blocks = blocks; this.blocks = blocks;
this.signs = new HashMap<>();
} }
public ChunkNibble() { public ChunkNibble() {
// empty // empty
this.blocks = new HashMap<>(); this.blocks = new HashMap<>();
this.signs = new HashMap<>();
} }
public Block getBlock(ChunkNibbleLocation loc) { public Blocks getBlock(ChunkNibbleLocation loc) {
return blocks.get(loc); return blocks.get(loc);
} }
public Block getBlock(int x, int y, int z) { public Blocks getBlock(int x, int y, int z) {
return getBlock(new ChunkNibbleLocation(x, y, z)); return getBlock(new ChunkNibbleLocation(x, y, z));
} }
public void setBlock(int x, int y, int z, Block block) { public void setBlock(int x, int y, int z, Blocks block) {
blocks.put(new ChunkNibbleLocation(x, y, z), block); blocks.put(new ChunkNibbleLocation(x, y, z), block);
} }
public void setBlock(ChunkNibbleLocation location, Block block) { public void setBlock(ChunkNibbleLocation location, Blocks block) {
blocks.put(location, block); blocks.put(location, block);
} }
public void updateSign(ChunkNibbleLocation location, String[] lines) {
signs.put(location, lines);
}
public String[] getSignText(ChunkNibbleLocation location) {
return signs.get(location);
}
} }

View File

@ -14,7 +14,7 @@
package de.bixilon.minosoft.game.datatypes.world; package de.bixilon.minosoft.game.datatypes.world;
import de.bixilon.minosoft.game.datatypes.Dimension; import de.bixilon.minosoft.game.datatypes.Dimension;
import de.bixilon.minosoft.game.datatypes.blocks.Block; import de.bixilon.minosoft.game.datatypes.blocks.Blocks;
import de.bixilon.minosoft.game.datatypes.entities.Entity; import de.bixilon.minosoft.game.datatypes.entities.Entity;
import java.util.HashMap; import java.util.HashMap;
@ -49,15 +49,15 @@ public class World {
return chunks; return chunks;
} }
public Block getBlock(BlockPosition pos) { public Blocks getBlock(BlockPosition pos) {
ChunkLocation loc = pos.getChunkLocation(); ChunkLocation loc = pos.getChunkLocation();
if (getChunk(loc) != null) { if (getChunk(loc) != null) {
return getChunk(loc).getBlock(pos.getX() % 16, pos.getY(), pos.getZ() % 16); return getChunk(loc).getBlock(pos.getX() % 16, pos.getY(), pos.getZ() % 16);
} }
return Block.AIR; return Blocks.AIR;
} }
public void setBlock(BlockPosition pos, Block block) { public void setBlock(BlockPosition pos, Blocks block) {
if (getChunk(pos.getChunkLocation()) != null) { if (getChunk(pos.getChunkLocation()) != null) {
getChunk(pos.getChunkLocation()).setBlock(pos.getX() % 16, pos.getY(), pos.getZ() % 16, block); getChunk(pos.getChunkLocation()).setBlock(pos.getX() % 16, pos.getY(), pos.getZ() % 16, block);
} }
@ -117,4 +117,13 @@ public class World {
public void setDimension(Dimension dimension) { public void setDimension(Dimension dimension) {
this.dimension = dimension; this.dimension = dimension;
} }
public void updateSign(BlockPosition position, String[] lines) {
//ToDo check if block is really a sign
getChunk(position.getChunkLocation()).updateSign(position, lines);
}
public String[] getSignText(BlockPosition position) {
return getChunk(position.getChunkLocation()).getSignText(position);
}
} }

View File

@ -13,8 +13,8 @@
package de.bixilon.minosoft.protocol.packets.clientbound.play; package de.bixilon.minosoft.protocol.packets.clientbound.play;
import de.bixilon.minosoft.game.datatypes.blocks.Blocks;
import de.bixilon.minosoft.game.datatypes.world.BlockPosition; import de.bixilon.minosoft.game.datatypes.world.BlockPosition;
import de.bixilon.minosoft.game.datatypes.blocks.Block;
import de.bixilon.minosoft.logging.Log; import de.bixilon.minosoft.logging.Log;
import de.bixilon.minosoft.protocol.packets.ClientboundPacket; import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
import de.bixilon.minosoft.protocol.protocol.InPacketBuffer; import de.bixilon.minosoft.protocol.protocol.InPacketBuffer;
@ -24,7 +24,7 @@ import de.bixilon.minosoft.util.BitByte;
public class PacketBlockChange implements ClientboundPacket { public class PacketBlockChange implements ClientboundPacket {
BlockPosition position; BlockPosition position;
Block block; Blocks block;
@Override @Override
@ -32,7 +32,7 @@ public class PacketBlockChange implements ClientboundPacket {
switch (v) { switch (v) {
case VERSION_1_7_10: case VERSION_1_7_10:
position = new BlockPosition(buffer.readInteger(), BitByte.byteToUShort(buffer.readByte()), buffer.readInteger()); position = new BlockPosition(buffer.readInteger(), BitByte.byteToUShort(buffer.readByte()), buffer.readInteger());
block = Block.byLegacy(buffer.readVarInt(), buffer.readByte()); block = Blocks.byLegacy(buffer.readVarInt(), buffer.readByte());
break; break;
} }
} }
@ -51,7 +51,7 @@ public class PacketBlockChange implements ClientboundPacket {
return position; return position;
} }
public Block getBlock() { public Blocks getBlock() {
return block; return block;
} }
} }

View File

@ -13,13 +13,12 @@
package de.bixilon.minosoft.protocol.packets.clientbound.play; package de.bixilon.minosoft.protocol.packets.clientbound.play;
import de.bixilon.minosoft.game.datatypes.blocks.Block; import de.bixilon.minosoft.game.datatypes.blocks.Blocks;
import de.bixilon.minosoft.game.datatypes.world.ChunkLocation; import de.bixilon.minosoft.game.datatypes.world.ChunkLocation;
import de.bixilon.minosoft.game.datatypes.world.InChunkLocation; import de.bixilon.minosoft.game.datatypes.world.InChunkLocation;
import de.bixilon.minosoft.logging.Log; import de.bixilon.minosoft.logging.Log;
import de.bixilon.minosoft.protocol.packets.ClientboundPacket; import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
import de.bixilon.minosoft.protocol.protocol.InPacketBuffer; import de.bixilon.minosoft.protocol.protocol.InPacketBuffer;
import de.bixilon.minosoft.protocol.protocol.PacketDataException;
import de.bixilon.minosoft.protocol.protocol.PacketHandler; import de.bixilon.minosoft.protocol.protocol.PacketHandler;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
@ -27,7 +26,7 @@ import java.util.HashMap;
public class PacketMultiBlockChange implements ClientboundPacket { public class PacketMultiBlockChange implements ClientboundPacket {
ChunkLocation location; ChunkLocation location;
final HashMap<InChunkLocation, Block> blocks = new HashMap<>(); final HashMap<InChunkLocation, Blocks> blocks = new HashMap<>();
@Override @Override
@ -47,7 +46,7 @@ public class PacketMultiBlockChange implements ClientboundPacket {
byte y = (byte) ((raw & 0xFF_00_00) >> 16); byte y = (byte) ((raw & 0xFF_00_00) >> 16);
byte z = (byte) ((raw & 0x0F_00_00_00) >> 24); byte z = (byte) ((raw & 0x0F_00_00_00) >> 24);
byte x = (byte) (Math.abs((raw & 0xF0_00_00_00) >> 28)); byte x = (byte) (Math.abs((raw & 0xF0_00_00_00) >> 28));
blocks.put(new InChunkLocation(x, y, z), Block.byLegacy(blockId, meta)); blocks.put(new InChunkLocation(x, y, z), Blocks.byLegacy(blockId, meta));
} }
break; break;
@ -68,7 +67,7 @@ public class PacketMultiBlockChange implements ClientboundPacket {
return location; return location;
} }
public HashMap<InChunkLocation, Block> getBlocks() { public HashMap<InChunkLocation, Blocks> getBlocks() {
return blocks; return blocks;
} }
} }

View File

@ -0,0 +1,57 @@
/*
* Codename Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.protocol.packets.clientbound.play;
import de.bixilon.minosoft.game.datatypes.world.BlockPosition;
import de.bixilon.minosoft.logging.Log;
import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
import de.bixilon.minosoft.protocol.protocol.InPacketBuffer;
import de.bixilon.minosoft.protocol.protocol.PacketHandler;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class PacketUpdateSign implements ClientboundPacket {
BlockPosition position;
String[] lines = new String[4];
@Override
public void read(InPacketBuffer buffer, ProtocolVersion v) {
switch (v) {
case VERSION_1_7_10:
position = new BlockPosition(buffer.readInteger(), buffer.readShort(), buffer.readInteger());
for (byte i = 0; i < 4; i++) {
lines[i] = buffer.readString();
}
break;
}
}
@Override
public void log() {
Log.game(String.format("Sign data received at: %s", position.toString()));
}
@Override
public void handle(PacketHandler h) {
h.handle(this);
}
public BlockPosition getPosition() {
return position;
}
public String[] getLines() {
return lines;
}
}

View File

@ -251,4 +251,8 @@ public class PacketHandler {
public void handle(PacketRemoveEntityEffect pkg) { public void handle(PacketRemoveEntityEffect pkg) {
connection.getPlayer().getWorld().getEntity(pkg.getEntityId()).removeEffect(pkg.getEffect()); connection.getPlayer().getWorld().getEntity(pkg.getEntityId()).removeEffect(pkg.getEffect());
} }
public void handle(PacketUpdateSign pkg) {
connection.getPlayer().getWorld().updateSign(pkg.getPosition(), pkg.getLines());
}
} }

View File

@ -76,6 +76,7 @@ public interface Protocol {
packetClassMapping.put(Packets.Clientbound.PLAY_CHUNK_DATA, PacketChunkData.class); packetClassMapping.put(Packets.Clientbound.PLAY_CHUNK_DATA, PacketChunkData.class);
packetClassMapping.put(Packets.Clientbound.PLAY_ENTITY_EFFECT, PacketEntityEffect.class); packetClassMapping.put(Packets.Clientbound.PLAY_ENTITY_EFFECT, PacketEntityEffect.class);
packetClassMapping.put(Packets.Clientbound.PLAY_REMOVE_ENTITY_EFFECT, PacketRemoveEntityEffect.class); packetClassMapping.put(Packets.Clientbound.PLAY_REMOVE_ENTITY_EFFECT, PacketRemoveEntityEffect.class);
packetClassMapping.put(Packets.Clientbound.PLAY_UPDATE_SIGN, PacketUpdateSign.class);
} }
int getProtocolVersion(); int getProtocolVersion();

View File

@ -13,7 +13,7 @@
package de.bixilon.minosoft.util; package de.bixilon.minosoft.util;
import de.bixilon.minosoft.game.datatypes.blocks.Block; import de.bixilon.minosoft.game.datatypes.blocks.Blocks;
import de.bixilon.minosoft.game.datatypes.world.Chunk; import de.bixilon.minosoft.game.datatypes.world.Chunk;
import de.bixilon.minosoft.game.datatypes.world.ChunkNibble; import de.bixilon.minosoft.game.datatypes.world.ChunkNibble;
import de.bixilon.minosoft.game.datatypes.world.ChunkNibbleLocation; import de.bixilon.minosoft.game.datatypes.world.ChunkNibbleLocation;
@ -50,7 +50,7 @@ public class ChunkUtil {
for (byte c = 0; c < 16; c++) { // max sections per chunks in chunk column for (byte c = 0; c < 16; c++) { // max sections per chunks in chunk column
if (BitByte.isBitSet(sectionBitMask, c)) { if (BitByte.isBitSet(sectionBitMask, c)) {
HashMap<ChunkNibbleLocation, Block> blockMap = new HashMap<>(); HashMap<ChunkNibbleLocation, Blocks> blockMap = new HashMap<>();
for (int nibbleY = 0; nibbleY < 16; nibbleY++) { for (int nibbleY = 0; nibbleY < 16; nibbleY++) {
for (int nibbleZ = 0; nibbleZ < 16; nibbleZ++) { for (int nibbleZ = 0; nibbleZ < 16; nibbleZ++) {
@ -76,8 +76,8 @@ public class ChunkUtil {
// ToDo light, biome // ToDo light, biome
Block block = Block.byLegacy(singeBlockId, singleMeta); Blocks block = Blocks.byLegacy(singeBlockId, singleMeta);
if (block == Block.AIR) { if (block == Blocks.AIR) {
continue; continue;
} }
blockMap.put(new ChunkNibbleLocation(nibbleX, nibbleY, nibbleZ), block); blockMap.put(new ChunkNibbleLocation(nibbleX, nibbleY, nibbleZ), block);