Add entity handling for 1.10 to 1.12.2 (#1195)

* Fix entity type data type for 1.13 below
* Add entity handling for 1.10 to 1.12.2
* Update comments for EntityPalette113
This commit is contained in:
ReinforceZwei 2020-08-11 19:44:18 +08:00 committed by GitHub
parent a28409043c
commit e6d34c3cf1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 163 additions and 8 deletions

View file

@ -370,7 +370,17 @@ namespace MinecraftClient.Protocol.Handlers
entityUUID = ReadNextUUID(cache);
}
EntityType entityType = entityPalette.FromId(ReadNextVarInt(cache), living);
EntityType entityType;
// Entity type data type change from byte to varint after 1.14
if (protocolversion > Protocol18Handler.MC113Version)
{
entityType = entityPalette.FromId(ReadNextVarInt(cache), living);
}
else
{
entityType = entityPalette.FromId(ReadNextByte(cache), living);
}
Double entityX = ReadNextDouble(cache);
Double entityY = ReadNextDouble(cache);
Double entityZ = ReadNextDouble(cache);

View file

@ -84,7 +84,7 @@ namespace MinecraftClient.Protocol.Handlers
handler.SetInventoryEnabled(false);
}
if (handler.GetEntityHandlingEnabled() && (protocolversion <= MC1122Version || protocolversion > MC1161Version))
if (handler.GetEntityHandlingEnabled() && (protocolversion < MC110Version || protocolversion > MC1161Version))
{
ConsoleIO.WriteLineFormatted("§8Entities are currently not handled for that MC version.");
handler.SetEntityHandlingEnabled(false);
@ -102,7 +102,7 @@ namespace MinecraftClient.Protocol.Handlers
}
else Block.Palette = new Palette112();
if (protocolversion >= MC114Version)
if (protocolversion >= MC113Version)
{
if (protocolversion > MC1161Version && handler.GetEntityHandlingEnabled())
throw new NotImplementedException("Please update entity types handling for this Minecraft version. See EntityType.cs");
@ -110,9 +110,11 @@ namespace MinecraftClient.Protocol.Handlers
entityPalette = new EntityPalette116();
else if (protocolversion >= MC115Version)
entityPalette = new EntityPalette115();
else entityPalette = new EntityPalette114();
else if (protocolVersion >= MC114Version)
entityPalette = new EntityPalette114();
else entityPalette = new EntityPalette113();
}
else entityPalette = new EntityPalette113();
else entityPalette = new EntityPalette112();
}
/// <summary>