Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-09-08 05:42:51 +02:00
Ursprung
a03a3a2a8d
Commit
e05c585b37
@ -63,14 +63,19 @@ public class EntityPositionHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityPositionStorage positionStorage = create ? storageSupplier.get() : storedEntity.get(storageClass);
|
EntityPositionStorage positionStorage;
|
||||||
if (positionStorage == null) {
|
if (create) {
|
||||||
ViaBackwards.getPlatform().getLogger().warning("Stored entity with id " + entityId + " missing " + storageClass.getSimpleName());
|
positionStorage = storageSupplier.get();
|
||||||
return;
|
storedEntity.put(positionStorage);
|
||||||
|
} else {
|
||||||
|
positionStorage = storedEntity.get(storageClass);
|
||||||
|
if (positionStorage == null) {
|
||||||
|
ViaBackwards.getPlatform().getLogger().warning("Stored entity with id " + entityId + " missing " + storageClass.getSimpleName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
positionStorage.setCoordinates(x, y, z, relative);
|
positionStorage.setCoordinates(x, y, z, relative);
|
||||||
storedEntity.put(positionStorage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityPositionStorage getStorage(UserConnection user, int entityId) {
|
public EntityPositionStorage getStorage(UserConnection user, int entityId) {
|
||||||
|
@ -65,7 +65,9 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends En
|
|||||||
@Override
|
@Override
|
||||||
public void handleMetadata(int entityId, List<Metadata> metadataList, UserConnection connection) {
|
public void handleMetadata(int entityId, List<Metadata> metadataList, UserConnection connection) {
|
||||||
EntityType type = tracker(connection).entityType(entityId);
|
EntityType type = tracker(connection).entityType(entityId);
|
||||||
if (type == null) return; // Don't handle untracked entities - basically always the fault of a plugin sending virtual entities through concurrency-unsafe handling
|
if (type == null) {
|
||||||
|
return; // Don't handle untracked entities - basically always the fault of a plugin sending virtual entities through concurrency-unsafe handling
|
||||||
|
}
|
||||||
|
|
||||||
super.handleMetadata(entityId, metadataList, connection);
|
super.handleMetadata(entityId, metadataList, connection);
|
||||||
|
|
||||||
@ -84,11 +86,9 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends En
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add any other extra meta for mapped entities
|
// Add any other extra meta for mapped entities
|
||||||
if (entityData != null) {
|
//TODO only do this once for a first meta packet?
|
||||||
//TODO only do this once for a first meta packet?
|
if (entityData != null && entityData.hasBaseMeta()) {
|
||||||
if (entityData != null && entityData.hasBaseMeta()) {
|
entityData.defaultMeta().createMeta(new WrappedMetadata(metadataList));
|
||||||
entityData.defaultMeta().createMeta(new WrappedMetadata(metadataList));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,9 +180,9 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends En
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ONLY TRACKS, DOESN'T REWRITE IDS
|
// ONLY TRACKS, DOESN'T REWRITE IDS
|
||||||
protected PacketHandler getTrackerHandler(Type intType, int typeIndex) {
|
protected PacketHandler getTrackerHandler(Type<? extends Number> intType, int typeIndex) {
|
||||||
return wrapper -> {
|
return wrapper -> {
|
||||||
Number id = (Number) wrapper.get(intType, typeIndex);
|
Number id = wrapper.get(intType, typeIndex);
|
||||||
tracker(wrapper.user()).addEntity(wrapper.get(Type.VAR_INT, 0), typeFromId(id.intValue()));
|
tracker(wrapper.user()).addEntity(wrapper.get(Type.VAR_INT, 0), typeFromId(id.intValue()));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -191,7 +191,7 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends En
|
|||||||
return getTrackerHandler(Type.VAR_INT, 1);
|
return getTrackerHandler(Type.VAR_INT, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected PacketHandler getTrackerHandler(EntityType entityType, Type intType) {
|
protected PacketHandler getTrackerHandler(EntityType entityType, Type<? extends Number> intType) {
|
||||||
return wrapper -> tracker(wrapper.user()).addEntity((int) wrapper.get(intType, 0), entityType);
|
return wrapper -> tracker(wrapper.user()).addEntity((int) wrapper.get(intType, 0), entityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2T
|
|||||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage;
|
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage;
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.EntityPositionStorage1_14;
|
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.EntityPositionStorage1_14;
|
||||||
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
||||||
|
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
||||||
import com.viaversion.viaversion.api.minecraft.Position;
|
import com.viaversion.viaversion.api.minecraft.Position;
|
||||||
import com.viaversion.viaversion.api.minecraft.VillagerData;
|
import com.viaversion.viaversion.api.minecraft.VillagerData;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types;
|
import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types;
|
||||||
@ -318,6 +319,11 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
|||||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Max Players
|
wrapper.passthrough(Type.UNSIGNED_BYTE); // Max Players
|
||||||
wrapper.passthrough(Type.STRING); // Level Type
|
wrapper.passthrough(Type.STRING); // Level Type
|
||||||
wrapper.read(Type.VAR_INT); // Read View Distance
|
wrapper.read(Type.VAR_INT); // Read View Distance
|
||||||
|
|
||||||
|
// Manually add position storage
|
||||||
|
int entitiyId = wrapper.get(Type.VAR_INT, 0);
|
||||||
|
StoredEntityData storedEntity = protocol.getEntityRewriter().tracker(wrapper.user()).entityData(entitiyId);
|
||||||
|
storedEntity.put(new EntityPositionStorage1_14());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren