Upload files to "src/openonyx/utilities"
This commit is contained in:
1 parent
adf4bfb90f
commit
bd310281b5
5 files changed
+126
No files matched your search
@@ -0,0 +1,22 @@
|
|||||||
|
package openonyx.utilities;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
public final class AsyncExecutor {
|
||||||
|
private static final ExecutorService EXECUTOR_SERVICE = Executors.newCachedThreadPool(new AsyncExecutorPart());
|
||||||
|
private static final AtomicInteger ATOMIC_INTEGER = new AtomicInteger();
|
||||||
|
|
||||||
|
private AsyncExecutor() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Executor getExecutorservice() {
|
||||||
|
return EXECUTOR_SERVICE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void L(Runnable runnable) {
|
||||||
|
EXECUTOR_SERVICE.execute(runnable);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package openonyx.utilities;
|
||||||
|
|
||||||
|
import java.util.concurrent.ThreadFactory;
|
||||||
|
|
||||||
|
class AsyncExecutorPart implements ThreadFactory {
|
||||||
|
@Override
|
||||||
|
public Thread newThread(Runnable runnable) {
|
||||||
|
Thread thread = new Thread(runnable, "onyx-worker-" + AsyncExecutor.ATOMIC_INTEGER.incrementAndGet());
|
||||||
|
thread.setDaemon(true);
|
||||||
|
return thread;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package openonyx.utilities;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemBlock;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import openonyx.core.MinecraftAccess;
|
||||||
|
|
||||||
|
public class BlockItemUtils implements MinecraftAccess {
|
||||||
|
public static Block L(ItemStack itemStack) {
|
||||||
|
ItemStack itemStack1 = itemStack;
|
||||||
|
ItemBlock itemBlock;
|
||||||
|
Item item;
|
||||||
|
return itemStack1 != null && (item = itemStack1.getItem()) instanceof ItemBlock ? (itemBlock = (ItemBlock)item).getBlock() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean L(ItemStack itemStack) {
|
||||||
|
ItemStack itemStack1 = itemStack;
|
||||||
|
Block block;
|
||||||
|
return (block = L(itemStack1)) == null ? false : block.isFullCube();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package openonyx.utilities;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.item.ItemBlock;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import openonyx.core.MinecraftAccess;
|
||||||
|
import openonyx.features.player.internal.ScaffoldBlockFilter;
|
||||||
|
|
||||||
|
public final class BlockStackComparators implements MinecraftAccess {
|
||||||
|
public static final Comparator<ItemStack> COMPARATOR = new BlockStackComparatorsPart();
|
||||||
|
private static final double h = 0.8;
|
||||||
|
private static final double l = 1.7;
|
||||||
|
public static final Comparator<ItemStack> COMPARATOR2 = BlockStackComparators.COMPARATOR6.reversed();
|
||||||
|
public static final Comparator<ItemStack> COMPARATOR3 = (itemStack, itemStack1) -> Boolean.compare(L(itemStack).isNormalCube(), L(itemStack1).isNormalCube());
|
||||||
|
public static final Comparator<ItemStack> COMPARATOR4 = (itemStack, itemStack1) -> {
|
||||||
|
boolean bl;
|
||||||
|
ItemStack itemStack2;
|
||||||
|
if (!ScaffoldBlockFilter.L(itemStack)) {
|
||||||
|
bl = true;
|
||||||
|
itemStack2 = itemStack1;
|
||||||
|
} else {
|
||||||
|
bl = false;
|
||||||
|
itemStack2 = itemStack1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Boolean.compare(bl, !ScaffoldBlockFilter.L(itemStack2));
|
||||||
|
};
|
||||||
|
public static final Comparator<ItemStack> COMPARATOR5 = (itemStack, itemStack1) -> Boolean.compare(L(itemStack).isFullCube(), L(itemStack1).isFullCube());
|
||||||
|
public static final Comparator<ItemStack> COMPARATOR6 = Comparator.comparingInt(itemStack -> itemStack.stackSize);
|
||||||
|
private static final double e = 2.0;
|
||||||
|
|
||||||
|
private static Block L(ItemStack itemStack) {
|
||||||
|
return ((ItemBlock)itemStack.getItem()).getBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
private BlockStackComparators() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double L(ItemStack itemStack, boolean bl) {
|
||||||
|
ItemStack itemStack1 = itemStack;
|
||||||
|
float f = L(itemStack1).getBlockHardness(mc.theWorld, BlockPos.ORIGIN);
|
||||||
|
return bl && f >= 0.8 && f <= 2.0 ? 0.0 : Math.abs(1.7 - f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Comparator<ItemStack> L(boolean bl) {
|
||||||
|
return (itemStack, itemStack1) -> Double.compare(L(itemStack1, bl), L(itemStack, bl));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package openonyx.utilities;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
class BlockStackComparatorsPart implements Comparator<ItemStack> {
|
||||||
|
private final ChainedComparator<Block> chainedComparator;
|
||||||
|
|
||||||
|
BlockStackComparatorsPart() {
|
||||||
|
Comparator[] comparators = new Comparator[1];
|
||||||
|
boolean bl = true;
|
||||||
|
comparators[0] = Comparator.comparingDouble(block -> block.slipperiness);
|
||||||
|
this.chainedComparator = new ChainedComparator<>(comparators);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int L(ItemStack itemStack, ItemStack itemStack1) {
|
||||||
|
return this.chainedComparator.compare(BlockStackComparators.L(itemStack), BlockStackComparators.L(itemStack1));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user