Search in sources :

Example 11 with ILocation

use of com.minecolonies.api.colony.requestsystem.location.ILocation in project minecolonies by Minecolonies.

the class PrivateWorkerCraftingRequestResolverFactory method deserialize.

@NotNull
@Override
public PrivateWorkerCraftingRequestResolver 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 PrivateWorkerCraftingRequestResolver(location, token);
}
Also used : ILocation(com.minecolonies.api.colony.requestsystem.location.ILocation) PrivateWorkerCraftingRequestResolver(com.minecolonies.coremod.colony.requestsystem.resolvers.PrivateWorkerCraftingRequestResolver) NotNull(org.jetbrains.annotations.NotNull)

Example 12 with ILocation

use of com.minecolonies.api.colony.requestsystem.location.ILocation in project minecolonies by Minecolonies.

the class StandardPlayerRequestResolverFactory method getNewInstance.

@NotNull
@Override
public StandardPlayerRequestResolver getNewInstance(@NotNull final IFactoryController factoryController, @NotNull final IRequestManager iRequestManager, @NotNull final Object... context) throws IllegalArgumentException {
    final ILocation location;
    try {
        location = factoryController.getNewInstance(TypeConstants.ILOCATION, iRequestManager.getColony().getCenter(), iRequestManager.getColony().getWorld().provider.getDimension());
    } catch (final Exception ex) {
        throw ex;
    }
    final IToken<?> token = factoryController.getNewInstance(TypeConstants.ITOKEN, iRequestManager.getColony().getID() * CONST_PLAYER_RESOLVER_ID_SCALE);
    return new StandardPlayerRequestResolver(location, token);
}
Also used : ILocation(com.minecolonies.api.colony.requestsystem.location.ILocation) StandardPlayerRequestResolver(com.minecolonies.coremod.colony.requestsystem.resolvers.StandardPlayerRequestResolver) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with ILocation

use of com.minecolonies.api.colony.requestsystem.location.ILocation in project minecolonies by Minecolonies.

the class StandardPlayerRequestResolverFactory method deserialize.

@NotNull
@Override
public StandardPlayerRequestResolver 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));
    final Set<IToken<?>> assignedRequests = NBTUtils.streamCompound(nbt.getTagList(NBT_ASSIGNED_REQUESTS, Constants.NBT.TAG_COMPOUND)).map(c -> (IToken<?>) controller.deserialize(c)).collect(Collectors.toSet());
    final StandardPlayerRequestResolver resolver = new StandardPlayerRequestResolver(location, token);
    resolver.setAllAssignedRequests(assignedRequests);
    return resolver;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ILocation(com.minecolonies.api.colony.requestsystem.location.ILocation) StandardPlayerRequestResolver(com.minecolonies.coremod.colony.requestsystem.resolvers.StandardPlayerRequestResolver) Constants(net.minecraftforge.common.util.Constants) IToken(com.minecolonies.api.colony.requestsystem.token.IToken) Set(java.util.Set) TypeToken(com.google.common.reflect.TypeToken) IFactoryController(com.minecolonies.api.colony.requestsystem.factory.IFactoryController) Collectors(java.util.stream.Collectors) IRequestManager(com.minecolonies.api.colony.requestsystem.manager.IRequestManager) IFactory(com.minecolonies.api.colony.requestsystem.factory.IFactory) TypeConstants(com.minecolonies.api.util.constant.TypeConstants) NBTUtils(com.minecolonies.api.util.NBTUtils) NotNull(org.jetbrains.annotations.NotNull) ILocation(com.minecolonies.api.colony.requestsystem.location.ILocation) IToken(com.minecolonies.api.colony.requestsystem.token.IToken) StandardPlayerRequestResolver(com.minecolonies.coremod.colony.requestsystem.resolvers.StandardPlayerRequestResolver) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with ILocation

use of com.minecolonies.api.colony.requestsystem.location.ILocation in project minecolonies by Minecolonies.

the class WarehouseRequestResolverFactory method deserialize.

@NotNull
@Override
public WarehouseRequestResolver 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 WarehouseRequestResolver(location, token);
}
Also used : ILocation(com.minecolonies.api.colony.requestsystem.location.ILocation) IToken(com.minecolonies.api.colony.requestsystem.token.IToken) WarehouseRequestResolver(com.minecolonies.coremod.colony.requestsystem.resolvers.WarehouseRequestResolver) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ILocation (com.minecolonies.api.colony.requestsystem.location.ILocation)14 NotNull (org.jetbrains.annotations.NotNull)10 IToken (com.minecolonies.api.colony.requestsystem.token.IToken)7 Collectors (java.util.stream.Collectors)3 ItemStack (net.minecraft.item.ItemStack)3 Nullable (org.jetbrains.annotations.Nullable)3 TypeToken (com.google.common.reflect.TypeToken)2 IFactory (com.minecolonies.api.colony.requestsystem.factory.IFactory)2 IFactoryController (com.minecolonies.api.colony.requestsystem.factory.IFactoryController)2 IRequestManager (com.minecolonies.api.colony.requestsystem.manager.IRequestManager)2 IRequest (com.minecolonies.api.colony.requestsystem.request.IRequest)2 Delivery (com.minecolonies.api.colony.requestsystem.requestable.Delivery)2 NBTUtils (com.minecolonies.api.util.NBTUtils)2 Colony (com.minecolonies.coremod.colony.Colony)2 BuildingBasedRequester (com.minecolonies.coremod.colony.requestsystem.requesters.BuildingBasedRequester)2 StandardPlayerRequestResolver (com.minecolonies.coremod.colony.requestsystem.resolvers.StandardPlayerRequestResolver)2 TileEntityColonyBuilding (com.minecolonies.coremod.tileentities.TileEntityColonyBuilding)2 TileEntity (net.minecraft.tileentity.TileEntity)2 TileEntityChest (net.minecraft.tileentity.TileEntityChest)2 BlockPos (net.minecraft.util.math.BlockPos)2