Upload files to "src/openonyx/utilities"

This commit is contained in:
winterflyt committed 2026-11-30 06:18:56 +02:00
1 parent e5f9d06113
commit dbe91559df
5 files changed
+418

No files matched your search

@@ -0,0 +1,15 @@
package openonyx.utilities;
public class InputFlagUtils {
public static boolean L(InputFlags inputFlags) {
return inputFlags.forward() || inputFlags.backward() || inputFlags.left() || inputFlags.right();
}
public static InputFlags L(InputFlags inputFlags, boolean bl, boolean bl1, boolean bl2, boolean bl3, boolean bl4, boolean bl5, boolean bl6) {
return new InputFlags(bl, bl1, bl2, bl3, bl4, bl5, bl6);
}
public static boolean L(MovementInputState movementInputState) {
return movementInputState.forwards() || movementInputState.backwards() || movementInputState.left() || movementInputState.right();
}
}
+144
View File
@@ -0,0 +1,144 @@
package openonyx.utilities;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
public final class ItemCatalog {
private static List<ItemCatalogData> itemCatalogDatas;
private ItemCatalog() {
}
private static List<ItemCatalogData> d() {
ArrayList arrayList = new ArrayList();
Iterator iterator = Item.itemRegistry.iterator();
label40:
while (true) {
Iterator iterator2 = iterator;
while (iterator2.hasNext()) {
Item item;
if ((item = (Item)iterator.next()) == null) {
iterator2 = iterator;
} else {
ResourceLocation resourceLocation;
if ((resourceLocation = Item.itemRegistry.getNameForObject(item)) != null) {
String string = resourceLocation.toString();
Iterator iterator1 = L(item).iterator();
while (true) {
iterator2 = iterator1;
while (true) {
if (!iterator2.hasNext()) {
continue label40;
}
ItemStack itemStack;
if ((itemStack = (ItemStack)iterator1.next()) == null) {
break;
}
if (itemStack.getItem() == null) {
iterator2 = iterator1;
} else {
String string1 = L(itemStack, resourceLocation.getResourcePath());
iterator2 = iterator1;
arrayList.add(
new ItemCatalogData(
itemStack,
string,
string1,
new StringBuilder().insert(0, string).append(' ').append(string1).toString().toLowerCase(Locale.ROOT)
)
);
}
}
}
}
iterator2 = iterator;
}
}
return arrayList;
}
}
public static List<ItemCatalogData> L(String string, int i) {
String string1 = string;
ArrayList arrayList = new ArrayList();
String string2 = string1 == null ? "" : string1.trim().toLowerCase(Locale.ROOT);
Iterator iterator = L().iterator();
label32:
while (true) {
for (Iterator iterator1 = iterator; iterator1.hasNext(); iterator1 = iterator) {
ItemCatalogData itemCatalogData = (ItemCatalogData)iterator.next();
if (string2.isEmpty() || itemCatalogData.search().contains(string2)) {
arrayList.add(itemCatalogData);
if (i > 0 && arrayList.size() >= i) {
break label32;
}
continue label32;
}
}
return arrayList;
}
return arrayList;
}
private static String L(ItemStack itemStack, String string) {
ItemStack itemStack1 = itemStack;
try {
String string1;
if ((string1 = itemStack1.getDisplayName()) != null && !string1.isEmpty()) {
return string1;
}
} catch (RuntimeException runtimeException) {
}
return string;
}
private static List<ItemStack> L(Item item) {
Item item1 = item;
ArrayList arrayList = new ArrayList();
ArrayList arrayList1;
label17: {
try {
item1.getSubItems(item1, null, arrayList);
} catch (RuntimeException runtimeException) {
arrayList1 = arrayList;
arrayList.clear();
break label17;
}
arrayList1 = arrayList;
}
if (arrayList1.isEmpty()) {
arrayList.add(new ItemStack(item1));
}
return arrayList;
}
public static List<ItemCatalogData> L() {
if (itemCatalogDatas == null) {
itemCatalogDatas = d();
}
return itemCatalogDatas;
}
}
@@ -0,0 +1,6 @@
package openonyx.utilities;
import net.minecraft.item.ItemStack;
public record ItemCatalogData(ItemStack stack, String id, String name, String search) {
}
+34
View File
@@ -0,0 +1,34 @@
package openonyx.utilities;
public enum ItemPriority {
IMPORTANT_FOR_USAGE_3(35),
IMPORTANT_FOR_USAGE_1(20),
IMPORTANT_FOR_USER_SAFETY(60),
IMPORTANT_FOR_PLAYER_LIFE(40),
NOT_IMPORTANT(-20),
IMPORTANT_FOR_USAGE_2(30),
NORMAL(0);
private final int l;
ItemPriority(int j) {
this.l = j;
}
private static ItemPriority[] L() {
ItemPriority[] itemPrioritys = new ItemPriority[7];
boolean bl = true;
itemPrioritys[0] = NOT_IMPORTANT;
itemPrioritys[1] = NORMAL;
itemPrioritys[2] = IMPORTANT_FOR_USAGE_1;
itemPrioritys[3] = IMPORTANT_FOR_USAGE_2;
itemPrioritys[4] = IMPORTANT_FOR_USAGE_3;
itemPrioritys[5] = IMPORTANT_FOR_PLAYER_LIFE;
itemPrioritys[6] = IMPORTANT_FOR_USER_SAFETY;
return itemPrioritys;
}
public int L() {
return this.l;
}
}
+219
View File
@@ -0,0 +1,219 @@
package openonyx.utilities;
import java.util.Iterator;
import java.util.Locale;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
public final class ItemSpec {
private final ItemSpecMode itemSpecMode;
private final String m;
public static final int h = -1;
public static final char l = '@';
public static final char I = '~';
private final ItemSpecMode2 itemSpecMode2;
private final String i;
private final int f;
private final Item item;
public static final char e = '#';
public static ItemSpec L(ItemSpecMode itemSpecMode) {
return itemSpecModex == null ? null : new ItemSpec(ItemSpecMode2.GROUP, null, -1, itemSpecModex, null);
}
private ItemSpec(ItemSpecMode2 itemSpecMode2, Item item, int i, ItemSpecMode itemSpecMode, String string) {
this.itemSpecMode2 = itemSpecMode2x;
this.item = itemx;
this.f = ix;
this.itemSpecMode = itemSpecModex;
this.m = string;
this.i = this.i();
}
public boolean L() {
return this.itemSpecMode2 == ItemSpecMode2.ITEM;
}
private ItemStack d() {
ItemSpec itemSpec1 = this;
Iterator iterator = Item.itemRegistry.iterator();
while (iterator.hasNext()) {
Item itemx;
if ((itemx = (Item)iterator.next()) != null && d(itemx).contains(itemSpec1.m)) {
return new ItemStack(itemx);
}
}
return null;
}
public static ItemSpec d(String string) {
String string1 = string;
if (string1 == null) {
return null;
}
if ((string = string1.trim()).isEmpty()) {
return null;
}
if (string.charAt(0) == '@') {
try {
return L(ItemSpecMode.valueOf(string.substring(1).toUpperCase(Locale.ROOT)));
} catch (IllegalArgumentException illegalArgumentException) {
return null;
}
} else {
if (string.charAt(0) == '~') {
return L(string.substring(1));
}
int ix = string.indexOf(35);
int j = -1;
if (ix >= 0) {
try {
j = Integer.parseInt(string.substring(ix + 1).trim());
} catch (NumberFormatException numberFormatException) {
return null;
}
string = string.substring(0, ix).trim();
}
ResourceLocation resourceLocation = new ResourceLocation(string);
return !Item.itemRegistry.containsKey(resourceLocation) ? null : L(Item.itemRegistry.getObject(resourceLocation), j);
}
}
public static ItemSpec L(Item item, int i) {
return itemx == null ? null : new ItemSpec(ItemSpecMode2.ITEM, itemx, ix, null, null);
}
private String i() {
switch (this.itemSpecMode2) {
case NAME:
while (false) {
}
return this.f == -1 ? L(this.item) : new StringBuilder().insert(0, L(this.item)).append('#').append(this.f).toString();
case GROUP:
return '@' + this.itemSpecMode.name();
case ITEM:
return '~' + this.m;
default:
throw new MatchException(null, null);
}
}
@Override
public String toString() {
return this.i;
}
private static String d(Item item) {
Item item1 = itemx;
ResourceLocation resourceLocation;
return (resourceLocation = Item.itemRegistry.getNameForObject(item1)) == null ? "" : resourceLocation.getResourcePath();
}
public static ItemSpec L(String string) {
String string1 = string;
if (string1 == null) {
return null;
} else {
return (string = string1.trim().toLowerCase(Locale.ROOT)).isEmpty() ? null : new ItemSpec(ItemSpecMode2.NAME, null, -1, null, string);
}
}
private String D() {
ItemSpec itemSpec1 = this;
try {
String string;
if ((string = new ItemStack(itemSpec1.item, 1, itemSpec1.f == -1 ? 0 : itemSpec1.f).getDisplayName()) != null && !string.isEmpty()) {
return string;
}
} catch (RuntimeException runtimeException) {
}
return d(itemSpec1.item);
}
public ItemStack L() {
switch (this.itemSpecMode2) {
case NAME:
return new ItemStack(this.item, 1, this.f == -1 ? 0 : this.f);
case GROUP:
while (false) {
}
return this.itemSpecMode.L();
case ITEM:
return this.d();
default:
throw new MatchException(null, null);
}
}
public static ItemSpec L(ItemStack itemStack) {
return itemStack != null && itemStack.getItem() != null ? L(itemStack.getItem(), itemStack.getMetadata()) : null;
}
@Override
public int hashCode() {
return this.i.hashCode();
}
public String d() {
ItemSpec itemSpec1 = this;
switch (itemSpec1.itemSpecMode2) {
case NAME:
while (false) {
}
String string = itemSpec1.D();
return itemSpec1.f == -1 ? string : new StringBuilder().insert(0, string).append(" #").append(itemSpec1.f).toString();
case GROUP:
return itemSpec1.itemSpecMode.L();
case ITEM:
return new StringBuilder().insert(0, "*").append(itemSpec1.m).append("*").toString();
default:
throw new MatchException(null, null);
}
}
public static String L(Item item) {
return String.valueOf(Item.itemRegistry.getNameForObject(itemx));
}
public boolean L(ItemStack itemStack) {
if (itemStack != null && itemStack.getItem() != null) {
switch (this.itemSpecMode2) {
case NAME:
while (false) {
}
return itemStack.getItem() == this.item && (this.f == -1 || itemStack.getMetadata() == this.f);
case GROUP:
return this.itemSpecMode.d(itemStack);
case ITEM:
return d(itemStack.getItem()).contains(this.m);
default:
throw new MatchException(null, null);
}
} else {
return false;
}
}
public String L() {
return this.i;
}
@Override
public boolean equals(Object object) {
return object instanceof ItemSpec itemSpec1 && this.i.equals(itemSpec1.i);
}
}