Skip to content

Commit

Permalink
Concrete mixer can do multiple things before going back to the hut (#…
Browse files Browse the repository at this point in the history
…10331)

Concrete mixer can do multiple things before going back to the hut
  • Loading branch information
Raycoms committed Nov 27, 2024
1 parent 87d8ff6 commit 8ac9d05
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 113 deletions.
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.api.util.NBTUtils;
Expand Down Expand Up @@ -53,11 +52,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 @@ -83,7 +77,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 @@ -125,7 +118,6 @@ public void deserializeNBT(@NotNull final HolderLookup.Provider provider, final
{
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_INT_ARRAY);
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();
}
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))
{
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

0 comments on commit 8ac9d05

Please sign in to comment.