use of com.teamwizardry.wizardry.common.network.PacketSyncWorktable in project Wizardry by TeamWizardry.
the class WorktableGui method syncToServer.
public void syncToServer() {
Set<CommonWorktableModule> commonModules = new HashSet<>();
for (TableModule head : getSpellHeads()) {
TableModule lastModule = head;
CommonWorktableModule lastCommonModule = new CommonWorktableModule(lastModule.hashCode(), lastModule.getModule(), lastModule.getPos(), null, new HashMap<>());
commonModules.add(lastCommonModule);
while (lastModule != null) {
if (lastModule != head) {
CommonWorktableModule commonModule = new CommonWorktableModule(lastModule.hashCode(), lastModule.getModule(), lastModule.getPos(), null, new HashMap<>());
lastCommonModule.setLinksTo(commonModule);
lastCommonModule = commonModule;
}
for (ModuleInstance module : ModuleRegistry.INSTANCE.getModules(ModuleType.MODIFIER)) {
if (!(module instanceof ModuleInstanceModifier))
continue;
if (!lastModule.hasData(Integer.class, module.getNBTKey()))
continue;
int count = lastModule.getData(Integer.class, module.getNBTKey());
lastCommonModule.addModifier((ModuleInstanceModifier) module, count);
}
lastModule = lastModule.getLinksTo();
}
}
int dim = Minecraft.getMinecraft().world.provider.getDimension();
PacketHandler.NETWORK.sendToServer(new PacketSyncWorktable(dim, pos, commonModules));
}
Aggregations