Skip to content
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

Concrete mixer can do multiple things before going back to the hut #10331

Merged
merged 4 commits into from
Nov 24, 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 @@ -653,7 +653,21 @@ public enum AIWorkerState implements IAIState
/**
* Harvest the netherwart.
*/
HARVEST_NETHERWART(true);
HARVEST_NETHERWART(true),

/*
###Concrete mixers###
*/

/**
* Continues placing blocks until can't place anymore.
*/
CONCRETE_MIXER_PLACING(true),

/**
* Harvest all blocks placed in the water.
*/
CONCRETE_MIXER_HARVESTING(true);

/**
* Is it okay to eat.
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/minecolonies/api/items/ModTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.minecolonies.api.util.constant.TagConstants;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BiomeTags;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.minecolonies.api.colony.IColony;
import com.minecolonies.api.colony.jobs.registry.JobEntry;
import com.minecolonies.api.colony.requestsystem.token.IToken;
import com.minecolonies.api.items.ModTags;
import com.minecolonies.api.equipment.ModEquipmentTypes;
import com.minecolonies.api.util.ItemStackUtils;
import com.minecolonies.core.colony.buildings.AbstractBuilding;
Expand Down Expand Up @@ -51,11 +50,6 @@ public class BuildingConcreteMixer extends AbstractBuilding
*/
private final Map<Integer, List<BlockPos>> waterPos = new HashMap<>();

/**
* The minimum found water level
*/
private int minWaterLevel = WATER_DEPTH_SUPPORT;

/**
* Instantiates a new concrete mason building.
*
Expand All @@ -81,7 +75,6 @@ public void registerBlockPosition(@NotNull final BlockState blockState, @NotNull
fluidPos.add(pos);
}
waterPos.put(blockState.getFluidState().getAmount(), fluidPos);
minWaterLevel = Math.min(minWaterLevel, blockState.getFluidState().getAmount());
}
}

Expand Down Expand Up @@ -123,7 +116,6 @@ public void deserializeNBT(final CompoundTag compound)
{
final CompoundTag waterCompound = waterMapList.getCompound(i);
final int level = waterCompound.getInt(TAG_LEVEL);
minWaterLevel = Math.min(minWaterLevel, level);

final ListTag waterTagList = waterCompound.getList(TAG_WATER, Tag.TAG_COMPOUND);
final List<BlockPos> water = new ArrayList<>();
Expand Down Expand Up @@ -154,6 +146,21 @@ public int getMaxBuildingLevel()
return CONST_DEFAULT_MAX_BUILDING_LEVEL;
}

/**
* Get the max amount of concrete placed at once.
*
* @return the number of concrete.
*/
public int getMaxConcretePlaced()
{
int size = 0;
for (List<BlockPos> positions : waterPos.values())
{
size += positions.size();
Raycoms marked this conversation as resolved.
Show resolved Hide resolved
}
return size;
}

/**
* Check if there are open positions to mine.
*
Expand All @@ -162,17 +169,18 @@ public int getMaxBuildingLevel()
@Nullable
public BlockPos getBlockToMine()
{
for (int i = 1; i <= minWaterLevel; i++)
for (int i = 1; i <= WATER_DEPTH_SUPPORT; i++)
{
for (final BlockPos pos : waterPos.getOrDefault(i, Collections.emptyList()))
{
if (colony.getWorld().getBlockState(pos).is(ModTags.concreteBlocks))
final BlockState state = colony.getWorld().getBlockState(pos);
if (!state.isAir() && !state.is(Blocks.WATER))
{
return pos;
}
}
}

return null;
}

Expand All @@ -184,18 +192,18 @@ public BlockPos getBlockToMine()
@Nullable
public BlockPos getBlockToPlace()
{
for (int i = 1; i <= minWaterLevel; i++)
for (int i = 1; i <= WATER_DEPTH_SUPPORT; i++)
{
for (final BlockPos pos : waterPos.getOrDefault(i, Collections.emptyList()))
{
final BlockState state = colony.getWorld().getBlockState(pos);
if (!state.getFluidState().isEmpty() && state.getBlock() == Blocks.WATER)
if (state.is(Blocks.WATER))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flowing water is not water though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I tested this, and it is.

If a block contains flowing water the block is still marked as containing water, the fluid state however just lists a different water depth.
There's no need for a depth check because the waterPos already has determined the required water level should be good in the schematic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please double check this. Because at least in some cases as far as I am aware, if air gets some low level water into it, it's fluidstate not empty, but actual state is not water.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if that is the case with low level water, then it's a non issue, because we only support up to a max depth of 5, and it worked correctly for every depth we support.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference I had a debugger out, and every level it's blockstate was set to being the actual block of water, disregarding how high the water actually was

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've double checked it again and it works fine. On top of that we already calculate the actual positions during construction, so I need not worry about calculating the depth of the water because the position itself is calculated to have water in it.
So that means we know the position is valid, so as long as there's then some water in it again, we're fine.

{
return pos;
}
}
}

return null;
}

Expand All @@ -210,7 +218,7 @@ public int outputBlockCountInWorld(final ItemStack primaryOutput)
int count = 0;
if (primaryOutput.getItem() instanceof BlockItem)
{
for (int i = 1; i <= minWaterLevel; i++)
for (int i = 1; i <= WATER_DEPTH_SUPPORT; i++)
{
for (final BlockPos pos : waterPos.getOrDefault(i, Collections.emptyList()))
{
Expand Down
Loading