mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 10:55:17 +00:00
Detector rails can now take comparator output from pool minecarts, like they do for chest carts. Output calculated with same formula as a comparator on a pool block itself.
This commit is contained in:
1 parent
639fcc78f4
commit
b62ae8a2cb
3 files changed
+14
-6
No files matched your search
@@ -209,11 +209,7 @@ public class BlockPool extends BlockMod implements IWandHUD, IWandable, ILexicon
|
||||
@Override
|
||||
public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos) {
|
||||
TilePool pool = (TilePool) world.getTileEntity(pos);
|
||||
int val = (int) ((double) pool.getCurrentMana() / (double) pool.manaCap * 15.0);
|
||||
if(pool.getCurrentMana() > 0)
|
||||
val = Math.max(val, 1);
|
||||
|
||||
return val;
|
||||
return TilePool.calculateComparatorLevel(pool.getCurrentMana(), pool.manaCap);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -140,6 +140,13 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
|
||||
ManaNetworkEvent.removePool(this);
|
||||
}
|
||||
|
||||
public static int calculateComparatorLevel(int mana, int max) {
|
||||
int val = (int) ((double) mana / (double) max * 15.0);
|
||||
if(mana > 0)
|
||||
val = Math.max(val, 1);
|
||||
return val;
|
||||
}
|
||||
|
||||
public static RecipeManaInfusion getMatchingRecipe(@Nonnull ItemStack stack, @Nonnull IBlockState state) {
|
||||
List<RecipeManaInfusion> matchingNonCatRecipes = new ArrayList<>();
|
||||
List<RecipeManaInfusion> matchingCatRecipes = new ArrayList<>();
|
||||
|
||||
@@ -179,7 +179,7 @@ public class EntityPoolMinecart extends EntityMinecart {
|
||||
|
||||
if(can) {
|
||||
pump.hasCartOnTop = true;
|
||||
pump.comparator = (int) ((double) getMana() / (double) TilePool.MAX_MANA * 15);
|
||||
pump.comparator = (int) ((double) getMana() / (double) TilePool.MAX_MANA * 15); // different from TilePool.calculateComparatorLevel, kept for compatibility
|
||||
}
|
||||
|
||||
}
|
||||
@@ -199,6 +199,11 @@ public class EntityPoolMinecart extends EntityMinecart {
|
||||
setMana(cmp.getInteger(TAG_MANA));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorLevel() {
|
||||
return TilePool.calculateComparatorLevel(getMana(), TilePool.MAX_MANA);
|
||||
}
|
||||
|
||||
public int getMana() {
|
||||
return dataManager.get(MANA);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user