Skip to content
Open
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 @@ -33,9 +33,9 @@ public final class BuildingConstants
public static final String TAG_LEVELS = "levels";

/**
* The NBT Tag to store the location of the cobblestone at the shaft.
* The NBT Tag to store the location of the block behind the ladder at the shaft.
*/
public static final String TAG_CLOCATION = "cobblelocation";
public static final String TAG_LBLOCATION = "ladderbacklocation";

/**
* The NBT Tag to store the active node the miner is working on.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class SchematicTagConstants
/**
* Miner tags
*/
public static final String TAG_COBBLE = "cobble";
public static final String TAG_LADDER_BACK = "cobble";
public static final String TAG_LADDER = "ladder";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static void init()
citizen -> citizen.getWorkBuilding() instanceof BuildingFarmer && citizen.getWorkBuilding().getModule(BuildingModules.FARMER_FIELDS).hasNoExtensions());

InteractionValidatorRegistry.registerStandardPredicate(Component.translatable(INVALID_MINESHAFT),
citizen -> citizen.getWorkBuilding() instanceof BuildingMiner && citizen.getJob() instanceof JobMiner && (((BuildingMiner) citizen.getWorkBuilding()).getCobbleLocation() == null || ((BuildingMiner) citizen.getWorkBuilding()).getLadderLocation() == null));
citizen -> citizen.getWorkBuilding() instanceof BuildingMiner && citizen.getJob() instanceof JobMiner && (((BuildingMiner) citizen.getWorkBuilding()).getLadderBackLocation() == null || ((BuildingMiner) citizen.getWorkBuilding()).getLadderLocation() == null));

InteractionValidatorRegistry.registerStandardPredicate(Component.translatable(COM_MINECOLONIES_COREMOD_ENTITY_WORKER_INVENTORYFULLCHEST),
citizen -> citizen.getWorkBuilding() != null && InventoryUtils.isBuildingFull(citizen.getWorkBuilding()));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/minecolonies/core/MineColonies.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public MineColonies()
TagManager.registerSpecificTagOption(TAG_KNIGHT, b -> b instanceof BlockHutGateHouse);
TagManager.registerSpecificTagOption(TAG_ARCHER, b -> b instanceof BlockHutGateHouse);

TagManager.registerSpecificTagOption(TAG_COBBLE, b -> b instanceof BlockHutMiner);
TagManager.registerSpecificTagOption(TAG_LADDER_BACK, b -> b instanceof BlockHutMiner);
TagManager.registerSpecificTagOption(TAG_LADDER, b -> b instanceof BlockHutMiner);

TagManager.registerSpecificTagOption(TAG_LEISURE, b -> b instanceof BlockDecorationController);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public void repairLevel(final int level)
if (building instanceof BuildingMiner)
{
final BlockPos ladderPos = ((BuildingMiner) building).getLadderLocation();
final BlockPos vector = ladderPos.subtract(((BuildingMiner) building).getCobbleLocation());
final BlockPos vector = ladderPos.subtract(((BuildingMiner) building).getLadderBackLocation());
final int xOffset = SHAFT_RADIUS * vector.getX();
final int zOffset = SHAFT_RADIUS * vector.getZ();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@
import java.util.Map;
import java.util.Set;

import static com.minecolonies.api.util.constant.BuildingConstants.TAG_CLOCATION;
import static com.minecolonies.api.util.constant.BuildingConstants.TAG_LBLOCATION;
import static com.minecolonies.api.util.constant.BuildingConstants.TAG_LLOCATION;
import static com.minecolonies.api.util.constant.Constants.STACKSIZE;
import static com.minecolonies.api.util.constant.EquipmentLevelConstants.TOOL_LEVEL_WOOD_OR_GOLD;
import static com.minecolonies.api.util.constant.SchematicTagConstants.TAG_COBBLE;
import static com.minecolonies.api.util.constant.SchematicTagConstants.TAG_LADDER;
import static com.minecolonies.api.util.constant.SchematicTagConstants.*;

/**
* The miners building.
Expand Down Expand Up @@ -68,9 +67,9 @@ public class BuildingMiner extends AbstractBuildingStructureBuilder
private static final String MINER = "miner";

/**
* The location of the topmost cobblestone the ladder starts at.
* The location of the topmost block where the ladder starts at.
*/
private BlockPos cobbleLocation;
private BlockPos ladderBackLocation;

/**
* The location of the topmost ladder in the shaft.
Expand All @@ -89,11 +88,9 @@ public BuildingMiner(final IColony c, final BlockPos l)

final ItemStack stackLadder = new ItemStack(Blocks.LADDER);
final ItemStack stackTorch = new ItemStack(Blocks.TORCH);
final ItemStack stackCobble = new ItemStack(Blocks.COBBLESTONE);

keepX.put(stack -> ItemStack.isSameItem(stackLadder, stack), new Tuple<>(STACKSIZE, true));
keepX.put(stack -> ItemStack.isSameItem(stackTorch, stack), new Tuple<>(STACKSIZE, true));
keepX.put(stack -> ItemStack.isSameItem(stackCobble, stack), new Tuple<>(STACKSIZE, true));

keepX.put(itemStack -> ItemStackUtils.hasEquipmentLevel(itemStack, ModEquipmentTypes.pickaxe.get(), TOOL_LEVEL_WOOD_OR_GOLD, getMaxEquipmentLevel()), new Tuple<>(1, true));
keepX.put(itemStack -> ItemStackUtils.hasEquipmentLevel(itemStack, ModEquipmentTypes.shovel.get(), TOOL_LEVEL_WOOD_OR_GOLD, getMaxEquipmentLevel()), new Tuple<>(1, true));
Expand Down Expand Up @@ -146,15 +143,15 @@ public void deserializeNBT(final CompoundTag compound)
super.deserializeNBT(compound);

ladderLocation = BlockPosUtil.readOrNull(compound, TAG_LLOCATION);
cobbleLocation = BlockPosUtil.readOrNull(compound, TAG_CLOCATION);
ladderBackLocation = BlockPosUtil.readOrNull(compound, TAG_LBLOCATION);
}

@Override
public CompoundTag serializeNBT()
{
final CompoundTag compound = super.serializeNBT();

BlockPosUtil.writeOptional(compound, TAG_CLOCATION, cobbleLocation);
BlockPosUtil.writeOptional(compound, TAG_LBLOCATION, ladderBackLocation);
BlockPosUtil.writeOptional(compound, TAG_LLOCATION, ladderLocation);

return compound;
Expand Down Expand Up @@ -227,30 +224,30 @@ public BlockPos getLadderLocation()
}

/**
* Getter of the cobbleLocation.
* Getter of the ladderBackLocation.
*
* @return the location.
*/
public BlockPos getCobbleLocation()
public BlockPos getLadderBackLocation()
{
if (cobbleLocation == null)
if (ladderBackLocation == null)
{
loadLadderPos();
}

return cobbleLocation;
return ladderBackLocation;
}

private void loadLadderPos()
{
final Map<String, Set<BlockPos>> map = getTileEntity().getWorldTagNamePosMap();
final Set<BlockPos> cobblePos = map.getOrDefault(TAG_COBBLE, new HashSet<>());
final Set<BlockPos> ladderBackPos = map.getOrDefault(TAG_LADDER_BACK, new HashSet<>());
final Set<BlockPos> ladderPos = map.getOrDefault(TAG_LADDER, new HashSet<>());
if (cobblePos.isEmpty() || ladderPos.isEmpty())
if (ladderBackPos.isEmpty() || ladderPos.isEmpty())
{
return;
}
cobbleLocation = cobblePos.iterator().next();
ladderBackLocation = ladderBackPos.iterator().next();
ladderLocation = ladderPos.iterator().next();
}

Expand Down Expand Up @@ -302,7 +299,7 @@ public static void initStructure(final MineNode mineNode, final int rotateTimes,
*/
private static int getRotationFromVector(final BuildingMiner buildingMiner)
{
final BlockPos vector = buildingMiner.getLadderLocation().subtract(buildingMiner.getCobbleLocation());
final BlockPos vector = buildingMiner.getLadderLocation().subtract(buildingMiner.getLadderBackLocation());

if (vector.getX() == 1)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public class EntityAIStructureMiner extends AbstractEntityAIStructureWithWorkOrd
/**
* Batchsizes of fill blocks to request.
*/
private static final int COBBLE_REQUEST_BATCHES = 32;
private static final int MAINFILL_REQUEST_BATCHES = 32;

/**
* Batch sizes of ladders to request.
Expand Down Expand Up @@ -180,7 +180,7 @@ protected IAIState startWorkingAtOwnBuilding()
return START_WORKING;
}

if (building.getLadderLocation() == null || building.getCobbleLocation() == null)
if (building.getLadderLocation() == null || building.getLadderBackLocation() == null)
{
worker.getCitizenData().triggerInteraction(new StandardInteraction(Component.translatable(INVALID_MINESHAFT), ChatPriority.BLOCKING));
return START_WORKING;
Expand Down Expand Up @@ -342,24 +342,24 @@ public boolean walkToConstructionSite(final BlockPos currentBlock)
@NotNull
private IAIState repairLadder()
{
@NotNull final BlockPos nextCobble =
new BlockPos(building.getCobbleLocation().getX(), getLastLadder(building.getLadderLocation(), world) - 1, building.getCobbleLocation().getZ());
@NotNull final BlockPos nextLadderBack =
new BlockPos(building.getLadderBackLocation().getX(), getLastLadder(building.getLadderLocation(), world) - 1, building.getLadderBackLocation().getZ());
@NotNull final BlockPos nextLadder =
new BlockPos(building.getLadderLocation().getX(), getLastLadder(building.getLadderLocation(), world) - 1, building.getLadderLocation().getZ());
@NotNull final BlockPos safeStand =
new BlockPos(building.getLadderLocation().getX(), getLastLadder(building.getLadderLocation(), world), building.getLadderLocation().getZ());

if (!world.getBlockState(nextCobble).isSolid())
if (!world.getBlockState(nextLadderBack).isSolid())
{
if (!checkIfRequestForItemExistOrCreate(new ItemStack(getSolidSubstitution(nextCobble).getBlock()), COBBLE_REQUEST_BATCHES, 1))
if (!checkIfRequestForItemExistOrCreate(new ItemStack(getSolidSubstitution(nextLadderBack).getBlock()), MAINFILL_REQUEST_BATCHES, 1))
{
return getState();
}
if (!world.getBlockState(nextCobble).isAir() && !mineBlock(nextCobble, safeStand))
if (!world.getBlockState(nextLadderBack).isAir() && !mineBlock(nextLadderBack, safeStand))
{
return getState();
}
setBlockFromInventory(nextCobble, getLadderBackFillBlock());
setBlockFromInventory(nextLadderBack, getMainFillBlock());
return getState();
}

Expand All @@ -376,7 +376,7 @@ private IAIState repairLadder()
//Get ladder orientation
final BlockState metadata = Blocks.LADDER.defaultBlockState()
.setValue(HorizontalDirectionalBlock.FACING,
BlockPosUtil.directionFromDelta(nextLadder.getX() - nextCobble.getX(), 0, nextLadder.getZ() - nextCobble.getZ()));
BlockPosUtil.directionFromDelta(nextLadder.getX() - nextLadderBack.getX(), 0, nextLadder.getZ() - nextLadderBack.getZ()));
setBlockFromInventory(nextLadder, Blocks.LADDER, metadata);
return getState();
}
Expand All @@ -393,20 +393,6 @@ private Block getMainFillBlock()
return building.getSetting(FILL_BLOCK).getValue().getBlock();
}

/**
* Get the ladderback fill block. Cobble for overworld, netherrack for nether.
*
* @return the ladderback fill block.
*/
private Block getLadderBackFillBlock()
{
if (WorldUtil.isNetherType(world))
{
return Blocks.NETHERRACK;
}
return Blocks.COBBLESTONE;
}

@NotNull
private IAIState checkMineShaft()
{
Expand Down Expand Up @@ -468,7 +454,7 @@ private IAIState doShaftMining()

private IAIState advanceLadder(final IAIState state)
{
if (!checkIfRequestForItemExistOrCreate(new ItemStack(getLadderBackFillBlock()), COBBLE_REQUEST_BATCHES, 1) ||
if (!checkIfRequestForItemExistOrCreate(new ItemStack(getMainFillBlock()), MAINFILL_REQUEST_BATCHES, 1) ||
!checkIfRequestForItemExistOrCreate(new ItemStack(Blocks.LADDER), LADDER_REQUEST_BATCHES, 1))
{
return state;
Expand All @@ -479,21 +465,21 @@ private IAIState advanceLadder(final IAIState state)
return MINER_REPAIRING_LADDER;
}

final BlockPos vector = building.getLadderLocation().subtract(building.getCobbleLocation());
final BlockPos vector = building.getLadderLocation().subtract(building.getLadderBackLocation());
final int xOffset = SHAFT_RADIUS * vector.getX();
final int zOffset = SHAFT_RADIUS * vector.getZ();

@NotNull final BlockPos nextLadder =
new BlockPos(building.getLadderLocation().getX(), getLastLadder(building.getLadderLocation(), world) - 1, building.getLadderLocation().getZ());
@NotNull final BlockPos safeCobble =
@NotNull final BlockPos safeLadderBack =
new BlockPos(building.getLadderLocation().getX(), getLastLadder(building.getLadderLocation(), world) - 2, building.getLadderLocation().getZ());

//Check for safe floor
for (int x = -SAFE_CHECK_RANGE; x <= SAFE_CHECK_RANGE; x++)
{
for (int z = -SAFE_CHECK_RANGE; z <= SAFE_CHECK_RANGE; z++)
{
@NotNull final BlockPos curBlock = new BlockPos(safeCobble.getX() + x + xOffset, safeCobble.getY(), safeCobble.getZ() + z + zOffset);
@NotNull final BlockPos curBlock = new BlockPos(safeLadderBack.getX() + x + xOffset, safeLadderBack.getY(), safeLadderBack.getZ() + z + zOffset);
if (!secureBlock(curBlock, currentStandingPosition))
{
return state;
Expand All @@ -503,21 +489,21 @@ private IAIState advanceLadder(final IAIState state)

@NotNull final BlockPos safeStand =
new BlockPos(building.getLadderLocation().getX(), getLastLadder(building.getLadderLocation(), world), building.getLadderLocation().getZ());
@NotNull final BlockPos nextCobble =
new BlockPos(building.getCobbleLocation().getX(), getLastLadder(building.getLadderLocation(), world) - 1, building.getCobbleLocation().getZ());
@NotNull final BlockPos nextLadderBack =
new BlockPos(building.getLadderBackLocation().getX(), getLastLadder(building.getLadderLocation(), world) - 1, building.getLadderBackLocation().getZ());

final MinerLevelManagementModule module = building.getFirstModuleOccurance(MinerLevelManagementModule.class);
if (module.getStartingLevelShaft() == 0)
{
module.setStartingLevelShaft(nextCobble.getY() - 4);
module.setStartingLevelShaft(nextLadderBack.getY() - 4);
}

if (nextCobble.getY() < module.getStartingLevelShaft())
if (nextLadderBack.getY() < module.getStartingLevelShaft())
{
return MINER_BUILDING_SHAFT;
}

if (!world.getBlockState(nextCobble).canBeReplaced() && (!mineBlock(nextCobble, safeStand))
if (!world.getBlockState(nextLadderBack).canBeReplaced() && (!mineBlock(nextLadderBack, safeStand))
|| (!world.getBlockState(nextLadder).canBeReplaced() && !mineBlock(nextLadder, safeStand)))
{
//waiting until blocks are mined
Expand All @@ -529,7 +515,7 @@ private IAIState advanceLadder(final IAIState state)
final BlockState metadata = getBlockState(safeStand);

//set solid block
setBlockFromInventory(nextCobble, getLadderBackFillBlock());
setBlockFromInventory(nextLadderBack, getMainFillBlock());
//set ladder
setBlockFromInventory(nextLadder, Blocks.LADDER, metadata);
this.incrementActionsDoneAndDecSaturation();
Expand Down Expand Up @@ -570,7 +556,7 @@ private BlockPos getNextBlockInShaftToMine()
@Nullable BlockPos nextBlockToMine = null;
double bestDistance = Double.MAX_VALUE;

final BlockPos vector = building.getLadderLocation().subtract(building.getCobbleLocation());
final BlockPos vector = building.getLadderLocation().subtract(building.getLadderBackLocation());
final int xOffset = SHAFT_RADIUS * vector.getX();
final int zOffset = SHAFT_RADIUS * vector.getZ();

Expand Down Expand Up @@ -655,7 +641,7 @@ private IAIState doShaftBuilding()
final BlockPos ladderPos = building.getLadderLocation();
final int lastLadder = getLastLadder(ladderPos, world) + 1;

final BlockPos vector = ladderPos.subtract(building.getCobbleLocation());
final BlockPos vector = ladderPos.subtract(building.getLadderBackLocation());
final int xOffset = SHAFT_RADIUS * vector.getX();
final int zOffset = SHAFT_RADIUS * vector.getZ();

Expand Down Expand Up @@ -769,7 +755,7 @@ private boolean secureBlock(@NotNull final BlockPos curBlock, @NotNull final Blo
setDelay(1);
return false;
}
if (!checkIfRequestForItemExistOrCreate(new ItemStack(getMainFillBlock()), COBBLE_REQUEST_BATCHES, 1))
if (!checkIfRequestForItemExistOrCreate(new ItemStack(getMainFillBlock()), MAINFILL_REQUEST_BATCHES, 1))
{
return false;
}
Expand Down Expand Up @@ -964,7 +950,7 @@ private BlockPos getNodeMiningPosition(final BlockPos blockToMine)
return blockToMine;
}
final Vec2i parentPos = module.getActiveNode().getParent();
final BlockPos vector = building.getLadderLocation().subtract(building.getCobbleLocation());
final BlockPos vector = building.getLadderLocation().subtract(building.getLadderBackLocation());

if (parentPos != null && module.getCurrentLevel().getNode(parentPos) != null
&& module.getCurrentLevel().getNode(parentPos).getStyle() == MineNode.NodeType.SHAFT)
Expand Down
Loading