diff --git a/build.gradle.kts b/build.gradle.kts index 98ecd204..2e16b7c7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -119,10 +119,9 @@ subprojects { java { target("src/**/java/**/*.java") endWithNewline() - indentWithSpaces() + indentWithSpaces(4) removeUnusedImports() - toggleOffOn() - eclipse().configFile(rootProject.file("codeformat/codeformat.xml")) + palantirJavaFormat() importOrderFile(rootProject.file("codeformat/mega.importorder")) // courtesy of diffplug/spotless#240 @@ -234,4 +233,4 @@ for (platform in property("enabledPlatforms").toString().split(',')) { skip() } } -} \ No newline at end of file +} diff --git a/codeformat/codeformat.xml b/codeformat/codeformat.xml deleted file mode 100644 index 4352de1b..00000000 --- a/codeformat/codeformat.xml +++ /dev/null @@ -1,365 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/common/src/main/java/gripe/_90/megacells/block/MEGAPatternProviderBlock.java b/common/src/main/java/gripe/_90/megacells/block/MEGAPatternProviderBlock.java index ffcdf482..149e45bb 100644 --- a/common/src/main/java/gripe/_90/megacells/block/MEGAPatternProviderBlock.java +++ b/common/src/main/java/gripe/_90/megacells/block/MEGAPatternProviderBlock.java @@ -41,12 +41,11 @@ import gripe._90.megacells.definition.MEGATranslations; public class MEGAPatternProviderBlock extends AEBaseEntityBlock { - public static final EnumProperty PUSH_DIRECTION = EnumProperty.create("push_direction", - PushDirection.class); + public static final EnumProperty PUSH_DIRECTION = + EnumProperty.create("push_direction", PushDirection.class); - public static final MenuType MENU = MenuTypeBuilder - .create(Menu::new, PatternProviderLogicHost.class) - .build("mega_pattern_provider"); + public static final MenuType MENU = + MenuTypeBuilder.create(Menu::new, PatternProviderLogicHost.class).build("mega_pattern_provider"); public MEGAPatternProviderBlock(Properties props) { super(props); @@ -67,8 +66,8 @@ protected void createBlockStateDefinition(StateDefinition.Builder spriteGet TextureAtlasSprite ringSideVer = spriteGetter.apply(RING_SIDE_VER); return switch (this.type) { - case UNIT -> new UnitBakedModel(ringCorner, ringSideHor, ringSideVer, - spriteGetter.apply(UNIT_BASE)); + case UNIT -> new UnitBakedModel(ringCorner, ringSideHor, ringSideVer, spriteGetter.apply(UNIT_BASE)); case ACCELERATOR, STORAGE_1M, STORAGE_4M, STORAGE_16M, STORAGE_64M, STORAGE_256M -> new LightBakedModel( - ringCorner, ringSideHor, ringSideVer, spriteGetter.apply(LIGHT_BASE), + ringCorner, + ringSideHor, + ringSideVer, + spriteGetter.apply(LIGHT_BASE), this.getLightMaterial(spriteGetter)); - case MONITOR -> new MonitorBakedModel(ringCorner, ringSideHor, ringSideVer, + case MONITOR -> new MonitorBakedModel( + ringCorner, + ringSideHor, + ringSideVer, spriteGetter.apply(UNIT_BASE), spriteGetter.apply(MONITOR_BASE), spriteGetter.apply(MONITOR_LIGHT_DARK), diff --git a/common/src/main/java/gripe/_90/megacells/crafting/DecompressionPatternDecoder.java b/common/src/main/java/gripe/_90/megacells/crafting/DecompressionPatternDecoder.java index 48a0cc64..888cac3c 100644 --- a/common/src/main/java/gripe/_90/megacells/crafting/DecompressionPatternDecoder.java +++ b/common/src/main/java/gripe/_90/megacells/crafting/DecompressionPatternDecoder.java @@ -11,8 +11,7 @@ public class DecompressionPatternDecoder implements IPatternDetailsDecoder { public static final DecompressionPatternDecoder INSTANCE = new DecompressionPatternDecoder(); - private DecompressionPatternDecoder() { - } + private DecompressionPatternDecoder() {} @Override public boolean isEncodedPattern(ItemStack stack) { @@ -21,7 +20,9 @@ public boolean isEncodedPattern(ItemStack stack) { @Override public MEGADecompressionPattern decodePattern(AEItemKey what, Level level) { - if (level == null || what == null || !(what.getItem() instanceof MEGADecompressionPattern.Item) + if (level == null + || what == null + || !(what.getItem() instanceof MEGADecompressionPattern.Item) || !(what.hasTag())) { return null; } diff --git a/common/src/main/java/gripe/_90/megacells/crafting/DecompressionPatternEncoding.java b/common/src/main/java/gripe/_90/megacells/crafting/DecompressionPatternEncoding.java index 1e67a53e..044c6b67 100644 --- a/common/src/main/java/gripe/_90/megacells/crafting/DecompressionPatternEncoding.java +++ b/common/src/main/java/gripe/_90/megacells/crafting/DecompressionPatternEncoding.java @@ -26,8 +26,7 @@ public static int getFactor(CompoundTag nbt) { return nbt.getInt(NBT_FACTOR); } - public static void encode(CompoundTag tag, AEItemKey compressed, AEItemKey decompressed, - int factor) { + public static void encode(CompoundTag tag, AEItemKey compressed, AEItemKey decompressed, int factor) { tag.put(NBT_COMPRESSED, compressed.toTag()); tag.put(NBT_DECOMPRESSED, decompressed.toTag()); tag.putInt(NBT_FACTOR, factor); diff --git a/common/src/main/java/gripe/_90/megacells/crafting/MEGADecompressionPattern.java b/common/src/main/java/gripe/_90/megacells/crafting/MEGADecompressionPattern.java index ae273848..1bd6d0b9 100644 --- a/common/src/main/java/gripe/_90/megacells/crafting/MEGADecompressionPattern.java +++ b/common/src/main/java/gripe/_90/megacells/crafting/MEGADecompressionPattern.java @@ -26,8 +26,8 @@ public MEGADecompressionPattern(AEItemKey definition) { var factor = DecompressionPatternEncoding.getFactor(tag); var output = decompressed.toStack(factor); - this.inputs = new IInput[] { new Input() }; - this.outputs = new GenericStack[] { GenericStack.fromItemStack(output) }; + this.inputs = new IInput[] {new Input()}; + this.outputs = new GenericStack[] {GenericStack.fromItemStack(output)}; } @Override @@ -47,7 +47,8 @@ public GenericStack[] getOutputs() { @Override public boolean equals(Object obj) { - return obj != null && obj.getClass() == getClass() + return obj != null + && obj.getClass() == getClass() && ((MEGADecompressionPattern) obj).definition.equals(definition); } @@ -59,7 +60,7 @@ public int hashCode() { private class Input implements IInput { @Override public GenericStack[] getPossibleInputs() { - return new GenericStack[] { new GenericStack(input, 1) }; + return new GenericStack[] {new GenericStack(input, 1)}; } @Override diff --git a/common/src/main/java/gripe/_90/megacells/definition/MEGABlockEntities.java b/common/src/main/java/gripe/_90/megacells/definition/MEGABlockEntities.java index 3ad4f204..b03e834b 100644 --- a/common/src/main/java/gripe/_90/megacells/definition/MEGABlockEntities.java +++ b/common/src/main/java/gripe/_90/megacells/definition/MEGABlockEntities.java @@ -23,7 +23,7 @@ import gripe._90.megacells.block.entity.MEGAPatternProviderBlockEntity; import gripe._90.megacells.util.Utils; -@SuppressWarnings({ "unused", "unchecked" }) +@SuppressWarnings({"unused", "unchecked"}) public final class MEGABlockEntities { public static void init() { // controls static load order @@ -36,37 +36,57 @@ public static Map> getBlockEntityTypes() { return ImmutableMap.copyOf(BLOCK_ENTITY_TYPES); } - // spotless:off - public static final BlockEntityType MEGA_ENERGY_CELL = create("mega_energy_cell", EnergyCellBlockEntity.class, EnergyCellBlockEntity::new, MEGABlocks.MEGA_ENERGY_CELL); - - public static final BlockEntityType MEGA_CRAFTING_UNIT = create("mega_crafting_unit", CraftingBlockEntity.class, CraftingBlockEntity::new, MEGABlocks.MEGA_CRAFTING_UNIT, MEGABlocks.CRAFTING_ACCELERATOR); - public static final BlockEntityType MEGA_CRAFTING_STORAGE = create("mega_crafting_storage", CraftingBlockEntity.class, CraftingBlockEntity::new, MEGABlocks.CRAFTING_STORAGE_1M, MEGABlocks.CRAFTING_STORAGE_4M, MEGABlocks.CRAFTING_STORAGE_16M, MEGABlocks.CRAFTING_STORAGE_64M, MEGABlocks.CRAFTING_STORAGE_256M); - public static final BlockEntityType MEGA_CRAFTING_MONITOR = create("mega_crafting_monitor", CraftingMonitorBlockEntity.class, CraftingMonitorBlockEntity::new, MEGABlocks.CRAFTING_MONITOR); - - public static final BlockEntityType MEGA_PATTERN_PROVIDER = create("mega_pattern_provider", MEGAPatternProviderBlockEntity.class, MEGAPatternProviderBlockEntity::new, MEGABlocks.MEGA_PATTERN_PROVIDER); - // spotless:on + public static final BlockEntityType MEGA_ENERGY_CELL = create( + "mega_energy_cell", EnergyCellBlockEntity.class, EnergyCellBlockEntity::new, MEGABlocks.MEGA_ENERGY_CELL); + + public static final BlockEntityType MEGA_CRAFTING_UNIT = create( + "mega_crafting_unit", + CraftingBlockEntity.class, + CraftingBlockEntity::new, + MEGABlocks.MEGA_CRAFTING_UNIT, + MEGABlocks.CRAFTING_ACCELERATOR); + public static final BlockEntityType MEGA_CRAFTING_STORAGE = create( + "mega_crafting_storage", + CraftingBlockEntity.class, + CraftingBlockEntity::new, + MEGABlocks.CRAFTING_STORAGE_1M, + MEGABlocks.CRAFTING_STORAGE_4M, + MEGABlocks.CRAFTING_STORAGE_16M, + MEGABlocks.CRAFTING_STORAGE_64M, + MEGABlocks.CRAFTING_STORAGE_256M); + public static final BlockEntityType MEGA_CRAFTING_MONITOR = create( + "mega_crafting_monitor", + CraftingMonitorBlockEntity.class, + CraftingMonitorBlockEntity::new, + MEGABlocks.CRAFTING_MONITOR); + + public static final BlockEntityType MEGA_PATTERN_PROVIDER = create( + "mega_pattern_provider", + MEGAPatternProviderBlockEntity.class, + MEGAPatternProviderBlockEntity::new, + MEGABlocks.MEGA_PATTERN_PROVIDER); @SafeVarargs - private static BlockEntityType create(String id, Class entityClass, + private static BlockEntityType create( + String id, + Class entityClass, BlockEntityFactory factory, BlockDefinition>... blockDefinitions) { Preconditions.checkArgument(blockDefinitions.length > 0); - var blocks = Arrays.stream(blockDefinitions) - .map(BlockDefinition::block) - .toArray(AEBaseEntityBlock[]::new); + var blocks = Arrays.stream(blockDefinitions).map(BlockDefinition::block).toArray(AEBaseEntityBlock[]::new); - AtomicReference> typeHolder = new AtomicReference<>(); - BlockEntityType.BlockEntitySupplier supplier = (blockPos, blockState) -> factory.create(typeHolder.get(), - blockPos, blockState); - var type = BlockEntityType.Builder.of(supplier, blocks).build(null); + var typeHolder = new AtomicReference>(); + var type = BlockEntityType.Builder.of( + (blockPos, blockState) -> factory.create(typeHolder.get(), blockPos, blockState), blocks) + .build(null); typeHolder.set(type); // Makes it available to the supplier used above BLOCK_ENTITY_TYPES.put(Utils.makeId(id), type); AEBaseBlockEntity.registerBlockEntityItem(type, blockDefinitions[0].asItem()); for (var block : blocks) { - AEBaseEntityBlock baseBlock = (AEBaseEntityBlock) block; + var baseBlock = (AEBaseEntityBlock) block; baseBlock.setBlockEntity(entityClass, type, null, null); } @@ -77,5 +97,4 @@ private static BlockEntityType create(String id interface BlockEntityFactory { T create(BlockEntityType type, BlockPos pos, BlockState state); } - } diff --git a/common/src/main/java/gripe/_90/megacells/definition/MEGABlocks.java b/common/src/main/java/gripe/_90/megacells/definition/MEGABlocks.java index cb6500d5..3babfb01 100644 --- a/common/src/main/java/gripe/_90/megacells/definition/MEGABlocks.java +++ b/common/src/main/java/gripe/_90/megacells/definition/MEGABlocks.java @@ -48,41 +48,85 @@ public static List> getBlocks() { .sound(SoundType.METAL) .forceSolidOn(); - // spotless:off - public static final BlockDefinition SKY_STEEL_BLOCK = block("Sky Steel Block", "sky_steel_block", () -> new AEDecorativeBlock(BlockBehaviour.Properties.of().strength(5.0f, 12.0f).requiresCorrectToolForDrops().mapColor(MapColor.METAL).sound(SoundType.METAL))); - - public static final BlockDefinition MEGA_ENERGY_CELL = block("Superdense Energy Cell", "mega_energy_cell", () -> new EnergyCellBlock(12800000, 3200, 12800), EnergyCellBlockItem::new); - - public static final BlockDefinition MEGA_CRAFTING_UNIT = block("MEGA Crafting Unit", "mega_crafting_unit", () -> new CraftingUnitBlock(MEGACraftingUnitType.UNIT)); - public static final BlockDefinition CRAFTING_ACCELERATOR = craftingBlock("MEGA Crafting Co-Processing Unit", "mega_crafting_accelerator", () -> new CraftingUnitBlock(MEGACraftingUnitType.ACCELERATOR), () -> AEItems.ENGINEERING_PROCESSOR); - public static final BlockDefinition CRAFTING_STORAGE_1M = craftingBlock("1M MEGA Crafting Storage", "1m_crafting_storage", () -> new CraftingUnitBlock(MEGACraftingUnitType.STORAGE_1M), () -> MEGAItems.CELL_COMPONENT_1M); - public static final BlockDefinition CRAFTING_STORAGE_4M = craftingBlock("4M MEGA Crafting Storage", "4m_crafting_storage", () -> new CraftingUnitBlock(MEGACraftingUnitType.STORAGE_4M), () -> MEGAItems.CELL_COMPONENT_4M); - public static final BlockDefinition CRAFTING_STORAGE_16M = craftingBlock("16M MEGA Crafting Storage", "16m_crafting_storage", () -> new CraftingUnitBlock(MEGACraftingUnitType.STORAGE_16M), () -> MEGAItems.CELL_COMPONENT_16M); - public static final BlockDefinition CRAFTING_STORAGE_64M = craftingBlock("64M MEGA Crafting Storage", "64m_crafting_storage", () -> new CraftingUnitBlock(MEGACraftingUnitType.STORAGE_64M), () -> MEGAItems.CELL_COMPONENT_64M); - public static final BlockDefinition CRAFTING_STORAGE_256M = craftingBlock("256M MEGA Crafting Storage", "256m_crafting_storage", () -> new CraftingUnitBlock(MEGACraftingUnitType.STORAGE_256M), () -> MEGAItems.CELL_COMPONENT_256M); - public static final BlockDefinition CRAFTING_MONITOR = craftingBlock("MEGA Crafting Monitor", "mega_crafting_monitor", () -> new CraftingMonitorBlock(MEGACraftingUnitType.MONITOR), () -> AEParts.STORAGE_MONITOR); - - public static final BlockDefinition MEGA_PATTERN_PROVIDER = block("MEGA Pattern Provider", "mega_pattern_provider", () -> new MEGAPatternProviderBlock(props), MEGAPatternProviderBlock.Item::new); - // spotless:on - - private static BlockDefinition craftingBlock(String englishName, String id, - Supplier blockSupplier, - Supplier disassemblyExtra) { - return block(englishName, id, blockSupplier, + public static final BlockDefinition SKY_STEEL_BLOCK = block( + "Sky Steel Block", + "sky_steel_block", + () -> new AEDecorativeBlock(BlockBehaviour.Properties.of() + .strength(5.0f, 12.0f) + .requiresCorrectToolForDrops() + .mapColor(MapColor.METAL) + .sound(SoundType.METAL))); + + public static final BlockDefinition MEGA_ENERGY_CELL = block( + "Superdense Energy Cell", + "mega_energy_cell", + () -> new EnergyCellBlock(12800000, 3200, 12800), + EnergyCellBlockItem::new); + + public static final BlockDefinition MEGA_CRAFTING_UNIT = + block("MEGA Crafting Unit", "mega_crafting_unit", () -> new CraftingUnitBlock(MEGACraftingUnitType.UNIT)); + public static final BlockDefinition CRAFTING_ACCELERATOR = craftingBlock( + "MEGA Crafting Co-Processing Unit", + "mega_crafting_accelerator", + () -> new CraftingUnitBlock(MEGACraftingUnitType.ACCELERATOR), + () -> AEItems.ENGINEERING_PROCESSOR); + public static final BlockDefinition CRAFTING_STORAGE_1M = craftingBlock( + "1M MEGA Crafting Storage", + "1m_crafting_storage", + () -> new CraftingUnitBlock(MEGACraftingUnitType.STORAGE_1M), + () -> MEGAItems.CELL_COMPONENT_1M); + public static final BlockDefinition CRAFTING_STORAGE_4M = craftingBlock( + "4M MEGA Crafting Storage", + "4m_crafting_storage", + () -> new CraftingUnitBlock(MEGACraftingUnitType.STORAGE_4M), + () -> MEGAItems.CELL_COMPONENT_4M); + public static final BlockDefinition CRAFTING_STORAGE_16M = craftingBlock( + "16M MEGA Crafting Storage", + "16m_crafting_storage", + () -> new CraftingUnitBlock(MEGACraftingUnitType.STORAGE_16M), + () -> MEGAItems.CELL_COMPONENT_16M); + public static final BlockDefinition CRAFTING_STORAGE_64M = craftingBlock( + "64M MEGA Crafting Storage", + "64m_crafting_storage", + () -> new CraftingUnitBlock(MEGACraftingUnitType.STORAGE_64M), + () -> MEGAItems.CELL_COMPONENT_64M); + public static final BlockDefinition CRAFTING_STORAGE_256M = craftingBlock( + "256M MEGA Crafting Storage", + "256m_crafting_storage", + () -> new CraftingUnitBlock(MEGACraftingUnitType.STORAGE_256M), + () -> MEGAItems.CELL_COMPONENT_256M); + public static final BlockDefinition CRAFTING_MONITOR = craftingBlock( + "MEGA Crafting Monitor", + "mega_crafting_monitor", + () -> new CraftingMonitorBlock(MEGACraftingUnitType.MONITOR), + () -> AEParts.STORAGE_MONITOR); + + public static final BlockDefinition MEGA_PATTERN_PROVIDER = block( + "MEGA Pattern Provider", + "mega_pattern_provider", + () -> new MEGAPatternProviderBlock(props), + MEGAPatternProviderBlock.Item::new); + + private static BlockDefinition craftingBlock( + String englishName, String id, Supplier blockSupplier, Supplier disassemblyExtra) { + return block( + englishName, + id, + blockSupplier, (block, props) -> new MEGACraftingBlockItem(block, props, disassemblyExtra)); } - private static BlockDefinition block(String englishName, String id, - Supplier blockSupplier) { + private static BlockDefinition block( + String englishName, String id, Supplier blockSupplier) { return block(englishName, id, blockSupplier, null); } - private static BlockDefinition block(String englishName, String id, Supplier blockSupplier, + private static BlockDefinition block( + String englishName, + String id, + Supplier blockSupplier, BiFunction itemFactory) { - - // Create block and matching item - T block = blockSupplier.get(); - + var block = blockSupplier.get(); var itemProperties = new Item.Properties(); BlockItem item; @@ -97,7 +141,7 @@ private static BlockDefinition block(String englishName, St item = new BlockItem(block, itemProperties); } - BlockDefinition definition = new BlockDefinition<>(englishName, Utils.makeId(id), block, item); + var definition = new BlockDefinition<>(englishName, Utils.makeId(id), block, item); BLOCKS.add(definition); return definition; } diff --git a/common/src/main/java/gripe/_90/megacells/definition/MEGACreativeTab.java b/common/src/main/java/gripe/_90/megacells/definition/MEGACreativeTab.java index fd8e64ac..1c86a9ab 100644 --- a/common/src/main/java/gripe/_90/megacells/definition/MEGACreativeTab.java +++ b/common/src/main/java/gripe/_90/megacells/definition/MEGACreativeTab.java @@ -17,8 +17,8 @@ public class MEGACreativeTab { public static final CreativeModeTab TAB = Utils.PLATFORM.getCreativeTab(MEGACreativeTab::populateTab); public static final ResourceLocation ID = Utils.makeId("tab"); - private static void populateTab(CreativeModeTab.ItemDisplayParameters itemDisplayParameters, - CreativeModeTab.Output output) { + private static void populateTab( + CreativeModeTab.ItemDisplayParameters itemDisplayParameters, CreativeModeTab.Output output) { var itemDefs = new ArrayList>(); var blacklist = List.of(MEGAItems.DECOMPRESSION_PATTERN); diff --git a/common/src/main/java/gripe/_90/megacells/definition/MEGAItems.java b/common/src/main/java/gripe/_90/megacells/definition/MEGAItems.java index ea84780d..bcba6658 100644 --- a/common/src/main/java/gripe/_90/megacells/definition/MEGAItems.java +++ b/common/src/main/java/gripe/_90/megacells/definition/MEGAItems.java @@ -34,22 +34,27 @@ public static List> getItems() { return Collections.unmodifiableList(ITEMS); } - // spotless:off - public static final ItemDefinition SKY_STEEL_INGOT = item("Sky Steel Ingot", "sky_steel_ingot", p -> new MaterialItem(p.fireResistant())); + public static final ItemDefinition SKY_STEEL_INGOT = + item("Sky Steel Ingot", "sky_steel_ingot", p -> new MaterialItem(p.fireResistant())); - public static final ItemDefinition ACCUMULATION_PROCESSOR_PRESS = item("Inscriber Accumulation Press", "accumulation_processor_press", MaterialItem::new); - public static final ItemDefinition ACCUMULATION_PROCESSOR_PRINT = item("Printed Accumulation Circuit", "printed_accumulation_processor", MaterialItem::new); - public static final ItemDefinition ACCUMULATION_PROCESSOR = item("Accumulation Processor", "accumulation_processor", MaterialItem::new); + public static final ItemDefinition ACCUMULATION_PROCESSOR_PRESS = + item("Inscriber Accumulation Press", "accumulation_processor_press", MaterialItem::new); + public static final ItemDefinition ACCUMULATION_PROCESSOR_PRINT = + item("Printed Accumulation Circuit", "printed_accumulation_processor", MaterialItem::new); + public static final ItemDefinition ACCUMULATION_PROCESSOR = + item("Accumulation Processor", "accumulation_processor", MaterialItem::new); - public static final ItemDefinition MEGA_ITEM_CELL_HOUSING = item("MEGA Item Cell Housing", "mega_item_cell_housing", MaterialItem::new); - public static final ItemDefinition MEGA_FLUID_CELL_HOUSING = item("MEGA Fluid Cell Housing", "mega_fluid_cell_housing", MaterialItem::new); + public static final ItemDefinition MEGA_ITEM_CELL_HOUSING = + item("MEGA Item Cell Housing", "mega_item_cell_housing", MaterialItem::new); + public static final ItemDefinition MEGA_FLUID_CELL_HOUSING = + item("MEGA Fluid Cell Housing", "mega_fluid_cell_housing", MaterialItem::new); public static final ItemDefinition CELL_COMPONENT_1M = component(1); public static final ItemDefinition CELL_COMPONENT_4M = component(4); public static final ItemDefinition CELL_COMPONENT_16M = component(16); public static final ItemDefinition CELL_COMPONENT_64M = component(64); public static final ItemDefinition CELL_COMPONENT_256M = component(256); - + public static final StorageTier TIER_1M = tier(1, CELL_COMPONENT_1M); public static final StorageTier TIER_4M = tier(2, CELL_COMPONENT_4M); public static final StorageTier TIER_16M = tier(3, CELL_COMPONENT_16M); @@ -68,8 +73,10 @@ public static List> getItems() { public static final ItemDefinition FLUID_CELL_64M = fluidCell(TIER_64M); public static final ItemDefinition FLUID_CELL_256M = fluidCell(TIER_256M); - public static final ItemDefinition BULK_CELL_COMPONENT = item("MEGA Bulk Storage Component", "bulk_cell_component", MaterialItem::new); - public static final ItemDefinition BULK_ITEM_CELL = item("MEGA Bulk Item Storage Cell", "bulk_item_cell", MEGABulkCell::new); + public static final ItemDefinition BULK_CELL_COMPONENT = + item("MEGA Bulk Storage Component", "bulk_cell_component", MaterialItem::new); + public static final ItemDefinition BULK_ITEM_CELL = + item("MEGA Bulk Item Storage Cell", "bulk_item_cell", MEGABulkCell::new); public static final ItemDefinition PORTABLE_ITEM_CELL_1M = itemPortable(TIER_1M); public static final ItemDefinition PORTABLE_ITEM_CELL_4M = itemPortable(TIER_4M); @@ -83,10 +90,13 @@ public static List> getItems() { public static final ItemDefinition PORTABLE_FLUID_CELL_64M = fluidPortable(TIER_64M); public static final ItemDefinition PORTABLE_FLUID_CELL_256M = fluidPortable(TIER_256M); - public static final ItemDefinition GREATER_ENERGY_CARD = item("Greater Energy Card", "greater_energy_card", p -> new EnergyCardItem(p, 8)); - public static final ItemDefinition COMPRESSION_CARD = item("Compression Card", "compression_card", UpgradeCardItem::new); - public static final ItemDefinition DECOMPRESSION_PATTERN = item("Decompression Pattern", "decompression_pattern", MEGADecompressionPattern.Item::new); - // spotless:on + public static final ItemDefinition GREATER_ENERGY_CARD = + item("Greater Energy Card", "greater_energy_card", p -> new EnergyCardItem(p, 8)); + public static final ItemDefinition COMPRESSION_CARD = + item("Compression Card", "compression_card", UpgradeCardItem::new); + + public static final ItemDefinition DECOMPRESSION_PATTERN = + item("Decompression Pattern", "decompression_pattern", MEGADecompressionPattern.Item::new); public static List> getItemCells() { return List.of(ITEM_CELL_1M, ITEM_CELL_4M, ITEM_CELL_16M, ITEM_CELL_64M, ITEM_CELL_256M); @@ -97,60 +107,85 @@ public static List> getFluidCells() { } public static List> getItemPortables() { - return List.of(PORTABLE_ITEM_CELL_1M, PORTABLE_ITEM_CELL_4M, PORTABLE_ITEM_CELL_16M, PORTABLE_ITEM_CELL_64M, + return List.of( + PORTABLE_ITEM_CELL_1M, + PORTABLE_ITEM_CELL_4M, + PORTABLE_ITEM_CELL_16M, + PORTABLE_ITEM_CELL_64M, PORTABLE_ITEM_CELL_256M); } public static List> getFluidPortables() { - return List.of(PORTABLE_FLUID_CELL_1M, PORTABLE_FLUID_CELL_4M, PORTABLE_FLUID_CELL_16M, PORTABLE_FLUID_CELL_64M, + return List.of( + PORTABLE_FLUID_CELL_1M, + PORTABLE_FLUID_CELL_4M, + PORTABLE_FLUID_CELL_16M, + PORTABLE_FLUID_CELL_64M, PORTABLE_FLUID_CELL_256M); } private static StorageTier tier(int index, ItemDefinition component) { int multiplier = (int) Math.pow(4, index - 1); - return new StorageTier(index, multiplier + "m", 1048576 * multiplier, 2.5 + 0.5 * multiplier, - component::asItem); + return new StorageTier( + index, multiplier + "m", 1048576 * multiplier, 2.5 + 0.5 * multiplier, component::asItem); } private static ItemDefinition component(int mb) { - return item(mb + "M MEGA Storage Component", "cell_component_" + mb + "m", + return item( + mb + "M MEGA Storage Component", + "cell_component_" + mb + "m", p -> new StorageComponentItem(p, mb * 1024)); } public static ItemDefinition itemCell(StorageTier tier) { - return item(tier.namePrefix().toUpperCase() + " MEGA Item Storage Cell", + return item( + tier.namePrefix().toUpperCase() + " MEGA Item Storage Cell", "item_storage_cell_" + tier.namePrefix(), - p -> new BasicStorageCell(p.stacksTo(1), tier.componentSupplier().get(), MEGA_ITEM_CELL_HOUSING, - tier.idleDrain(), tier.bytes() / 1024, tier.bytes() / 128, 63, AEKeyType.items())); + p -> new BasicStorageCell( + p.stacksTo(1), + tier.componentSupplier().get(), + MEGA_ITEM_CELL_HOUSING, + tier.idleDrain(), + tier.bytes() / 1024, + tier.bytes() / 128, + 63, + AEKeyType.items())); } public static ItemDefinition fluidCell(StorageTier tier) { - return item(tier.namePrefix().toUpperCase() + " MEGA Fluid Storage Cell", + return item( + tier.namePrefix().toUpperCase() + " MEGA Fluid Storage Cell", "fluid_storage_cell_" + tier.namePrefix(), - p -> new BasicStorageCell(p.stacksTo(1), tier.componentSupplier().get(), MEGA_FLUID_CELL_HOUSING, - tier.idleDrain(), tier.bytes() / 1024, tier.bytes() / 128, 9, AEKeyType.fluids())); + p -> new BasicStorageCell( + p.stacksTo(1), + tier.componentSupplier().get(), + MEGA_FLUID_CELL_HOUSING, + tier.idleDrain(), + tier.bytes() / 1024, + tier.bytes() / 128, + 9, + AEKeyType.fluids())); } public static ItemDefinition itemPortable(StorageTier tier) { - return item(tier.namePrefix().toUpperCase() + " Portable Item Cell", "portable_item_cell_" + tier.namePrefix(), + return item( + tier.namePrefix().toUpperCase() + " Portable Item Cell", + "portable_item_cell_" + tier.namePrefix(), p -> new MEGAPortableCell(p, tier, AEKeyType.items(), MEStorageMenu.PORTABLE_ITEM_CELL_TYPE, 0x353535)); } public static ItemDefinition fluidPortable(StorageTier tier) { - return item(tier.namePrefix().toUpperCase() + " Portable Fluid Cell", + return item( + tier.namePrefix().toUpperCase() + " Portable Fluid Cell", "portable_fluid_cell_" + tier.namePrefix(), - p -> new MEGAPortableCell(p, tier, AEKeyType.fluids(), MEStorageMenu.PORTABLE_FLUID_CELL_TYPE, - 0x00F1C5)); + p -> new MEGAPortableCell( + p, tier, AEKeyType.fluids(), MEStorageMenu.PORTABLE_FLUID_CELL_TYPE, 0x00F1C5)); } - public static ItemDefinition item(String englishName, String id, - Function factory) { - Item.Properties p = new Item.Properties(); - T item = factory.apply(p); - - ItemDefinition definition = new ItemDefinition<>(englishName, Utils.makeId(id), item); + public static ItemDefinition item( + String englishName, String id, Function factory) { + var definition = new ItemDefinition<>(englishName, Utils.makeId(id), factory.apply(new Item.Properties())); ITEMS.add(definition); - return definition; } } diff --git a/common/src/main/java/gripe/_90/megacells/definition/MEGAParts.java b/common/src/main/java/gripe/_90/megacells/definition/MEGAParts.java index 7aef06ce..1105d6bc 100644 --- a/common/src/main/java/gripe/_90/megacells/definition/MEGAParts.java +++ b/common/src/main/java/gripe/_90/megacells/definition/MEGAParts.java @@ -19,18 +19,24 @@ public static void init() { // controls static load order } - // spotless:off - public static final ItemDefinition> MEGA_PATTERN_PROVIDER = customPart("MEGA Pattern Provider", "cable_mega_pattern_provider", MEGAPatternProviderPart.class, MEGAPatternProviderPart.Item::new); - public static final ItemDefinition> DECOMPRESSION_MODULE = part("MEGA Decompression Module", "decompression_module", DecompressionModulePart.class, DecompressionModulePart::new); - // spotless:on - - private static ItemDefinition> part(String englishName, String id, Class partClass, - Function, T> factory) { + public static final ItemDefinition> MEGA_PATTERN_PROVIDER = customPart( + "MEGA Pattern Provider", + "cable_mega_pattern_provider", + MEGAPatternProviderPart.class, + MEGAPatternProviderPart.Item::new); + public static final ItemDefinition> DECOMPRESSION_MODULE = part( + "MEGA Decompression Module", + "decompression_module", + DecompressionModulePart.class, + DecompressionModulePart::new); + + private static ItemDefinition> part( + String englishName, String id, Class partClass, Function, T> factory) { return customPart(englishName, id, partClass, props -> new PartItem<>(props, partClass, factory)); } - private static ItemDefinition> customPart(String englishName, String id, - Class partClass, Function> itemFactory) { + private static ItemDefinition> customPart( + String englishName, String id, Class partClass, Function> itemFactory) { PartModels.registerModels(PartModelsHelper.createModels(partClass)); return MEGAItems.item(englishName, id, itemFactory); } diff --git a/common/src/main/java/gripe/_90/megacells/definition/MEGATags.java b/common/src/main/java/gripe/_90/megacells/definition/MEGATags.java index 86fc2190..1ec5a9fd 100644 --- a/common/src/main/java/gripe/_90/megacells/definition/MEGATags.java +++ b/common/src/main/java/gripe/_90/megacells/definition/MEGATags.java @@ -9,15 +9,17 @@ import gripe._90.megacells.util.Utils; public final class MEGATags { - public static final TagKey SKY_STEEL_INGOT = itemTag(switch (Utils.PLATFORM.getLoader()) { - case FABRIC -> "c:sky_steel_ingots"; - case FORGE -> "forge:ingots/sky_steel"; - }); + public static final TagKey SKY_STEEL_INGOT = itemTag( + switch (Utils.PLATFORM.getLoader()) { + case FABRIC -> "c:sky_steel_ingots"; + case FORGE -> "forge:ingots/sky_steel"; + }); - private static final String SKY_STEEL_BLOCK_TAG = switch (Utils.PLATFORM.getLoader()) { - case FABRIC -> "c:sky_steel_blocks"; - case FORGE -> "forge:storage_blocks/sky_steel"; - }; + private static final String SKY_STEEL_BLOCK_TAG = + switch (Utils.PLATFORM.getLoader()) { + case FABRIC -> "c:sky_steel_blocks"; + case FORGE -> "forge:storage_blocks/sky_steel"; + }; public static final TagKey SKY_STEEL_BLOCK = blockTag(SKY_STEEL_BLOCK_TAG); public static final TagKey SKY_STEEL_BLOCK_ITEM = itemTag(SKY_STEEL_BLOCK_TAG); diff --git a/common/src/main/java/gripe/_90/megacells/init/InitStorageCells.java b/common/src/main/java/gripe/_90/megacells/init/InitStorageCells.java index 739178dc..0c4122fb 100644 --- a/common/src/main/java/gripe/_90/megacells/init/InitStorageCells.java +++ b/common/src/main/java/gripe/_90/megacells/init/InitStorageCells.java @@ -14,19 +14,20 @@ public class InitStorageCells { public static void init() { - Stream.of(MEGAItems.getItemCells(), MEGAItems.getItemPortables()).flatMap(Collection::stream) + Stream.of(MEGAItems.getItemCells(), MEGAItems.getItemPortables()) + .flatMap(Collection::stream) .forEach(c -> StorageCellModels.registerModel(c, Utils.makeId("block/drive/cells/mega_item_cell"))); - Stream.of(MEGAItems.getFluidCells(), MEGAItems.getFluidPortables()).flatMap(Collection::stream) + Stream.of(MEGAItems.getFluidCells(), MEGAItems.getFluidPortables()) + .flatMap(Collection::stream) .forEach(c -> StorageCellModels.registerModel(c, Utils.makeId("block/drive/cells/mega_fluid_cell"))); StorageCells.addCellHandler(MEGABulkCell.HANDLER); StorageCellModels.registerModel(MEGAItems.BULK_ITEM_CELL, Utils.makeId("block/drive/cells/bulk_item_cell")); if (Utils.PLATFORM.isAddonLoaded(Addons.APPBOT)) { - Stream.of(AppBotItems.getCells(), - AppBotItems.getPortables()).flatMap(Collection::stream) - .forEach(c -> StorageCellModels.registerModel(c, - Utils.makeId("block/drive/cells/mega_mana_cell"))); + Stream.of(AppBotItems.getCells(), AppBotItems.getPortables()) + .flatMap(Collection::stream) + .forEach(c -> StorageCellModels.registerModel(c, Utils.makeId("block/drive/cells/mega_mana_cell"))); } } } diff --git a/common/src/main/java/gripe/_90/megacells/init/InitUpgrades.java b/common/src/main/java/gripe/_90/megacells/init/InitUpgrades.java index 349d61cf..3a9d962e 100644 --- a/common/src/main/java/gripe/_90/megacells/init/InitUpgrades.java +++ b/common/src/main/java/gripe/_90/megacells/init/InitUpgrades.java @@ -54,10 +54,17 @@ public static void init() { Upgrades.add(MEGAItems.COMPRESSION_CARD, MEGAItems.BULK_ITEM_CELL, 1); - for (var portableCell : List.of(AEItems.PORTABLE_ITEM_CELL1K, AEItems.PORTABLE_ITEM_CELL4K, - AEItems.PORTABLE_ITEM_CELL16K, AEItems.PORTABLE_ITEM_CELL64K, AEItems.PORTABLE_ITEM_CELL256K, - AEItems.PORTABLE_FLUID_CELL1K, AEItems.PORTABLE_FLUID_CELL4K, AEItems.PORTABLE_FLUID_CELL16K, - AEItems.PORTABLE_FLUID_CELL64K, AEItems.PORTABLE_FLUID_CELL256K)) { + for (var portableCell : List.of( + AEItems.PORTABLE_ITEM_CELL1K, + AEItems.PORTABLE_ITEM_CELL4K, + AEItems.PORTABLE_ITEM_CELL16K, + AEItems.PORTABLE_ITEM_CELL64K, + AEItems.PORTABLE_ITEM_CELL256K, + AEItems.PORTABLE_FLUID_CELL1K, + AEItems.PORTABLE_FLUID_CELL4K, + AEItems.PORTABLE_FLUID_CELL16K, + AEItems.PORTABLE_FLUID_CELL64K, + AEItems.PORTABLE_FLUID_CELL256K)) { Upgrades.add(MEGAItems.GREATER_ENERGY_CARD, portableCell, 2, portableCellGroup); } diff --git a/common/src/main/java/gripe/_90/megacells/integration/appbot/AppBotIntegration.java b/common/src/main/java/gripe/_90/megacells/integration/appbot/AppBotIntegration.java index 2327f9fd..b57c63ea 100644 --- a/common/src/main/java/gripe/_90/megacells/integration/appbot/AppBotIntegration.java +++ b/common/src/main/java/gripe/_90/megacells/integration/appbot/AppBotIntegration.java @@ -14,8 +14,11 @@ public static void initUpgrades() { AppBotItems.getPortables() .forEach(c -> Upgrades.add(GREATER_ENERGY_CARD, c, 2, GuiText.PortableCells.getTranslationKey())); - for (var portable : List.of(ABItems.PORTABLE_MANA_CELL_1K, ABItems.PORTABLE_MANA_CELL_4K, - ABItems.PORTABLE_MANA_CELL_16K, ABItems.PORTABLE_MANA_CELL_64K, + for (var portable : List.of( + ABItems.PORTABLE_MANA_CELL_1K, + ABItems.PORTABLE_MANA_CELL_4K, + ABItems.PORTABLE_MANA_CELL_16K, + ABItems.PORTABLE_MANA_CELL_64K, ABItems.PORTABLE_MANA_CELL_256K)) { Upgrades.add(GREATER_ENERGY_CARD, portable, 2, GuiText.PortableCells.getTranslationKey()); } diff --git a/common/src/main/java/gripe/_90/megacells/integration/appbot/AppBotItems.java b/common/src/main/java/gripe/_90/megacells/integration/appbot/AppBotItems.java index 9fbb79f0..2757dc76 100644 --- a/common/src/main/java/gripe/_90/megacells/integration/appbot/AppBotItems.java +++ b/common/src/main/java/gripe/_90/megacells/integration/appbot/AppBotItems.java @@ -18,8 +18,8 @@ public static void init() { Utils.LOGGER.info("Initialised Applied Botanics integration."); } - public static final ItemDefinition MEGA_MANA_CELL_HOUSING = MEGAItems.item("MEGA Mana Cell Housing", - "mega_mana_cell_housing", MaterialItem::new); + public static final ItemDefinition MEGA_MANA_CELL_HOUSING = + MEGAItems.item("MEGA Mana Cell Housing", "mega_mana_cell_housing", MaterialItem::new); public static final ItemDefinition MANA_CELL_1M = cell(MEGAItems.TIER_1M); public static final ItemDefinition MANA_CELL_4M = cell(MEGAItems.TIER_4M); @@ -38,18 +38,24 @@ public static List> getCells() { } public static List> getPortables() { - return List.of(PORTABLE_MANA_CELL_1M, PORTABLE_MANA_CELL_4M, PORTABLE_MANA_CELL_16M, PORTABLE_MANA_CELL_64M, + return List.of( + PORTABLE_MANA_CELL_1M, + PORTABLE_MANA_CELL_4M, + PORTABLE_MANA_CELL_16M, + PORTABLE_MANA_CELL_64M, PORTABLE_MANA_CELL_256M); } private static ItemDefinition cell(StorageTier tier) { - return MEGAItems.item(tier.namePrefix().toUpperCase() + " MEGA Mana Storage Cell", + return MEGAItems.item( + tier.namePrefix().toUpperCase() + " MEGA Mana Storage Cell", "mana_storage_cell_" + tier.namePrefix(), p -> new ManaCellItem(p, tier.componentSupplier().get(), tier.bytes() / 1024, tier.idleDrain())); } private static ItemDefinition portable(StorageTier tier) { - return MEGAItems.item(tier.namePrefix().toUpperCase() + " Portable Mana Cell", + return MEGAItems.item( + tier.namePrefix().toUpperCase() + " Portable Mana Cell", "portable_mana_cell_" + tier.namePrefix(), p -> new PortableManaCellItem(p, tier.bytes() / 1024, tier.idleDrain())); } diff --git a/common/src/main/java/gripe/_90/megacells/item/MEGABulkCell.java b/common/src/main/java/gripe/_90/megacells/item/MEGABulkCell.java index 9a04cbd9..61e7d7f2 100644 --- a/common/src/main/java/gripe/_90/megacells/item/MEGABulkCell.java +++ b/common/src/main/java/gripe/_90/megacells/item/MEGABulkCell.java @@ -57,9 +57,10 @@ public void appendHoverText(ItemStack is, Level level, @NotNull List if (storedItem != null) { lines.add(Tooltips.of(MEGATranslations.Contains.text(storedItem.getDisplayName()))); var quantity = inv.getStoredQuantity(); - lines.add(Tooltips.of(MEGATranslations.Quantity.text(quantity < Long.MAX_VALUE - ? Tooltips.ofNumber(quantity) - : MEGATranslations.ALot.text().withStyle(Tooltips.NUMBER_TEXT)))); + lines.add(Tooltips.of(MEGATranslations.Quantity.text( + quantity < Long.MAX_VALUE + ? Tooltips.ofNumber(quantity) + : MEGATranslations.ALot.text().withStyle(Tooltips.NUMBER_TEXT)))); } else { lines.add(Tooltips.of(MEGATranslations.Empty.text())); } @@ -80,9 +81,10 @@ public void appendHoverText(ItemStack is, Level level, @NotNull List } } - lines.add(Tooltips.of(MEGATranslations.Compression.text(inv.isCompressionEnabled() - ? MEGATranslations.Enabled.text().withStyle(ChatFormatting.GREEN) - : MEGATranslations.Disabled.text().withStyle(ChatFormatting.RED)))); + lines.add(Tooltips.of(MEGATranslations.Compression.text( + inv.isCompressionEnabled() + ? MEGATranslations.Enabled.text().withStyle(ChatFormatting.GREEN) + : MEGATranslations.Disabled.text().withStyle(ChatFormatting.RED)))); } } @@ -123,12 +125,10 @@ public FuzzyMode getFuzzyMode(ItemStack itemStack) { } @Override - public void setFuzzyMode(ItemStack itemStack, FuzzyMode fuzzyMode) { - } + public void setFuzzyMode(ItemStack itemStack, FuzzyMode fuzzyMode) {} public static class Handler implements ICellHandler { - private Handler() { - } + private Handler() {} @Override public boolean isCell(ItemStack is) { diff --git a/common/src/main/java/gripe/_90/megacells/item/MEGAPortableCell.java b/common/src/main/java/gripe/_90/megacells/item/MEGAPortableCell.java index 32b71b4d..d4f4c929 100644 --- a/common/src/main/java/gripe/_90/megacells/item/MEGAPortableCell.java +++ b/common/src/main/java/gripe/_90/megacells/item/MEGAPortableCell.java @@ -16,8 +16,8 @@ public class MEGAPortableCell extends PortableCellItem { private final StorageTier tier; - public MEGAPortableCell(Properties props, StorageTier tier, AEKeyType keyType, MenuType menu, - int defaultColour) { + public MEGAPortableCell( + Properties props, StorageTier tier, AEKeyType keyType, MenuType menu, int defaultColour) { super(keyType, 18 + tier.index() * 9, menu, tier, props.stacksTo(1), defaultColour); this.tier = tier; } @@ -34,7 +34,8 @@ public StorageTier getTier() { @Override public ResourceLocation getRecipeId() { - return Utils.makeId("cells/portable/" + Objects.requireNonNull(getRegistryName()).getPath()); + return Utils.makeId( + "cells/portable/" + Objects.requireNonNull(getRegistryName()).getPath()); } @Override diff --git a/common/src/main/java/gripe/_90/megacells/item/cell/BulkCellInventory.java b/common/src/main/java/gripe/_90/megacells/item/cell/BulkCellInventory.java index 6bb9f97e..7572f042 100644 --- a/common/src/main/java/gripe/_90/megacells/item/cell/BulkCellInventory.java +++ b/common/src/main/java/gripe/_90/megacells/item/cell/BulkCellInventory.java @@ -129,8 +129,10 @@ public long insert(AEKey what, long amount, Actionable mode, IActionSource sourc return 0; } - if (compressionEnabled && !partitionList.isListed(what) - && !compressed.containsKey(item) && !decompressed.containsKey(item)) { + if (compressionEnabled + && !partitionList.isListed(what) + && !compressed.containsKey(item) + && !decompressed.containsKey(item)) { return 0; } @@ -158,8 +160,11 @@ public long extract(AEKey what, long amount, Actionable mode, IActionSource sour return 0; } - if (compressionEnabled && !storedItem.equals(what) && !filterItem.equals(what) - && !compressed.containsKey(item) && !decompressed.containsKey(item)) { + if (compressionEnabled + && !storedItem.equals(what) + && !filterItem.equals(what) + && !compressed.containsKey(item) + && !decompressed.containsKey(item)) { return 0; } @@ -193,8 +198,8 @@ private BigInteger compressedTransferFactor(AEItemKey what) { } } - private BigInteger compressedTransferFactor(Object2IntMap variants, long baseFactor, - Function, Pair> subLister) { + private BigInteger compressedTransferFactor( + Object2IntMap variants, long baseFactor, Function, Pair> subLister) { var variantKeys = new LinkedList<>(variants.keySet()); var toStored = new Object2IntLinkedOpenHashMap<>(variants); @@ -252,7 +257,9 @@ public void getAvailableStacks(KeyCounter out) { allVariants.put(storedItem, decompressed.getInt(decompressedKeys.getLast())); allVariants.putAll(compressed); } else if (!compressed.isEmpty()) { - allVariants.put(storedItem, compressed.values().intStream().findFirst().orElseThrow()); + allVariants.put( + storedItem, + compressed.values().intStream().findFirst().orElseThrow()); allVariants.putAll(compressed); } else { allVariants.put(storedItem, 1); diff --git a/common/src/main/java/gripe/_90/megacells/part/DecompressionModulePart.java b/common/src/main/java/gripe/_90/megacells/part/DecompressionModulePart.java index f57ef386..521f9406 100644 --- a/common/src/main/java/gripe/_90/megacells/part/DecompressionModulePart.java +++ b/common/src/main/java/gripe/_90/megacells/part/DecompressionModulePart.java @@ -38,7 +38,8 @@ public class DecompressionModulePart extends AEBasePart implements ICraftingProv public DecompressionModulePart(IPartItem partItem) { super(partItem); - getMainNode().setFlags(GridFlags.REQUIRE_CHANNEL) + getMainNode() + .setFlags(GridFlags.REQUIRE_CHANNEL) .addService(IGridTickable.class, this) .addService(ICraftingProvider.class, this) .setIdlePowerUsage(10.0); @@ -106,8 +107,8 @@ public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall) for (var output : outputs.object2LongEntrySet()) { var what = output.getKey(); var amount = output.getLongValue(); - var inserted = storage.getInventory().insert(what, amount, Actionable.MODULATE, - IActionSource.ofMachine(this)); + var inserted = + storage.getInventory().insert(what, amount, Actionable.MODULATE, IActionSource.ofMachine(this)); if (inserted >= amount) { outputs.removeLong(what); diff --git a/common/src/main/java/gripe/_90/megacells/part/MEGAPatternProviderPart.java b/common/src/main/java/gripe/_90/megacells/part/MEGAPatternProviderPart.java index 79b15bf5..1f22ed16 100644 --- a/common/src/main/java/gripe/_90/megacells/part/MEGAPatternProviderPart.java +++ b/common/src/main/java/gripe/_90/megacells/part/MEGAPatternProviderPart.java @@ -38,8 +38,8 @@ public class MEGAPatternProviderPart extends PatternProviderPart { public static final PartModel MODELS_ON = new PartModel(MODEL_BASE, AppEng.makeId("part/interface_on")); @PartModels - public static final PartModel MODELS_HAS_CHANNEL = new PartModel(MODEL_BASE, - AppEng.makeId("part/interface_has_channel")); + public static final PartModel MODELS_HAS_CHANNEL = + new PartModel(MODEL_BASE, AppEng.makeId("part/interface_has_channel")); public MEGAPatternProviderPart(IPartItem partItem) { super(partItem); diff --git a/common/src/main/java/gripe/_90/megacells/service/CompressionService.java b/common/src/main/java/gripe/_90/megacells/service/CompressionService.java index 82bacaa5..b538a795 100644 --- a/common/src/main/java/gripe/_90/megacells/service/CompressionService.java +++ b/common/src/main/java/gripe/_90/megacells/service/CompressionService.java @@ -25,76 +25,89 @@ public class CompressionService { private final Set> compressionChains = new ObjectLinkedOpenHashSet<>(); - private CompressionService() { - } + private CompressionService() {} public Optional> getChain(AEItemKey key) { - return compressionChains.stream().filter(chain -> chain.containsKey(key)).findFirst(); + return compressionChains.stream() + .filter(chain -> chain.containsKey(key)) + .findFirst(); } public Object2IntMap getVariants(AEItemKey key, boolean decompress) { - return getChain(key).map(chain -> { - var keys = new ObjectArrayList<>(chain.keySet()); + return getChain(key) + .map(chain -> { + var keys = new ObjectArrayList<>(chain.keySet()); - // Reverse ordering when going from provided storage/filter variant to least-compressed "base unit" - if (decompress) { - Collections.reverse(keys); - } + // Reverse ordering when going from provided storage/filter variant to least-compressed "base unit" + if (decompress) { + Collections.reverse(keys); + } - // Split variant chain into separate compressed/decompressed chains, omitting the initial variant provided - var variants = new Object2IntLinkedOpenHashMap(); - keys.subList(keys.indexOf(key) + 1, keys.size()).forEach(k -> variants.put(k, chain.getInt(k))); - return variants; - }).orElseGet(Object2IntLinkedOpenHashMap::new); + // Split variant chain into separate compressed/decompressed chains, omitting the initial variant + // provided + var variants = new Object2IntLinkedOpenHashMap(); + keys.subList(keys.indexOf(key) + 1, keys.size()).forEach(k -> variants.put(k, chain.getInt(k))); + return variants; + }) + .orElseGet(Object2IntLinkedOpenHashMap::new); } public void loadRecipes(RecipeManager recipeManager, RegistryAccess access) { - // Clear old variant cache in case of the server restarting or recipes being reloaded compressionChains.clear(); // Retrieve all available "compression" and "decompression" recipes on the current server (if running) var allRecipes = recipeManager.getAllRecipesFor(RecipeType.CRAFTING); var candidates = Stream.concat( - allRecipes.stream().filter(recipe -> isCompressionRecipe(recipe, access)), - allRecipes.stream().filter(recipe -> isDecompressionRecipe(recipe, access))).toList(); + allRecipes.stream().filter(recipe -> isCompressionRecipe(recipe, access)), + allRecipes.stream().filter(recipe -> isDecompressionRecipe(recipe, access))) + .toList(); // Filter gathered candidate recipes and retain only those that are reversible (i.e. those which can be carried // out back and forth to compress/decompress a resource without affecting the underlying quantity of it) - var validRecipes = candidates.stream().filter(recipe -> { - var compressible = false; - var decompressible = false; - - var input = recipe.getIngredients().get(0); - var output = recipe.getResultItem(access); - - var checkAgainst = candidates.stream().filter(r -> isCompressionRecipe(recipe, access) - ? isDecompressionRecipe(r, access) - : isCompressionRecipe(r, access)).toList(); - - for (var candidate : checkAgainst) { - for (var item : candidate.getIngredients().get(0).getItems()) { - if (item.getItem().equals(output.getItem())) { - compressible = true; + var validRecipes = candidates.stream() + .filter(recipe -> { + var compressible = false; + var decompressible = false; + + var input = recipe.getIngredients().get(0); + var output = recipe.getResultItem(access); + + var checkAgainst = candidates.stream() + .filter(r -> isCompressionRecipe(recipe, access) + ? isDecompressionRecipe(r, access) + : isCompressionRecipe(r, access)) + .toList(); + + for (var candidate : checkAgainst) { + for (var item : candidate.getIngredients().get(0).getItems()) { + if (item.getItem().equals(output.getItem())) { + compressible = true; + } + } + + for (var item : input.getItems()) { + if (item.getItem() + .equals(candidate.getResultItem(access).getItem())) { + decompressible = true; + } + } + + if (compressible && decompressible) { + break; + } } - } - - for (var item : input.getItems()) { - if (item.getItem().equals(candidate.getResultItem(access).getItem())) { - decompressible = true; - } - } - - if (compressible && decompressible) { - break; - } - } - return compressible && decompressible; - }).toList(); + return compressible && decompressible; + }) + .toList(); - var compressed = validRecipes.stream().filter(recipe -> isCompressionRecipe(recipe, access)).toList(); - var decompressed = validRecipes.stream().filter(recipe -> isDecompressionRecipe(recipe, access)).toList(); + var compressed = validRecipes.stream() + .filter(recipe -> isCompressionRecipe(recipe, access)) + .toList(); + var decompressed = validRecipes.stream() + .filter(recipe -> isDecompressionRecipe(recipe, access)) + .toList(); // Pull all available compression chains from the recipe shortlist and add these to the handler cache for (var recipe : compressed) { @@ -103,18 +116,16 @@ public void loadRecipes(RecipeManager recipeManager, RegistryAccess access) { if (compressionChains.stream().noneMatch(chain -> chain.containsKey(AEItemKey.of(baseVariant)))) { var decompressionChain = new Object2IntLinkedOpenHashMap(); - for (var lowerVariant = getSubsequentVariant(baseVariant, decompressed, - access); lowerVariant != null;) { - decompressionChain.put(AEItemKey.of(lowerVariant.first()), (int) lowerVariant.second()); - lowerVariant = getSubsequentVariant(lowerVariant.first(), decompressed, access); + for (var lower = getSubsequentVariant(baseVariant, decompressed, access); lower != null; ) { + decompressionChain.put(AEItemKey.of(lower.first()), (int) lower.second()); + lower = getSubsequentVariant(lower.first(), decompressed, access); } var compressionChain = new Object2IntLinkedOpenHashMap(); - for (var higherVariant = getSubsequentVariant(baseVariant, compressed, - access); higherVariant != null;) { - compressionChain.put(AEItemKey.of(higherVariant.first()), (int) higherVariant.second()); - higherVariant = getSubsequentVariant(higherVariant.first(), compressed, access); + for (var higher = getSubsequentVariant(baseVariant, compressed, access); higher != null; ) { + compressionChain.put(AEItemKey.of(higher.first()), (int) higher.second()); + higher = getSubsequentVariant(higher.first(), compressed, access); } if (compressionChain.isEmpty() && decompressionChain.isEmpty()) { @@ -129,9 +140,11 @@ public void loadRecipes(RecipeManager recipeManager, RegistryAccess access) { decompressionKeys.forEach(k -> fullChain.put(k, decompressionChain.getInt(k))); // Retrieve appropriate multiplier for base variant for completion's sake - fullChain.put(AEItemKey.of(baseVariant), fullChain.isEmpty() - ? compressionChain.getInt(compressionChain.firstKey()) - : fullChain.getInt(fullChain.lastKey())); + fullChain.put( + AEItemKey.of(baseVariant), + fullChain.isEmpty() + ? compressionChain.getInt(compressionChain.firstKey()) + : fullChain.getInt(fullChain.lastKey())); fullChain.putAll(compressionChain); compressionChains.add(fullChain); @@ -139,27 +152,27 @@ public void loadRecipes(RecipeManager recipeManager, RegistryAccess access) { } } - private boolean isCompressionRecipe(CraftingRecipe recipe, RegistryAccess registryAccess) { + private boolean isCompressionRecipe(CraftingRecipe recipe, RegistryAccess access) { return (recipe.getIngredients().size() == 4 || recipe.getIngredients().size() == 9) - && recipe.getIngredients().stream().distinct().limit(2).count() == 1 - && recipe.getResultItem(registryAccess).getCount() == 1; + && recipe.getIngredients().stream().distinct().count() <= 1 + && recipe.getResultItem(access).getCount() == 1; } - private boolean isDecompressionRecipe(CraftingRecipe recipe, RegistryAccess registryAccess) { - return (recipe.getResultItem(registryAccess).getCount() == 4 - || recipe.getResultItem(registryAccess).getCount() == 9) + private boolean isDecompressionRecipe(CraftingRecipe recipe, RegistryAccess access) { + return (recipe.getResultItem(access).getCount() == 4 + || recipe.getResultItem(access).getCount() == 9) && recipe.getIngredients().size() == 1; } - private Pair getSubsequentVariant(Item item, List recipes, - RegistryAccess registryAccess) { + private Pair getSubsequentVariant(Item item, List recipes, RegistryAccess access) { for (var recipe : recipes) { for (var input : recipe.getIngredients().get(0).getItems()) { if (input.getItem().equals(item)) { - return Pair.of(recipe.getResultItem(registryAccess).getItem(), - isCompressionRecipe(recipe, registryAccess) + return Pair.of( + recipe.getResultItem(access).getItem(), + isCompressionRecipe(recipe, access) ? recipe.getIngredients().size() - : recipe.getResultItem(registryAccess).getCount()); + : recipe.getResultItem(access).getCount()); } } } diff --git a/common/src/main/java/gripe/_90/megacells/service/DecompressionService.java b/common/src/main/java/gripe/_90/megacells/service/DecompressionService.java index 6baf10da..ee2c308b 100644 --- a/common/src/main/java/gripe/_90/megacells/service/DecompressionService.java +++ b/common/src/main/java/gripe/_90/megacells/service/DecompressionService.java @@ -112,21 +112,24 @@ private StorageCell getCellByDriveSlot(DriveBlockEntity drive, int slot) throws private Object2IntMap getChain(BulkCellInventory cell) { if (cell.isCompressionEnabled()) { - return CompressionService.INSTANCE.getChain(cell.getStoredItem()).map(c -> { - var keys = new ObjectArrayList<>(c.keySet()); - Collections.reverse(keys); - - var decompressed = new Object2IntLinkedOpenHashMap(); - var highest = keys.indexOf(cell.getHighestCompressed()); - - if (highest > -1) { - for (var key : keys.subList(highest, keys.size())) { - decompressed.put(key, c.getInt(key)); - } - } - - return decompressed; - }).orElseGet(Object2IntLinkedOpenHashMap::new); + return CompressionService.INSTANCE + .getChain(cell.getStoredItem()) + .map(c -> { + var keys = new ObjectArrayList<>(c.keySet()); + Collections.reverse(keys); + + var decompressed = new Object2IntLinkedOpenHashMap(); + var highest = keys.indexOf(cell.getHighestCompressed()); + + if (highest > -1) { + for (var key : keys.subList(highest, keys.size())) { + decompressed.put(key, c.getInt(key)); + } + } + + return decompressed; + }) + .orElseGet(Object2IntLinkedOpenHashMap::new); } return new Object2IntLinkedOpenHashMap<>(); diff --git a/common/src/main/java/gripe/_90/megacells/util/Loaders.java b/common/src/main/java/gripe/_90/megacells/util/Loaders.java index e8d6e624..0f7140f0 100644 --- a/common/src/main/java/gripe/_90/megacells/util/Loaders.java +++ b/common/src/main/java/gripe/_90/megacells/util/Loaders.java @@ -1,5 +1,6 @@ package gripe._90.megacells.util; public enum Loaders { - FABRIC, FORGE + FABRIC, + FORGE } diff --git a/common/src/main/java/gripe/_90/megacells/util/Utils.java b/common/src/main/java/gripe/_90/megacells/util/Utils.java index 08a83f6e..b80fea0d 100644 --- a/common/src/main/java/gripe/_90/megacells/util/Utils.java +++ b/common/src/main/java/gripe/_90/megacells/util/Utils.java @@ -10,14 +10,14 @@ import gripe._90.megacells.util.service.Platform; public final class Utils { - private Utils() { - } + private Utils() {} public static final String MODID = "megacells"; public static final Logger LOGGER = LoggerFactory.getLogger("MEGA Cells"); - public static final Platform PLATFORM = ServiceLoader.load(Platform.class).findFirst().orElseThrow(); + public static final Platform PLATFORM = + ServiceLoader.load(Platform.class).findFirst().orElseThrow(); public static ResourceLocation makeId(String path) { return new ResourceLocation(MODID, path); diff --git a/fabric/src/data/java/gripe/_90/megacells/datagen/LootTableProvider.java b/fabric/src/data/java/gripe/_90/megacells/datagen/LootTableProvider.java index aad72019..32cf1215 100644 --- a/fabric/src/data/java/gripe/_90/megacells/datagen/LootTableProvider.java +++ b/fabric/src/data/java/gripe/_90/megacells/datagen/LootTableProvider.java @@ -24,9 +24,14 @@ class LootTableProvider extends SimpleFabricLootTableProvider { @Override public void generate(@NotNull BiConsumer consumer) { - MEGABlocks.getBlocks() - .forEach(block -> consumer.accept(Utils.makeId("blocks/" + block.id().getPath()), - LootTable.lootTable().withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1)) - .add(LootItem.lootTableItem(block)).when(ExplosionCondition.survivesExplosion())))); + for (var block : MEGABlocks.getBlocks()) { + consumer.accept( + Utils.makeId("blocks/" + block.id().getPath()), + LootTable.lootTable() + .withPool(LootPool.lootPool() + .setRolls(ConstantValue.exactly(1)) + .add(LootItem.lootTableItem(block)) + .when(ExplosionCondition.survivesExplosion()))); + } } } diff --git a/fabric/src/data/java/gripe/_90/megacells/datagen/ModelProvider.java b/fabric/src/data/java/gripe/_90/megacells/datagen/ModelProvider.java index 7cca8684..f941d329 100644 --- a/fabric/src/data/java/gripe/_90/megacells/datagen/ModelProvider.java +++ b/fabric/src/data/java/gripe/_90/megacells/datagen/ModelProvider.java @@ -48,28 +48,41 @@ class ModelProvider extends FabricModelProvider { private static final TextureSlot LAYER3 = TextureSlot.create("layer3"); private static final ResourceLocation GENERATED = new ResourceLocation("item/generated"); - private static final ModelTemplate CELL = new ModelTemplate(Optional.of(GENERATED), - Optional.empty(), TextureSlot.LAYER0, TextureSlot.LAYER1); - private static final ModelTemplate PORTABLE = new ModelTemplate(Optional.of(GENERATED), - Optional.empty(), TextureSlot.LAYER0, TextureSlot.LAYER1, TextureSlot.LAYER2, LAYER3); + private static final ModelTemplate CELL = + new ModelTemplate(Optional.of(GENERATED), Optional.empty(), TextureSlot.LAYER0, TextureSlot.LAYER1); + private static final ModelTemplate PORTABLE = new ModelTemplate( + Optional.of(GENERATED), + Optional.empty(), + TextureSlot.LAYER0, + TextureSlot.LAYER1, + TextureSlot.LAYER2, + LAYER3); private static final TextureSlot CELL_TEXTURE = TextureSlot.create("cell"); - private static final ModelTemplate DRIVE_CELL = new ModelTemplate( - Optional.of(AppEng.makeId("block/drive/drive_cell")), Optional.empty(), CELL_TEXTURE); + private static final ModelTemplate DRIVE_CELL = + new ModelTemplate(Optional.of(AppEng.makeId("block/drive/drive_cell")), Optional.empty(), CELL_TEXTURE); private static final TextureSlot SIDES = TextureSlot.create("sides"); private static final TextureSlot SIDES_STATUS = TextureSlot.create("sidesStatus"); private static final ModelTemplate PATTERN_PROVIDER = new ModelTemplate( - Optional.of(AppEng.makeId("part/pattern_provider_base")), Optional.empty(), - SIDES, SIDES_STATUS, TextureSlot.BACK, TextureSlot.FRONT, TextureSlot.PARTICLE); + Optional.of(AppEng.makeId("part/pattern_provider_base")), + Optional.empty(), + SIDES, + SIDES_STATUS, + TextureSlot.BACK, + TextureSlot.FRONT, + TextureSlot.PARTICLE); private static final ModelTemplate CABLE_PATTERN_PROVIDER = new ModelTemplate( - Optional.of(AppEng.makeId("item/cable_interface")), Optional.empty(), - SIDES, TextureSlot.BACK, TextureSlot.FRONT); + Optional.of(AppEng.makeId("item/cable_interface")), + Optional.empty(), + SIDES, + TextureSlot.BACK, + TextureSlot.FRONT); - private static final VariantProperty Z_ROT = new VariantProperty<>("ae2:z", - r -> new JsonPrimitive(r.ordinal() * 90)); + private static final VariantProperty Z_ROT = + new VariantProperty<>("ae2:z", r -> new JsonPrimitive(r.ordinal() * 90)); ModelProvider(FabricDataOutput output) { super(output); @@ -119,8 +132,8 @@ public void generateItemModels(ItemModelGenerators generator) { generator.generateFlatItem(MEGAItems.GREATER_ENERGY_CARD.asItem(), ModelTemplates.FLAT_ITEM); generator.generateFlatItem(MEGAItems.COMPRESSION_CARD.asItem(), ModelTemplates.FLAT_ITEM); - generator.generateFlatItem(MEGAItems.DECOMPRESSION_PATTERN.asItem(), AEItems.CRAFTING_PATTERN.asItem(), - ModelTemplates.FLAT_ITEM); + generator.generateFlatItem( + MEGAItems.DECOMPRESSION_PATTERN.asItem(), AEItems.CRAFTING_PATTERN.asItem(), ModelTemplates.FLAT_ITEM); var cells = new ArrayList<>(MEGAItems.getItemCells()); cells.addAll(MEGAItems.getFluidCells()); @@ -131,8 +144,12 @@ public void generateItemModels(ItemModelGenerators generator) { generator.generateFlatItem(AppBotItems.MEGA_MANA_CELL_HOUSING.asItem(), ModelTemplates.FLAT_ITEM); // lot of assumptions being made here in advance - AppBotItems.getPortables().forEach(p -> portableModel(p, "mana", - new ResourceLocation(Addons.APPBOT.getModId(), "item/portable_cell_mana_housing"), generator)); + AppBotItems.getPortables() + .forEach(p -> portableModel( + p, + "mana", + new ResourceLocation(Addons.APPBOT.getModId(), "item/portable_cell_mana_housing"), + generator)); driveCell("mega_mana_cell", generator); } @@ -161,20 +178,32 @@ private void generatePartModels(ItemModelGenerators generator) { } private void cellModel(ItemDefinition cell, ItemModelGenerators generator) { - CELL.create(Utils.makeId("item/" + cell.id().getPath()), new TextureMapping() - .put(TextureSlot.LAYER0, Utils.makeId("item/cell/standard/" + cell.id().getPath())) - .put(TextureSlot.LAYER1, AppEng.makeId("item/storage_cell_led")), generator.output); + CELL.create( + Utils.makeId("item/" + cell.id().getPath()), + new TextureMapping() + .put( + TextureSlot.LAYER0, + Utils.makeId("item/cell/standard/" + cell.id().getPath())) + .put(TextureSlot.LAYER1, AppEng.makeId("item/storage_cell_led")), + generator.output); } - private void portableModel(ItemDefinition portable, String screenType, ResourceLocation housingTexture, + private void portableModel( + ItemDefinition portable, + String screenType, + ResourceLocation housingTexture, ItemModelGenerators generator) { var path = portable.id().getPath(); var tierSuffix = path.substring(path.lastIndexOf('_') + 1); - PORTABLE.create(Utils.makeId("item/" + portable.id().getPath()), new TextureMapping() - .put(TextureSlot.LAYER0, Utils.makeId("item/cell/portable/portable_cell_" + screenType + "_screen")) - .put(TextureSlot.LAYER1, AppEng.makeId("item/portable_cell_led")) - .put(TextureSlot.LAYER2, housingTexture) - .put(LAYER3, Utils.makeId("item/cell/portable/portable_cell_side_" + tierSuffix)), + PORTABLE.create( + Utils.makeId("item/" + portable.id().getPath()), + new TextureMapping() + .put( + TextureSlot.LAYER0, + Utils.makeId("item/cell/portable/portable_cell_" + screenType + "_screen")) + .put(TextureSlot.LAYER1, AppEng.makeId("item/portable_cell_led")) + .put(TextureSlot.LAYER2, housingTexture) + .put(LAYER3, Utils.makeId("item/cell/portable/portable_cell_side_" + tierSuffix)), generator.output); } @@ -189,9 +218,15 @@ private void craftingUnit(Block block, String texture, BlockModelGenerators gene var craftingUnit = MultiVariantGenerator.multiVariant(block) .with(PropertyDispatch.property(AbstractCraftingUnitBlock.FORMED) - .select(false, Variant.variant().with(VariantProperties.MODEL, - ModelTemplates.CUBE_ALL.create(unformed, TextureMapping.cube(unformed), - generator.modelOutput))) + .select( + false, + Variant.variant() + .with( + VariantProperties.MODEL, + ModelTemplates.CUBE_ALL.create( + unformed, + TextureMapping.cube(unformed), + generator.modelOutput))) .select(true, Variant.variant().with(VariantProperties.MODEL, formed))); generator.blockStateOutput.accept(craftingUnit); @@ -202,14 +237,17 @@ private void craftingUnit(Block block, String texture, BlockModelGenerators gene private void craftingMonitor(BlockModelGenerators generator) { var unformed = Utils.makeId("block/crafting/monitor"); var unit = Utils.makeId("block/crafting/unit"); - var unformedModel = ModelTemplates.CUBE.create(unformed, new TextureMapping() - .put(TextureSlot.NORTH, unformed) - .put(TextureSlot.EAST, unit) - .put(TextureSlot.SOUTH, unit) - .put(TextureSlot.WEST, unit) - .put(TextureSlot.DOWN, unit) - .put(TextureSlot.UP, unit) - .put(TextureSlot.PARTICLE, unformed), generator.modelOutput); + var unformedModel = ModelTemplates.CUBE.create( + unformed, + new TextureMapping() + .put(TextureSlot.NORTH, unformed) + .put(TextureSlot.EAST, unit) + .put(TextureSlot.SOUTH, unit) + .put(TextureSlot.WEST, unit) + .put(TextureSlot.DOWN, unit) + .put(TextureSlot.UP, unit) + .put(TextureSlot.PARTICLE, unformed), + generator.modelOutput); var formedModel = Utils.makeId("block/crafting/monitor_formed"); generator.blockStateOutput.accept(MultiVariantGenerator.multiVariant(MEGABlocks.CRAFTING_MONITOR.block()) @@ -234,44 +272,46 @@ private JsonObject customModelLoader(ResourceLocation loc) { } private void patternProviderBlock(BlockModelGenerators generator) { - var normal = ModelTemplates.CUBE_ALL.create(MEGABlocks.MEGA_PATTERN_PROVIDER.block(), + var normal = ModelTemplates.CUBE_ALL.create( + MEGABlocks.MEGA_PATTERN_PROVIDER.block(), TextureMapping.cube(MEGABlocks.MEGA_PATTERN_PROVIDER.block()), generator.modelOutput); - var oriented = ModelTemplates.CUBE - .create(Utils.makeId("block/mega_pattern_provider_oriented"), new TextureMapping() + var oriented = ModelTemplates.CUBE.create( + Utils.makeId("block/mega_pattern_provider_oriented"), + new TextureMapping() .put(TextureSlot.UP, Utils.makeId("block/mega_pattern_provider_alternate_front")) .put(TextureSlot.DOWN, Utils.makeId("block/mega_pattern_provider_alternate")) .put(TextureSlot.NORTH, Utils.makeId("block/mega_pattern_provider_alternate_arrow")) .copySlot(TextureSlot.NORTH, TextureSlot.EAST) .copySlot(TextureSlot.NORTH, TextureSlot.SOUTH) .copySlot(TextureSlot.NORTH, TextureSlot.WEST) - .put(TextureSlot.PARTICLE, normal), generator.modelOutput); + .put(TextureSlot.PARTICLE, normal), + generator.modelOutput); generator.blockStateOutput.accept(MultiVariantGenerator.multiVariant(MEGABlocks.MEGA_PATTERN_PROVIDER.block()) - .with(PropertyDispatch.property(MEGAPatternProviderBlock.PUSH_DIRECTION).generate(pushDirection -> { - var forward = pushDirection.getDirection(); - - if (forward == null) { - return Variant.variant().with(VariantProperties.MODEL, normal); - } else { - var orientation = BlockOrientation.get(forward); - return applyRotation( - Variant.variant().with(VariantProperties.MODEL, oriented), - // + 90 because the default model is oriented UP, while block orientation assumes NORTH - orientation.getAngleX() + 90, - orientation.getAngleY(), - 0); - } - }))); + .with(PropertyDispatch.property(MEGAPatternProviderBlock.PUSH_DIRECTION) + .generate(pushDirection -> { + var forward = pushDirection.getDirection(); + + if (forward == null) { + return Variant.variant().with(VariantProperties.MODEL, normal); + } else { + var orientation = BlockOrientation.get(forward); + return applyRotation( + Variant.variant().with(VariantProperties.MODEL, oriented), + // + 90 because the default model is oriented UP, while block orientation + // assumes NORTH + orientation.getAngleX() + 90, + orientation.getAngleY(), + 0); + } + }))); generator.delegateItemModel(MEGABlocks.MEGA_PATTERN_PROVIDER.block(), normal); } protected Variant applyOrientation(Variant variant, BlockOrientation orientation) { - return applyRotation(variant, - orientation.getAngleX(), - orientation.getAngleY(), - orientation.getAngleZ()); + return applyRotation(variant, orientation.getAngleX(), orientation.getAngleY(), orientation.getAngleZ()); } protected Variant applyRotation(Variant variant, int angleX, int angleY, int angleZ) { @@ -309,13 +349,21 @@ private void patternProviderPart(ItemModelGenerators generator) { var provider = Utils.makeId("part/mega_pattern_provider"); var monitorBack = Utils.makeId("part/mega_monitor_back"); var monitorSides = Utils.makeId("part/mega_monitor_sides"); - PATTERN_PROVIDER.create(provider, new TextureMapping() - .put(SIDES_STATUS, Utils.makeId("part/mega_monitor_sides_status")) - .put(SIDES, monitorSides).put(TextureSlot.BACK, monitorBack) - .put(TextureSlot.FRONT, provider).put(TextureSlot.PARTICLE, monitorBack), + PATTERN_PROVIDER.create( + provider, + new TextureMapping() + .put(SIDES_STATUS, Utils.makeId("part/mega_monitor_sides_status")) + .put(SIDES, monitorSides) + .put(TextureSlot.BACK, monitorBack) + .put(TextureSlot.FRONT, provider) + .put(TextureSlot.PARTICLE, monitorBack), generator.output); - CABLE_PATTERN_PROVIDER.create(Utils.makeId("item/cable_mega_pattern_provider"), new TextureMapping() - .put(SIDES, monitorSides).put(TextureSlot.FRONT, provider).put(TextureSlot.BACK, monitorBack), + CABLE_PATTERN_PROVIDER.create( + Utils.makeId("item/cable_mega_pattern_provider"), + new TextureMapping() + .put(SIDES, monitorSides) + .put(TextureSlot.FRONT, provider) + .put(TextureSlot.BACK, monitorBack), generator.output); } @@ -325,9 +373,13 @@ private void energyCell(BlockModelGenerators generator) { List> itemModelOverrides = new ArrayList<>(); for (var i = 0; i < 5; i++) { - fillStage.select(i, Variant.variant().with(VariantProperties.MODEL, - generator.createSuffixedVariant(cell.block(), "_" + i, ModelTemplates.CUBE_ALL, - TextureMapping::cube))); + fillStage.select( + i, + Variant.variant() + .with( + VariantProperties.MODEL, + generator.createSuffixedVariant( + cell.block(), "_" + i, ModelTemplates.CUBE_ALL, TextureMapping::cube))); if (i < 4) { var fillPredicate = new JsonObject(); fillPredicate.addProperty("ae2:fill_level", 0.25 * i); @@ -336,16 +388,19 @@ private void energyCell(BlockModelGenerators generator) { } } - generator.blockStateOutput.accept(MultiVariantGenerator.multiVariant(cell.block()).with(fillStage)); - generator.modelOutput.accept(Utils.makeId("item/" + cell.id().getPath()), new OverrideableDelegatedModel( - Utils.makeId("block/" + cell.id().getPath() + "_0"), itemModelOverrides)); + generator.blockStateOutput.accept( + MultiVariantGenerator.multiVariant(cell.block()).with(fillStage)); + generator.modelOutput.accept( + Utils.makeId("item/" + cell.id().getPath()), + new OverrideableDelegatedModel( + Utils.makeId("block/" + cell.id().getPath() + "_0"), itemModelOverrides)); } static class OverrideableDelegatedModel extends DelegatedModel { private final List> overrides; - public OverrideableDelegatedModel(ResourceLocation resourceLocation, - List> overrides) { + public OverrideableDelegatedModel( + ResourceLocation resourceLocation, List> overrides) { super(resourceLocation); this.overrides = overrides; } diff --git a/fabric/src/data/java/gripe/_90/megacells/datagen/RecipeProvider.java b/fabric/src/data/java/gripe/_90/megacells/datagen/RecipeProvider.java index 8cf6ce49..73d17fc1 100644 --- a/fabric/src/data/java/gripe/_90/megacells/datagen/RecipeProvider.java +++ b/fabric/src/data/java/gripe/_90/megacells/datagen/RecipeProvider.java @@ -46,7 +46,6 @@ class RecipeProvider extends FabricRecipeProvider { @Override public void buildRecipes(@NotNull Consumer consumer) { - // spotless:off component(consumer, MEGAItems.TIER_1M, StorageTier.SIZE_256K, AEItems.SKY_DUST.asItem()); component(consumer, MEGAItems.TIER_4M, MEGAItems.TIER_1M, AEItems.ENDER_DUST.asItem()); component(consumer, MEGAItems.TIER_16M, MEGAItems.TIER_4M, AEItems.ENDER_DUST.asItem()); @@ -56,28 +55,117 @@ public void buildRecipes(@NotNull Consumer consumer) { housing(consumer, MEGAItems.MEGA_ITEM_CELL_HOUSING, MEGATags.SKY_STEEL_INGOT); housing(consumer, MEGAItems.MEGA_FLUID_CELL_HOUSING, ConventionTags.COPPER_INGOT); - cell(consumer, MEGAItems.ITEM_CELL_1M, MEGAItems.CELL_COMPONENT_1M, MEGAItems.MEGA_ITEM_CELL_HOUSING, ConventionTags.IRON_INGOT); - cell(consumer, MEGAItems.ITEM_CELL_4M, MEGAItems.CELL_COMPONENT_4M, MEGAItems.MEGA_ITEM_CELL_HOUSING, ConventionTags.IRON_INGOT); - cell(consumer, MEGAItems.ITEM_CELL_16M, MEGAItems.CELL_COMPONENT_16M, MEGAItems.MEGA_ITEM_CELL_HOUSING, ConventionTags.IRON_INGOT); - cell(consumer, MEGAItems.ITEM_CELL_64M, MEGAItems.CELL_COMPONENT_64M, MEGAItems.MEGA_ITEM_CELL_HOUSING, ConventionTags.IRON_INGOT); - cell(consumer, MEGAItems.ITEM_CELL_256M, MEGAItems.CELL_COMPONENT_256M, MEGAItems.MEGA_ITEM_CELL_HOUSING, ConventionTags.IRON_INGOT); - cell(consumer, MEGAItems.FLUID_CELL_1M, MEGAItems.CELL_COMPONENT_1M, MEGAItems.MEGA_FLUID_CELL_HOUSING, ConventionTags.COPPER_INGOT); - cell(consumer, MEGAItems.FLUID_CELL_4M, MEGAItems.CELL_COMPONENT_4M, MEGAItems.MEGA_FLUID_CELL_HOUSING, ConventionTags.COPPER_INGOT); - cell(consumer, MEGAItems.FLUID_CELL_16M, MEGAItems.CELL_COMPONENT_16M, MEGAItems.MEGA_FLUID_CELL_HOUSING, ConventionTags.COPPER_INGOT); - cell(consumer, MEGAItems.FLUID_CELL_64M, MEGAItems.CELL_COMPONENT_64M, MEGAItems.MEGA_FLUID_CELL_HOUSING, ConventionTags.COPPER_INGOT); - cell(consumer, MEGAItems.FLUID_CELL_256M, MEGAItems.CELL_COMPONENT_256M, MEGAItems.MEGA_FLUID_CELL_HOUSING, ConventionTags.COPPER_INGOT); - - portable(consumer, MEGAItems.PORTABLE_ITEM_CELL_1M, MEGAItems.CELL_COMPONENT_1M, MEGAItems.MEGA_ITEM_CELL_HOUSING); - portable(consumer, MEGAItems.PORTABLE_ITEM_CELL_4M, MEGAItems.CELL_COMPONENT_4M, MEGAItems.MEGA_ITEM_CELL_HOUSING); - portable(consumer, MEGAItems.PORTABLE_ITEM_CELL_16M, MEGAItems.CELL_COMPONENT_16M, MEGAItems.MEGA_ITEM_CELL_HOUSING); - portable(consumer, MEGAItems.PORTABLE_ITEM_CELL_64M, MEGAItems.CELL_COMPONENT_64M, MEGAItems.MEGA_ITEM_CELL_HOUSING); - portable(consumer, MEGAItems.PORTABLE_ITEM_CELL_256M, MEGAItems.CELL_COMPONENT_256M, MEGAItems.MEGA_ITEM_CELL_HOUSING); - portable(consumer, MEGAItems.PORTABLE_FLUID_CELL_1M, MEGAItems.CELL_COMPONENT_1M, MEGAItems.MEGA_FLUID_CELL_HOUSING); - portable(consumer, MEGAItems.PORTABLE_FLUID_CELL_4M, MEGAItems.CELL_COMPONENT_4M, MEGAItems.MEGA_FLUID_CELL_HOUSING); - portable(consumer, MEGAItems.PORTABLE_FLUID_CELL_16M, MEGAItems.CELL_COMPONENT_16M, MEGAItems.MEGA_FLUID_CELL_HOUSING); - portable(consumer, MEGAItems.PORTABLE_FLUID_CELL_64M, MEGAItems.CELL_COMPONENT_64M, MEGAItems.MEGA_FLUID_CELL_HOUSING); - portable(consumer, MEGAItems.PORTABLE_FLUID_CELL_256M, MEGAItems.CELL_COMPONENT_256M, MEGAItems.MEGA_FLUID_CELL_HOUSING); - // spotless:on + cell( + consumer, + MEGAItems.ITEM_CELL_1M, + MEGAItems.CELL_COMPONENT_1M, + MEGAItems.MEGA_ITEM_CELL_HOUSING, + ConventionTags.IRON_INGOT); + cell( + consumer, + MEGAItems.ITEM_CELL_4M, + MEGAItems.CELL_COMPONENT_4M, + MEGAItems.MEGA_ITEM_CELL_HOUSING, + ConventionTags.IRON_INGOT); + cell( + consumer, + MEGAItems.ITEM_CELL_16M, + MEGAItems.CELL_COMPONENT_16M, + MEGAItems.MEGA_ITEM_CELL_HOUSING, + ConventionTags.IRON_INGOT); + cell( + consumer, + MEGAItems.ITEM_CELL_64M, + MEGAItems.CELL_COMPONENT_64M, + MEGAItems.MEGA_ITEM_CELL_HOUSING, + ConventionTags.IRON_INGOT); + cell( + consumer, + MEGAItems.ITEM_CELL_256M, + MEGAItems.CELL_COMPONENT_256M, + MEGAItems.MEGA_ITEM_CELL_HOUSING, + ConventionTags.IRON_INGOT); + cell( + consumer, + MEGAItems.FLUID_CELL_1M, + MEGAItems.CELL_COMPONENT_1M, + MEGAItems.MEGA_FLUID_CELL_HOUSING, + ConventionTags.COPPER_INGOT); + cell( + consumer, + MEGAItems.FLUID_CELL_4M, + MEGAItems.CELL_COMPONENT_4M, + MEGAItems.MEGA_FLUID_CELL_HOUSING, + ConventionTags.COPPER_INGOT); + cell( + consumer, + MEGAItems.FLUID_CELL_16M, + MEGAItems.CELL_COMPONENT_16M, + MEGAItems.MEGA_FLUID_CELL_HOUSING, + ConventionTags.COPPER_INGOT); + cell( + consumer, + MEGAItems.FLUID_CELL_64M, + MEGAItems.CELL_COMPONENT_64M, + MEGAItems.MEGA_FLUID_CELL_HOUSING, + ConventionTags.COPPER_INGOT); + cell( + consumer, + MEGAItems.FLUID_CELL_256M, + MEGAItems.CELL_COMPONENT_256M, + MEGAItems.MEGA_FLUID_CELL_HOUSING, + ConventionTags.COPPER_INGOT); + + portable( + consumer, + MEGAItems.PORTABLE_ITEM_CELL_1M, + MEGAItems.CELL_COMPONENT_1M, + MEGAItems.MEGA_ITEM_CELL_HOUSING); + portable( + consumer, + MEGAItems.PORTABLE_ITEM_CELL_4M, + MEGAItems.CELL_COMPONENT_4M, + MEGAItems.MEGA_ITEM_CELL_HOUSING); + portable( + consumer, + MEGAItems.PORTABLE_ITEM_CELL_16M, + MEGAItems.CELL_COMPONENT_16M, + MEGAItems.MEGA_ITEM_CELL_HOUSING); + portable( + consumer, + MEGAItems.PORTABLE_ITEM_CELL_64M, + MEGAItems.CELL_COMPONENT_64M, + MEGAItems.MEGA_ITEM_CELL_HOUSING); + portable( + consumer, + MEGAItems.PORTABLE_ITEM_CELL_256M, + MEGAItems.CELL_COMPONENT_256M, + MEGAItems.MEGA_ITEM_CELL_HOUSING); + portable( + consumer, + MEGAItems.PORTABLE_FLUID_CELL_1M, + MEGAItems.CELL_COMPONENT_1M, + MEGAItems.MEGA_FLUID_CELL_HOUSING); + portable( + consumer, + MEGAItems.PORTABLE_FLUID_CELL_4M, + MEGAItems.CELL_COMPONENT_4M, + MEGAItems.MEGA_FLUID_CELL_HOUSING); + portable( + consumer, + MEGAItems.PORTABLE_FLUID_CELL_16M, + MEGAItems.CELL_COMPONENT_16M, + MEGAItems.MEGA_FLUID_CELL_HOUSING); + portable( + consumer, + MEGAItems.PORTABLE_FLUID_CELL_64M, + MEGAItems.CELL_COMPONENT_64M, + MEGAItems.MEGA_FLUID_CELL_HOUSING); + portable( + consumer, + MEGAItems.PORTABLE_FLUID_CELL_256M, + MEGAItems.CELL_COMPONENT_256M, + MEGAItems.MEGA_FLUID_CELL_HOUSING); ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, MEGABlocks.SKY_STEEL_BLOCK) .pattern("###") @@ -91,9 +179,15 @@ public void buildRecipes(@NotNull Consumer consumer) { .unlockedBy("has_sky_steel_ingot", has(MEGATags.SKY_STEEL_INGOT)) .save(consumer, Utils.makeId("crafting/sky_steel_ingot_from_sky_steel_block")); - TransformRecipeBuilder.transform(consumer, Utils.makeId("transform/sky_steel_ingot"), MEGAItems.SKY_STEEL_INGOT, - 2, TransformCircumstance.fluid(FluidTags.WATER), Ingredient.of(ConventionTags.IRON_INGOT), - Ingredient.of(AEItems.CERTUS_QUARTZ_CRYSTAL_CHARGED), Ingredient.of(AEBlocks.SKY_STONE_BLOCK)); + TransformRecipeBuilder.transform( + consumer, + Utils.makeId("transform/sky_steel_ingot"), + MEGAItems.SKY_STEEL_INGOT, + 2, + TransformCircumstance.fluid(FluidTags.WATER), + Ingredient.of(ConventionTags.IRON_INGOT), + Ingredient.of(AEItems.CERTUS_QUARTZ_CRYSTAL_CHARGED), + Ingredient.of(AEBlocks.SKY_STONE_BLOCK)); InscriberRecipeBuilder.inscribe(AEItems.SINGULARITY, MEGAItems.ACCUMULATION_PROCESSOR_PRESS, 1) .setTop(Ingredient.of(AEItems.CALCULATION_PROCESSOR_PRESS)) @@ -226,8 +320,8 @@ public void buildRecipes(@NotNull Consumer consumer) { } } - private void component(Consumer consumer, StorageTier tier, StorageTier preceding, - ItemLike binder) { + private void component( + Consumer consumer, StorageTier tier, StorageTier preceding, ItemLike binder) { var precedingComponent = preceding.componentSupplier().get(); ShapedRecipeBuilder.shaped(RecipeCategory.MISC, tier.componentSupplier().get()) .pattern("aba") @@ -238,14 +332,26 @@ private void component(Consumer consumer, StorageTier tier, Stor .define('c', precedingComponent) .define('d', AEBlocks.QUARTZ_VIBRANT_GLASS) .unlockedBy("has_accumulation_processor", has(MEGAItems.ACCUMULATION_PROCESSOR)) - .unlockedBy("has_" + BuiltInRegistries.ITEM.getKey(precedingComponent).getPath(), + .unlockedBy( + "has_" + + BuiltInRegistries.ITEM + .getKey(precedingComponent) + .getPath(), has(precedingComponent)) - .save(consumer, Utils - .makeId("cells/" + BuiltInRegistries.ITEM.getKey(tier.componentSupplier().get()).getPath())); + .save( + consumer, + Utils.makeId("cells/" + + BuiltInRegistries.ITEM + .getKey(tier.componentSupplier().get()) + .getPath())); } - private void cell(Consumer consumer, ItemDefinition cell, ItemDefinition component, - ItemDefinition housing, TagKey housingMaterial) { + private void cell( + Consumer consumer, + ItemDefinition cell, + ItemDefinition component, + ItemDefinition housing, + TagKey housingMaterial) { ShapedRecipeBuilder.shaped(RecipeCategory.MISC, cell) .pattern("aba") .pattern("bcb") @@ -265,7 +371,10 @@ private void cell(Consumer consumer, ItemDefinition cell, Ite .save(consumer, Utils.makeId("cells/standard/" + cell.id().getPath() + "_with_housing")); } - private void portable(Consumer consumer, ItemDefinition cell, ItemDefinition component, + private void portable( + Consumer consumer, + ItemDefinition cell, + ItemDefinition component, ItemDefinition housing) { ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, cell) .requires(AEBlocks.CHEST) @@ -298,18 +407,23 @@ private void craftingBlock(Consumer consumer, BlockDefinition .save(consumer, Utils.makeId("crafting/" + unit.id().getPath())); } - private void manaCells(Consumer consumer, ItemDefinition cell, ItemDefinition portable, - StorageTier tier) { + private void manaCells( + Consumer consumer, ItemDefinition cell, ItemDefinition portable, StorageTier tier) { var component = tier.componentSupplier().get(); var componentPath = BuiltInRegistries.ITEM.getKey(component).getPath(); - ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, cell).requires(AppBotItems.MEGA_MANA_CELL_HOUSING) - .requires(tier.componentSupplier().get()).unlockedBy("has_" + componentPath, has(component)) + ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, cell) + .requires(AppBotItems.MEGA_MANA_CELL_HOUSING) + .requires(tier.componentSupplier().get()) + .unlockedBy("has_" + componentPath, has(component)) .unlockedBy("has_mega_mana_cell_housing", has(AppBotItems.MEGA_MANA_CELL_HOUSING)) .save(consumer, Utils.makeId("cells/standard/" + cell.id().getPath() + "_with_housing")); - ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, portable).requires(AEBlocks.CHEST).requires(component) - .requires(AEBlocks.DENSE_ENERGY_CELL).requires(AppBotItems.MEGA_MANA_CELL_HOUSING) + ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, portable) + .requires(AEBlocks.CHEST) + .requires(component) + .requires(AEBlocks.DENSE_ENERGY_CELL) + .requires(AppBotItems.MEGA_MANA_CELL_HOUSING) .unlockedBy("has_mega_mana_cell_housing", has(AppBotItems.MEGA_MANA_CELL_HOUSING)) .unlockedBy("has_" + componentPath, has(component)) .unlockedBy("has_dense_energy_cell", has(AEBlocks.DENSE_ENERGY_CELL)) diff --git a/fabric/src/data/java/gripe/_90/megacells/datagen/TagProvider.java b/fabric/src/data/java/gripe/_90/megacells/datagen/TagProvider.java index a0c3a2f9..d8c4e719 100644 --- a/fabric/src/data/java/gripe/_90/megacells/datagen/TagProvider.java +++ b/fabric/src/data/java/gripe/_90/megacells/datagen/TagProvider.java @@ -50,7 +50,10 @@ static class Blocks extends FabricTagProvider.BlockTagProvider { @Override protected void addTags(HolderLookup.Provider provider) { - MEGABlocks.getBlocks().forEach(block -> tag(BlockTags.MINEABLE_WITH_PICKAXE).add(getKey(block))); + for (var block : MEGABlocks.getBlocks()) { + tag(BlockTags.MINEABLE_WITH_PICKAXE).add(getKey(block)); + } + tag(MEGATags.SKY_STEEL_BLOCK).add(getKey(MEGABlocks.SKY_STEEL_BLOCK)); } diff --git a/fabric/src/main/java/gripe/_90/megacells/MEGACells.java b/fabric/src/main/java/gripe/_90/megacells/MEGACells.java index da962654..7249e03d 100644 --- a/fabric/src/main/java/gripe/_90/megacells/MEGACells.java +++ b/fabric/src/main/java/gripe/_90/megacells/MEGACells.java @@ -63,13 +63,13 @@ private void registerAll() { Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, blockEntity.getKey(), blockEntity.getValue()); } - Registry.register(BuiltInRegistries.MENU, AppEng.makeId("mega_pattern_provider"), - MEGAPatternProviderBlock.MENU); + Registry.register( + BuiltInRegistries.MENU, AppEng.makeId("mega_pattern_provider"), MEGAPatternProviderBlock.MENU); } private void initCompression() { - ServerLifecycleEvents.SERVER_STARTED.register(server -> CompressionService.INSTANCE - .loadRecipes(server.getRecipeManager(), server.registryAccess())); + ServerLifecycleEvents.SERVER_STARTED.register( + server -> CompressionService.INSTANCE.loadRecipes(server.getRecipeManager(), server.registryAccess())); ServerLifecycleEvents.END_DATA_PACK_RELOAD.register((server, resourceManager, success) -> { if (success) { CompressionService.INSTANCE.loadRecipes(server.getRecipeManager(), server.registryAccess()); diff --git a/fabric/src/main/java/gripe/_90/megacells/MEGACellsClient.java b/fabric/src/main/java/gripe/_90/megacells/MEGACellsClient.java index e0781d42..97918cee 100644 --- a/fabric/src/main/java/gripe/_90/megacells/MEGACellsClient.java +++ b/fabric/src/main/java/gripe/_90/megacells/MEGACellsClient.java @@ -45,11 +45,10 @@ public void onAe2Initialized() { } private void initScreens() { - ClientLifecycleEvents.CLIENT_STARTED.register(client -> { - InitScreens.register(MEGAPatternProviderBlock.MENU, - PatternProviderScreen::new, - "/screens/megacells/mega_pattern_provider.json"); - }); + ClientLifecycleEvents.CLIENT_STARTED.register(client -> InitScreens.register( + MEGAPatternProviderBlock.MENU, + PatternProviderScreen::new, + "/screens/megacells/mega_pattern_provider.json")); } private void initBlockModels() { @@ -65,8 +64,8 @@ private void initBlockModels() { } private void initItemModels() { - ItemProperties.register(MEGABlocks.MEGA_ENERGY_CELL.asItem(), AppEng.makeId("fill_level"), - (is, level, entity, seed) -> { + ItemProperties.register( + MEGABlocks.MEGA_ENERGY_CELL.asItem(), AppEng.makeId("fill_level"), (is, level, entity, seed) -> { var energyCell = (EnergyCellBlockItem) MEGABlocks.MEGA_ENERGY_CELL.asItem(); double curPower = energyCell.getAECurrentPower(is); diff --git a/forge/src/main/java/gripe/_90/megacells/datagen/LootTableProvider.java b/forge/src/main/java/gripe/_90/megacells/datagen/LootTableProvider.java index e8e3a37a..943cea44 100644 --- a/forge/src/main/java/gripe/_90/megacells/datagen/LootTableProvider.java +++ b/forge/src/main/java/gripe/_90/megacells/datagen/LootTableProvider.java @@ -33,8 +33,13 @@ protected BlockLoot() { @Override protected void generate() { for (var block : getKnownBlocks()) { - add(block, LootTable.lootTable().withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1)) - .add(LootItem.lootTableItem(block)).when(ExplosionCondition.survivesExplosion()))); + add( + block, + LootTable.lootTable() + .withPool(LootPool.lootPool() + .setRolls(ConstantValue.exactly(1)) + .add(LootItem.lootTableItem(block)) + .when(ExplosionCondition.survivesExplosion()))); } } diff --git a/forge/src/main/java/gripe/_90/megacells/datagen/ModelProvider.java b/forge/src/main/java/gripe/_90/megacells/datagen/ModelProvider.java index e3bb2925..0eea0621 100644 --- a/forge/src/main/java/gripe/_90/megacells/datagen/ModelProvider.java +++ b/forge/src/main/java/gripe/_90/megacells/datagen/ModelProvider.java @@ -40,18 +40,18 @@ abstract class ModelProvider { static class Items extends ItemModelProvider { - // spotless:off private static final ResourceLocation CRAFTING_PATTERN = AppEng.makeId("item/crafting_pattern"); private static final ResourceLocation STORAGE_CELL_LED = AppEng.makeId("item/storage_cell_led"); private static final ResourceLocation PORTABLE_CELL_LED = AppEng.makeId("item/portable_cell_led"); - private static final ResourceLocation PORTABLE_CELL_ITEM_HOUSING = AppEng.makeId("item/portable_cell_item_housing"); - private static final ResourceLocation PORTABLE_CELL_FLUID_HOUSING = AppEng.makeId("item/portable_cell_fluid_housing"); + private static final ResourceLocation PORTABLE_CELL_ITEM_HOUSING = + AppEng.makeId("item/portable_cell_item_housing"); + private static final ResourceLocation PORTABLE_CELL_FLUID_HOUSING = + AppEng.makeId("item/portable_cell_fluid_housing"); private static final ResourceLocation CABLE_INTERFACE = AppEng.makeId("item/cable_interface"); private static final ResourceLocation DRIVE_CELL = AppEng.makeId("block/drive/drive_cell"); - //spotless:on public Items(PackOutput output, ExistingFileHelper existing) { super(output, Utils.MODID, existing); @@ -85,7 +85,10 @@ protected void registerModels() { basicItem(MEGAItems.GREATER_ENERGY_CARD.asItem()); basicItem(MEGAItems.COMPRESSION_CARD.asItem()); - singleTexture(MEGAItems.DECOMPRESSION_PATTERN.id().getPath(), mcLoc("item/generated"), "layer0", + singleTexture( + MEGAItems.DECOMPRESSION_PATTERN.id().getPath(), + mcLoc("item/generated"), + "layer0", CRAFTING_PATTERN); MEGAItems.getItemPortables().forEach(p -> portableModel(p, "item", PORTABLE_CELL_ITEM_HOUSING)); @@ -137,9 +140,13 @@ private void cellModel(ItemDefinition cell) { private void portableModel(ItemDefinition portable, String screenType, ResourceLocation housingTexture) { var path = portable.id().getPath(); var tierSuffix = path.substring(path.lastIndexOf('_') + 1); - singleTexture(path, mcLoc("item/generated"), "layer0", - Utils.makeId("item/cell/portable/portable_cell_%s_screen".formatted(screenType))) - .texture("layer1", PORTABLE_CELL_LED).texture("layer2", housingTexture) + singleTexture( + path, + mcLoc("item/generated"), + "layer0", + Utils.makeId("item/cell/portable/portable_cell_%s_screen".formatted(screenType))) + .texture("layer1", PORTABLE_CELL_LED) + .texture("layer2", housingTexture) .texture("layer3", "item/cell/portable/portable_cell_side_%s".formatted(tierSuffix)); } @@ -158,8 +165,8 @@ private void patternProviderPart() { static class Blocks extends AE2BlockStateProvider { // because for whatever reason this isn't fucking accessible from BlockStateProvider - private static final ExistingFileHelper.ResourceType MODEL = new ExistingFileHelper.ResourceType( - PackType.CLIENT_RESOURCES, ".json", "models"); + private static final ExistingFileHelper.ResourceType MODEL = + new ExistingFileHelper.ResourceType(PackType.CLIENT_RESOURCES, ".json", "models"); private static final ResourceLocation DRIVE_CELL = AppEng.makeId("block/drive/drive_cell"); @@ -195,7 +202,9 @@ private void energyCell() { for (var i = 0; i < 5; i++) { var model = models().cubeAll(path + "_" + i, Utils.makeId("block/" + path + "_" + i)); - blockBuilder.partialState().with(EnergyCellBlock.ENERGY_STORAGE, i) + blockBuilder + .partialState() + .with(EnergyCellBlock.ENERGY_STORAGE, i) .setModels(new ConfiguredModel(model)); models.add(model); } @@ -213,9 +222,11 @@ private void energyCell() { private void craftingModel(BlockDefinition block, String name) { var blockModel = models().cubeAll("block/crafting/" + name, Utils.makeId("block/crafting/" + name)); getVariantBuilder(block.block()) - .partialState().with(AbstractCraftingUnitBlock.FORMED, false) + .partialState() + .with(AbstractCraftingUnitBlock.FORMED, false) .setModels(new ConfiguredModel(blockModel)) - .partialState().with(AbstractCraftingUnitBlock.FORMED, true) + .partialState() + .with(AbstractCraftingUnitBlock.FORMED, true) .setModels(new ConfiguredModel(models().getBuilder("ae2:block/crafting/mega_" + name + "_formed"))); simpleBlockItem(block.block(), blockModel); } @@ -236,8 +247,8 @@ private void craftingMonitor() { return Variant.variant().with(VariantProperties.MODEL, formedModel); } else { return applyOrientation( - Variant.variant().with(VariantProperties.MODEL, - unformedModel.getLocation()), + Variant.variant() + .with(VariantProperties.MODEL, unformedModel.getLocation()), BlockOrientation.get(facing)); } })); @@ -251,27 +262,35 @@ private void patternProvider() { simpleBlockItem(def.block(), normalModel); var arrow = Utils.makeId("block/mega_pattern_provider_alternate_arrow"); - var orientedModel = models().cube("block/mega_pattern_provider_oriented", - Utils.makeId("block/mega_pattern_provider_alternate"), - Utils.makeId("block/mega_pattern_provider_alternate_front"), arrow, arrow, arrow, arrow) + var orientedModel = models().cube( + "block/mega_pattern_provider_oriented", + Utils.makeId("block/mega_pattern_provider_alternate"), + Utils.makeId("block/mega_pattern_provider_alternate_front"), + arrow, + arrow, + arrow, + arrow) .texture("particle", "block/mega_pattern_provider"); multiVariantGenerator(MEGABlocks.MEGA_PATTERN_PROVIDER, Variant.variant()) - .with(PropertyDispatch.property(MEGAPatternProviderBlock.PUSH_DIRECTION).generate(pushDirection -> { - var forward = pushDirection.getDirection(); - if (forward == null) { - return Variant.variant().with(VariantProperties.MODEL, normalModel.getLocation()); - } else { - var orientation = BlockOrientation.get(forward); - return applyRotation( - Variant.variant().with(VariantProperties.MODEL, orientedModel.getLocation()), - // + 90 because the default model is oriented UP, while block orientation assumes - // NORTH - orientation.getAngleX() + 90, - orientation.getAngleY(), - 0); - } - })); + .with(PropertyDispatch.property(MEGAPatternProviderBlock.PUSH_DIRECTION) + .generate(pushDirection -> { + var forward = pushDirection.getDirection(); + if (forward == null) { + return Variant.variant().with(VariantProperties.MODEL, normalModel.getLocation()); + } else { + var orientation = BlockOrientation.get(forward); + return applyRotation( + Variant.variant() + .with(VariantProperties.MODEL, orientedModel.getLocation()), + // + 90 because the default model is oriented UP, while block orientation + // assumes + // NORTH + orientation.getAngleX() + 90, + orientation.getAngleY(), + 0); + } + })); } } diff --git a/forge/src/main/java/gripe/_90/megacells/datagen/RecipeProvider.java b/forge/src/main/java/gripe/_90/megacells/datagen/RecipeProvider.java index ed11831e..81c53df4 100644 --- a/forge/src/main/java/gripe/_90/megacells/datagen/RecipeProvider.java +++ b/forge/src/main/java/gripe/_90/megacells/datagen/RecipeProvider.java @@ -53,7 +53,6 @@ public RecipeProvider(PackOutput output) { @Override protected void buildRecipes(@NotNull Consumer consumer) { - // spotless:off component(consumer, MEGAItems.TIER_1M, StorageTier.SIZE_256K, AEItems.SKY_DUST.asItem()); component(consumer, MEGAItems.TIER_4M, MEGAItems.TIER_1M, AEItems.ENDER_DUST.asItem()); component(consumer, MEGAItems.TIER_16M, MEGAItems.TIER_4M, AEItems.ENDER_DUST.asItem()); @@ -63,28 +62,117 @@ protected void buildRecipes(@NotNull Consumer consumer) { housing(consumer, MEGAItems.MEGA_ITEM_CELL_HOUSING, MEGATags.SKY_STEEL_INGOT); housing(consumer, MEGAItems.MEGA_FLUID_CELL_HOUSING, ConventionTags.COPPER_INGOT); - cell(consumer, MEGAItems.ITEM_CELL_1M, MEGAItems.CELL_COMPONENT_1M, MEGAItems.MEGA_ITEM_CELL_HOUSING, ConventionTags.IRON_INGOT); - cell(consumer, MEGAItems.ITEM_CELL_4M, MEGAItems.CELL_COMPONENT_4M, MEGAItems.MEGA_ITEM_CELL_HOUSING, ConventionTags.IRON_INGOT); - cell(consumer, MEGAItems.ITEM_CELL_16M, MEGAItems.CELL_COMPONENT_16M, MEGAItems.MEGA_ITEM_CELL_HOUSING, ConventionTags.IRON_INGOT); - cell(consumer, MEGAItems.ITEM_CELL_64M, MEGAItems.CELL_COMPONENT_64M, MEGAItems.MEGA_ITEM_CELL_HOUSING, ConventionTags.IRON_INGOT); - cell(consumer, MEGAItems.ITEM_CELL_256M, MEGAItems.CELL_COMPONENT_256M, MEGAItems.MEGA_ITEM_CELL_HOUSING, ConventionTags.IRON_INGOT); - cell(consumer, MEGAItems.FLUID_CELL_1M, MEGAItems.CELL_COMPONENT_1M, MEGAItems.MEGA_FLUID_CELL_HOUSING, ConventionTags.COPPER_INGOT); - cell(consumer, MEGAItems.FLUID_CELL_4M, MEGAItems.CELL_COMPONENT_4M, MEGAItems.MEGA_FLUID_CELL_HOUSING, ConventionTags.COPPER_INGOT); - cell(consumer, MEGAItems.FLUID_CELL_16M, MEGAItems.CELL_COMPONENT_16M, MEGAItems.MEGA_FLUID_CELL_HOUSING, ConventionTags.COPPER_INGOT); - cell(consumer, MEGAItems.FLUID_CELL_64M, MEGAItems.CELL_COMPONENT_64M, MEGAItems.MEGA_FLUID_CELL_HOUSING, ConventionTags.COPPER_INGOT); - cell(consumer, MEGAItems.FLUID_CELL_256M, MEGAItems.CELL_COMPONENT_256M, MEGAItems.MEGA_FLUID_CELL_HOUSING, ConventionTags.COPPER_INGOT); - - portable(consumer, MEGAItems.PORTABLE_ITEM_CELL_1M, MEGAItems.CELL_COMPONENT_1M, MEGAItems.MEGA_ITEM_CELL_HOUSING); - portable(consumer, MEGAItems.PORTABLE_ITEM_CELL_4M, MEGAItems.CELL_COMPONENT_4M, MEGAItems.MEGA_ITEM_CELL_HOUSING); - portable(consumer, MEGAItems.PORTABLE_ITEM_CELL_16M, MEGAItems.CELL_COMPONENT_16M, MEGAItems.MEGA_ITEM_CELL_HOUSING); - portable(consumer, MEGAItems.PORTABLE_ITEM_CELL_64M, MEGAItems.CELL_COMPONENT_64M, MEGAItems.MEGA_ITEM_CELL_HOUSING); - portable(consumer, MEGAItems.PORTABLE_ITEM_CELL_256M, MEGAItems.CELL_COMPONENT_256M, MEGAItems.MEGA_ITEM_CELL_HOUSING); - portable(consumer, MEGAItems.PORTABLE_FLUID_CELL_1M, MEGAItems.CELL_COMPONENT_1M, MEGAItems.MEGA_FLUID_CELL_HOUSING); - portable(consumer, MEGAItems.PORTABLE_FLUID_CELL_4M, MEGAItems.CELL_COMPONENT_4M, MEGAItems.MEGA_FLUID_CELL_HOUSING); - portable(consumer, MEGAItems.PORTABLE_FLUID_CELL_16M, MEGAItems.CELL_COMPONENT_16M, MEGAItems.MEGA_FLUID_CELL_HOUSING); - portable(consumer, MEGAItems.PORTABLE_FLUID_CELL_64M, MEGAItems.CELL_COMPONENT_64M, MEGAItems.MEGA_FLUID_CELL_HOUSING); - portable(consumer, MEGAItems.PORTABLE_FLUID_CELL_256M, MEGAItems.CELL_COMPONENT_256M, MEGAItems.MEGA_FLUID_CELL_HOUSING); - // spotless:on + cell( + consumer, + MEGAItems.ITEM_CELL_1M, + MEGAItems.CELL_COMPONENT_1M, + MEGAItems.MEGA_ITEM_CELL_HOUSING, + ConventionTags.IRON_INGOT); + cell( + consumer, + MEGAItems.ITEM_CELL_4M, + MEGAItems.CELL_COMPONENT_4M, + MEGAItems.MEGA_ITEM_CELL_HOUSING, + ConventionTags.IRON_INGOT); + cell( + consumer, + MEGAItems.ITEM_CELL_16M, + MEGAItems.CELL_COMPONENT_16M, + MEGAItems.MEGA_ITEM_CELL_HOUSING, + ConventionTags.IRON_INGOT); + cell( + consumer, + MEGAItems.ITEM_CELL_64M, + MEGAItems.CELL_COMPONENT_64M, + MEGAItems.MEGA_ITEM_CELL_HOUSING, + ConventionTags.IRON_INGOT); + cell( + consumer, + MEGAItems.ITEM_CELL_256M, + MEGAItems.CELL_COMPONENT_256M, + MEGAItems.MEGA_ITEM_CELL_HOUSING, + ConventionTags.IRON_INGOT); + cell( + consumer, + MEGAItems.FLUID_CELL_1M, + MEGAItems.CELL_COMPONENT_1M, + MEGAItems.MEGA_FLUID_CELL_HOUSING, + ConventionTags.COPPER_INGOT); + cell( + consumer, + MEGAItems.FLUID_CELL_4M, + MEGAItems.CELL_COMPONENT_4M, + MEGAItems.MEGA_FLUID_CELL_HOUSING, + ConventionTags.COPPER_INGOT); + cell( + consumer, + MEGAItems.FLUID_CELL_16M, + MEGAItems.CELL_COMPONENT_16M, + MEGAItems.MEGA_FLUID_CELL_HOUSING, + ConventionTags.COPPER_INGOT); + cell( + consumer, + MEGAItems.FLUID_CELL_64M, + MEGAItems.CELL_COMPONENT_64M, + MEGAItems.MEGA_FLUID_CELL_HOUSING, + ConventionTags.COPPER_INGOT); + cell( + consumer, + MEGAItems.FLUID_CELL_256M, + MEGAItems.CELL_COMPONENT_256M, + MEGAItems.MEGA_FLUID_CELL_HOUSING, + ConventionTags.COPPER_INGOT); + + portable( + consumer, + MEGAItems.PORTABLE_ITEM_CELL_1M, + MEGAItems.CELL_COMPONENT_1M, + MEGAItems.MEGA_ITEM_CELL_HOUSING); + portable( + consumer, + MEGAItems.PORTABLE_ITEM_CELL_4M, + MEGAItems.CELL_COMPONENT_4M, + MEGAItems.MEGA_ITEM_CELL_HOUSING); + portable( + consumer, + MEGAItems.PORTABLE_ITEM_CELL_16M, + MEGAItems.CELL_COMPONENT_16M, + MEGAItems.MEGA_ITEM_CELL_HOUSING); + portable( + consumer, + MEGAItems.PORTABLE_ITEM_CELL_64M, + MEGAItems.CELL_COMPONENT_64M, + MEGAItems.MEGA_ITEM_CELL_HOUSING); + portable( + consumer, + MEGAItems.PORTABLE_ITEM_CELL_256M, + MEGAItems.CELL_COMPONENT_256M, + MEGAItems.MEGA_ITEM_CELL_HOUSING); + portable( + consumer, + MEGAItems.PORTABLE_FLUID_CELL_1M, + MEGAItems.CELL_COMPONENT_1M, + MEGAItems.MEGA_FLUID_CELL_HOUSING); + portable( + consumer, + MEGAItems.PORTABLE_FLUID_CELL_4M, + MEGAItems.CELL_COMPONENT_4M, + MEGAItems.MEGA_FLUID_CELL_HOUSING); + portable( + consumer, + MEGAItems.PORTABLE_FLUID_CELL_16M, + MEGAItems.CELL_COMPONENT_16M, + MEGAItems.MEGA_FLUID_CELL_HOUSING); + portable( + consumer, + MEGAItems.PORTABLE_FLUID_CELL_64M, + MEGAItems.CELL_COMPONENT_64M, + MEGAItems.MEGA_FLUID_CELL_HOUSING); + portable( + consumer, + MEGAItems.PORTABLE_FLUID_CELL_256M, + MEGAItems.CELL_COMPONENT_256M, + MEGAItems.MEGA_FLUID_CELL_HOUSING); ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, MEGABlocks.SKY_STEEL_BLOCK) .pattern("###") @@ -98,9 +186,15 @@ protected void buildRecipes(@NotNull Consumer consumer) { .unlockedBy("has_sky_steel_ingot", has(MEGATags.SKY_STEEL_INGOT)) .save(consumer, Utils.makeId("crafting/sky_steel_ingot_from_sky_steel_block")); - TransformRecipeBuilder.transform(consumer, Utils.makeId("transform/sky_steel_ingot"), MEGAItems.SKY_STEEL_INGOT, - 2, TransformCircumstance.fluid(FluidTags.WATER), Ingredient.of(ConventionTags.IRON_INGOT), - Ingredient.of(AEItems.CERTUS_QUARTZ_CRYSTAL_CHARGED), Ingredient.of(AEBlocks.SKY_STONE_BLOCK)); + TransformRecipeBuilder.transform( + consumer, + Utils.makeId("transform/sky_steel_ingot"), + MEGAItems.SKY_STEEL_INGOT, + 2, + TransformCircumstance.fluid(FluidTags.WATER), + Ingredient.of(ConventionTags.IRON_INGOT), + Ingredient.of(AEItems.CERTUS_QUARTZ_CRYSTAL_CHARGED), + Ingredient.of(AEBlocks.SKY_STONE_BLOCK)); InscriberRecipeBuilder.inscribe(AEItems.SINGULARITY, MEGAItems.ACCUMULATION_PROCESSOR_PRESS, 1) .setTop(Ingredient.of(AEItems.CALCULATION_PROCESSOR_PRESS)) @@ -227,21 +321,64 @@ protected void buildRecipes(@NotNull Consumer consumer) { if (Utils.PLATFORM.isAddonLoaded(Addons.APPMEK)) { var osmiumTag = ItemTags.create(new ResourceLocation("forge", "ingots/osmium")); - // spotless:off housing(consumer, AppMekItems.MEGA_CHEMICAL_CELL_HOUSING, osmiumTag); - cell(consumer, AppMekItems.CHEMICAL_CELL_1M, MEGAItems.CELL_COMPONENT_1M, AppMekItems.MEGA_CHEMICAL_CELL_HOUSING, osmiumTag); - cell(consumer, AppMekItems.CHEMICAL_CELL_4M, MEGAItems.CELL_COMPONENT_4M, AppMekItems.MEGA_CHEMICAL_CELL_HOUSING, osmiumTag); - cell(consumer, AppMekItems.CHEMICAL_CELL_16M, MEGAItems.CELL_COMPONENT_16M, AppMekItems.MEGA_CHEMICAL_CELL_HOUSING, osmiumTag); - cell(consumer, AppMekItems.CHEMICAL_CELL_64M, MEGAItems.CELL_COMPONENT_64M, AppMekItems.MEGA_CHEMICAL_CELL_HOUSING, osmiumTag); - cell(consumer, AppMekItems.CHEMICAL_CELL_256M, MEGAItems.CELL_COMPONENT_256M, AppMekItems.MEGA_CHEMICAL_CELL_HOUSING, osmiumTag); - - portable(consumer, AppMekItems.PORTABLE_CHEMICAL_CELL_1M, MEGAItems.CELL_COMPONENT_1M, AppMekItems.MEGA_CHEMICAL_CELL_HOUSING); - portable(consumer, AppMekItems.PORTABLE_CHEMICAL_CELL_4M, MEGAItems.CELL_COMPONENT_4M, AppMekItems.MEGA_CHEMICAL_CELL_HOUSING); - portable(consumer, AppMekItems.PORTABLE_CHEMICAL_CELL_16M, MEGAItems.CELL_COMPONENT_16M, AppMekItems.MEGA_CHEMICAL_CELL_HOUSING); - portable(consumer, AppMekItems.PORTABLE_CHEMICAL_CELL_64M, MEGAItems.CELL_COMPONENT_64M, AppMekItems.MEGA_CHEMICAL_CELL_HOUSING); - portable(consumer, AppMekItems.PORTABLE_CHEMICAL_CELL_256M, MEGAItems.CELL_COMPONENT_256M, AppMekItems.MEGA_CHEMICAL_CELL_HOUSING); - //spotless:on + cell( + consumer, + AppMekItems.CHEMICAL_CELL_1M, + MEGAItems.CELL_COMPONENT_1M, + AppMekItems.MEGA_CHEMICAL_CELL_HOUSING, + osmiumTag); + cell( + consumer, + AppMekItems.CHEMICAL_CELL_4M, + MEGAItems.CELL_COMPONENT_4M, + AppMekItems.MEGA_CHEMICAL_CELL_HOUSING, + osmiumTag); + cell( + consumer, + AppMekItems.CHEMICAL_CELL_16M, + MEGAItems.CELL_COMPONENT_16M, + AppMekItems.MEGA_CHEMICAL_CELL_HOUSING, + osmiumTag); + cell( + consumer, + AppMekItems.CHEMICAL_CELL_64M, + MEGAItems.CELL_COMPONENT_64M, + AppMekItems.MEGA_CHEMICAL_CELL_HOUSING, + osmiumTag); + cell( + consumer, + AppMekItems.CHEMICAL_CELL_256M, + MEGAItems.CELL_COMPONENT_256M, + AppMekItems.MEGA_CHEMICAL_CELL_HOUSING, + osmiumTag); + + portable( + consumer, + AppMekItems.PORTABLE_CHEMICAL_CELL_1M, + MEGAItems.CELL_COMPONENT_1M, + AppMekItems.MEGA_CHEMICAL_CELL_HOUSING); + portable( + consumer, + AppMekItems.PORTABLE_CHEMICAL_CELL_4M, + MEGAItems.CELL_COMPONENT_4M, + AppMekItems.MEGA_CHEMICAL_CELL_HOUSING); + portable( + consumer, + AppMekItems.PORTABLE_CHEMICAL_CELL_16M, + MEGAItems.CELL_COMPONENT_16M, + AppMekItems.MEGA_CHEMICAL_CELL_HOUSING); + portable( + consumer, + AppMekItems.PORTABLE_CHEMICAL_CELL_64M, + MEGAItems.CELL_COMPONENT_64M, + AppMekItems.MEGA_CHEMICAL_CELL_HOUSING); + portable( + consumer, + AppMekItems.PORTABLE_CHEMICAL_CELL_256M, + MEGAItems.CELL_COMPONENT_256M, + AppMekItems.MEGA_CHEMICAL_CELL_HOUSING); // TODO InscriberRecipeBuilder.inscribe(AEItems.SINGULARITY, AppMekItems.RADIOACTIVE_CELL_COMPONENT, 1) @@ -272,8 +409,8 @@ protected void buildRecipes(@NotNull Consumer consumer) { } } - private void component(Consumer consumer, StorageTier tier, StorageTier preceding, - ItemLike binder) { + private void component( + Consumer consumer, StorageTier tier, StorageTier preceding, ItemLike binder) { var precedingComponent = preceding.componentSupplier().get(); ShapedRecipeBuilder.shaped(RecipeCategory.MISC, tier.componentSupplier().get()) .pattern("aba") @@ -284,14 +421,25 @@ private void component(Consumer consumer, StorageTier tier, Stor .define('c', precedingComponent) .define('d', AEBlocks.QUARTZ_VIBRANT_GLASS) .unlockedBy("has_accumulation_processor", has(MEGAItems.ACCUMULATION_PROCESSOR)) - .unlockedBy("has_" + Objects.requireNonNull(ForgeRegistries.ITEMS.getKey(precedingComponent)).getPath(), + .unlockedBy( + "has_" + + Objects.requireNonNull(ForgeRegistries.ITEMS.getKey(precedingComponent)) + .getPath(), has(precedingComponent)) - .save(consumer, Utils.makeId("cells/" + Objects - .requireNonNull(ForgeRegistries.ITEMS.getKey(tier.componentSupplier().get())).getPath())); + .save( + consumer, + Utils.makeId("cells/" + + Objects.requireNonNull(ForgeRegistries.ITEMS.getKey( + tier.componentSupplier().get())) + .getPath())); } - private void cell(Consumer consumer, ItemDefinition cell, ItemDefinition component, - ItemDefinition housing, TagKey housingMaterial) { + private void cell( + Consumer consumer, + ItemDefinition cell, + ItemDefinition component, + ItemDefinition housing, + TagKey housingMaterial) { ShapedRecipeBuilder.shaped(RecipeCategory.MISC, cell) .pattern("aba") .pattern("bcb") @@ -311,7 +459,10 @@ private void cell(Consumer consumer, ItemDefinition cell, Ite .save(consumer, Utils.makeId("cells/standard/" + cell.id().getPath() + "_with_housing")); } - private void portable(Consumer consumer, ItemDefinition cell, ItemDefinition component, + private void portable( + Consumer consumer, + ItemDefinition cell, + ItemDefinition component, ItemDefinition housing) { ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, cell) .requires(AEBlocks.CHEST) @@ -344,18 +495,24 @@ private void craftingBlock(Consumer consumer, BlockDefinition .save(consumer, Utils.makeId("crafting/" + unit.id().getPath())); } - private void manaCells(Consumer consumer, ItemDefinition cell, ItemDefinition portable, - StorageTier tier) { + private void manaCells( + Consumer consumer, ItemDefinition cell, ItemDefinition portable, StorageTier tier) { var component = tier.componentSupplier().get(); - var componentPath = Objects.requireNonNull(ForgeRegistries.ITEMS.getKey(component)).getPath(); + var componentPath = + Objects.requireNonNull(ForgeRegistries.ITEMS.getKey(component)).getPath(); - ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, cell).requires(AppBotItems.MEGA_MANA_CELL_HOUSING) - .requires(tier.componentSupplier().get()).unlockedBy("has_" + componentPath, has(component)) + ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, cell) + .requires(AppBotItems.MEGA_MANA_CELL_HOUSING) + .requires(tier.componentSupplier().get()) + .unlockedBy("has_" + componentPath, has(component)) .unlockedBy("has_mega_mana_cell_housing", has(AppBotItems.MEGA_MANA_CELL_HOUSING)) .save(consumer, Utils.makeId("cells/standard/" + cell.id().getPath() + "_with_housing")); - ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, portable).requires(AEBlocks.CHEST).requires(component) - .requires(AEBlocks.DENSE_ENERGY_CELL).requires(AppBotItems.MEGA_MANA_CELL_HOUSING) + ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, portable) + .requires(AEBlocks.CHEST) + .requires(component) + .requires(AEBlocks.DENSE_ENERGY_CELL) + .requires(AppBotItems.MEGA_MANA_CELL_HOUSING) .unlockedBy("has_mega_mana_cell_housing", has(AppBotItems.MEGA_MANA_CELL_HOUSING)) .unlockedBy("has_" + componentPath, has(component)) .unlockedBy("has_dense_energy_cell", has(AEBlocks.DENSE_ENERGY_CELL)) diff --git a/forge/src/main/java/gripe/_90/megacells/datagen/TagProvider.java b/forge/src/main/java/gripe/_90/megacells/datagen/TagProvider.java index 6d48af69..8a74e6b3 100644 --- a/forge/src/main/java/gripe/_90/megacells/datagen/TagProvider.java +++ b/forge/src/main/java/gripe/_90/megacells/datagen/TagProvider.java @@ -28,8 +28,11 @@ abstract class TagProvider { static class Items extends ItemTagsProvider { - public Items(PackOutput output, CompletableFuture registries, - CompletableFuture> blockTags, @Nullable ExistingFileHelper existing) { + public Items( + PackOutput output, + CompletableFuture registries, + CompletableFuture> blockTags, + @Nullable ExistingFileHelper existing) { super(output, registries, blockTags, Utils.MODID, existing); } @@ -51,14 +54,17 @@ private ResourceKey getKey(ItemDefinition item) { } static class Blocks extends BlockTagsProvider { - public Blocks(PackOutput output, CompletableFuture registries, + public Blocks( + PackOutput output, + CompletableFuture registries, @Nullable ExistingFileHelper existing) { super(output, registries, Utils.MODID, existing); } @Override protected void addTags(@NotNull HolderLookup.Provider provider) { - MEGABlocks.getBlocks().forEach(block -> tag(BlockTags.MINEABLE_WITH_PICKAXE).add(getKey(block))); + MEGABlocks.getBlocks() + .forEach(block -> tag(BlockTags.MINEABLE_WITH_PICKAXE).add(getKey(block))); tag(MEGATags.SKY_STEEL_BLOCK).add(getKey(MEGABlocks.SKY_STEEL_BLOCK)); } diff --git a/forge/src/main/java/gripe/_90/megacells/forge/MEGACells.java b/forge/src/main/java/gripe/_90/megacells/forge/MEGACells.java index 67bcc5b1..5988d8c4 100644 --- a/forge/src/main/java/gripe/_90/megacells/forge/MEGACells.java +++ b/forge/src/main/java/gripe/_90/megacells/forge/MEGACells.java @@ -85,8 +85,7 @@ private void registerAll(RegisterEvent event) { } if (event.getRegistryKey().equals(Registries.MENU)) { - ForgeRegistries.MENU_TYPES.register(AppEng.makeId("mega_pattern_provider"), - MEGAPatternProviderBlock.MENU); + ForgeRegistries.MENU_TYPES.register(AppEng.makeId("mega_pattern_provider"), MEGAPatternProviderBlock.MENU); } } @@ -103,10 +102,10 @@ private void initCells(FMLCommonSetupEvent event) { } private void initCompression() { - MinecraftForge.EVENT_BUS.addListener((ServerStartedEvent event) -> CompressionService.INSTANCE - .loadRecipes(event.getServer().getRecipeManager(), event.getServer().registryAccess())); - MinecraftForge.EVENT_BUS.addListener((AddReloadListenerEvent event) -> CompressionService.INSTANCE - .loadRecipes(event.getServerResources().getRecipeManager(), event.getRegistryAccess())); + MinecraftForge.EVENT_BUS.addListener((ServerStartedEvent event) -> CompressionService.INSTANCE.loadRecipes( + event.getServer().getRecipeManager(), event.getServer().registryAccess())); + MinecraftForge.EVENT_BUS.addListener((AddReloadListenerEvent event) -> CompressionService.INSTANCE.loadRecipes( + event.getServerResources().getRecipeManager(), event.getRegistryAccess())); GridServices.register(DecompressionService.class, DecompressionService.class); PatternDetailsHelper.registerDecoder(DecompressionPatternDecoder.INSTANCE); diff --git a/forge/src/main/java/gripe/_90/megacells/forge/MEGACellsClient.java b/forge/src/main/java/gripe/_90/megacells/forge/MEGACellsClient.java index fb2836a5..0290431e 100644 --- a/forge/src/main/java/gripe/_90/megacells/forge/MEGACellsClient.java +++ b/forge/src/main/java/gripe/_90/megacells/forge/MEGACellsClient.java @@ -45,7 +45,9 @@ public MEGACellsClient() { } private void initScreens(FMLClientSetupEvent ignoredEvent) { - InitScreens.register(MEGAPatternProviderBlock.MENU, PatternProviderScreen::new, + InitScreens.register( + MEGAPatternProviderBlock.MENU, + PatternProviderScreen::new, "/screens/megacells/mega_pattern_provider.json"); } @@ -57,7 +59,8 @@ private void initRenderTypes(FMLClientSetupEvent ignoredEvent) { private void initBuiltInModels() { for (var type : MEGACraftingUnitType.values()) { - BuiltInModelHooks.addBuiltInModel(AppEng.makeId("block/crafting/mega_" + type.getAffix() + "_formed"), + BuiltInModelHooks.addBuiltInModel( + AppEng.makeId("block/crafting/mega_" + type.getAffix() + "_formed"), new CraftingCubeModel(new MEGACraftingUnitModelProvider(type))); } } @@ -65,8 +68,8 @@ private void initBuiltInModels() { private void initModels(ModelEvent.RegisterGeometryLoaders event) { BlockEntityRenderers.register(MEGABlockEntities.MEGA_CRAFTING_MONITOR, CraftingMonitorRenderer::new); - ItemProperties.register(MEGABlocks.MEGA_ENERGY_CELL.asItem(), AppEng.makeId("fill_level"), - (is, level, entity, seed) -> { + ItemProperties.register( + MEGABlocks.MEGA_ENERGY_CELL.asItem(), AppEng.makeId("fill_level"), (is, level, entity, seed) -> { var energyCell = (EnergyCellBlockItem) MEGABlocks.MEGA_ENERGY_CELL.asItem(); double curPower = energyCell.getAECurrentPower(is); diff --git a/forge/src/main/java/gripe/_90/megacells/integration/appmek/AppMekIntegration.java b/forge/src/main/java/gripe/_90/megacells/integration/appmek/AppMekIntegration.java index dcf9004d..06ec879f 100644 --- a/forge/src/main/java/gripe/_90/megacells/integration/appmek/AppMekIntegration.java +++ b/forge/src/main/java/gripe/_90/megacells/integration/appmek/AppMekIntegration.java @@ -34,19 +34,24 @@ public static void initUpgrades() { Upgrades.add(AEItems.VOID_CARD, portable, 1, storageCellGroup); }); - for (var portable : List.of(AMItems.PORTABLE_CHEMICAL_CELL_1K, AMItems.PORTABLE_CHEMICAL_CELL_4K, - AMItems.PORTABLE_CHEMICAL_CELL_16K, AMItems.PORTABLE_CHEMICAL_CELL_64K, + for (var portable : List.of( + AMItems.PORTABLE_CHEMICAL_CELL_1K, + AMItems.PORTABLE_CHEMICAL_CELL_4K, + AMItems.PORTABLE_CHEMICAL_CELL_16K, + AMItems.PORTABLE_CHEMICAL_CELL_64K, AMItems.PORTABLE_CHEMICAL_CELL_256K)) { Upgrades.add(MEGAItems.GREATER_ENERGY_CARD, portable.get(), 2, portableCellGroup); } } public static void initStorageCells() { - Stream.of(AppMekItems.getCells(), AppMekItems.getPortables()).flatMap(Collection::stream) + Stream.of(AppMekItems.getCells(), AppMekItems.getPortables()) + .flatMap(Collection::stream) .forEach(c -> StorageCellModels.registerModel(c, Utils.makeId("block/drive/cells/mega_chemical_cell"))); StorageCells.addCellHandler(MEGARadioactiveCell.HANDLER); - StorageCellModels.registerModel(AppMekItems.RADIOACTIVE_CHEMICAL_CELL.asItem(), + StorageCellModels.registerModel( + AppMekItems.RADIOACTIVE_CHEMICAL_CELL.asItem(), Utils.makeId("block/drive/cells/radioactive_chemical_cell")); } } diff --git a/forge/src/main/java/gripe/_90/megacells/integration/appmek/AppMekItems.java b/forge/src/main/java/gripe/_90/megacells/integration/appmek/AppMekItems.java index 27a5e6f7..5466952f 100644 --- a/forge/src/main/java/gripe/_90/megacells/integration/appmek/AppMekItems.java +++ b/forge/src/main/java/gripe/_90/megacells/integration/appmek/AppMekItems.java @@ -19,45 +19,54 @@ public static void init() { Utils.LOGGER.info("Initialised Applied Mekanistics integration."); } - public static final ItemDefinition MEGA_CHEMICAL_CELL_HOUSING = MEGAItems - .item("MEGA Chemical Cell Housing", "mega_chemical_cell_housing", MaterialItem::new); + public static final ItemDefinition MEGA_CHEMICAL_CELL_HOUSING = + MEGAItems.item("MEGA Chemical Cell Housing", "mega_chemical_cell_housing", MaterialItem::new); - // spotless:off public static final ItemDefinition CHEMICAL_CELL_1M = cell(MEGAItems.TIER_1M); public static final ItemDefinition CHEMICAL_CELL_4M = cell(MEGAItems.TIER_4M); public static final ItemDefinition CHEMICAL_CELL_16M = cell(MEGAItems.TIER_16M); public static final ItemDefinition CHEMICAL_CELL_64M = cell(MEGAItems.TIER_64M); public static final ItemDefinition CHEMICAL_CELL_256M = cell(MEGAItems.TIER_256M); - public static final ItemDefinition PORTABLE_CHEMICAL_CELL_1M = portable(MEGAItems.TIER_1M); - public static final ItemDefinition PORTABLE_CHEMICAL_CELL_4M = portable(MEGAItems.TIER_4M); - public static final ItemDefinition PORTABLE_CHEMICAL_CELL_16M = portable(MEGAItems.TIER_16M); - public static final ItemDefinition PORTABLE_CHEMICAL_CELL_64M = portable(MEGAItems.TIER_64M); - public static final ItemDefinition PORTABLE_CHEMICAL_CELL_256M = portable(MEGAItems.TIER_256M); - //spotless:on + public static final ItemDefinition PORTABLE_CHEMICAL_CELL_1M = + portable(MEGAItems.TIER_1M); + public static final ItemDefinition PORTABLE_CHEMICAL_CELL_4M = + portable(MEGAItems.TIER_4M); + public static final ItemDefinition PORTABLE_CHEMICAL_CELL_16M = + portable(MEGAItems.TIER_16M); + public static final ItemDefinition PORTABLE_CHEMICAL_CELL_64M = + portable(MEGAItems.TIER_64M); + public static final ItemDefinition PORTABLE_CHEMICAL_CELL_256M = + portable(MEGAItems.TIER_256M); - public static final ItemDefinition RADIOACTIVE_CELL_COMPONENT = MEGAItems - .item("MEGA Radioactive Storage Component", "radioactive_cell_component", MaterialItem::new); - public static final ItemDefinition RADIOACTIVE_CHEMICAL_CELL = MEGAItems - .item("MEGA Radioactive Chemical Storage Cell", "radioactive_chemical_cell", MEGARadioactiveCell::new); + public static final ItemDefinition RADIOACTIVE_CELL_COMPONENT = + MEGAItems.item("MEGA Radioactive Storage Component", "radioactive_cell_component", MaterialItem::new); + public static final ItemDefinition RADIOACTIVE_CHEMICAL_CELL = MEGAItems.item( + "MEGA Radioactive Chemical Storage Cell", "radioactive_chemical_cell", MEGARadioactiveCell::new); public static List> getCells() { return List.of(CHEMICAL_CELL_1M, CHEMICAL_CELL_4M, CHEMICAL_CELL_16M, CHEMICAL_CELL_64M, CHEMICAL_CELL_256M); } public static List> getPortables() { - return List.of(PORTABLE_CHEMICAL_CELL_1M, PORTABLE_CHEMICAL_CELL_4M, PORTABLE_CHEMICAL_CELL_16M, - PORTABLE_CHEMICAL_CELL_64M, PORTABLE_CHEMICAL_CELL_256M); + return List.of( + PORTABLE_CHEMICAL_CELL_1M, + PORTABLE_CHEMICAL_CELL_4M, + PORTABLE_CHEMICAL_CELL_16M, + PORTABLE_CHEMICAL_CELL_64M, + PORTABLE_CHEMICAL_CELL_256M); } private static ItemDefinition cell(StorageTier tier) { - return MEGAItems.item(tier.namePrefix().toUpperCase() + " MEGA Chemical Storage Cell", + return MEGAItems.item( + tier.namePrefix().toUpperCase() + " MEGA Chemical Storage Cell", "chemical_storage_cell_" + tier.namePrefix(), p -> new ChemicalStorageCell(p, tier, MEGA_CHEMICAL_CELL_HOUSING)); } private static ItemDefinition portable(StorageTier tier) { - return MEGAItems.item(tier.namePrefix().toUpperCase() + " Portable Chemical Cell", + return MEGAItems.item( + tier.namePrefix().toUpperCase() + " Portable Chemical Cell", "portable_chemical_cell_" + tier.namePrefix(), p -> new MEGAPortableChemicalCell(p, tier, 0x33528D)); } diff --git a/forge/src/main/java/gripe/_90/megacells/integration/appmek/item/MEGARadioactiveCell.java b/forge/src/main/java/gripe/_90/megacells/integration/appmek/item/MEGARadioactiveCell.java index 333562b3..99d94e32 100644 --- a/forge/src/main/java/gripe/_90/megacells/integration/appmek/item/MEGARadioactiveCell.java +++ b/forge/src/main/java/gripe/_90/megacells/integration/appmek/item/MEGARadioactiveCell.java @@ -42,12 +42,11 @@ public FuzzyMode getFuzzyMode(ItemStack itemStack) { } @Override - public void setFuzzyMode(ItemStack itemStack, FuzzyMode fuzzyMode) { - } + public void setFuzzyMode(ItemStack itemStack, FuzzyMode fuzzyMode) {} @Override - public void appendHoverText(@NotNull ItemStack is, Level level, @NotNull List lines, - @NotNull TooltipFlag adv) { + public void appendHoverText( + @NotNull ItemStack is, Level level, @NotNull List lines, @NotNull TooltipFlag adv) { var inv = HANDLER.getCellInventory(is, null); if (inv != null) { @@ -55,8 +54,10 @@ public void appendHoverText(@NotNull ItemStack is, Level level, @NotNull List