mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-26 14:52:58 +00:00
Add comparator support for a large number of blocks (#5474)
* Add comparator support to a lot of various blocks. Closes #5447 * Add comparator support for various generator blocks * Cleanup some old calculations not using the new utils method
This commit is contained in:
1 parent
52796ff18f
commit
c8d2fbbac8
34 files changed
+341
-64
No files matched your search
@@ -63,6 +63,7 @@ import net.minecraft.util.EnumFacing.Axis;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.ChunkCache;
|
||||
@@ -1079,6 +1080,17 @@ public final class MekanismUtils {
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param amount Amount currently stored
|
||||
* @param capacity Total amount that can be stored.
|
||||
*
|
||||
* @return A redstone level based on the percentage of the amount stored.
|
||||
*/
|
||||
public static int redstoneLevelFromContents(double amount, double capacity) {
|
||||
double fractionFull = capacity == 0 ? 0 : amount / capacity;
|
||||
return MathHelper.floor((float) (fractionFull * 14.0F)) + (fractionFull > 0 ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clamp a double to int without using Math.min due to double representation issues. Primary use: power systems that use int, where Mek uses doubles internally
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user