Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-26 00:00:33 +01:00
Handle 1.14 zombies/skeletons holding up arms
Dieser Commit ist enthalten in:
Ursprung
08743513ca
Commit
aca265956f
@ -10,8 +10,6 @@
|
||||
|
||||
package nl.matsv.viabackwards.api.entities.meta;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
@ -19,10 +17,7 @@ import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public class MetaHandlerEvent {
|
||||
private final UserConnection user;
|
||||
private final EntityTracker.StoredEntity entity;
|
||||
@ -31,15 +26,25 @@ public class MetaHandlerEvent {
|
||||
private final MetaStorage storage;
|
||||
private List<Metadata> extraData;
|
||||
|
||||
public MetaHandlerEvent(UserConnection user, EntityTracker.StoredEntity entity, int index, Metadata data, MetaStorage storage) {
|
||||
this.user = user;
|
||||
this.entity = entity;
|
||||
this.index = index;
|
||||
this.data = data;
|
||||
this.storage = storage;
|
||||
}
|
||||
|
||||
public boolean hasData() {
|
||||
return data != null;
|
||||
}
|
||||
|
||||
public Optional<Metadata> getMetaByIndex(int index) {
|
||||
for (Metadata meta : storage.getMetaDataList())
|
||||
if (index == meta.getId())
|
||||
return Optional.of(meta);
|
||||
return Optional.empty();
|
||||
public Metadata getMetaByIndex(int index) {
|
||||
for (Metadata meta : storage.getMetaDataList()) {
|
||||
if (index == meta.getId()) {
|
||||
return meta;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void clearExtraData() {
|
||||
@ -49,4 +54,31 @@ public class MetaHandlerEvent {
|
||||
public void createMeta(Metadata metadata) {
|
||||
(extraData != null ? extraData : (extraData = new ArrayList<>())).add(metadata);
|
||||
}
|
||||
|
||||
public UserConnection getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public EntityTracker.StoredEntity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public Metadata getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public MetaStorage getStorage() {
|
||||
return storage;
|
||||
}
|
||||
|
||||
/**
|
||||
* May be null, use {@link #createMeta(Metadata)} for adding metadata.
|
||||
*/
|
||||
public List<Metadata> getExtraData() {
|
||||
return extraData;
|
||||
}
|
||||
}
|
||||
|
@ -437,6 +437,22 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
|
||||
registerMetaHandler().filter(Entity1_14Types.EntityType.ZOMBIE_VILLAGER, 18).handle(villagerDataHandler);
|
||||
registerMetaHandler().filter(Entity1_14Types.EntityType.VILLAGER, 16).handle(villagerDataHandler);
|
||||
|
||||
// Holding arms up - from bitfield into own boolean
|
||||
registerMetaHandler().filter(Entity1_14Types.EntityType.ABSTRACT_SKELETON, true, 13).handle(e -> {
|
||||
byte value = (byte) e.getData().getValue();
|
||||
if ((value & 4) != 0) {
|
||||
e.createMeta(new Metadata(14, MetaType1_13_2.Boolean, true));
|
||||
}
|
||||
return e.getData();
|
||||
});
|
||||
registerMetaHandler().filter(Entity1_14Types.EntityType.ZOMBIE, true, 13).handle(e -> {
|
||||
byte value = (byte) e.getData().getValue();
|
||||
if ((value & 4) != 0) {
|
||||
e.createMeta(new Metadata(16, MetaType1_13_2.Boolean, true));
|
||||
}
|
||||
return e.getData();
|
||||
});
|
||||
|
||||
registerMetaHandler().filter(Entity1_14Types.EntityType.ZOMBIE, true).handle(e -> {
|
||||
Metadata meta = e.getData();
|
||||
int index = e.getIndex();
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren