3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-25 15:50:10 +01:00

Handle new attack mode flag in insentient

Dieser Commit ist enthalten in:
creeper123123321 2019-04-21 15:34:23 -03:00
Ursprung 70cb461c32
Commit b2352105e6
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 0AC57D54786721D1
2 geänderte Dateien mit 34 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -11,6 +11,7 @@ import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.Particle;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets.InventoryPackets;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.storage.EntityTracker;
import java.util.ArrayList;
import java.util.List;
@ -22,6 +23,8 @@ public class MetadataRewriter {
try {
metadata.setMetaType(MetaType1_14.byId(metadata.getMetaType().getTypeID()));
EntityTracker tracker = connection.get(EntityTracker.class);
if (metadata.getMetaType() == MetaType1_14.Slot) {
InventoryPackets.toClient((Item) metadata.getValue());
} else if (metadata.getMetaType() == MetaType1_14.BlockID) {
@ -42,6 +45,14 @@ public class MetadataRewriter {
metadata.setId(metadata.getId() + 1);
}
if (type.isOrHasParent(Entity1_14Types.EntityType.ABSTRACT_INSENTIENT)) {
if (metadata.getId() == 13) {
tracker.setInsentientData(entityId, (byte) ((((Number)metadata.getValue()).byteValue() & ~0x4)
| (tracker.getInsentientData(entityId) & 0x4))); // New attacking metadata
metadata.setValue(tracker.getInsentientData(entityId));
}
}
if (type.isOrHasParent(Entity1_14Types.EntityType.MINECART_ABSTRACT)) {
if (metadata.getId() == 10) {
// New block format
@ -91,11 +102,17 @@ public class MetadataRewriter {
}
} else if (type.isOrHasParent(Entity1_14Types.EntityType.ABSTRACT_SKELETON)) {
if (metadata.getId() == 12) {
metadatas.remove(metadata); // TODO "Is swinging arms", maybe moved to pos / entity status
tracker.setInsentientData(entityId, (byte) ((tracker.getInsentientData(entityId) & ~0x4)
| ((boolean) metadata.getValue() ? 0x4 : 0))); // New attacking
metadatas.remove(metadata); // "Is swinging arms"
metadatas.add(new Metadata(13, MetaType1_14.Byte, tracker.getInsentientData(entityId)));
}
} else if (type.isOrHasParent(Entity1_14Types.EntityType.ZOMBIE)) {
if (metadata.getId() == 16) {
metadatas.remove(metadata); // TODO "Are hands held up", maybe moved to pos / entity status
tracker.setInsentientData(entityId, (byte) ((tracker.getInsentientData(entityId) & ~0x4)
| ((boolean) metadata.getValue() ? 0x4 : 0))); // New attacking
metadatas.remove(metadata); // "Are hands held up"
metadatas.add(new Metadata(13, MetaType1_14.Byte, tracker.getInsentientData(entityId)));
} else if (metadata.getId() > 16) {
metadata.setId(metadata.getId() - 1);
}
@ -108,7 +125,10 @@ public class MetadataRewriter {
if (type.isOrHasParent(Entity1_14Types.EntityType.ABSTRACT_ILLAGER_BASE)) {
if (metadata.getId() == 14) {
metadatas.remove(metadata); // TODO "Has target (aggressive state)", maybe moved to pos / entity status
tracker.setInsentientData(entityId, (byte) ((tracker.getInsentientData(entityId) & ~0x4)
| ((boolean) metadata.getValue() ? 0x4 : 0))); // New attacking
metadatas.remove(metadata); // "Has target (aggressive state)"
metadatas.add(new Metadata(13, MetaType1_14.Byte, tracker.getInsentientData(entityId)));
}
}

Datei anzeigen

@ -13,6 +13,7 @@ import java.util.concurrent.ConcurrentHashMap;
public class EntityTracker extends StoredObject {
private final Map<Integer, Entity1_14Types.EntityType> clientEntityTypes = new ConcurrentHashMap<>();
private final Map<Integer, Byte> insentientData = new ConcurrentHashMap<>();
@Getter
@Setter
private int latestTradeWindowId;
@ -23,12 +24,22 @@ public class EntityTracker extends StoredObject {
public void removeEntity(int entityId) {
clientEntityTypes.remove(entityId);
insentientData.remove(entityId);
}
public void addEntity(int entityId, UUID uuid, Entity1_14Types.EntityType type) {
clientEntityTypes.put(entityId, type);
}
public byte getInsentientData(int entity) {
Byte val = insentientData.get(entity);
return val == null ? 0 : val;
}
public void setInsentientData(int entity, byte value) {
insentientData.put(entity, value);
}
public boolean has(int entityId) {
return clientEntityTypes.containsKey(entityId);
}