Added laser medium upgrade factor to encourage upgrades
Fixed laser tree farm with diagonally connected branches Fixed laser tree farm with dark oak and jungle trees
This commit is contained in:
parent
fcc81b7f5a
commit
84432eb6e1
8 changed files with 75 additions and 24 deletions
|
@ -416,15 +416,38 @@ public class Commons {
|
|||
|
||||
// searching methods
|
||||
|
||||
public static final EnumFacing[] UP_DIRECTIONS = { EnumFacing.UP, EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.WEST, EnumFacing.EAST };
|
||||
public static final EnumFacing[] HORIZONTAL_DIRECTIONS = { EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.WEST, EnumFacing.EAST };
|
||||
public static final EnumFacing[] VERTICAL_DIRECTIONS = { EnumFacing.UP, EnumFacing.DOWN };
|
||||
public static final EnumFacing[] FACINGS_VERTICAL = { EnumFacing.DOWN, EnumFacing.UP };
|
||||
public static final VectorI[] DIRECTIONS_UP_CONE = {
|
||||
new VectorI( 0, 1, 0),
|
||||
new VectorI( 1, 0, 0),
|
||||
new VectorI( 0, 0, 1),
|
||||
new VectorI(-1, 0, 0),
|
||||
new VectorI( 0, 0, -1),
|
||||
new VectorI( 1, 1, 0),
|
||||
new VectorI( 0, 1, 1),
|
||||
new VectorI(-1, 1, 0),
|
||||
new VectorI( 0, 1, -1) };
|
||||
public static final VectorI[] DIRECTIONS_HORIZONTAL = {
|
||||
new VectorI( 1, 0, 0),
|
||||
new VectorI( 0, 0, 1),
|
||||
new VectorI(-1, 0, 0),
|
||||
new VectorI( 0, 0, -1) };
|
||||
public static final VectorI[] DIRECTIONS_VERTICAL = {
|
||||
new VectorI( 0, -1, 0),
|
||||
new VectorI( 0, 1, 0) };
|
||||
public static final VectorI[] DIRECTIONS_ANY = {
|
||||
new VectorI( 0, -1, 0),
|
||||
new VectorI( 0, 1, 0),
|
||||
new VectorI( 1, 0, 0),
|
||||
new VectorI( 0, 0, 1),
|
||||
new VectorI(-1, 0, 0),
|
||||
new VectorI( 0, 0, -1) };
|
||||
|
||||
public static Set<BlockPos> getConnectedBlocks(final World world, final BlockPos start, final EnumFacing[] directions, final Set<Block> whitelist, final int maxRange, final BlockPos... ignore) {
|
||||
public static Set<BlockPos> getConnectedBlocks(final World world, final BlockPos start, final VectorI[] directions, final Set<Block> whitelist, final int maxRange, final BlockPos... ignore) {
|
||||
return getConnectedBlocks(world, Collections.singletonList(start), directions, whitelist, maxRange, ignore);
|
||||
}
|
||||
|
||||
public static Set<BlockPos> getConnectedBlocks(final World world, final Collection<BlockPos> start, final EnumFacing[] directions, final Set<Block> whitelist, final int maxRange, final BlockPos... ignore) {
|
||||
public static Set<BlockPos> getConnectedBlocks(final World world, final Collection<BlockPos> start, final VectorI[] directions, final Set<Block> whitelist, final int maxRange, final BlockPos... ignore) {
|
||||
final Set<BlockPos> toIgnore = new HashSet<>();
|
||||
if (ignore != null) {
|
||||
toIgnore.addAll(Arrays.asList(ignore));
|
||||
|
@ -444,8 +467,10 @@ public class Commons {
|
|||
iterated.add(current);
|
||||
}
|
||||
|
||||
for(final EnumFacing direction : directions) {
|
||||
final BlockPos next = current.offset(direction);
|
||||
for(final VectorI direction : directions) {
|
||||
final BlockPos next = new BlockPos(current.getX() + direction.x,
|
||||
current.getY() + direction.y,
|
||||
current.getZ() + direction.z );
|
||||
if (!iterated.contains(next) && !toIgnore.contains(next) && !toIterate.contains(next) && !toIterateNext.contains(next)) {
|
||||
if (whitelist.contains(new VectorI(next).getBlockState_noChunkLoading(world).getBlock())) {
|
||||
toIterateNext.add(next);
|
||||
|
|
|
@ -28,6 +28,7 @@ public abstract class TileEntityAbstractLaser extends TileEntityAbstractMachine
|
|||
// computed properties
|
||||
protected EnumFacing laserMedium_direction = null;
|
||||
protected int cache_laserMedium_count = 0;
|
||||
protected double cache_laserMedium_factor = 1.0D;
|
||||
protected int cache_laserMedium_energyStored = 0;
|
||||
protected int cache_laserMedium_maxStorage = 0;
|
||||
|
||||
|
@ -100,6 +101,7 @@ public abstract class TileEntityAbstractLaser extends TileEntityAbstractMachine
|
|||
// save results
|
||||
laserMedium_direction = facing;
|
||||
cache_laserMedium_count = count;
|
||||
cache_laserMedium_factor = Math.max(1.0D, count * WarpDriveConfig.LASER_MEDIUM_FACTOR_BY_TIER[enumTier.getIndex()]);
|
||||
cache_laserMedium_energyStored = energyStored;
|
||||
cache_laserMedium_maxStorage = maxStorage;
|
||||
return;
|
||||
|
@ -109,6 +111,7 @@ public abstract class TileEntityAbstractLaser extends TileEntityAbstractMachine
|
|||
// nothing found
|
||||
laserMedium_direction = null;
|
||||
cache_laserMedium_count = 0;
|
||||
cache_laserMedium_factor = 0.0D;
|
||||
cache_laserMedium_energyStored = 0;
|
||||
cache_laserMedium_maxStorage = 0;
|
||||
}
|
||||
|
|
|
@ -494,7 +494,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
|
|||
|
||||
private void updateParameters() {
|
||||
final int maxScanRadius = WarpDriveConfig.TREE_FARM_MAX_SCAN_RADIUS_NO_LASER_MEDIUM
|
||||
+ cache_laserMedium_count * WarpDriveConfig.TREE_FARM_MAX_SCAN_RADIUS_PER_LASER_MEDIUM;
|
||||
+ (int) Math.floor(cache_laserMedium_factor * WarpDriveConfig.TREE_FARM_MAX_SCAN_RADIUS_PER_LASER_MEDIUM);
|
||||
radiusX_actual = Math.min(radiusX_requested, maxScanRadius);
|
||||
radiusZ_actual = Math.min(radiusZ_requested, maxScanRadius);
|
||||
}
|
||||
|
@ -575,9 +575,9 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
|
|||
if (breakLeaves) {
|
||||
whitelist.addAll(Dictionary.BLOCKS_LEAVES);
|
||||
}
|
||||
final int maxLogDistance = WarpDriveConfig.TREE_FARM_MAX_LOG_DISTANCE
|
||||
+ cache_laserMedium_count * WarpDriveConfig.TREE_FARM_MAX_LOG_DISTANCE_PER_MEDIUM;
|
||||
logPositions = Commons.getConnectedBlocks(world, logPositions, Commons.UP_DIRECTIONS, whitelist, maxLogDistance);
|
||||
final int maxLogDistance = WarpDriveConfig.TREE_FARM_MAX_LOG_DISTANCE_NO_LASER_MEDIUM
|
||||
+ (int) Math.floor(cache_laserMedium_factor * WarpDriveConfig.TREE_FARM_MAX_LOG_DISTANCE_PER_MEDIUM);
|
||||
logPositions = Commons.getConnectedBlocks(world, logPositions, Commons.DIRECTIONS_UP_CONE, whitelist, maxLogDistance);
|
||||
}
|
||||
if (WarpDriveConfig.LOGGING_COLLECTION) {
|
||||
WarpDrive.logger.info(String.format("Found %d valuables", logPositions.size()));
|
||||
|
|
|
@ -110,7 +110,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractMiner {
|
|||
|
||||
final boolean isOnPlanet = CelestialObjectManager.hasAtmosphere(world, pos.getX(), pos.getZ());
|
||||
radiusCapacity = WarpDriveConfig.MINING_LASER_RADIUS_NO_LASER_MEDIUM
|
||||
+ cache_laserMedium_count * WarpDriveConfig.MINING_LASER_RADIUS_PER_LASER_MEDIUM;
|
||||
+ (int) Math.floor(cache_laserMedium_factor * WarpDriveConfig.MINING_LASER_RADIUS_PER_LASER_MEDIUM);
|
||||
|
||||
delayTicks--;
|
||||
if (currentState == STATE_WARMUP) {
|
||||
|
|
|
@ -99,10 +99,10 @@ public class CompatRustic implements IBlockTransformer {
|
|||
if (classBlockStakeTied.isInstance(block)) {// @TODO Rustic mod is forcing drops here, not sure how to work around it without ASM => anchor block
|
||||
final BlockPos blockPos = new BlockPos(x, y, z);
|
||||
// get all horizontal ropes
|
||||
final Set<BlockPos> setBlockPosHorizontalRopes = Commons.getConnectedBlocks(world, blockPos, Commons.HORIZONTAL_DIRECTIONS, setBlockRope, 16);
|
||||
final Set<BlockPos> setBlockPosHorizontalRopes = Commons.getConnectedBlocks(world, blockPos, Commons.DIRECTIONS_HORIZONTAL, setBlockRope, 16);
|
||||
for (final BlockPos blockPosHorizontalRope : setBlockPosHorizontalRopes) {
|
||||
// get all vertical/hanging ropes
|
||||
final Set<BlockPos> setBlockPosVerticalRopes = Commons.getConnectedBlocks(world, blockPosHorizontalRope, Commons.VERTICAL_DIRECTIONS, setBlockRope, 16);
|
||||
final Set<BlockPos> setBlockPosVerticalRopes = Commons.getConnectedBlocks(world, blockPosHorizontalRope, Commons.DIRECTIONS_VERTICAL, setBlockRope, 16);
|
||||
for (final BlockPos blockPosVerticalRope : setBlockPosVerticalRopes) {
|
||||
final boolean isDone = world.setBlockToAir(blockPosVerticalRope);
|
||||
if (!isDone) {
|
||||
|
|
|
@ -290,6 +290,7 @@ public class WarpDriveConfig {
|
|||
|
||||
// Laser medium
|
||||
public static int[] LASER_MEDIUM_MAX_ENERGY_STORED_BY_TIER = { 1000000, 10000, 30000, 100000 };
|
||||
public static double[] LASER_MEDIUM_FACTOR_BY_TIER = { 1.25D, 0.5D, 1.0D, 1.5D };
|
||||
|
||||
// Laser Emitter
|
||||
// 1 main laser + 4 boosting lasers = 10 * 100k + 0.6 * 40 * 100k = 3.4M
|
||||
|
@ -356,12 +357,16 @@ public class WarpDriveConfig {
|
|||
public static double MINING_LASER_FORTUNE_ENERGY_FACTOR = 1.5;
|
||||
|
||||
// Tree farm
|
||||
// oak tree height is 8 to 11 logs + 2 leaves
|
||||
// dark oak tree height is up to 25 logs + 2 leaves
|
||||
// jungle tree height is up to 30 logs + 1 leaf
|
||||
// => basic setup is 8, then 18, then up to 32
|
||||
public static int TREE_FARM_MAX_MEDIUMS_COUNT = 5;
|
||||
public static int TREE_FARM_MAX_SCAN_RADIUS_NO_LASER_MEDIUM = 3;
|
||||
public static int TREE_FARM_MAX_SCAN_RADIUS_PER_LASER_MEDIUM = 2;
|
||||
public static int TREE_FARM_totalMaxRadius = 0;
|
||||
public static int TREE_FARM_MAX_LOG_DISTANCE = 8;
|
||||
public static int TREE_FARM_MAX_LOG_DISTANCE_PER_MEDIUM = 4;
|
||||
public static int TREE_FARM_MAX_LOG_DISTANCE_NO_LASER_MEDIUM = 8;
|
||||
public static int TREE_FARM_MAX_LOG_DISTANCE_PER_MEDIUM = 6;
|
||||
|
||||
// Cloaking
|
||||
public static int CLOAKING_MAX_ENERGY_STORED = 500000000;
|
||||
|
@ -936,6 +941,9 @@ public class WarpDriveConfig {
|
|||
LASER_MEDIUM_MAX_ENERGY_STORED_BY_TIER =
|
||||
config.get("laser_medium", "max_energy_stored_by_tier", LASER_MEDIUM_MAX_ENERGY_STORED_BY_TIER, "Maximum energy stored for a given tier").getIntList();
|
||||
clampByTier(1, Integer.MAX_VALUE, LASER_MEDIUM_MAX_ENERGY_STORED_BY_TIER);
|
||||
LASER_MEDIUM_FACTOR_BY_TIER =
|
||||
config.get("laser_medium", "bonus_factor_by_tier", LASER_MEDIUM_FACTOR_BY_TIER, "Bonus multiplier of a laser medium line for a given tier").getDoubleList();
|
||||
clampByTier(0.0D, 4.0D, LASER_MEDIUM_FACTOR_BY_TIER);
|
||||
|
||||
// Laser cannon
|
||||
LASER_CANNON_MAX_MEDIUMS_COUNT = Commons.clamp(1, 64,
|
||||
|
@ -1048,8 +1056,8 @@ public class WarpDriveConfig {
|
|||
config.get("tree_farm", "max_scan_radius_per_laser_medium", TREE_FARM_MAX_SCAN_RADIUS_PER_LASER_MEDIUM, "Bonus to maximum scan radius per laser medium, on X and Z axis, measured in blocks").getInt());
|
||||
TREE_FARM_totalMaxRadius = TREE_FARM_MAX_SCAN_RADIUS_NO_LASER_MEDIUM + TREE_FARM_MAX_MEDIUMS_COUNT * TREE_FARM_MAX_SCAN_RADIUS_PER_LASER_MEDIUM;
|
||||
|
||||
TREE_FARM_MAX_LOG_DISTANCE = Commons.clamp(1, 64,
|
||||
config.get("tree_farm", "max_reach_distance", TREE_FARM_MAX_LOG_DISTANCE, "Maximum reach distance of the laser without any laser medium, measured in blocks").getInt());
|
||||
TREE_FARM_MAX_LOG_DISTANCE_NO_LASER_MEDIUM = Commons.clamp(1, 64,
|
||||
config.get("tree_farm", "max_reach_distance_no_laser_medium", TREE_FARM_MAX_LOG_DISTANCE_NO_LASER_MEDIUM, "Maximum reach distance of the laser without any laser medium, measured in blocks").getInt());
|
||||
TREE_FARM_MAX_LOG_DISTANCE_PER_MEDIUM = Commons.clamp(0, 16,
|
||||
config.get("tree_farm", "max_reach_distance_per_laser_medium", TREE_FARM_MAX_LOG_DISTANCE_PER_MEDIUM, "Bonus to maximum reach distance per laser medium, measured in blocks").getInt());
|
||||
|
||||
|
@ -1191,7 +1199,20 @@ public class WarpDriveConfig {
|
|||
|
||||
public static void clampByTier(final int min, final int max, final int[] values) {
|
||||
if (values.length != EnumTier.length) {
|
||||
WarpDrive.logger.error(String.format("Invalid configuration value, expected %d integers, got %d %s. Update your configuration and restart your game!",
|
||||
WarpDrive.logger.error(String.format("Invalid configuration value, expected %d values, got %d %s. Update your configuration and restart your game!",
|
||||
EnumTier.length, values.length, Arrays.toString(values)));
|
||||
assert false;
|
||||
return;
|
||||
}
|
||||
values[0] = Commons.clamp(min , max , values[0]);
|
||||
values[1] = Commons.clamp(min , values[2], values[1]);
|
||||
values[2] = Commons.clamp(values[1], values[3], values[2]);
|
||||
values[3] = Commons.clamp(values[2], max , values[3]);
|
||||
}
|
||||
|
||||
public static void clampByTier(final double min, final double max, final double[] values) {
|
||||
if (values.length != EnumTier.length) {
|
||||
WarpDrive.logger.error(String.format("Invalid configuration value, expected %d values, got %d %s. Update your configuration and restart your game!",
|
||||
EnumTier.length, values.length, Arrays.toString(values)));
|
||||
assert false;
|
||||
return;
|
||||
|
|
|
@ -179,7 +179,7 @@ public class AcceleratorSetup extends GlobalPosition {
|
|||
WarpDrive.blockElectromagnets_glass[2],
|
||||
WarpDrive.blockVoidShellPlain,
|
||||
WarpDrive.blockVoidShellGlass);
|
||||
final Set<BlockPos> connections = Commons.getConnectedBlocks(world, new BlockPos(x, y, z), EnumFacing.VALUES, whitelist, 3);
|
||||
final Set<BlockPos> connections = Commons.getConnectedBlocks(world, new BlockPos(x, y, z), Commons.DIRECTIONS_ANY, whitelist, 3);
|
||||
VectorI firstVoidShell = null;
|
||||
for (final BlockPos connection : connections) {
|
||||
final Block block = world.getBlockState(connection).getBlock();
|
||||
|
@ -201,7 +201,7 @@ public class AcceleratorSetup extends GlobalPosition {
|
|||
WarpDrive.blockVoidShellPlain,
|
||||
WarpDrive.blockVoidShellGlass);
|
||||
TrajectoryPoint trajectoryPoint = null;
|
||||
for (final EnumFacing direction : Commons.HORIZONTAL_DIRECTIONS) {
|
||||
for (final EnumFacing direction : EnumFacing.HORIZONTALS) {
|
||||
final VectorI next = firstVoidShell.clone(direction);
|
||||
if (whitelist.contains(next.getBlockState_noChunkLoading(world).getBlock())) {
|
||||
trajectoryPoint = new TrajectoryPoint(world, firstVoidShell.translate(direction), direction);
|
||||
|
|
|
@ -37,11 +37,13 @@ public class AirSpreader {
|
|||
}
|
||||
|
||||
// identify leaking directions
|
||||
EnumFacing[] directions = EnumFacing.VALUES;
|
||||
final EnumFacing[] directions;
|
||||
if (stateCenter.isLeakingHorizontally()) {
|
||||
directions = Commons.HORIZONTAL_DIRECTIONS;
|
||||
directions = EnumFacing.HORIZONTALS;
|
||||
} else if (stateCenter.isLeakingVertically()) {
|
||||
directions = Commons.VERTICAL_DIRECTIONS;
|
||||
directions = Commons.FACINGS_VERTICAL;
|
||||
} else {
|
||||
directions = EnumFacing.VALUES;
|
||||
}
|
||||
|
||||
// collect air state in adjacent blocks
|
||||
|
|
Loading…
Reference in a new issue