/* * This file is part of TechReborn, licensed under the MIT License (MIT). * * Copyright (c) 2020 TechReborn * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package techreborn.init; import net.minecraft.block.Block; import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.item.ItemConvertible; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; import org.apache.commons.lang3.Validate; import techreborn.TechReborn; import techreborn.blockentity.cable.CableBlockEntity; import techreborn.blockentity.generator.LightningRodBlockEntity; import techreborn.blockentity.generator.PlasmaGeneratorBlockEntity; import techreborn.blockentity.generator.SolarPanelBlockEntity; import techreborn.blockentity.generator.advanced.*; import techreborn.blockentity.generator.basic.SolidFuelGeneratorBlockEntity; import techreborn.blockentity.generator.basic.WaterMillBlockEntity; import techreborn.blockentity.generator.basic.WindMillBlockEntity; import techreborn.blockentity.lighting.LampBlockEntity; import techreborn.blockentity.machine.iron.IronAlloyFurnaceBlockEntity; import techreborn.blockentity.machine.iron.IronFurnaceBlockEntity; import techreborn.blockentity.machine.misc.AlarmBlockEntity; import techreborn.blockentity.machine.misc.ChargeOMatBlockEntity; import techreborn.blockentity.machine.misc.DrainBlockEntity; import techreborn.blockentity.machine.multiblock.*; import techreborn.blockentity.machine.multiblock.casing.MachineCasingBlockEntity; import techreborn.blockentity.machine.tier1.*; import techreborn.blockentity.machine.tier3.ChunkLoaderBlockEntity; import techreborn.blockentity.machine.tier3.IndustrialCentrifugeBlockEntity; import techreborn.blockentity.machine.tier3.MatterFabricatorBlockEntity; import techreborn.blockentity.storage.energy.AdjustableSUBlockEntity; import techreborn.blockentity.storage.energy.HighVoltageSUBlockEntity; import techreborn.blockentity.storage.energy.LowVoltageSUBlockEntity; import techreborn.blockentity.storage.energy.MediumVoltageSUBlockEntity; import techreborn.blockentity.storage.energy.idsu.InterdimensionalSUBlockEntity; import techreborn.blockentity.storage.energy.lesu.LSUStorageBlockEntity; import techreborn.blockentity.storage.energy.lesu.LapotronicSUBlockEntity; import techreborn.blockentity.storage.fluid.TankUnitBaseBlockEntity; import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity; import techreborn.blockentity.transformers.EVTransformerBlockEntity; import techreborn.blockentity.transformers.HVTransformerBlockEntity; import techreborn.blockentity.transformers.LVTransformerBlockEntity; import techreborn.blockentity.transformers.MVTransformerBlockEntity; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.function.Supplier; public class TRBlockEntities { private static final List> TYPES = new ArrayList<>(); public static final BlockEntityType STORAGE_UNIT = register(StorageUnitBaseBlockEntity::new, "storage_unit", TRContent.StorageUnit.values()); public static final BlockEntityType TANK_UNIT = register(TankUnitBaseBlockEntity::new, "tank_unit", TRContent.TankUnit.values()); public static final BlockEntityType DRAIN = register(DrainBlockEntity::new, "drain", TRContent.Machine.DRAIN); public static final BlockEntityType THERMAL_GEN = register(ThermalGeneratorBlockEntity::new, "thermal_generator", TRContent.Machine.THERMAL_GENERATOR); public static final BlockEntityType INDUSTRIAL_CENTRIFUGE = register(IndustrialCentrifugeBlockEntity::new, "industrial_centrifuge", TRContent.Machine.INDUSTRIAL_CENTRIFUGE); public static final BlockEntityType ROLLING_MACHINE = register(RollingMachineBlockEntity::new, "rolling_machine", TRContent.Machine.ROLLING_MACHINE); public static final BlockEntityType INDUSTRIAL_BLAST_FURNACE = register(IndustrialBlastFurnaceBlockEntity::new, "industrial_blast_furnace", TRContent.Machine.INDUSTRIAL_BLAST_FURNACE); public static final BlockEntityType ALLOY_SMELTER = register(AlloySmelterBlockEntity::new, "alloy_smelter", TRContent.Machine.ALLOY_SMELTER); public static final BlockEntityType INDUSTRIAL_GRINDER = register(IndustrialGrinderBlockEntity::new, "industrial_grinder", TRContent.Machine.INDUSTRIAL_GRINDER); public static final BlockEntityType IMPLOSION_COMPRESSOR = register(ImplosionCompressorBlockEntity::new, "implosion_compressor", TRContent.Machine.IMPLOSION_COMPRESSOR); public static final BlockEntityType MATTER_FABRICATOR = register(MatterFabricatorBlockEntity::new, "matter_fabricator", TRContent.Machine.MATTER_FABRICATOR); public static final BlockEntityType CHUNK_LOADER = register(ChunkLoaderBlockEntity::new, "chunk_loader", TRContent.Machine.CHUNK_LOADER); public static final BlockEntityType CHARGE_O_MAT = register(ChargeOMatBlockEntity::new, "charge_o_mat", TRContent.Machine.CHARGE_O_MAT); public static final BlockEntityType PLAYER_DETECTOR = register(PlayerDectectorBlockEntity::new, "player_detector", TRContent.Machine.PLAYER_DETECTOR); public static final BlockEntityType CABLE = register(CableBlockEntity::new, "cable", TRContent.Cables.values()); public static final BlockEntityType MACHINE_CASINGS = register(MachineCasingBlockEntity::new, "machine_casing", TRContent.MachineBlocks.getCasings()); public static final BlockEntityType DRAGON_EGG_SYPHON = register(DragonEggSyphonBlockEntity::new, "dragon_egg_syphon", TRContent.Machine.DRAGON_EGG_SYPHON); public static final BlockEntityType ASSEMBLY_MACHINE = register(AssemblingMachineBlockEntity::new, "assembly_machine", TRContent.Machine.ASSEMBLY_MACHINE); public static final BlockEntityType DIESEL_GENERATOR = register(DieselGeneratorBlockEntity::new, "diesel_generator", TRContent.Machine.DIESEL_GENERATOR); public static final BlockEntityType INDUSTRIAL_ELECTROLYZER = register(IndustrialElectrolyzerBlockEntity::new, "industrial_electrolyzer", TRContent.Machine.INDUSTRIAL_ELECTROLYZER); public static final BlockEntityType SEMI_FLUID_GENERATOR = register(SemiFluidGeneratorBlockEntity::new, "semi_fluid_generator", TRContent.Machine.SEMI_FLUID_GENERATOR); public static final BlockEntityType GAS_TURBINE = register(GasTurbineBlockEntity::new, "gas_turbine", TRContent.Machine.GAS_TURBINE); public static final BlockEntityType IRON_ALLOY_FURNACE = register(IronAlloyFurnaceBlockEntity::new, "iron_alloy_furnace", TRContent.Machine.IRON_ALLOY_FURNACE); public static final BlockEntityType CHEMICAL_REACTOR = register(ChemicalReactorBlockEntity::new, "chemical_reactor", TRContent.Machine.CHEMICAL_REACTOR); public static final BlockEntityType INTERDIMENSIONAL_SU = register(InterdimensionalSUBlockEntity::new, "interdimensional_su", TRContent.Machine.INTERDIMENSIONAL_SU); public static final BlockEntityType ADJUSTABLE_SU = register(AdjustableSUBlockEntity::new, "adjustable_su", TRContent.Machine.ADJUSTABLE_SU); public static final BlockEntityType LAPOTRONIC_SU = register(LapotronicSUBlockEntity::new, "lapotronic_su", TRContent.Machine.LAPOTRONIC_SU); public static final BlockEntityType LSU_STORAGE = register(LSUStorageBlockEntity::new, "lsu_storage", TRContent.Machine.LSU_STORAGE); public static final BlockEntityType DISTILLATION_TOWER = register(DistillationTowerBlockEntity::new, "distillation_tower", TRContent.Machine.DISTILLATION_TOWER); public static final BlockEntityType VACUUM_FREEZER = register(VacuumFreezerBlockEntity::new, "vacuum_freezer", TRContent.Machine.VACUUM_FREEZER); public static final BlockEntityType FUSION_CONTROL_COMPUTER = register(FusionControlComputerBlockEntity::new, "fusion_control_computer", TRContent.Machine.FUSION_CONTROL_COMPUTER); public static final BlockEntityType LIGHTNING_ROD = register(LightningRodBlockEntity::new, "lightning_rod", TRContent.Machine.LIGHTNING_ROD); public static final BlockEntityType INDUSTRIAL_SAWMILL = register(IndustrialSawmillBlockEntity::new, "industrial_sawmill", TRContent.Machine.INDUSTRIAL_SAWMILL); public static final BlockEntityType SOLID_FUEL_GENEREATOR = register(SolidFuelGeneratorBlockEntity::new, "solid_fuel_generator", TRContent.Machine.SOLID_FUEL_GENERATOR); public static final BlockEntityType EXTRACTOR = register(ExtractorBlockEntity::new, "extractor", TRContent.Machine.EXTRACTOR); public static final BlockEntityType RESIN_BASIN = register(ResinBasinBlockEntity::new, "resin_basin", TRContent.Machine.RESIN_BASIN); public static final BlockEntityType COMPRESSOR = register(CompressorBlockEntity::new, "compressor", TRContent.Machine.COMPRESSOR); public static final BlockEntityType ELECTRIC_FURNACE = register(ElectricFurnaceBlockEntity::new, "electric_furnace", TRContent.Machine.ELECTRIC_FURNACE); public static final BlockEntityType SOLAR_PANEL = register(SolarPanelBlockEntity::new, "solar_panel", TRContent.SolarPanels.values()); public static final BlockEntityType WATER_MILL = register(WaterMillBlockEntity::new, "water_mill", TRContent.Machine.WATER_MILL); public static final BlockEntityType WIND_MILL = register(WindMillBlockEntity::new, "wind_mill", TRContent.Machine.WIND_MILL); public static final BlockEntityType RECYCLER = register(RecyclerBlockEntity::new, "recycler", TRContent.Machine.RECYCLER); public static final BlockEntityType LOW_VOLTAGE_SU = register(LowVoltageSUBlockEntity::new, "low_voltage_su", TRContent.Machine.LOW_VOLTAGE_SU); public static final BlockEntityType MEDIUM_VOLTAGE_SU = register(MediumVoltageSUBlockEntity::new, "medium_voltage_su", TRContent.Machine.MEDIUM_VOLTAGE_SU); public static final BlockEntityType HIGH_VOLTAGE_SU = register(HighVoltageSUBlockEntity::new, "high_voltage_su", TRContent.Machine.HIGH_VOLTAGE_SU); public static final BlockEntityType LV_TRANSFORMER = register(LVTransformerBlockEntity::new, "lv_transformer", TRContent.Machine.LV_TRANSFORMER); public static final BlockEntityType MV_TRANSFORMER = register(MVTransformerBlockEntity::new, "mv_transformer", TRContent.Machine.MV_TRANSFORMER); public static final BlockEntityType HV_TRANSFORMER = register(HVTransformerBlockEntity::new, "hv_transformer", TRContent.Machine.HV_TRANSFORMER); public static final BlockEntityType EV_TRANSFORMER = register(EVTransformerBlockEntity::new, "ev_transformer", TRContent.Machine.EV_TRANSFORMER); public static final BlockEntityType AUTO_CRAFTING_TABLE = register(AutoCraftingTableBlockEntity::new, "auto_crafting_table", TRContent.Machine.AUTO_CRAFTING_TABLE); public static final BlockEntityType IRON_FURNACE = register(IronFurnaceBlockEntity::new, "iron_furnace", TRContent.Machine.IRON_FURNACE); public static final BlockEntityType SCRAPBOXINATOR = register(ScrapboxinatorBlockEntity::new, "scrapboxinator", TRContent.Machine.SCRAPBOXINATOR); public static final BlockEntityType PLASMA_GENERATOR = register(PlasmaGeneratorBlockEntity::new, "plasma_generator", TRContent.Machine.PLASMA_GENERATOR); public static final BlockEntityType LAMP = register(LampBlockEntity::new, "lamp", TRContent.Machine.LAMP_INCANDESCENT, TRContent.Machine.LAMP_LED); public static final BlockEntityType ALARM = register(AlarmBlockEntity::new, "alarm", TRContent.Machine.ALARM); public static final BlockEntityType FLUID_REPLICATOR = register(FluidReplicatorBlockEntity::new, "fluid_replicator", TRContent.Machine.FLUID_REPLICATOR); public static final BlockEntityType SOLID_CANNING_MACHINE = register(SoildCanningMachineBlockEntity::new, "solid_canning_machine", TRContent.Machine.SOLID_CANNING_MACHINE); public static final BlockEntityType WIRE_MILL = register(WireMillBlockEntity::new, "wire_mill", TRContent.Machine.WIRE_MILL); public static final BlockEntityType GREENHOUSE_CONTROLLER = register(GreenhouseControllerBlockEntity::new, "greenhouse_controller", TRContent.Machine.GREENHOUSE_CONTROLLER); public static BlockEntityType register(Supplier supplier, String name, ItemConvertible... items) { return register(supplier, name, Arrays.stream(items).map(itemConvertible -> Block.getBlockFromItem(itemConvertible.asItem())).toArray(Block[]::new)); } public static BlockEntityType register(Supplier 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(), BlockEntityType.Builder.create(supplier, blocks)); } public static BlockEntityType register(String id, BlockEntityType.Builder builder) { BlockEntityType blockEntityType = builder.build(null); Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(id), blockEntityType); TRBlockEntities.TYPES.add(blockEntityType); return blockEntityType; } }