Java Code Examples for net.minecraft.entity.data.DataTracker#Entry

The following examples show how to use net.minecraft.entity.data.DataTracker#Entry . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MixinDataTracker.java    From multiconnect with MIT License 6 votes vote down vote up
@Override
public void multiconnect_setEntityTo(Entity entity) {
    lock.writeLock().lock();
    this.trackedEntity = entity;
    //noinspection ConstantConditions
    Collection<DataTracker.Entry<?>> otherEntries = ((MixinDataTracker) (Object) entity.getDataTracker()).entries.values();
    Map<Integer, DataTracker.Entry<?>> oldThisEntries = new HashMap<>(this.entries);
    this.entries.clear();
    for (DataTracker.Entry<?> otherEntry : otherEntries) {
        int dataId = otherEntry.getData().getId();
        DataTracker.Entry<?> entry = oldThisEntries.getOrDefault(dataId, otherEntry);
        entries.put(dataId, entry);
        entry.setDirty(true);
    }
    dirty = true;
    lock.writeLock().unlock();
}
 
Example 2
Source File: PendingDataTrackerEntries.java    From multiconnect with MIT License 5 votes vote down vote up
public static void setEntries(int entityId, List<DataTracker.Entry<?>> entries) {
    synchronized (PendingDataTrackerEntries.entries) {
        if (entries == null) {
            PendingDataTrackerEntries.entries.remove(entityId);
        } else {
            PendingDataTrackerEntries.entries.put(entityId, entries);
        }
    }
}
 
Example 3
Source File: MixinClientPlayNetworkHandler.java    From multiconnect with MIT License 5 votes vote down vote up
@Unique
private void applyPendingEntityTrackerValues(int entityId) {
    if (ConnectionInfo.protocolVersion <= Protocols.V1_14_4) {
        List<DataTracker.Entry<?>> entries = PendingDataTrackerEntries.getEntries(entityId);
        if (entries != null) {
            PendingDataTrackerEntries.setEntries(entityId, null);
            EntityTrackerUpdateS2CPacket trackerPacket = new EntityTrackerUpdateS2CPacket();
            //noinspection ConstantConditions
            TrackerUpdatePacketAccessor trackerPacketAccessor = (TrackerUpdatePacketAccessor) trackerPacket;
            trackerPacketAccessor.setId(entityId);
            trackerPacketAccessor.setTrackedValues(entries);
            onEntityTrackerUpdate(trackerPacket);
        }
    }
}
 
Example 4
Source File: MixinDataTracker.java    From multiconnect with MIT License 5 votes vote down vote up
@Override
public void multiconnect_recomputeEntries() {
    if (entries == null)
        return;
    List<DataTracker.Entry<?>> entryList = new ArrayList<>(entries.values());
    entries.clear();
    for (DataTracker.Entry entry : entryList) {
        entries.put(entry.getData().getId(), entry);
    }
}
 
Example 5
Source File: PendingDataTrackerEntries.java    From multiconnect with MIT License 4 votes vote down vote up
public static List<DataTracker.Entry<?>> getEntries(int entityId) {
    synchronized (entries) {
        return entries.get(entityId);
    }
}
 
Example 6
Source File: TrackerUpdatePacketAccessor.java    From multiconnect with MIT License 4 votes vote down vote up
@Accessor
void setTrackedValues(List<DataTracker.Entry<?>> entries);
 
Example 7
Source File: MixinDataTracker.java    From multiconnect with MIT License 4 votes vote down vote up
@Inject(method = "writeEntryToPacket", at = @At("HEAD"), cancellable = true)
private static <T> void onWriteEntryToPacket(PacketByteBuf buf, DataTracker.Entry<T> entry, CallbackInfo ci) {
    if (entry.getData().getId() < 0)
        ci.cancel();
}
 
Example 8
Source File: MixinDataTracker.java    From multiconnect with MIT License 4 votes vote down vote up
@Inject(method = "getEntry", at = @At("RETURN"))
private void assertCorrectType(TrackedData<?> requested, CallbackInfoReturnable<DataTracker.Entry<?>> ci) {
    if (ci.getReturnValue().getData().getType() != requested.getType()) {
        throw new AssertionError("getEntry returned wrong type!");
    }
}