use of com.minecolonies.api.colony.requestsystem.location.ILocation in project minecolonies by Minecolonies.
the class DeliveryRequestResolverFactory method deserialize.
@NotNull
@Override
public DeliveryRequestResolver deserialize(@NotNull final IFactoryController controller, @NotNull final NBTTagCompound nbt) {
final IToken token = controller.deserialize(nbt.getCompoundTag(NBT_TOKEN));
final ILocation location = controller.deserialize(nbt.getCompoundTag(NBT_LOCATION));
return new DeliveryRequestResolver(location, token);
}
use of com.minecolonies.api.colony.requestsystem.location.ILocation in project minecolonies by Minecolonies.
the class StandardRetryingRequestResolverFactory method deserialize.
@NotNull
@Override
public StandardRetryingRequestResolver deserialize(@NotNull final IFactoryController controller, @NotNull final NBTTagCompound nbt) {
final Map<IToken<?>, Integer> assignments = NBTUtils.streamCompound(nbt.getTagList(NBT_TRIES, Constants.NBT.TAG_COMPOUND)).map(assignmentCompound -> {
IToken token = controller.deserialize(assignmentCompound.getCompoundTag(NBT_TOKEN));
Integer tries = assignmentCompound.getInteger(NBT_VALUE);
return new HashMap.SimpleEntry<>(token, tries);
}).collect(Collectors.toMap(HashMap.SimpleEntry::getKey, HashMap.SimpleEntry::getValue));
final Map<IToken<?>, Integer> delays = NBTUtils.streamCompound(nbt.getTagList(NBT_DELAYS, Constants.NBT.TAG_COMPOUND)).map(assignmentCompound -> {
IToken token = controller.deserialize(assignmentCompound.getCompoundTag(NBT_TOKEN));
Integer tries = assignmentCompound.getInteger(NBT_VALUE);
return new HashMap.SimpleEntry<>(token, tries);
}).collect(Collectors.toMap(HashMap.SimpleEntry::getKey, HashMap.SimpleEntry::getValue));
final IToken<?> token = controller.deserialize(nbt.getCompoundTag(NBT_TOKEN));
final ILocation location = controller.deserialize(nbt.getCompoundTag(NBT_LOCATION));
final StandardRetryingRequestResolver retryingRequestResolver = new StandardRetryingRequestResolver(token, location);
retryingRequestResolver.updateData(assignments, delays);
return retryingRequestResolver;
}
use of com.minecolonies.api.colony.requestsystem.location.ILocation in project minecolonies by Minecolonies.
the class BuildingBasedRequester method deserialize.
public static BuildingBasedRequester deserialize(final IFactoryController controller, final NBTTagCompound compound) {
final ILocation location = controller.deserialize(compound.getCompoundTag(NBT_LOCATION));
final IToken<?> token = controller.deserialize(compound.getCompoundTag(NBT_ID));
return new BuildingBasedRequester(location, token);
}
use of com.minecolonies.api.colony.requestsystem.location.ILocation in project minecolonies by Minecolonies.
the class BuildingBasedRequesterFactory method getNewInstance.
@NotNull
@Override
public BuildingBasedRequester getNewInstance(@NotNull final IFactoryController factoryController, @NotNull final AbstractBuilding building, @NotNull final Object... context) throws IllegalArgumentException {
if (context.length != 0) {
throw new IllegalArgumentException("To many context elements. Only 0 supported.");
}
final ILocation location = factoryController.getNewInstance(TypeConstants.ILOCATION, building.getLocation(), building.getColony().getWorld().provider.getDimension());
final IToken token = factoryController.getNewInstance(TypeConstants.ITOKEN);
return new BuildingBasedRequester(location, token);
}
use of com.minecolonies.api.colony.requestsystem.location.ILocation in project minecolonies by Minecolonies.
the class Delivery method deserialize.
@NotNull
public static Delivery deserialize(@NotNull final IFactoryController controller, @NotNull final NBTTagCompound compound) {
final ILocation start = controller.deserialize(compound.getCompoundTag(NBT_START));
final ILocation target = controller.deserialize(compound.getCompoundTag(NBT_TARGET));
final ItemStack stack = ItemStackUtils.deserializeFromNBT(compound.getCompoundTag(NBT_STACK));
return new Delivery(start, target, stack);
}
Aggregations