use of com.minecolonies.api.research.effects.IResearchEffectManager in project minecolonies by Minecolonies.
the class LocalResearchTree method readFromNBT.
@Override
public void readFromNBT(final CompoundNBT compound, final IResearchEffectManager effects) {
researchTree.clear();
inProgress.clear();
isComplete.clear();
maxLevelResearchCompleted.clear();
NBTUtils.streamCompound(compound.getList(TAG_RESEARCH_TREE, Constants.NBT.TAG_COMPOUND)).map(researchCompound -> (ILocalResearch) StandardFactoryController.getInstance().deserialize(researchCompound)).forEach(research -> {
// / region Updated ID helper.
if (!MinecoloniesAPIProxy.getInstance().getGlobalResearchTree().hasResearch(research.getBranch(), research.getId())) {
if (ResearchCompatMap.updateMap.containsKey(research.getId().getPath())) {
final ResearchState currentState = research.getState();
final int progress = research.getProgress();
research = new LocalResearch(ResearchCompatMap.updateMap.get(research.getId().getPath()), new ResourceLocation(com.minecolonies.api.util.constant.Constants.MOD_ID, research.getBranch().getPath()), research.getDepth());
research.setState(currentState);
research.setProgress(progress);
Log.getLogger().warn("Research " + research.getId().getPath() + " was in colony save file, and was updated to " + research.getId());
} else if (research.getBranch().getNamespace().contains("minecraft")) {
final ResearchState currentState = research.getState();
final int progress = research.getProgress();
research = new LocalResearch(new ResourceLocation(com.minecolonies.api.util.constant.Constants.MOD_ID, research.getId().getPath()), new ResourceLocation(com.minecolonies.api.util.constant.Constants.MOD_ID, research.getBranch().getPath()), research.getDepth());
research.setState(currentState);
research.setProgress(progress);
} else {
if (MinecoloniesAPIProxy.getInstance().getConfig().getServer().researchDebugLog.get()) {
Log.getLogger().warn("Research " + research.getId() + " was in colony save file, but was not in CompatMap.");
}
}
}
if (research.getState() == ResearchState.FINISHED) {
// or to have a different research that was in a now-removed data pack. But those will get just thrown away.
if (MinecoloniesAPIProxy.getInstance().getGlobalResearchTree().hasResearch(research.getBranch(), research.getId())) {
for (final IResearchEffect<?> effect : MinecoloniesAPIProxy.getInstance().getGlobalResearchTree().getResearch(research.getBranch(), research.getId()).getEffects()) {
effects.applyEffect(effect);
}
} else {
if (MinecoloniesAPIProxy.getInstance().getConfig().getServer().researchDebugLog.get()) {
Log.getLogger().warn("Research " + research.getId() + " was in colony save file, but not found as valid current research. Progress on this research may be reset.");
}
}
}
addResearch(research.getBranch(), research);
});
}
use of com.minecolonies.api.research.effects.IResearchEffectManager in project minecolonies by ldtteam.
the class LocalResearchTree method readFromNBT.
@Override
public void readFromNBT(final CompoundNBT compound, final IResearchEffectManager effects) {
researchTree.clear();
inProgress.clear();
isComplete.clear();
maxLevelResearchCompleted.clear();
NBTUtils.streamCompound(compound.getList(TAG_RESEARCH_TREE, Constants.NBT.TAG_COMPOUND)).map(researchCompound -> (ILocalResearch) StandardFactoryController.getInstance().deserialize(researchCompound)).forEach(research -> {
// / region Updated ID helper.
if (!MinecoloniesAPIProxy.getInstance().getGlobalResearchTree().hasResearch(research.getBranch(), research.getId())) {
if (ResearchCompatMap.updateMap.containsKey(research.getId().getPath())) {
final ResearchState currentState = research.getState();
final int progress = research.getProgress();
research = new LocalResearch(ResearchCompatMap.updateMap.get(research.getId().getPath()), new ResourceLocation(com.minecolonies.api.util.constant.Constants.MOD_ID, research.getBranch().getPath()), research.getDepth());
research.setState(currentState);
research.setProgress(progress);
Log.getLogger().warn("Research " + research.getId().getPath() + " was in colony save file, and was updated to " + research.getId());
} else if (research.getBranch().getNamespace().contains("minecraft")) {
final ResearchState currentState = research.getState();
final int progress = research.getProgress();
research = new LocalResearch(new ResourceLocation(com.minecolonies.api.util.constant.Constants.MOD_ID, research.getId().getPath()), new ResourceLocation(com.minecolonies.api.util.constant.Constants.MOD_ID, research.getBranch().getPath()), research.getDepth());
research.setState(currentState);
research.setProgress(progress);
} else {
if (MinecoloniesAPIProxy.getInstance().getConfig().getServer().researchDebugLog.get()) {
Log.getLogger().warn("Research " + research.getId() + " was in colony save file, but was not in CompatMap.");
}
}
}
if (research.getState() == ResearchState.FINISHED) {
// or to have a different research that was in a now-removed data pack. But those will get just thrown away.
if (MinecoloniesAPIProxy.getInstance().getGlobalResearchTree().hasResearch(research.getBranch(), research.getId())) {
for (final IResearchEffect<?> effect : MinecoloniesAPIProxy.getInstance().getGlobalResearchTree().getResearch(research.getBranch(), research.getId()).getEffects()) {
effects.applyEffect(effect);
}
} else {
if (MinecoloniesAPIProxy.getInstance().getConfig().getServer().researchDebugLog.get()) {
Log.getLogger().warn("Research " + research.getId() + " was in colony save file, but not found as valid current research. Progress on this research may be reset.");
}
}
}
addResearch(research.getBranch(), research);
});
}
Aggregations