-
-
Notifications
You must be signed in to change notification settings - Fork 342
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
base: version/main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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. | ||
* | ||
|
@@ -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()); | ||
} | ||
} | ||
|
||
|
@@ -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<>(); | ||
|
@@ -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. | ||
* | ||
|
@@ -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; | ||
} | ||
|
||
|
@@ -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)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. flowing water is not water though There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
{ | ||
return pos; | ||
} | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
|
@@ -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())) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The positions stored in the map contain the depth as the key, and the positions of the water at the given level.
By the way the code looks it's technically allowed to have several water streams at the same time, there's no practical limit on this.