Refactor and import cleanup (Excluding network PR changed files)
This commit is contained in:
parent
a36a0e6f4a
commit
c4ef977f16
165 changed files with 1572 additions and 1625 deletions
|
@ -44,8 +44,8 @@ import java.util.stream.Collectors;
|
|||
public class FluidUtils {
|
||||
|
||||
@Nonnull
|
||||
public static Fluid fluidFromBlock(Block block){
|
||||
if(block instanceof AccessorFluidBlock){
|
||||
public static Fluid fluidFromBlock(Block block) {
|
||||
if (block instanceof AccessorFluidBlock) {
|
||||
return ((AccessorFluidBlock) block).getFluid();
|
||||
}
|
||||
return Fluids.EMPTY;
|
||||
|
@ -59,7 +59,7 @@ public class FluidUtils {
|
|||
ItemStack inputStack = inventory.getStack(inputSlot);
|
||||
ItemStack outputStack = inventory.getStack(outputSlot);
|
||||
|
||||
if(!(inputStack.getItem() instanceof ItemFluidInfo)) return false;
|
||||
if (!(inputStack.getItem() instanceof ItemFluidInfo)) return false;
|
||||
if (outputStack.getCount() >= outputStack.getMaxCount()) return false;
|
||||
if (FluidUtils.isContainerEmpty(inputStack)) return false;
|
||||
|
||||
|
@ -67,21 +67,21 @@ public class FluidUtils {
|
|||
FluidInstance targetFluidInstance = target.getFluidInstance(null);
|
||||
Fluid currentFluid = targetFluidInstance.getFluid();
|
||||
|
||||
if(targetFluidInstance.isEmpty() || currentFluid == itemFluidInfo.getFluid(inputStack)) {
|
||||
if (targetFluidInstance.isEmpty() || currentFluid == itemFluidInfo.getFluid(inputStack)) {
|
||||
FluidValue freeSpace = target.getCapacity(null).subtract(targetFluidInstance.getAmount());
|
||||
|
||||
if(!outputStack.isEmpty()){
|
||||
if(outputStack.getCount() >= outputStack.getMaxCount() || !outputStack.isItemEqual(itemFluidInfo.getEmpty())){
|
||||
if (!outputStack.isEmpty()) {
|
||||
if (outputStack.getCount() >= outputStack.getMaxCount() || !outputStack.isItemEqual(itemFluidInfo.getEmpty())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(freeSpace.equalOrMoreThan(FluidValue.BUCKET)){
|
||||
if (freeSpace.equalOrMoreThan(FluidValue.BUCKET)) {
|
||||
inputStack.decrement(1);
|
||||
targetFluidInstance.setFluid(itemFluidInfo.getFluid(inputStack));
|
||||
targetFluidInstance.addAmount(FluidValue.BUCKET);
|
||||
|
||||
if(outputStack.isEmpty()){
|
||||
if (outputStack.isEmpty()) {
|
||||
inventory.setStack(outputSlot, itemFluidInfo.getEmpty());
|
||||
} else {
|
||||
outputStack.increment(1);
|
||||
|
@ -96,17 +96,17 @@ public class FluidUtils {
|
|||
ItemStack inputStack = inventory.getStack(inputSlot);
|
||||
ItemStack outputStack = inventory.getStack(outputSlot);
|
||||
|
||||
if(!(inputStack.getItem() instanceof ItemFluidInfo)) return false;
|
||||
if (!(inputStack.getItem() instanceof ItemFluidInfo)) return false;
|
||||
if (!FluidUtils.isContainerEmpty(inputStack)) return false;
|
||||
|
||||
ItemFluidInfo itemFluidInfo = (ItemFluidInfo) inputStack.getItem();
|
||||
FluidInstance sourceFluid = source.getFluidInstance(null);
|
||||
|
||||
if(sourceFluid.getFluid() == Fluids.EMPTY || sourceFluid.getAmount().lessThan(FluidValue.BUCKET)){
|
||||
if (sourceFluid.getFluid() == Fluids.EMPTY || sourceFluid.getAmount().lessThan(FluidValue.BUCKET)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!outputStack.isEmpty()){
|
||||
if (!outputStack.isEmpty()) {
|
||||
if (outputStack.getCount() >= outputStack.getMaxCount()) return false;
|
||||
|
||||
if (!(outputStack.getItem() instanceof ItemFluidInfo)) return false;
|
||||
|
@ -115,12 +115,12 @@ public class FluidUtils {
|
|||
|
||||
ItemFluidInfo outputFluidInfo = (ItemFluidInfo) outputStack.getItem();
|
||||
|
||||
if(outputFluidInfo.getFluid(outputStack) != sourceFluid.getFluid()){
|
||||
if (outputFluidInfo.getFluid(outputStack) != sourceFluid.getFluid()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(outputStack.isEmpty()){
|
||||
if (outputStack.isEmpty()) {
|
||||
inventory.setStack(outputSlot, itemFluidInfo.getFull(sourceFluid.getFluid()));
|
||||
} else {
|
||||
outputStack.increment(1);
|
||||
|
@ -140,15 +140,13 @@ public class FluidUtils {
|
|||
public static FluidInstance getFluidStackInContainer(@Nonnull ItemStack invStack) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isContainerEmpty(ItemStack inputStack) {
|
||||
if (inputStack.isEmpty())
|
||||
return false;
|
||||
if (!(inputStack.getItem() instanceof ItemFluidInfo))
|
||||
return false;
|
||||
ItemFluidInfo itemFluidInfo = (ItemFluidInfo) inputStack.getItem();
|
||||
if (itemFluidInfo.getFluid(inputStack) != Fluids.EMPTY)
|
||||
return false;
|
||||
return true;
|
||||
return itemFluidInfo.getFluid(inputStack) == Fluids.EMPTY;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,12 +50,12 @@ public class InitUtils {
|
|||
RebornRegistry.registerIdent(block, new Identifier(TechReborn.MOD_ID, name));
|
||||
return block;
|
||||
}
|
||||
|
||||
|
||||
public static SoundEvent setup(String name) {
|
||||
Identifier identifier = new Identifier(TechReborn.MOD_ID, name);
|
||||
return Registry.register(Registry.SOUND_EVENT, identifier, new SoundEvent(identifier));
|
||||
}
|
||||
|
||||
|
||||
public static void initPoweredItems(Item item, DefaultedList<ItemStack> itemList) {
|
||||
ItemStack uncharged = new ItemStack(item);
|
||||
ItemStack charged = new ItemStack(item);
|
||||
|
|
|
@ -26,10 +26,9 @@ package techreborn.utils;
|
|||
|
||||
/**
|
||||
* @author drcrazy
|
||||
*
|
||||
*/
|
||||
public class PlayerUtils {
|
||||
|
||||
|
||||
public static int getLevelExperience(int level) {
|
||||
if (level >= 30) {
|
||||
return 112 + (level - 30) * 9;
|
||||
|
|
|
@ -64,14 +64,14 @@ public final class PoweredCraftingHandler implements ItemCraftCallback {
|
|||
return;
|
||||
}
|
||||
Map<Enchantment, Integer> map = Maps.newLinkedHashMap();
|
||||
for (int i = 0; i < craftingInventory.size(); i++){
|
||||
for (int i = 0; i < craftingInventory.size(); i++) {
|
||||
ItemStack ingredient = craftingInventory.getStack(i);
|
||||
if (ingredient.isEmpty()){
|
||||
if (ingredient.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
EnchantmentHelper.get(ingredient).forEach((key, value) -> map.merge(key, value, (v1, v2) -> v1 > v2 ? v1 : v2));
|
||||
}
|
||||
if (!map.isEmpty()){
|
||||
if (!map.isEmpty()) {
|
||||
EnchantmentHelper.set(map, stack);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,21 +39,19 @@ public class RecipeUtils {
|
|||
public static ItemStack getEmptyCell(int stackSize) {
|
||||
return DynamicCellItem.getEmptyCell(stackSize);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Used to get the matching output of a recipe type that only has 1 input
|
||||
*
|
||||
*/
|
||||
public static <T extends Recipe<?>> ItemStack getMatchingRecipes(World world, RecipeType<T> type, ItemStack input){
|
||||
public static <T extends Recipe<?>> ItemStack getMatchingRecipes(World world, RecipeType<T> type, ItemStack input) {
|
||||
return getRecipes(world, type).stream()
|
||||
.filter(recipe -> recipe.getPreviewInputs().size() == 1 && recipe.getPreviewInputs().get(0).test(input))
|
||||
.map(Recipe::getOutput)
|
||||
.findFirst()
|
||||
.orElse(ItemStack.EMPTY);
|
||||
.filter(recipe -> recipe.getPreviewInputs().size() == 1 && recipe.getPreviewInputs().get(0).test(input))
|
||||
.map(Recipe::getOutput)
|
||||
.findFirst()
|
||||
.orElse(ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
public static <T extends Recipe<?>> List<Recipe<?>> getRecipes(World world, RecipeType<T> type){
|
||||
|
||||
public static <T extends Recipe<?>> List<Recipe<?>> getRecipes(World world, RecipeType<T> type) {
|
||||
return world.getRecipeManager().values().stream().filter(iRecipe -> iRecipe.getType() == type).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,9 +84,9 @@ public class TagUtils {
|
|||
} else
|
||||
nameBuilder.append(charAt);
|
||||
}
|
||||
return new String[] {
|
||||
prefixBuilder.toString(),
|
||||
nameBuilder.toString()
|
||||
return new String[]{
|
||||
prefixBuilder.toString(),
|
||||
nameBuilder.toString()
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -112,8 +112,8 @@ public class TagUtils {
|
|||
|
||||
@Deprecated
|
||||
public static boolean isOre(
|
||||
@Nonnull
|
||||
ItemStack stack, String oreName) {
|
||||
@Nonnull
|
||||
ItemStack stack, String oreName) {
|
||||
throw new UnsupportedOperationException("Move to tags");
|
||||
}
|
||||
|
||||
|
|
|
@ -68,29 +68,29 @@ public class ToolTipAssistUtils {
|
|||
}
|
||||
|
||||
// Add reminder that they can use shift to calculate the entire stack
|
||||
if(shouldStackCalculate && !shiftHeld){
|
||||
if (shouldStackCalculate && !shiftHeld) {
|
||||
tips.add(new LiteralText(instructColour + "Hold shift for stack calculation"));
|
||||
}
|
||||
|
||||
return tips;
|
||||
}
|
||||
|
||||
public static void addInfo(String inKey, List<Text> list){
|
||||
public static void addInfo(String inKey, List<Text> list) {
|
||||
addInfo(inKey, list, true);
|
||||
}
|
||||
|
||||
public static void addInfo(String inKey, List<Text> list, boolean hidden){
|
||||
public static void addInfo(String inKey, List<Text> list, boolean hidden) {
|
||||
String key = ("techreborn.message.info." + inKey);
|
||||
|
||||
if(I18n.hasTranslation(key)){
|
||||
if(!hidden || Screen.hasShiftDown()){
|
||||
if (I18n.hasTranslation(key)) {
|
||||
if (!hidden || Screen.hasShiftDown()) {
|
||||
String info = I18n.translate(key);
|
||||
String infoLines[] = info.split("\\r?\\n");
|
||||
String[] infoLines = info.split("\\r?\\n");
|
||||
|
||||
for (String infoLine: infoLines) {
|
||||
for (String infoLine : infoLines) {
|
||||
list.add(new LiteralText(infoColour + infoLine));
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
list.add(new LiteralText(instructColour + "Hold shift for info"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,11 +70,12 @@ public class ToolsUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* Fills in set of BlockPos which should be broken by AOE mining
|
||||
* @param worldIn World reference
|
||||
* @param pos BlockPos Position of originally broken block
|
||||
* Fills in set of BlockPos which should be broken by AOE mining
|
||||
*
|
||||
* @param worldIn World reference
|
||||
* @param pos BlockPos Position of originally broken block
|
||||
* @param entityLiving LivingEntity Player who broke block
|
||||
* @param radius int Radius of additional blocks to include. E.g. for 3x3 mining radius will be 1
|
||||
* @param radius int Radius of additional blocks to include. E.g. for 3x3 mining radius will be 1
|
||||
* @return Set of BlockPos to process by tool block break logic
|
||||
*/
|
||||
public static Set<BlockPos> getAOEMiningBlocks(World worldIn, BlockPos pos, @Nullable LivingEntity entityLiving, int radius) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue