Use modern java features where we can, optimise imports.

This commit is contained in:
modmuss50 2021-05-29 20:32:05 +01:00
parent 52e4767247
commit 31e7b357dc
135 changed files with 342 additions and 794 deletions

View file

@ -28,10 +28,10 @@ import net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder;
import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback;
import net.minecraft.item.ItemConvertible;
import net.minecraft.loot.LootPool;
import net.minecraft.loot.provider.number.UniformLootNumberProvider;
import net.minecraft.loot.entry.ItemEntry;
import net.minecraft.loot.entry.LootPoolEntry;
import net.minecraft.loot.function.SetCountLootFunction;
import net.minecraft.loot.provider.number.UniformLootNumberProvider;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent.Ingots;
import techreborn.init.TRContent.Parts;
@ -94,24 +94,21 @@ public class ModLoot {
if (TechRebornConfig.enableOverworldLoot) {
switch (stringId) {
case "minecraft:chests/abandoned_mineshaft":
case "minecraft:chests/desert_pyramid":
case "minecraft:chests/igloo_chest":
case "minecraft:chests/jungle_temple":
case "minecraft:chests/simple_dungeon":
case "minecraft:chests/village/village_weaponsmith":
case "minecraft:chests/village/village_armorer":
case "minecraft:chests/village/village_toolsmith":
supplier.withPool(poolBasic);
break;
case "minecraft:chests/stronghold_corridor":
case "minecraft:chests/stronghold_crossing":
case "minecraft:chests/stronghold_library":
supplier.withPool(poolAdvanced);
break;
case "minecraft:chests/woodland_mansion":
supplier.withPool(poolIndustrial);
break;
case "minecraft:chests/abandoned_mineshaft",
"minecraft:chests/desert_pyramid",
"minecraft:chests/igloo_chest",
"minecraft:chests/jungle_temple",
"minecraft:chests/simple_dungeon",
"minecraft:chests/village/village_weaponsmith",
"minecraft:chests/village/village_armorer",
"minecraft:chests/village/village_toolsmith"
-> supplier.withPool(poolBasic);
case "minecraft:chests/stronghold_corridor",
"minecraft:chests/stronghold_crossing",
"minecraft:chests/stronghold_library"
-> supplier.withPool(poolAdvanced);
case "minecraft:chests/woodland_mansion"
-> supplier.withPool(poolIndustrial);
}
}

View file

@ -73,7 +73,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Supplier;
public class TRBlockEntities {
@ -146,7 +145,7 @@ public class TRBlockEntities {
public static <T extends BlockEntity> BlockEntityType<T> register(BiFunction<BlockPos, BlockState, T> supplier, String name, Block... blocks) {
Validate.isTrue(blocks.length > 0, "no blocks for blockEntity entity type!");
return register(new Identifier(TechReborn.MOD_ID, name).toString(), FabricBlockEntityTypeBuilder.create((pos, state) -> supplier.apply(pos, state), blocks));
return register(new Identifier(TechReborn.MOD_ID, name).toString(), FabricBlockEntityTypeBuilder.create(supplier::apply, blocks));
}
public static <T extends BlockEntity> BlockEntityType<T> register(String id, FabricBlockEntityTypeBuilder<T> builder) {

View file

@ -35,6 +35,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.structure.rule.RuleTest;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;
import reborncore.api.blockentity.IUpgrade;
import reborncore.common.fluid.FluidValue;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
@ -83,8 +84,6 @@ import techreborn.items.UpgradeItem;
import techreborn.items.armor.QuantumSuitItem;
import techreborn.items.tool.MiningLevel;
import techreborn.utils.InitUtils;
import org.jetbrains.annotations.Nullable;
import techreborn.world.DataDrivenFeature;
import java.util.*;

View file

@ -32,7 +32,6 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
@ -73,9 +72,9 @@ public class TemplateProcessor {
}
private void processFile(Path inputFile, Path outputFile, Map<String, String> values) throws IOException {
String input = new String(Files.readAllBytes(inputFile), StandardCharsets.UTF_8);
String input = Files.readString(inputFile);
String output = replaceValues(input, values);
Files.write(outputFile, output.getBytes(StandardCharsets.UTF_8));
Files.writeString(outputFile, output);
}
private static String replaceValues(String input, Map<String, String> values) {