Skip to content

Commit

Permalink
Add AppliedE integration
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed May 5, 2024
1 parent eb5d82d commit 2340371
Show file tree
Hide file tree
Showing 24 changed files with 473 additions and 9 deletions.
1 change: 1 addition & 0 deletions common/src/main/java/gripe/_90/megacells/core/Addons.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public enum Addons {
APPMEK("appmek"),
APPBOT("appbot"),
ARSENG("arseng"),
APPLIEDE("appliede"),
AE2WTLIB("ae2wtlib");

private final String modId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static Map<ResourceLocation, BlockEntityType<?>> getBlockEntityTypes() {
MEGABlocks.MEGA_PATTERN_PROVIDER);

@SafeVarargs
private static <T extends AEBaseBlockEntity> BlockEntityType<T> create(
public static <T extends AEBaseBlockEntity> BlockEntityType<T> create(
String id,
Class<T> entityClass,
BlockEntityFactory<T> factory,
Expand Down Expand Up @@ -96,7 +96,7 @@ private static <T extends AEBaseBlockEntity> BlockEntityType<T> create(
return type;
}

private interface BlockEntityFactory<T extends AEBaseBlockEntity> {
public interface BlockEntityFactory<T extends AEBaseBlockEntity> {
T create(BlockEntityType<T> type, BlockPos pos, BlockState state);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private static <T extends Block> BlockDefinition<T> craftingBlock(
(block, props) -> new MEGACraftingBlockItem(block, props, disassemblyExtra));
}

private static <T extends Block> BlockDefinition<T> block(
public static <T extends Block> BlockDefinition<T> block(
String englishName,
String id,
Supplier<T> blockSupplier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ private static ItemDefinition<MEGAPortableCell> fluidPortable(StorageTier tier)
p -> new MEGAPortableCell(p, tier, AEKeyType.fluids(), MEStorageMenu.PORTABLE_FLUID_CELL_TYPE, 0xF1C5));
}

private static <T extends IPart> ItemDefinition<PartItem<T>> part(
public static <T extends IPart> ItemDefinition<PartItem<T>> part(
String englishName, String id, Class<T> partClass, Function<IPartItem<T>, T> factory) {
PartModels.registerModels(PartModelsHelper.createModels(partClass));
return item(englishName, id, p -> new PartItem<>(p, partClass, factory));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static Map<ResourceLocation, MenuType<?>> getMenuTypes() {
create("mega_pattern_provider", MEGAPatternProviderMenu::new, PatternProviderLogicHost.class);
public static final MenuType<CellDockMenu> CELL_DOCK = create("cell_dock", CellDockMenu::new, CellDockPart.class);

private static <C extends AEBaseMenu, I> MenuType<C> create(
public static <C extends AEBaseMenu, I> MenuType<C> create(
String id, MenuTypeBuilder.MenuFactory<C, I> factory, Class<I> host) {
var menu = MenuTypeBuilder.create(factory, host).build(id);
MENU_TYPES.put(AppEng.makeId(id), menu);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void openMenu(Player player, MenuLocator locator) {

@Override
public void returnToMainMenu(Player player, ISubMenu subMenu) {
MenuOpener.open(MEGAMenus.MEGA_INTERFACE, player, subMenu.getLocator());
MenuOpener.returnTo(MEGAMenus.MEGA_INTERFACE, player, subMenu.getLocator());
}

@Override
Expand Down
11 changes: 11 additions & 0 deletions forge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ repositories {
name = "GeckoLib"
url = uri("https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/")
}

maven {
name = "Curse Maven"
url = uri("https://cursemaven.com")
content {
includeGroup("curse.maven")
}
}
}

dependencies {
Expand All @@ -93,6 +101,9 @@ dependencies {
modRuntimeOnly(libs.geckolib)
runtimeOnly(libs.mixinextras)

modImplementation(libs.appliede)
modImplementation(libs.projecte)

modImplementation(libs.ae2wtlib.forge)
modRuntimeOnly(libs.architectury.forge)
modRuntimeOnly(libs.curios)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@
import mekanism.common.registries.MekanismItems;
import mekanism.generators.common.registries.GeneratorsBlocks;

import gripe._90.appliede.AppliedE;
import gripe._90.megacells.MEGACells;
import gripe._90.megacells.core.Addons;
import gripe._90.megacells.definition.MEGAItems;
import gripe._90.megacells.integration.appliede.AppliedEIntegration;
import gripe._90.megacells.integration.appmek.AppMekItems;
import gripe._90.megacells.integration.arseng.ArsEngItems;

import moze_intel.projecte.gameObjs.registries.PEItems;

public class ForgeRecipeProvider extends RecipeProvider {
private static final TagKey<Item> OSMIUM = ItemTags.create(new ResourceLocation("forge", "ingots/osmium"));

Expand Down Expand Up @@ -108,6 +112,33 @@ protected void buildRecipes(@NotNull Consumer<FinishedRecipe> writer) {
sourcePortable(writer, ArsEngItems.PORTABLE_SOURCE_CELL_64M, MEGAItems.CELL_COMPONENT_64M);
sourcePortable(writer, ArsEngItems.PORTABLE_SOURCE_CELL_256M, MEGAItems.CELL_COMPONENT_256M);
}

if (MEGACells.PLATFORM.isAddonLoaded(Addons.APPLIEDE)) {
MEGACells.PLATFORM.addIntegrationRecipe(
writer,
ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, AppliedEIntegration.EMC_INTERFACE)
.requires(AppliedE.EMC_INTERFACE.get())
.requires(MEGAItems.ACCUMULATION_PROCESSOR)
.requires(PEItems.RED_MATTER.asItem())
.unlockedBy("has_emc_interface", has(AppliedE.EMC_INTERFACE.get()))
.unlockedBy("has_accumulation_processor", has(MEGAItems.ACCUMULATION_PROCESSOR)),
Addons.APPLIEDE,
MEGACells.makeId("network/mega_emc_interface"));
MEGACells.PLATFORM.addIntegrationRecipe(
writer,
ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, AppliedEIntegration.CABLE_EMC_INTERFACE)
.requires(AppliedEIntegration.EMC_INTERFACE)
.unlockedBy("has_mega_emc_interface", has(AppliedEIntegration.EMC_INTERFACE)),
Addons.APPLIEDE,
MEGACells.makeId("network/mega_emc_interface_part"));
MEGACells.PLATFORM.addIntegrationRecipe(
writer,
ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, AppliedEIntegration.EMC_INTERFACE)
.requires(AppliedEIntegration.CABLE_EMC_INTERFACE)
.unlockedBy("has_mega_emc_interface", has(AppliedEIntegration.EMC_INTERFACE)),
Addons.APPLIEDE,
MEGACells.makeId("network/mega_emc_interface_block"));
}
}

private void chemCell(Consumer<FinishedRecipe> writer, ItemDefinition<?> cell, ItemDefinition<?> component) {
Expand Down
18 changes: 17 additions & 1 deletion forge/src/main/java/gripe/_90/megacells/forge/ForgePlatform.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@
import appeng.core.definitions.AEBlocks;
import appeng.hooks.BuiltInModelHooks;
import appeng.init.InitVillager;
import appeng.init.client.InitScreens;

import me.shedaniel.autoconfig.AutoConfig;

import gripe._90.appliede.client.screen.EMCInterfaceScreen;
import gripe._90.megacells.MEGACells;
import gripe._90.megacells.block.MEGACraftingUnitType;
import gripe._90.megacells.client.render.MEGACraftingUnitModelProvider;
Expand All @@ -74,6 +76,8 @@
import gripe._90.megacells.definition.MEGACreativeTab;
import gripe._90.megacells.definition.MEGAItems;
import gripe._90.megacells.definition.MEGAMenus;
import gripe._90.megacells.integration.appliede.AppliedEIntegration;
import gripe._90.megacells.integration.appliede.MEGAEMCInterfaceMenu;
import gripe._90.megacells.integration.appmek.AppMekIntegration;
import gripe._90.megacells.integration.appmek.AppMekItems;
import gripe._90.megacells.integration.arseng.ArsEngIntegration;
Expand Down Expand Up @@ -117,6 +121,10 @@ public void initItems() {
if (isAddonLoaded(Addons.ARSENG)) {
ArsEngItems.init();
}

if (isAddonLoaded(Addons.APPLIEDE)) {
AppliedEIntegration.init();
}
}

@Override
Expand Down Expand Up @@ -249,7 +257,15 @@ public void addIntegrationRecipe(
public static class Client implements Platform.Client {
@Override
public void initScreens() {
modEventBus.addListener((FMLClientSetupEvent event) -> screens());
modEventBus.addListener((FMLClientSetupEvent event) -> {
event.enqueueWork(this::screens);
if (MEGACells.PLATFORM.isAddonLoaded(Addons.APPLIEDE)) {
event.enqueueWork(() -> InitScreens.register(
AppliedEIntegration.EMC_INTERFACE_MENU,
EMCInterfaceScreen<MEGAEMCInterfaceMenu>::new,
"/screens/megacells/mega_emc_interface.json"));
}
});

ModLoadingContext.get()
.registerExtensionPoint(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package gripe._90.megacells.integration.appliede;

import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.BlockItem;

import appeng.core.definitions.BlockDefinition;
import appeng.core.definitions.ItemDefinition;
import appeng.items.parts.PartItem;

import gripe._90.appliede.me.misc.EMCInterfaceLogicHost;
import gripe._90.megacells.MEGACells;
import gripe._90.megacells.definition.MEGABlockEntities;
import gripe._90.megacells.definition.MEGABlocks;
import gripe._90.megacells.definition.MEGAItems;
import gripe._90.megacells.definition.MEGAMenus;

public final class AppliedEIntegration {
public static final BlockDefinition<MEGAEMCInterfaceBlock> EMC_INTERFACE = MEGABlocks.block(
"MEGA Transmutation Interface", "mega_emc_interface", MEGAEMCInterfaceBlock::new, BlockItem::new);
public static final ItemDefinition<PartItem<MEGAEMCInterfacePart>> CABLE_EMC_INTERFACE = MEGAItems.part(
"MEGA Transmutation Interface",
"cable_mega_emc_interface",
MEGAEMCInterfacePart.class,
MEGAEMCInterfacePart::new);
public static final MenuType<MEGAEMCInterfaceMenu> EMC_INTERFACE_MENU =
MEGAMenus.create("mega_emc_interface", MEGAEMCInterfaceMenu::new, EMCInterfaceLogicHost.class);

static {
MEGABlockEntities.create(
"mega_emc_interface",
MEGAEMCInterfaceBlockEntity.class,
MEGAEMCInterfaceBlockEntity::new,
EMC_INTERFACE);
}

public static void init() {
MEGACells.LOGGER.info("Initialised AppliedE integration.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package gripe._90.megacells.integration.appliede;

import org.jetbrains.annotations.Nullable;

import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.BlockHitResult;

import appeng.block.AEBaseEntityBlock;
import appeng.menu.locator.MenuLocators;
import appeng.util.InteractionUtil;

public class MEGAEMCInterfaceBlock extends AEBaseEntityBlock<MEGAEMCInterfaceBlockEntity> {
public MEGAEMCInterfaceBlock() {
super(metalProps());
}

@Override
public InteractionResult onActivated(
Level level,
BlockPos pos,
Player player,
InteractionHand hand,
@Nullable ItemStack heldItem,
BlockHitResult hit) {
if (!InteractionUtil.isInAlternateUseMode(player)) {
var be = getBlockEntity(level, pos);

if (be != null) {
if (!level.isClientSide()) {
be.openMenu(player, MenuLocators.forBlockEntity(be));
}

return InteractionResult.sidedSuccess(level.isClientSide());
}
}

return InteractionResult.PASS;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package gripe._90.megacells.integration.appliede;

import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;

import appeng.menu.ISubMenu;
import appeng.menu.MenuOpener;
import appeng.menu.locator.MenuLocator;

import gripe._90.appliede.block.EMCInterfaceBlockEntity;
import gripe._90.appliede.me.misc.EMCInterfaceLogic;

public class MEGAEMCInterfaceBlockEntity extends EMCInterfaceBlockEntity {
public MEGAEMCInterfaceBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
}

@Override
protected EMCInterfaceLogic createLogic() {
return new EMCInterfaceLogic(getMainNode(), this, 18);
}

@Override
public void openMenu(Player player, MenuLocator locator) {
MenuOpener.open(AppliedEIntegration.EMC_INTERFACE_MENU, player, locator);
}

@Override
public void returnToMainMenu(Player player, ISubMenu subMenu) {
MenuOpener.returnTo(AppliedEIntegration.EMC_INTERFACE_MENU, player, subMenu.getLocator());
}

@Override
public ItemStack getMainMenuIcon() {
return AppliedEIntegration.EMC_INTERFACE.stack();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package gripe._90.megacells.integration.appliede;

import net.minecraft.world.entity.player.Inventory;

import gripe._90.appliede.me.misc.EMCInterfaceLogicHost;
import gripe._90.appliede.menu.EMCInterfaceMenu;

public class MEGAEMCInterfaceMenu extends EMCInterfaceMenu {
public MEGAEMCInterfaceMenu(int id, Inventory playerInventory, EMCInterfaceLogicHost host) {
super(AppliedEIntegration.EMC_INTERFACE_MENU, id, playerInventory, host);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package gripe._90.megacells.integration.appliede;

import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;

import appeng.api.parts.IPartItem;
import appeng.api.parts.IPartModel;
import appeng.core.AppEng;
import appeng.items.parts.PartModels;
import appeng.menu.ISubMenu;
import appeng.menu.MenuOpener;
import appeng.menu.locator.MenuLocator;
import appeng.parts.PartModel;

import gripe._90.appliede.me.misc.EMCInterfaceLogic;
import gripe._90.appliede.part.EMCInterfacePart;
import gripe._90.megacells.MEGACells;

public class MEGAEMCInterfacePart extends EMCInterfacePart {
private static final ResourceLocation MODEL_BASE = MEGACells.makeId("part/mega_emc_interface");

@PartModels
public static final PartModel MODELS_OFF = new PartModel(MODEL_BASE, AppEng.makeId("part/interface_off"));

@PartModels
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 MEGAEMCInterfacePart(IPartItem<?> partItem) {
super(partItem);
}

@Override
protected EMCInterfaceLogic createLogic() {
return new EMCInterfaceLogic(getMainNode(), this, 18);
}

@Override
public void openMenu(Player player, MenuLocator locator) {
MenuOpener.open(AppliedEIntegration.EMC_INTERFACE_MENU, player, locator);
}

@Override
public void returnToMainMenu(Player player, ISubMenu subMenu) {
MenuOpener.returnTo(AppliedEIntegration.EMC_INTERFACE_MENU, player, subMenu.getLocator());
}

@Override
public IPartModel getStaticModels() {
if (isActive() && isPowered()) {
return MODELS_HAS_CHANNEL;
} else if (isPowered()) {
return MODELS_ON;
} else {
return MODELS_OFF;
}
}

@Override
public ItemStack getMainMenuIcon() {
return AppliedEIntegration.CABLE_EMC_INTERFACE.stack();
}
}
Loading

0 comments on commit 2340371

Please sign in to comment.