8000 Some pickup changes & UI include warehouse list by Raycoms · Pull Request #9992 · ldtteam/minecolonies · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Some pickup changes & UI include warehouse list #9992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,10 @@ <R> ImmutableList<IRequest<? extends R>> getOpenRequestsOfTypeFiltered(
* Creates a pickup request for the building. It will make sure that only one pickup request exists per building, so it's safe to call multiple times. The call will return
* false if a pickup request already exists, or if the priority is not within the proper range, or if the pickup priority is set to NEVER (0).
*
* @param scaledPriority The priority of the pickup request. This value is considered already scaled!
* @param daysToPickup The priority of the pickup request. How many days it takes to be enacted!
* @return true if a pickup request could be created, false if not.
*/
boolean createPickupRequest(final int scaledPriority);
boolean createPickupRequest(final int daysToPickup);

@Override
ImmutableCollection<IRequestResolver<?>> getResolvers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ public abstract class AbstractDeliverymanRequestable implements IDeliverymanRequ
protected static final String NBT_PRIORITY = "Priority";
////// --------------------------- NBTConstants --------------------------- \\\\\\

private static final int MAX_BUILDING_PRIORITY = 10;
private static final int DEFAULT_DELIVERY_PRIORITY = 13;
private static final int MAX_AGING_PRIORITY = 14;
public static final int MAX_BUILDING_PRIORITY = 10;
protected static final int DEFAULT_DELIVERY_PRIORITY = 13;
private static final int MAX_AGING_PRIORITY = 14;
private static final int PLAYER_ACTION_PRIORITY = 15;

protected int priority = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
import java.util.function.Predicate;
import java.util.stream.Collectors;

import static com.minecolonies.api.colony.requestsystem.requestable.deliveryman.AbstractDeliverymanRequestable.MAX_BUILDING_PRIORITY;
import static com.minecolonies.api.colony.requestsystem.requestable.deliveryman.AbstractDeliverymanRequestable.getPlayerActionPriority;
import static com.minecolonies.api.util.constant.BuildingConstants.CONST_DEFAULT_MAX_BUILDING_LEVEL;
import static com.minecolonies.api.util.constant.BuildingConstants.NO_WORK_ORDER;
Expand Down Expand Up @@ -150,6 +151,11 @@ public abstract class AbstractBuilding extends AbstractBuildingContainer
protected List<IBuildingModule> modules = new ArrayList<>();
protected Int2ObjectOpenHashMap<IBuildingModule> modulesMap = new Int2ObjectOpenHashMap<>();

/**
* Day the next pickup should happen.
*/
public int pickUpDay = -1;

/**
* Constructor for a AbstractBuilding.
*
Expand Down Expand Up @@ -1514,13 +1520,20 @@ public <R> ImmutableList<IRequest<? extends R>> getOpenRequestsOfType(
}

@Override
public boolean createPickupRequest(final int scaledPriority)
public boolean createPickupRequest(final int daysToPickup)
{
if (scaledPriority < 0 || scaledPriority > getPlayerActionPriority(true))
if (pickUpDay == -1 || pickUpDay > colony.getDay() + daysToPickup)
{
pickUpDay = colony.getDay() + daysToPickup;
}

if (colony.getDay() < pickUpDay)
{
return false;
}

pickUpDay = -1;

final List<IToken<?>> reqs = new ArrayList<>(getOpenRequestsByRequestableType().getOrDefault(TypeConstants.PICKUP, Collections.emptyList()));
if (!reqs.isEmpty())
{
Expand All @@ -1539,7 +1552,7 @@ public boolean createPickupRequest(final int scaledPriority)
return false;
}

createRequest(new Pickup(scaledPriority), true);
createRequest(new Pickup(MAX_BUILDING_PRIORITY), true);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public abstract class AbstractBuildingContainer extends AbstractSchematicProvide
/**
* Priority of the building in the pickUpList. This is the unscaled value (mainly for a more intuitive GUI).
*/
private int unscaledPickUpPriority = 1;
private int unscaledPickUpPriority = 5;

/**
* The constructor for the building container.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.minecolonies.api.util.constant.ToolLevelConstants;
import com.minecolonies.api.util.constant.TranslationConstants;
import com.minecolonies.api.util.constant.translation.RequestSystemTranslationConstants;
import com.minecolonies.core.colony.buildings.modules.BuildingModules;
import com.minecolonies.core.colony.buildings.moduleviews.WorkerBuildingModuleView;
import com.minecolonies.core.colony.jobs.views.CrafterJobView;
import com.minecolonies.core.colony.jobs.views.DmanJobView;
Expand Down Expand Up @@ -285,6 +286,14 @@ public List<MutableComponent> getResolverToolTip(final IColonyView colony)
break;
}
}
else if (view.getBuildingType() == ModBuildings.wareHouse.get())
{
posInList = view.getModuleView(BuildingModules.WAREHOUSE_REQUEST_QUEUE).getTasks().indexOf(getId());
if (posInList >= 0)
{
break;
}
}
}

if (posInList >= 0)
Expand Down Expand Up @@ -364,6 +373,14 @@ public List<MutableComponent> getResolverToolTip(final IColonyView colony)
break;
}
}
else if (view.getBuildingType() == ModBuildings.wareHouse.get())
{
posInList = view.getModuleView(BuildingModules.WAREHOUSE_REQUEST_QUEUE).getTasks().indexOf(getId());
if (posInList >= 0)
{
break;
}
}
}

if (posInList >= 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public abstract class AbstractEntityAIBasic<J extends AbstractJob<?, J>, B exten
/**
* Indicator if something has actually been dumped.
*/
private boolean hasDumpedItems = false;
private int dumpedItems = 0;

/**
* Delay for walking.
Expand Down Expand Up @@ -1106,7 +1106,7 @@ private IAIState dumpInventory()
if (building.getPickUpPriority() > 0)
{
building.createPickupRequest(getMaxBuildingPriority(true));
hasDumpedItems = false;
dumpedItems = 0;
}
alreadyKept.clear();
slotAt = 0;
Expand All @@ -1122,12 +1122,20 @@ else if (dumpOneMoreSlot())
slotAt = 0;
this.clearActionsDone();

if (isAfterDumpPickupAllowed() && building.getPickUpPriority() > 0 && hasDumpedItems)
// Worker is not currently crafting, pickup is allowed.
// Note that this will not create a pickup request when another request is already in progress.
if (isAfterDumpPickupAllowed() && building.getPickUpPriority() > 0 && dumpedItems > 0)
{
// Worker is not currently crafting, pickup is allowed.
// Note that this will not create a pickup request when another request is already in progress.
building.createPickupRequest(scaledPriority(building.getPickUpPriority()));
hasDumpedItems = false;
// Only create a pickup request probabilistically.
if (worker.getRandom().nextInt(STACKSIZE * 2) < dumpedItems)
{
building.createPickupRequest(0);
}
else
{
building.createPickupRequest(10 - building.getPickUpPriority());
}
dumpedItems = 0;
}
return afterDump();
}
Expand Down Expand Up @@ -1212,7 +1220,7 @@ private boolean dumpOneMoreSlot()
worker.setItemInHand(InteractionHand.OFF_HAND, ItemStack.EMPTY);
}

hasDumpedItems = true;
dumpedItems += amount;
}
}
slotAt++;
Expand Down
0