mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 11:24:56 -04:00
fix loading of pre flattening mappings, entity id reading in early 1.7 versions, improve pre flattening mappings loading
This commit is contained in:
parent
26f96a3504
commit
16d66d2394
@ -184,9 +184,20 @@ public class Version {
|
|||||||
Log.verbose(String.format("Loading mappings for version %s...", this));
|
Log.verbose(String.format("Loading mappings for version %s...", this));
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
if (this.mapping == null) {
|
||||||
|
this.mapping = new VersionMapping(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getVersionId() == ProtocolDefinition.PRE_FLATTENING_VERSION_ID && Versions.PRE_FLATTENING_MAPPING == null) {
|
||||||
|
Versions.PRE_FLATTENING_MAPPING = this.mapping;
|
||||||
|
} else {
|
||||||
|
this.mapping.setParentMapping(Versions.PRE_FLATTENING_MAPPING);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
HashMap<String, JsonObject> files;
|
HashMap<String, JsonObject> files;
|
||||||
try {
|
try {
|
||||||
files = Util.readJsonTarStream(AssetsManager.readAssetAsStreamByHash(this.assetsManager.getAssetVersion().getMinosoftMappings()));
|
files = Util.readJsonTarStream(AssetsManager.readAssetAsStreamByHash(Resources.getAssetVersionByVersion(this).getMinosoftMappings()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// should not happen, but if this version is not flattened, we can fallback to the flatten mappings. Some things might not work...
|
// should not happen, but if this version is not flattened, we can fallback to the flatten mappings. Some things might not work...
|
||||||
Log.printException(e, LogLevels.VERBOSE);
|
Log.printException(e, LogLevels.VERBOSE);
|
||||||
@ -222,14 +233,7 @@ public class Version {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadVersionMappings(Mappings type, String mod, @Nullable JsonObject data) {
|
public void loadVersionMappings(Mappings type, String mod, @Nullable JsonObject data) {
|
||||||
if (this.mapping == null) {
|
|
||||||
this.mapping = new VersionMapping(this);
|
|
||||||
}
|
|
||||||
this.mapping.load(type, mod, data, this);
|
this.mapping.load(type, mod, data, this);
|
||||||
|
|
||||||
if (getVersionId() == ProtocolDefinition.PRE_FLATTENING_VERSION_ID && Versions.PRE_FLATTENING_MAPPING == null) {
|
|
||||||
Versions.PRE_FLATTENING_MAPPING = this.mapping;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -42,21 +42,21 @@ public class VersionMapping {
|
|||||||
private final HashMap<EntityMetaDataFields, Integer> entityMetaIndexMap = new HashMap<>(100);
|
private final HashMap<EntityMetaDataFields, Integer> entityMetaIndexMap = new HashMap<>(100);
|
||||||
private final HashMap<String, Pair<String, Integer>> entityMetaIndexOffsetParentMapping = new HashMap<>(100);
|
private final HashMap<String, Pair<String, Integer>> entityMetaIndexOffsetParentMapping = new HashMap<>(100);
|
||||||
private final HashBiMap<Integer, Class<? extends Entity>> entityIdClassMap = HashBiMap.create(100);
|
private final HashBiMap<Integer, Class<? extends Entity>> entityIdClassMap = HashBiMap.create(100);
|
||||||
|
private final HashBiMap<String, Motive> motiveIdentifierMap = HashBiMap.create();
|
||||||
|
private final HashBiMap<String, Particle> particleIdentifierMap = HashBiMap.create();
|
||||||
|
private final HashBiMap<String, Statistic> statisticIdentifierMap = HashBiMap.create();
|
||||||
|
private final HashBiMap<Integer, Item> itemMap = HashBiMap.create();
|
||||||
|
private final HashBiMap<Integer, Motive> motiveIdMap = HashBiMap.create();
|
||||||
|
private final HashBiMap<Integer, MobEffect> mobEffectMap = HashBiMap.create();
|
||||||
|
private final HashBiMap<Integer, Block> blockMap = HashBiMap.create();
|
||||||
|
private final HashBiMap<Integer, BlockId> blockIdMap = HashBiMap.create();
|
||||||
|
private final HashBiMap<Integer, Enchantment> enchantmentMap = HashBiMap.create();
|
||||||
|
private final HashBiMap<Integer, Particle> particleIdMap = HashBiMap.create();
|
||||||
|
private final HashBiMap<Integer, Statistic> statisticIdMap = HashBiMap.create();
|
||||||
private Version version;
|
private Version version;
|
||||||
private VersionMapping parentMapping;
|
private VersionMapping parentMapping;
|
||||||
private HashBiMap<String, Motive> motiveIdentifierMap = HashBiMap.create();
|
|
||||||
private HashBiMap<String, Particle> particleIdentifierMap = HashBiMap.create();
|
|
||||||
private HashBiMap<String, Statistic> statisticIdentifierMap = HashBiMap.create();
|
|
||||||
private HashMap<String, HashBiMap<String, Dimension>> dimensionIdentifierMap = new HashMap<>();
|
private HashMap<String, HashBiMap<String, Dimension>> dimensionIdentifierMap = new HashMap<>();
|
||||||
private HashBiMap<Integer, Item> itemMap = HashBiMap.create();
|
|
||||||
private HashBiMap<Integer, Motive> motiveIdMap = HashBiMap.create();
|
|
||||||
private HashBiMap<Integer, MobEffect> mobEffectMap = HashBiMap.create();
|
|
||||||
private HashBiMap<Integer, Dimension> dimensionMap = HashBiMap.create();
|
private HashBiMap<Integer, Dimension> dimensionMap = HashBiMap.create();
|
||||||
private HashBiMap<Integer, Block> blockMap = HashBiMap.create();
|
|
||||||
private HashBiMap<Integer, BlockId> blockIdMap = HashBiMap.create();
|
|
||||||
private HashBiMap<Integer, Enchantment> enchantmentMap = HashBiMap.create();
|
|
||||||
private HashBiMap<Integer, Particle> particleIdMap = HashBiMap.create();
|
|
||||||
private HashBiMap<Integer, Statistic> statisticIdMap = HashBiMap.create();
|
|
||||||
|
|
||||||
public VersionMapping(Version version) {
|
public VersionMapping(Version version) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
@ -301,22 +301,6 @@ public class VersionMapping {
|
|||||||
public void load(Mappings type, String mod, @Nullable JsonObject data, Version version) {
|
public void load(Mappings type, String mod, @Nullable JsonObject data, Version version) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case REGISTRIES -> {
|
case REGISTRIES -> {
|
||||||
if (!version.isFlattened() && version.getVersionId() != ProtocolDefinition.PRE_FLATTENING_VERSION_ID) {
|
|
||||||
// clone all values
|
|
||||||
this.itemMap = Versions.PRE_FLATTENING_MAPPING.itemMap;
|
|
||||||
this.enchantmentMap = Versions.PRE_FLATTENING_MAPPING.enchantmentMap;
|
|
||||||
this.statisticIdMap = Versions.PRE_FLATTENING_MAPPING.statisticIdMap;
|
|
||||||
this.statisticIdentifierMap = Versions.PRE_FLATTENING_MAPPING.statisticIdentifierMap;
|
|
||||||
this.blockIdMap = Versions.PRE_FLATTENING_MAPPING.blockIdMap;
|
|
||||||
this.motiveIdMap = Versions.PRE_FLATTENING_MAPPING.motiveIdMap;
|
|
||||||
this.motiveIdentifierMap = Versions.PRE_FLATTENING_MAPPING.motiveIdentifierMap;
|
|
||||||
this.particleIdMap = Versions.PRE_FLATTENING_MAPPING.particleIdMap;
|
|
||||||
this.particleIdentifierMap = Versions.PRE_FLATTENING_MAPPING.particleIdentifierMap;
|
|
||||||
this.mobEffectMap = Versions.PRE_FLATTENING_MAPPING.mobEffectMap;
|
|
||||||
this.dimensionMap = Versions.PRE_FLATTENING_MAPPING.dimensionMap;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -384,12 +368,6 @@ public class VersionMapping {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case BLOCKS -> {
|
case BLOCKS -> {
|
||||||
if (!version.isFlattened() && version.getVersionId() != ProtocolDefinition.PRE_FLATTENING_VERSION_ID) {
|
|
||||||
// clone all values
|
|
||||||
this.blockMap = Versions.PRE_FLATTENING_MAPPING.blockMap;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public class PacketSpawnExperienceOrb extends ClientboundPacket {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(InByteBuffer buffer) {
|
public boolean read(InByteBuffer buffer) {
|
||||||
int entityId = buffer.readVarInt();
|
int entityId = buffer.readEntityId();
|
||||||
Location location;
|
Location location;
|
||||||
if (buffer.getVersionId() < V_16W06A) {
|
if (buffer.getVersionId() < V_16W06A) {
|
||||||
location = new Location(buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt());
|
location = new Location(buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt());
|
||||||
|
@ -37,7 +37,7 @@ public class PacketSpawnMob extends ClientboundPacket {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(InByteBuffer buffer) throws Exception {
|
public boolean read(InByteBuffer buffer) throws Exception {
|
||||||
int entityId = buffer.readVarInt();
|
int entityId = buffer.readEntityId();
|
||||||
UUID uuid = null;
|
UUID uuid = null;
|
||||||
if (buffer.getVersionId() >= V_15W31A) {
|
if (buffer.getVersionId() >= V_15W31A) {
|
||||||
uuid = buffer.readUUID();
|
uuid = buffer.readUUID();
|
||||||
|
@ -37,7 +37,7 @@ public class PacketSpawnObject extends ClientboundPacket {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(InByteBuffer buffer) throws Exception {
|
public boolean read(InByteBuffer buffer) throws Exception {
|
||||||
int entityId = buffer.readVarInt();
|
int entityId = buffer.readEntityId();
|
||||||
UUID uuid = null;
|
UUID uuid = null;
|
||||||
if (buffer.getVersionId() >= V_15W31A) {
|
if (buffer.getVersionId() >= V_15W31A) {
|
||||||
uuid = buffer.readUUID();
|
uuid = buffer.readUUID();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user