Skip to content

Commit

Permalink
waste time
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed Jan 9, 2023
1 parent 1ca9c9e commit ed23256
Show file tree
Hide file tree
Showing 37 changed files with 47 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import gripe._90.megacells.util.Utils;

public class MEGACraftingUnitModelProvider extends AbstractCraftingUnitModelProvider<MEGACraftingUnitType> {

private static final List<Material> MATERIALS = new ArrayList<>();

protected static final Material RING_CORNER = texture("ring_corner");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
import gripe._90.megacells.integration.appbot.AppBotItems;

public class CommonModelSupplier {
private CommonModelSupplier() {
}

public static final List<ItemDefinition<?>> FLAT_ITEMS = Lists.newArrayList(MEGAItems.MEGA_ITEM_CELL_HOUSING,
MEGAItems.MEGA_FLUID_CELL_HOUSING, MEGAItems.CELL_COMPONENT_1M, MEGAItems.CELL_COMPONENT_4M,
MEGAItems.CELL_COMPONENT_16M, MEGAItems.CELL_COMPONENT_64M, MEGAItems.CELL_COMPONENT_256M,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
import gripe._90.megacells.util.Utils;

public class CommonRecipeSupplier {
private CommonRecipeSupplier() {
}

public static void buildRecipes(Consumer<FinishedRecipe> consumer) {
// spotless:off
component(consumer, MEGAItems.TIER_1M, StorageTier.SIZE_256K, AEItems.SKY_DUST.asItem());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@

import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;

import appeng.block.AEBaseEntityBlock;
import appeng.blockentity.AEBaseBlockEntity;
import appeng.blockentity.ClientTickingBlockEntity;
import appeng.blockentity.ServerTickingBlockEntity;
import appeng.blockentity.crafting.CraftingBlockEntity;
import appeng.blockentity.crafting.CraftingMonitorBlockEntity;
import appeng.blockentity.networking.EnergyCellBlockEntity;
Expand All @@ -27,9 +24,6 @@

@SuppressWarnings({ "unused", "unchecked" })
public final class MEGABlockEntities {
private MEGABlockEntities() {
}

public static void init() {
// controls static load order
Utils.LOGGER.info("Initialised block entities.");
Expand Down Expand Up @@ -68,20 +62,9 @@ private static <T extends AEBaseBlockEntity> BlockEntityType<T> create(String id

AEBaseBlockEntity.registerBlockEntityItem(type, blockDefinitions[0].asItem());

// If the block entity classes implement specific interfaces, automatically register them
// as tickers with the blocks that create that entity.
BlockEntityTicker<T> serverTicker = null;
if (ServerTickingBlockEntity.class.isAssignableFrom(entityClass)) {
serverTicker = (level, pos, state, entity) -> ((ServerTickingBlockEntity) entity).serverTick();
}
BlockEntityTicker<T> clientTicker = null;
if (ClientTickingBlockEntity.class.isAssignableFrom(entityClass)) {
clientTicker = (level, pos, state, entity) -> ((ClientTickingBlockEntity) entity).clientTick();
}

for (var block : blocks) {
AEBaseEntityBlock<T> baseBlock = (AEBaseEntityBlock<T>) block;
baseBlock.setBlockEntity(entityClass, type, clientTicker, serverTicker);
baseBlock.setBlockEntity(entityClass, type, null, null);
}

return type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
import gripe._90.megacells.util.Utils;

public final class MEGABlocks {
private MEGABlocks() {
}

public static void init() {
// controls static load order
Utils.LOGGER.info("Initialised blocks.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
import gripe._90.megacells.util.Utils;

public final class MEGAItems {
private MEGAItems() {
}

public static void init() {
// controls static load order
Utils.LOGGER.info("Initialised items.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import gripe._90.megacells.util.Utils;

public class InitStorageCells {

public static void init() {
Stream.of(MEGAItems.getItemCells(), MEGAItems.getItemPortables()).flatMap(Collection::stream)
.forEach(c -> StorageCellModels.registerModel(c, Utils.makeId("block/drive/cells/mega_item_cell")));
Expand Down
10 changes: 8 additions & 2 deletions common/src/main/java/gripe/_90/megacells/init/InitUpgrades.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import gripe._90.megacells.definition.MEGAItems;
import gripe._90.megacells.integration.ae2wt.AE2WTIntegration;
import gripe._90.megacells.integration.appbot.AppBotIntegration;
import gripe._90.megacells.util.Utils;

public class InitUpgrades {
public static void init() {
Expand Down Expand Up @@ -59,7 +60,12 @@ public static void init() {
Upgrades.add(MEGAItems.GREATER_ENERGY_CARD, portableCell, 2, portableCellGroup);
}

AE2WTIntegration.initUpgrades();
AppBotIntegration.initUpgrades();
if (Utils.PLATFORM.isModLoaded("ae2wtlib")) {
AE2WTIntegration.initUpgrades();
}

if (Utils.PLATFORM.isModLoaded("appbot")) {
AppBotIntegration.initUpgrades();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,8 @@
import gripe._90.megacells.util.Utils;

public final class AE2WTIntegration {
private AE2WTIntegration() {
}

public static void initUpgrades() {
if (Utils.PLATFORM.isModLoaded("ae2wtlib")) {
UpgradeHelper.addUpgradeToAllTerminals(GREATER_ENERGY_CARD, 0);
}

UpgradeHelper.addUpgradeToAllTerminals(GREATER_ENERGY_CARD, 0);
Utils.LOGGER.info("Initialised AE2WT integration.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,15 @@
import appeng.api.upgrades.Upgrades;
import appeng.core.localization.GuiText;

import gripe._90.megacells.util.Utils;

public final class AppBotIntegration {
private AppBotIntegration() {
}

public static void initUpgrades() {
if (Utils.PLATFORM.isModLoaded("appbot")) {
AppBotItems.getPortables()
.forEach(c -> Upgrades.add(GREATER_ENERGY_CARD, c, 2, GuiText.PortableCells.getTranslationKey()));
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,
ABItems.PORTABLE_MANA_CELL_256K)) {
Upgrades.add(GREATER_ENERGY_CARD, portable, 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,
ABItems.PORTABLE_MANA_CELL_256K)) {
Upgrades.add(GREATER_ENERGY_CARD, portable, 2, GuiText.PortableCells.getTranslationKey());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
import gripe._90.megacells.util.Utils;

public final class AppBotItems {
private AppBotItems() {
}

public static void init() {
// controls static load order
Utils.LOGGER.info("Initialised Applied Botanics integration.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import gripe._90.megacells.util.Utils;

public class MEGAPortableCell extends PortableCellItem {

private final StorageTier tier;

public MEGAPortableCell(Properties props, StorageTier tier, AEKeyType keyType, MenuType<MEStorageMenu> menu) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import gripe._90.megacells.item.MEGABulkCell;

public class BulkCellHandler implements ICellHandler {

public static final BulkCellHandler INSTANCE = new BulkCellHandler();

private BulkCellHandler() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
import gripe._90.megacells.util.Utils;

public class CompressionHandler {
private CompressionHandler() {
}

public static final CompressionHandler INSTANCE = new CompressionHandler();

private final List<CraftingRecipe> validRecipes = new ObjectArrayList<>();

private CompressionHandler() {
}

private boolean isCompressionRecipe(CraftingRecipe recipe) {
return (recipe.getIngredients().size() == 4 || recipe.getIngredients().size() == 9)
&& recipe.getIngredients().stream().distinct().limit(2).count() == 1
Expand Down
4 changes: 2 additions & 2 deletions common/src/main/java/gripe/_90/megacells/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import net.minecraft.resources.ResourceLocation;

import gripe._90.megacells.util.service.IPlatformHelper;
import gripe._90.megacells.util.service.Platform;

public final class Utils {
private Utils() {
Expand All @@ -17,7 +17,7 @@ private Utils() {

public static final Logger LOGGER = LoggerFactory.getLogger("MEGA Cells");

public static final IPlatformHelper PLATFORM = ServiceLoader.load(IPlatformHelper.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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import net.minecraft.world.item.CreativeModeTab;

public interface IPlatformHelper {
public interface Platform {
CreativeModeTab getCreativeTab();

boolean isModLoaded(String modId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.fabricmc.fabric.api.event.lifecycle.v1.CommonLifecycleEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.minecraft.core.Registry;
Expand Down Expand Up @@ -63,12 +62,11 @@ public void onAe2Initialized() {
InitAutoRotatingModel.init();
InitBlockEntityRenderers.init();
InitBuiltInModels.init();
InitItemColors.init();
InitRenderTypes.init();

// re-init AE2 props for MEGA energy cell
InitItemModelsProperties.init();

InitItemColors.init(ColorProviderRegistry.ITEM::register);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import gripe._90.megacells.definition.MEGAItems;
import gripe._90.megacells.definition.MEGATranslations;

public class LocalisationProvider extends FabricLanguageProvider {
protected LocalisationProvider(FabricDataGenerator gen, String locale) {
class LocalisationProvider extends FabricLanguageProvider {
LocalisationProvider(FabricDataGenerator gen, String locale) {
super(gen, locale);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import gripe._90.megacells.definition.MEGABlocks;
import gripe._90.megacells.util.Utils;

public class LootTableProvider extends SimpleFabricLootTableProvider {
public LootTableProvider(FabricDataGenerator dataGenerator) {
class LootTableProvider extends SimpleFabricLootTableProvider {
LootTableProvider(FabricDataGenerator dataGenerator) {
super(dataGenerator, LootContextParamSets.BLOCK);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;

public class MEGADataGenerators implements DataGeneratorEntrypoint {

@Override
public void onInitializeDataGenerator(FabricDataGenerator generator) {
var blockTags = new TagProvider.Blocks(generator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
import gripe._90.megacells.definition.MEGABlocks;
import gripe._90.megacells.util.Utils;

public class ModelProvider extends FabricModelProvider {

class ModelProvider extends FabricModelProvider {
static final TextureSlot LAYER1 = TextureSlot.create("layer1");
static final TextureSlot CELL_TEXTURE = TextureSlot.create("cell");

Expand All @@ -49,7 +48,7 @@ public class ModelProvider extends FabricModelProvider {
static final ResourceLocation STORAGE_CELL_LED = AppEng.makeId("item/storage_cell_led");
static final ResourceLocation PORTABLE_CELL_LED = AppEng.makeId("item/portable_cell_led");

public ModelProvider(FabricDataGenerator gen) {
ModelProvider(FabricDataGenerator gen) {
super(gen);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
import net.minecraft.data.recipes.FinishedRecipe;

public class RecipeProvider extends FabricRecipeProvider {

public RecipeProvider(FabricDataGenerator gen) {
class RecipeProvider extends FabricRecipeProvider {
RecipeProvider(FabricDataGenerator gen) {
super(gen);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

import gripe._90.megacells.definition.MEGABlocks;

public class TagProvider {
class TagProvider {
static class Items extends FabricTagProvider.ItemTagProvider {
public Items(FabricDataGenerator gen, @Nullable BlockTagProvider block) {
Items(FabricDataGenerator gen, @Nullable BlockTagProvider block) {
super(gen, block);
}

Expand All @@ -21,7 +21,7 @@ protected void generateTags() {
}

static class Blocks extends FabricTagProvider.BlockTagProvider {
public Blocks(FabricDataGenerator gen) {
Blocks(FabricDataGenerator gen) {
super(gen);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.color.item.ItemColor;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.minecraft.world.level.ItemLike;

import appeng.core.definitions.ItemDefinition;
Expand All @@ -18,7 +18,7 @@

@Environment(EnvType.CLIENT)
public class InitItemColors {
public static void init(Registry itemColors) {
public static void init() {
var cells = new ArrayList<ItemDefinition<?>>(List.of(
MEGAItems.ITEM_CELL_1M, MEGAItems.ITEM_CELL_4M, MEGAItems.ITEM_CELL_16M, MEGAItems.ITEM_CELL_64M,
MEGAItems.ITEM_CELL_256M, MEGAItems.FLUID_CELL_1M, MEGAItems.FLUID_CELL_4M, MEGAItems.FLUID_CELL_16M,
Expand All @@ -34,12 +34,7 @@ public static void init(Registry itemColors) {
portables.addAll(AppBotItems.getPortables());
}

itemColors.register(BasicStorageCell::getColor, cells.toArray(new ItemLike[0]));
itemColors.register(PortableCellItem::getColor, portables.toArray(new ItemLike[0]));
}

@FunctionalInterface
public interface Registry {
void register(ItemColor itemColor, ItemLike... itemLikes);
ColorProviderRegistry.ITEM.register(BasicStorageCell::getColor, cells.toArray(new ItemLike[0]));
ColorProviderRegistry.ITEM.register(PortableCellItem::getColor, portables.toArray(new ItemLike[0]));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import net.minecraft.world.item.ItemStack;

import gripe._90.megacells.definition.MEGAItems;
import gripe._90.megacells.util.service.IPlatformHelper;
import gripe._90.megacells.util.service.Platform;

public final class FabricPlatformHelper implements IPlatformHelper {
public final class FabricPlatform implements Platform {
@Override
public CreativeModeTab getCreativeTab() {
return FabricItemGroupBuilder.build(Utils.makeId("tab"),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gripe._90.megacells.util.FabricPlatform
Loading

0 comments on commit ed23256

Please sign in to comment.