use of com.minecolonies.api.colony.buildings.modules.settings.ISettingKey in project minecolonies by Minecolonies.
the class SettingsModule method deserializeNBT.
@Override
public void deserializeNBT(final CompoundNBT compound) {
final CompoundNBT settingsCompound = compound.getCompound("settings");
final ListNBT list = settingsCompound.getList("settingslist", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < list.size(); i++) {
final CompoundNBT entryCompound = list.getCompound(i);
final ResourceLocation key = new ResourceLocation(entryCompound.getString("key"));
try {
final ISetting setting = StandardFactoryController.getInstance().deserialize(entryCompound.getCompound("value"));
final ISettingKey<?> settingsKey = new SettingKey<>(setting.getClass(), key);
if (settings.containsKey(settingsKey)) {
settings.put(settingsKey, setting);
}
} catch (final IllegalArgumentException ex) {
Log.getLogger().warn("Detected Removed Setting");
}
}
}
use of com.minecolonies.api.colony.buildings.modules.settings.ISettingKey in project minecolonies by Minecolonies.
the class SettingsModule method serializeNBT.
@Override
public void serializeNBT(final CompoundNBT compound) {
final CompoundNBT settingsCompound = new CompoundNBT();
final ListNBT list = new ListNBT();
for (final Map.Entry<ISettingKey<?>, ISetting> setting : settings.entrySet()) {
final CompoundNBT entryCompound = new CompoundNBT();
entryCompound.putString("key", setting.getKey().getUniqueId().toString());
entryCompound.put("value", StandardFactoryController.getInstance().serialize(setting.getValue()));
list.add(entryCompound);
}
settingsCompound.put("settingslist", list);
compound.put("settings", settingsCompound);
}
use of com.minecolonies.api.colony.buildings.modules.settings.ISettingKey in project minecolonies by ldtteam.
the class SettingsModule method deserializeNBT.
@Override
public void deserializeNBT(final CompoundNBT compound) {
final CompoundNBT settingsCompound = compound.getCompound("settings");
final ListNBT list = settingsCompound.getList("settingslist", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < list.size(); i++) {
final CompoundNBT entryCompound = list.getCompound(i);
final ResourceLocation key = new ResourceLocation(entryCompound.getString("key"));
try {
final ISetting setting = StandardFactoryController.getInstance().deserialize(entryCompound.getCompound("value"));
final ISettingKey<?> settingsKey = new SettingKey<>(setting.getClass(), key);
if (settings.containsKey(settingsKey)) {
settings.put(settingsKey, setting);
}
} catch (final IllegalArgumentException ex) {
Log.getLogger().warn("Detected Removed Setting");
}
}
}
use of com.minecolonies.api.colony.buildings.modules.settings.ISettingKey in project minecolonies by Minecolonies.
the class GuardTaskSetting method render.
@Override
public void render(final ISettingKey<?> key, final Pane pane, final ISettingsModuleView settingsModuleView, final IBuildingView building, final Window window) {
final String setting = getSettings().get(getCurrentIndex());
final ButtonImage targetButton = pane.findPaneOfTypeByID("setTarget", ButtonImage.class);
final Text mineLabel = pane.findPaneOfTypeByID("minePos", Text.class);
if (setting.equals(PATROL_MINE) && building instanceof AbstractBuildingGuards.View) {
mineLabel.setVisible(true);
if (((AbstractBuildingGuards.View) building).getMinePos() != null) {
mineLabel.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.worherhuts.patrollingmine", ((AbstractBuildingGuards.View) building).getMinePos().toShortString()));
} else {
mineLabel.setText(new TranslationTextComponent("com.minecolonies.coremod.job.guard.assignmine"));
}
targetButton.setVisible(false);
} else if (!setting.equals(FOLLOW)) {
mineLabel.setVisible(false);
targetButton.setVisible(true);
if (setting.equals(PATROL)) {
if (!settingsModuleView.getSetting(AbstractBuildingGuards.PATROL_MODE).getValue().equals(PatrolModeSetting.MANUAL)) {
targetButton.setVisible(false);
} else {
targetButton.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.workerhuts.targetpatrol"));
}
} else {
targetButton.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.workerhuts.targetguard"));
}
targetButton.setHandler(button -> building.getModuleView(ToolModuleView.class).getWindow().open());
} else {
mineLabel.setVisible(false);
targetButton.setVisible(false);
}
pane.findPaneOfTypeByID("trigger", ButtonImage.class).setText(new TranslationTextComponent(setting));
}
use of com.minecolonies.api.colony.buildings.modules.settings.ISettingKey in project minecolonies by ldtteam.
the class SettingsModule method serializeNBT.
@Override
public void serializeNBT(final CompoundNBT compound) {
final CompoundNBT settingsCompound = new CompoundNBT();
final ListNBT list = new ListNBT();
for (final Map.Entry<ISettingKey<?>, ISetting> setting : settings.entrySet()) {
final CompoundNBT entryCompound = new CompoundNBT();
entryCompound.putString("key", setting.getKey().getUniqueId().toString());
entryCompound.put("value", StandardFactoryController.getInstance().serialize(setting.getValue()));
list.add(entryCompound);
}
settingsCompound.put("settingslist", list);
compound.put("settings", settingsCompound);
}
Aggregations