Small cleanup

This commit is contained in:
drcrazy 2020-07-18 19:30:08 +03:00
parent 01663648c4
commit 90521007bb
5 changed files with 5 additions and 123 deletions

View file

@ -25,16 +25,12 @@
package techreborn.utils;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tag.Tag;
import net.minecraft.tag.TagContainer;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class TagUtils {
public static <T> boolean hasTag(T type, Tag<T> tag) {
@ -52,69 +48,4 @@ public class TagUtils {
public static TagContainer<Fluid> getAllFluidTags(World world) {
return world.getTagManager().fluids();
}
public static String toFirstLower(String string) {
if (string == null || string.isEmpty())
return string;
return Character.toLowerCase(string.charAt(0)) + string.substring(1);
}
public static String toFirstUpper(String string) {
if (string.isEmpty())
return string;
return Character.toUpperCase(string.charAt(0)) + string.substring(1);
}
public static String joinDictName(String prefix, String name) {
return prefix + toFirstUpper(name);
}
public static String[] getDictData(String prefixed) {
StringBuilder prefixBuilder = new StringBuilder();
StringBuilder nameBuilder = new StringBuilder();
boolean prefixFinished = false;
for (int i = 0; i < prefixed.length(); i++) {
char charAt = prefixed.charAt(i);
if (!prefixFinished) {
if (Character.isUpperCase(charAt)) {
nameBuilder.append(Character.toLowerCase(charAt));
prefixFinished = true;
} else
prefixBuilder.append(charAt);
} else
nameBuilder.append(charAt);
}
return new String[]{
prefixBuilder.toString(),
nameBuilder.toString()
};
}
public static boolean isDictPrefixed(String name, String... prefixes) {
for (String prefix : prefixes)
if (name.startsWith(prefix))
return true;
return false;
}
@Deprecated
@Nonnull
public static ItemStack getDictOreOrEmpty(String name, int amount) {
throw new UnsupportedOperationException("Move to tags");
}
@Deprecated
public static boolean isOre(BlockState state, String oreName) {
throw new UnsupportedOperationException("Move to tags");
}
@Deprecated
public static boolean isOre(
@Nonnull
ItemStack stack, String oreName) {
throw new UnsupportedOperationException("Move to tags");
}
}