mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 10:55:17 +00:00
Corporea retainers use richer signal strength depending on request size
This commit is contained in:
1 parent
3c6794e722
commit
81f33e8d74
5 files changed
+21
-8
No files matched your search
@@ -297,4 +297,12 @@ public final class CorporeaHelper {
|
||||
public static String stripControlCodes(String str) {
|
||||
return patternControlCode.matcher(str).replaceAll("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the comparator strength for a corporea request that corporea crystal cubes and retainers use, following the usual "each step up requires double the items" formula.
|
||||
*/
|
||||
private static final double LOG_2 = Math.log(2);
|
||||
public static int signalStrengthForRequestSize(int requestSize) {
|
||||
return requestSize == 0 ? 0 : Math.min(15, (int) Math.floor(Math.log(requestSize) / LOG_2) + 1);
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ public class BlockCorporeaCrystalCube extends BlockCorporeaBase implements ILexi
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos) {
|
||||
return ((TileCorporeaCrystalCube) world.getTileEntity(pos)).compValue;
|
||||
return ((TileCorporeaCrystalCube) world.getTileEntity(pos)).getComparatorValue();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -75,7 +75,7 @@ public class BlockCorporeaRetainer extends BlockMod implements ILexiconable {
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos) {
|
||||
return ((TileCorporeaRetainer) world.getTileEntity(pos)).hasPendingRequest() ? 15 : 0;
|
||||
return ((TileCorporeaRetainer) world.getTileEntity(pos)).getComparatorValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-5
@@ -41,7 +41,7 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor
|
||||
ItemStack requestTarget = ItemStack.EMPTY;
|
||||
int itemCount = 0;
|
||||
int ticks = 0;
|
||||
public int compValue = 0;
|
||||
int compValue = 0;
|
||||
|
||||
private final IAnimationStateMachine asm;
|
||||
|
||||
@@ -111,7 +111,7 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor
|
||||
}
|
||||
|
||||
private void onUpdateCount() {
|
||||
compValue = getComparatorValue();
|
||||
compValue = CorporeaHelper.signalStrengthForRequestSize(itemCount);
|
||||
world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock());
|
||||
}
|
||||
|
||||
@@ -134,9 +134,7 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor
|
||||
}
|
||||
|
||||
public int getComparatorValue() {
|
||||
if(itemCount == 0)
|
||||
return 0;
|
||||
return Math.min(15, (int) Math.floor(Math.log(itemCount) / LOG_2) + 1);
|
||||
return compValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,6 +38,7 @@ public class TileCorporeaRetainer extends TileMod {
|
||||
BlockPos requestPos = BlockPos.ORIGIN;
|
||||
Object request;
|
||||
int requestCount;
|
||||
int compValue;
|
||||
|
||||
public void setPendingRequest(BlockPos pos, Object request, int requestCount) {
|
||||
if(pendingRequest)
|
||||
@@ -47,9 +48,15 @@ public class TileCorporeaRetainer extends TileMod {
|
||||
this.request = request;
|
||||
this.requestCount = requestCount;
|
||||
pendingRequest = true;
|
||||
|
||||
compValue = CorporeaHelper.signalStrengthForRequestSize(requestCount);
|
||||
world.updateComparatorOutputLevel(getPos(), world.getBlockState(getPos()).getBlock());
|
||||
}
|
||||
|
||||
|
||||
public int getComparatorValue() {
|
||||
return compValue;
|
||||
}
|
||||
|
||||
public boolean hasPendingRequest() {
|
||||
return pendingRequest;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user