mirror of
https://github.com/GTNewHorizons/Gadomancy.git
synced 2026-11-18 11:19:17 +00:00
- Achromatic handling finished.
This commit is contained in:
1 parent
37b151f61a
commit
22767153af
5 files changed
+33
-15
No files matched your search
@@ -32,6 +32,8 @@ public abstract class AbstractData {
|
||||
return providerId;
|
||||
}
|
||||
|
||||
public abstract boolean needsUpdate();
|
||||
|
||||
public abstract void writeAllDataToPacket(NBTTagCompound compound);
|
||||
|
||||
public abstract void writeToPacket(NBTTagCompound compound);
|
||||
|
||||
@@ -35,14 +35,16 @@ public class DataAchromatic extends AbstractData {
|
||||
int entityId = entity.getEntityId();
|
||||
|
||||
boolean needsUpdate = false;
|
||||
if(!addClientQueue.contains(entityId)) {
|
||||
if(!addClientQueue.contains(entityId) && !achromaticEntities.contains(entityId)) {
|
||||
addClientQueue.add(entityId);
|
||||
needsUpdate = true;
|
||||
}
|
||||
if(!achromaticEntities.contains(entityId)) {
|
||||
achromaticEntities.add(entityId);
|
||||
needsUpdate = true;
|
||||
}
|
||||
if(removeClientQueue.contains(entityId)) {
|
||||
removeClientQueue.remove(Integer.valueOf(entityId));
|
||||
addClientQueue.remove(Integer.valueOf(entityId));
|
||||
needsUpdate = false;
|
||||
}
|
||||
if(needsUpdate) {
|
||||
markDirty();
|
||||
}
|
||||
@@ -54,15 +56,16 @@ public class DataAchromatic extends AbstractData {
|
||||
int entityId = entity.getEntityId();
|
||||
|
||||
boolean needsUpdate = false;
|
||||
if(!removeClientQueue.contains(entityId)) {
|
||||
if(!removeClientQueue.contains(entityId) && achromaticEntities.contains(entityId)) {
|
||||
removeClientQueue.add(entityId);
|
||||
achromaticEntities.remove(Integer.valueOf(entityId));
|
||||
needsUpdate = true;
|
||||
}
|
||||
if(achromaticEntities.contains(entityId)) {
|
||||
achromaticEntities.remove((Integer)entityId);
|
||||
needsUpdate = true;
|
||||
if(addClientQueue.contains(entityId)) {
|
||||
addClientQueue.remove(Integer.valueOf(entityId));
|
||||
removeClientQueue.remove(Integer.valueOf(entityId));
|
||||
needsUpdate = false;
|
||||
}
|
||||
|
||||
if(needsUpdate) {
|
||||
markDirty();
|
||||
}
|
||||
@@ -74,6 +77,11 @@ public class DataAchromatic extends AbstractData {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsUpdate() {
|
||||
return !addClientQueue.isEmpty() || !removeClientQueue.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeAllDataToPacket(NBTTagCompound compound) {
|
||||
int[] array = new int[achromaticEntities.size()];
|
||||
@@ -120,10 +128,10 @@ public class DataAchromatic extends AbstractData {
|
||||
@Override
|
||||
public void handleIncomingData(AbstractData serverData) {
|
||||
DataAchromatic achromatic = (DataAchromatic) serverData;
|
||||
List<Integer> toAdd = achromatic.addClientQueue;
|
||||
achromaticEntities.addAll(toAdd);
|
||||
List<Integer> toRemove = achromatic.removeClientQueue;
|
||||
achromaticEntities.removeAll(toRemove);
|
||||
List<Integer> toAdd = achromatic.addClientQueue;
|
||||
achromaticEntities.addAll(toAdd);
|
||||
}
|
||||
|
||||
public static class Provider extends ProviderAutoAllocate<DataAchromatic> {
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.Map;
|
||||
* Gadomancy is Open Source and distributed under the
|
||||
* GNU LESSER GENERAL PUBLIC LICENSE
|
||||
* for more read the LICENSE file
|
||||
* <p/>
|
||||
*
|
||||
* Created by HellFirePvP @ 14.12.2015 22:06
|
||||
*/
|
||||
public class DataFamiliar extends AbstractData {
|
||||
@@ -82,6 +82,11 @@ public class DataFamiliar extends AbstractData {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsUpdate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeAllDataToPacket(NBTTagCompound compound) {
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
@@ -60,7 +60,7 @@ public class SyncDataHolder {
|
||||
PacketHandler.INSTANCE.sendTo(dataSync, (net.minecraft.entity.player.EntityPlayerMP) player);
|
||||
}
|
||||
|
||||
public static void recieveServerPacket(Map<String, AbstractData> data) {
|
||||
public static void receiveServerPacket(Map<String, AbstractData> data) {
|
||||
for(String key : data.keySet()) {
|
||||
AbstractData dat = clientData.get(key);
|
||||
if(dat != null) {
|
||||
@@ -74,8 +74,11 @@ public class SyncDataHolder {
|
||||
Map<String, AbstractData> pktData = new HashMap<String, AbstractData>();
|
||||
for(String s : dirtyData) {
|
||||
AbstractData d = getDataServer(s);
|
||||
pktData.put(s, d);
|
||||
if(d.needsUpdate()) {
|
||||
pktData.put(s, d);
|
||||
}
|
||||
}
|
||||
dirtyData.clear();
|
||||
PacketSyncData dataSync = new PacketSyncData(pktData, false);
|
||||
PacketHandler.INSTANCE.sendToAll(dataSync);
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public class PacketSyncData implements IMessage, IMessageHandler<PacketSyncData,
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketSyncData message, MessageContext ctx) {
|
||||
SyncDataHolder.recieveServerPacket(message.data);
|
||||
SyncDataHolder.receiveServerPacket(message.data);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user