update todo, add all items

This commit is contained in:
bixilon 2020-06-09 00:19:12 +02:00
parent ffbff15ca8
commit 56a8d5c3f1
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
12 changed files with 1058 additions and 13 deletions

View File

@ -13,11 +13,13 @@
package de.bixilon.minosoft.game.datatypes; package de.bixilon.minosoft.game.datatypes;
import de.bixilon.minosoft.game.datatypes.entities.Items;
import de.bixilon.minosoft.nbt.tag.CompoundTag; import de.bixilon.minosoft.nbt.tag.CompoundTag;
public class Slot { public class Slot {
int itemId; int itemId;
int itemCount; int itemCount;
short itemMetadata;
CompoundTag nbt; CompoundTag nbt;
public Slot(int itemId, int itemCount, CompoundTag nbt) { public Slot(int itemId, int itemCount, CompoundTag nbt) {
@ -26,8 +28,9 @@ public class Slot {
this.nbt = nbt; this.nbt = nbt;
} }
public Slot(short itemId, byte itemCount, short itemDamage, CompoundTag nbt) { public Slot(short itemId, byte itemCount, short itemMetadata, CompoundTag nbt) {
this.itemId = itemId; this.itemId = itemId;
this.itemMetadata = itemMetadata;
this.itemCount = itemCount; this.itemCount = itemCount;
this.nbt = nbt; this.nbt = nbt;
} }
@ -40,14 +43,19 @@ public class Slot {
return itemCount; return itemCount;
} }
public short getItemMetadata() {
return itemMetadata;
}
public CompoundTag getNbt() { public CompoundTag getNbt() {
return nbt; return nbt;
} }
public String getDisplayName() { public String getDisplayName() {
String itemName = Items.byLegacy(getItemId(), getItemMetadata()).name();
if (nbt != null && nbt.containsKey("display") && nbt.getCompoundTag("display").containsKey("Name")) { // check if object has nbt data, and a custom display name if (nbt != null && nbt.containsKey("display") && nbt.getCompoundTag("display").containsKey("Name")) { // check if object has nbt data, and a custom display name
return new TextComponent(nbt.getCompoundTag("display").getStringTag("Name").getValue()).getColoredMessage(); return String.format("%s (%s)", new TextComponent(nbt.getCompoundTag("display").getStringTag("Name").getValue()).getColoredMessage(), itemName);
} }
return "<ToDo>"; //ToDo display name per Item return itemName; //ToDo display name per Item
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -24,7 +24,6 @@ public class AgeableMetaData extends MobMetaData {
public int getAge() { public int getAge() {
//ToDo custom Potion Effect Color Type
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
return (int) sets.get(12).getData(); return (int) sets.get(12).getData();

View File

@ -32,7 +32,7 @@ public class PacketEncryptionKeyRequest implements ClientboundPacket {
publicKey = buffer.readBytes(buffer.readShort()); // read length, then the bytes publicKey = buffer.readBytes(buffer.readShort()); // read length, then the bytes
verifyToken = buffer.readBytes(buffer.readShort()); // read length, then the bytes verifyToken = buffer.readBytes(buffer.readShort()); // read length, then the bytes
break; break;
} // ToDo }
} }
@Override @Override

View File

@ -41,7 +41,7 @@ public class PacketEntityEquipment implements ClientboundPacket {
@Override @Override
public void log() { public void log() {
if (data != null) { if (data != null) {
Log.protocol(String.format("Entity equipment changed (entityId=%d, slot=%s): %s", entityId, slot.name(), data.getDisplayName())); Log.protocol(String.format("Entity equipment changed (entityId=%d, slot=%s): %dx %s", entityId, slot.name(), data.getItemCount(), data.getDisplayName()));
} else { } else {
// null means nothing, means air // null means nothing, means air
Log.protocol(String.format("Entity equipment changed (entityId=%d, slot=%s): AIR", entityId, slot.name())); Log.protocol(String.format("Entity equipment changed (entityId=%d, slot=%s): AIR", entityId, slot.name()));

View File

@ -29,7 +29,7 @@ public class PacketEntityHeadRotation implements ClientboundPacket {
switch (v) { switch (v) {
case VERSION_1_7_10: case VERSION_1_7_10:
this.entityId = buffer.readInteger(); this.entityId = buffer.readInteger();
this.headYaw = buffer.readByte(); //ToDo this.headYaw = buffer.readByte();
break; break;
} }
} }

View File

@ -33,7 +33,7 @@ public class PacketEntityPositionAndRotation implements ClientboundPacket {
case VERSION_1_7_10: case VERSION_1_7_10:
this.entityId = buffer.readInteger(); this.entityId = buffer.readInteger();
this.location = new RelativeLocation(buffer.readFixedPointNumberByte(), buffer.readFixedPointNumberByte(), buffer.readFixedPointNumberByte()); this.location = new RelativeLocation(buffer.readFixedPointNumberByte(), buffer.readFixedPointNumberByte(), buffer.readFixedPointNumberByte());
this.yaw = buffer.readByte(); //ToDo this.yaw = buffer.readByte(); //ToDo dividing, ...
this.pitch = buffer.readByte(); this.pitch = buffer.readByte();
break; break;
} }

View File

@ -30,7 +30,7 @@ public class PacketEntityRotation implements ClientboundPacket {
switch (v) { switch (v) {
case VERSION_1_7_10: case VERSION_1_7_10:
this.entityId = buffer.readInteger(); this.entityId = buffer.readInteger();
this.yaw = buffer.readByte(); //ToDo this.yaw = buffer.readByte();
this.pitch = buffer.readByte(); this.pitch = buffer.readByte();
break; break;
} }

View File

@ -33,7 +33,7 @@ public class PacketEntityTeleport implements ClientboundPacket {
case VERSION_1_7_10: case VERSION_1_7_10:
this.entityId = buffer.readInteger(); this.entityId = buffer.readInteger();
this.location = new Location(buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger()); this.location = new Location(buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger());
this.yaw = buffer.readByte(); //ToDo this.yaw = buffer.readByte();
this.pitch = buffer.readByte(); this.pitch = buffer.readByte();
break; break;
} }

View File

@ -36,7 +36,7 @@ public class PacketSpawnMob implements ClientboundPacket {
int entityId = buffer.readVarInt(); int entityId = buffer.readVarInt();
Mobs type = Mobs.byType(buffer.readByte()); Mobs type = Mobs.byType(buffer.readByte());
Location location = new Location(buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger()); Location location = new Location(buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger());
int yaw = buffer.readByte(); //ToDo int yaw = buffer.readByte();
int pitch = buffer.readByte(); int pitch = buffer.readByte();
int headPitch = buffer.readByte(); int headPitch = buffer.readByte();
Velocity velocity = new Velocity(buffer.readShort(), buffer.readShort(), buffer.readShort()); Velocity velocity = new Velocity(buffer.readShort(), buffer.readShort(), buffer.readShort());

View File

@ -112,7 +112,6 @@ public class InByteBuffer {
public String readString() { public String readString() {
int length = readVarInt(); int length = readVarInt();
if (length > ProtocolDefinition.STRING_MAX_LEN) { if (length > ProtocolDefinition.STRING_MAX_LEN) {
// ToDo throw new PacketDataException(String.format("String is longer than %s", ProtocolDefinition.STRING_MAX_LEN));
return null; return null;
} }
return new String(readBytes(length), StandardCharsets.UTF_8); return new String(readBytes(length), StandardCharsets.UTF_8);

View File

@ -89,7 +89,6 @@ public class OutByteBuffer {
public void writeString(String s) { public void writeString(String s) {
if (s.length() > ProtocolDefinition.STRING_MAX_LEN) { if (s.length() > ProtocolDefinition.STRING_MAX_LEN) {
//ToDo
writeByte((byte) 0); // write length 0 writeByte((byte) 0); // write length 0
} }
writeVarInt(s.length()); writeVarInt(s.length());