Skip to content

Commit 16eb6d5

Browse files
kj
1 parent 0ec1913 commit 16eb6d5

10 files changed

Lines changed: 220 additions & 43 deletions

File tree

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ dependencies {
146146
compileOnly("mezz.jei:jei-${minecraft_version}-neoforge-api:${jei_version}")
147147
runtimeOnly("mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}")
148148
compileOnly "org.appliedenergistics:appliedenergistics2:19.2.2-beta:api"
149+
implementation "org.appliedenergistics:appliedenergistics2:19.2.2-beta"
149150
}
150151

151152
// This block of code expands all declared replace properties in the specified resource targets.

gradle.properties

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ minecraft_version=1.21.1
1919
# as they do not follow standard versioning conventions.
2020
minecraft_version_range=[1.21.1, 1.22)
2121
# The Neo version must agree with the Minecraft version to get a valid artifact
22-
neo_version=21.1.77
22+
neo_version=21.1.113
2323
# The Neo version range can use any version of Neo as bounds
2424
neo_version_range=[21.1.0,)
2525
# The loader version range can only use the major version of FML as bounds
@@ -29,18 +29,18 @@ loader_version_range=[4,)
2929

3030
# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
3131
# Must match the String constant located in the main mod class annotated with @Mod.
32-
mod_id=examplemod
32+
mod_id=infinitypattern
3333
# The human-readable display name for the mod.
34-
mod_name=Example Mod
34+
mod_name=Infinity Pattern
3535
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
3636
mod_license=All Rights Reserved
3737
# The mod version. See https://semver.org/
3838
mod_version=1.0.0
3939
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
4040
# This should match the base package used for the mod sources.
4141
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
42-
mod_group_id=com.example.examplemod
42+
mod_group_id=com.neofastftl.infinitypattern
4343
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
44-
mod_authors=YourNameHere, OtherNameHere
44+
mod_authors=NeofastFTL
4545
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
4646
mod_description=Example mod description.\nNewline characters can be used and will be replaced properly.

src/main/java/com/example/examplemod/Config.java renamed to src/main/java/com/neofastftl/infinitypattern/Config.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.example.examplemod;
1+
package com.neofastftl.infinitypattern;
22

33
import java.util.List;
44
import java.util.Set;
@@ -14,7 +14,7 @@
1414

1515
// An example config class. This is not required, but it's a good idea to have one to keep your config organized.
1616
// Demonstrates how to use Neo's config APIs
17-
@EventBusSubscriber(modid = ExampleMod.MODID, bus = EventBusSubscriber.Bus.MOD)
17+
@EventBusSubscriber(modid = InfinityPattern.MODID, bus = EventBusSubscriber.Bus.MOD)
1818
public class Config
1919
{
2020
private static final ModConfigSpec.Builder BUILDER = new ModConfigSpec.Builder();

src/main/java/com/example/examplemod/ExampleMod.java renamed to src/main/java/com/neofastftl/infinitypattern/InfinityPattern.java

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
package com.example.examplemod;
1+
package com.neofastftl.infinitypattern;
22

3+
import appeng.api.ids.AEItemIds;
4+
import appeng.core.AppEng;
5+
import appeng.core.definitions.ItemDefinition;
6+
import appeng.items.materials.MaterialItem;
7+
import com.neofastftl.infinitypattern.item.ItemInfinityPattern;
38
import org.slf4j.Logger;
49

510
import com.mojang.logging.LogUtils;
@@ -34,48 +39,45 @@
3439
import net.neoforged.neoforge.registries.DeferredItem;
3540
import net.neoforged.neoforge.registries.DeferredRegister;
3641

42+
import java.util.ArrayList;
43+
import java.util.List;
44+
45+
import static net.minecraft.world.item.Items.registerItem;
46+
3747
// The value here should match an entry in the META-INF/neoforge.mods.toml file
38-
@Mod(ExampleMod.MODID)
39-
public class ExampleMod
48+
@Mod(InfinityPattern.MODID)
49+
public class InfinityPattern
4050
{
4151
// Define mod id in a common place for everything to reference
42-
public static final String MODID = "examplemod";
52+
public static final String MODID = "infinitypattern";
4353
// Directly reference a slf4j logger
4454
private static final Logger LOGGER = LogUtils.getLogger();
4555
// Create a Deferred Register to hold Blocks which will all be registered under the "examplemod" namespace
46-
public static final DeferredRegister.Blocks BLOCKS = DeferredRegister.createBlocks(MODID);
47-
// Create a Deferred Register to hold Items which will all be registered under the "examplemod" namespace
48-
public static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(MODID);
56+
public static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(InfinityPattern.MODID);
4957
// Create a Deferred Register to hold CreativeModeTabs which will all be registered under the "examplemod" namespace
5058
public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MODID);
5159

52-
// Creates a new Block with the id "examplemod:example_block", combining the namespace and path
53-
public static final DeferredBlock<Block> EXAMPLE_BLOCK = BLOCKS.registerSimpleBlock("example_block", BlockBehaviour.Properties.of().mapColor(MapColor.STONE));
54-
// Creates a new BlockItem with the id "examplemod:example_block", combining the namespace and path
55-
public static final DeferredItem<BlockItem> EXAMPLE_BLOCK_ITEM = ITEMS.registerSimpleBlockItem("example_block", EXAMPLE_BLOCK);
56-
5760
// Creates a new food item with the id "examplemod:example_id", nutrition 1 and saturation 2
58-
public static final DeferredItem<Item> EXAMPLE_ITEM = ITEMS.registerSimpleItem("example_item", new Item.Properties().food(new FoodProperties.Builder()
59-
.alwaysEdible().nutrition(1).saturationModifier(2f).build()));
61+
62+
public static final DeferredItem<Item> ITEM_INFINITYPATTERN = ITEMS.register("item_infinitypattern",
63+
() -> new ItemInfinityPattern(new Item.Properties()));
6064

6165
// Creates a creative tab with the id "examplemod:example_tab" for the example item, that is placed after the combat tab
62-
public static final DeferredHolder<CreativeModeTab, CreativeModeTab> EXAMPLE_TAB = CREATIVE_MODE_TABS.register("example_tab", () -> CreativeModeTab.builder()
63-
.title(Component.translatable("itemGroup.examplemod")) //The language key for the title of your CreativeModeTab
66+
public static final DeferredHolder<CreativeModeTab, CreativeModeTab> INFINITY_PATTERN = CREATIVE_MODE_TABS.register("infinitypattern", () -> CreativeModeTab.builder()
67+
.title(Component.translatable("itemGroup.infinitypattern")) //The language key for the title of your CreativeModeTab
6468
.withTabsBefore(CreativeModeTabs.COMBAT)
65-
.icon(() -> EXAMPLE_ITEM.get().getDefaultInstance())
69+
.icon(() -> ITEM_INFINITYPATTERN.get().getDefaultInstance())
6670
.displayItems((parameters, output) -> {
67-
output.accept(EXAMPLE_ITEM.get()); // Add the example item to the tab. For your own tabs, this method is preferred over the event
71+
output.accept(ITEM_INFINITYPATTERN.get()); // Add the example item to the tab. For your own tabs, this method is preferred over the event
6872
}).build());
6973

7074
// The constructor for the mod class is the first code that is run when your mod is loaded.
7175
// FML will recognize some parameter types like IEventBus or ModContainer and pass them in automatically.
72-
public ExampleMod(IEventBus modEventBus, ModContainer modContainer)
76+
public InfinityPattern(IEventBus modEventBus, ModContainer modContainer)
7377
{
7478
// Register the commonSetup method for modloading
7579
modEventBus.addListener(this::commonSetup);
7680

77-
// Register the Deferred Register to the mod event bus so blocks get registered
78-
BLOCKS.register(modEventBus);
7981
// Register the Deferred Register to the mod event bus so items get registered
8082
ITEMS.register(modEventBus);
8183
// Register the Deferred Register to the mod event bus so tabs get registered
@@ -86,9 +88,6 @@ public ExampleMod(IEventBus modEventBus, ModContainer modContainer)
8688
// Do not add this line if there are no @SubscribeEvent-annotated functions in this class, like onServerStarting() below.
8789
NeoForge.EVENT_BUS.register(this);
8890

89-
// Register the item to a creative tab
90-
modEventBus.addListener(this::addCreative);
91-
9291
// Register our mod's ModConfigSpec so that FML can create and load the config file for us
9392
modContainer.registerConfig(ModConfig.Type.COMMON, Config.SPEC);
9493
}
@@ -106,13 +105,6 @@ private void commonSetup(final FMLCommonSetupEvent event)
106105
Config.items.forEach((item) -> LOGGER.info("ITEM >> {}", item.toString()));
107106
}
108107

109-
// Add the example block item to the building blocks tab
110-
private void addCreative(BuildCreativeModeTabContentsEvent event)
111-
{
112-
if (event.getTabKey() == CreativeModeTabs.BUILDING_BLOCKS)
113-
event.accept(EXAMPLE_BLOCK_ITEM);
114-
}
115-
116108
// You can use SubscribeEvent and let the Event Bus discover methods to call
117109
@SubscribeEvent
118110
public void onServerStarting(ServerStartingEvent event)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.neofastftl.infinitypattern.item;
2+
3+
import net.minecraft.world.item.Item;
4+
5+
public class ItemInfinityPattern extends Item {
6+
7+
public ItemInfinityPattern(Properties properties) {
8+
super(properties);
9+
}
10+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package com.neofastftl.infinitypattern.mixins;
2+
3+
import java.util.List;
4+
import java.util.Set;
5+
6+
import org.objectweb.asm.tree.ClassNode;
7+
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
8+
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
9+
10+
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
11+
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
12+
13+
import net.neoforged.fml.ModList;
14+
import net.neoforged.fml.loading.LoadingModList;
15+
import net.neoforged.fml.loading.moddiscovery.ModInfo;
16+
17+
public class IFPATMixinPlugin implements IMixinConfigPlugin {
18+
19+
private static final Object2ObjectMap<String, String> MOD_MIXINS = new Object2ObjectOpenHashMap<>(
20+
new String[] {
21+
"com.neofastftl.infinitypattern.mixins.MixinPatternEncodingTermMenu"
22+
},
23+
new String[] {"infinitypattern", "infinitypattern", "infinitypattern", "infinitypattern", "infinitypattern"},
24+
Object2ObjectOpenHashMap.DEFAULT_LOAD_FACTOR);
25+
26+
@Override
27+
public void onLoad(String s) {
28+
String[] str;
29+
}
30+
31+
@Override
32+
public String getRefMapperConfig() {
33+
return null;
34+
}
35+
36+
@Override
37+
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
38+
return !MOD_MIXINS.containsKey(mixinClassName) || isModLoaded(MOD_MIXINS.get(mixinClassName));
39+
}
40+
41+
@Override
42+
public void acceptTargets(Set<String> set, Set<String> set1) {}
43+
44+
@Override
45+
public List<String> getMixins() {
46+
return null;
47+
}
48+
49+
@Override
50+
public void preApply(String s, ClassNode classNode, String s1, IMixinInfo iMixinInfo) {}
51+
52+
@Override
53+
public void postApply(String s, ClassNode classNode, String s1, IMixinInfo iMixinInfo) {}
54+
55+
private static boolean isModLoaded(String modId) {
56+
if (ModList.get() == null) {
57+
return LoadingModList.get().getMods().stream()
58+
.map(ModInfo::getModId)
59+
.anyMatch(modId::equals);
60+
} else {
61+
return ModList.get().isLoaded(modId);
62+
}
63+
}
64+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package com.neofastftl.infinitypattern.mixins;
2+
3+
import appeng.core.definitions.AEItems;
4+
import appeng.parts.encoding.PatternEncodingLogic;
5+
import com.llamalad7.mixinextras.sugar.Local;
6+
7+
import com.neofastftl.infinitypattern.InfinityPattern;
8+
import org.spongepowered.asm.mixin.Final;
9+
import org.spongepowered.asm.mixin.Mixin;
10+
import org.spongepowered.asm.mixin.Shadow;
11+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
12+
13+
import net.minecraft.world.entity.player.Inventory;
14+
import net.minecraft.world.inventory.MenuType;
15+
import net.minecraft.world.item.ItemStack;
16+
17+
import appeng.api.crafting.PatternDetailsHelper;
18+
import appeng.api.stacks.GenericStack;
19+
import appeng.api.storage.ITerminalHost;
20+
import appeng.menu.me.common.MEStorageMenu;
21+
import appeng.menu.me.items.PatternEncodingTermMenu;
22+
import appeng.menu.slot.RestrictedInputSlot;
23+
24+
@Mixin(PatternEncodingTermMenu.class)
25+
public class MixinPatternEncodingTermMenu extends MEStorageMenu {
26+
27+
@Final
28+
@Shadow(remap = false)
29+
private RestrictedInputSlot encodedPatternSlot;
30+
31+
private void onEncodePattern(
32+
CallbackInfoReturnable<ItemStack> cir,
33+
@Local(ordinal = 0) GenericStack[] in,
34+
@Local(ordinal = 1) GenericStack[] out) {
35+
36+
var encodeOutput = this.encodedPatternSlot.getItem();
37+
38+
// first check the output slots, should either be null, or a pattern (encoded or otherwise)
39+
if (!encodeOutput.isEmpty()
40+
&& !PatternDetailsHelper.isEncodedPattern(encodeOutput)
41+
&& !InfinityPattern.ITEM_INFINITYPATTERN.is(encodeOutput.getItemHolder().getDelegate())) {
42+
clearPattern();
43+
}
44+
}
45+
private void clearPattern() {
46+
var encodedPattern = this.encodedPatternSlot.getItem();
47+
if (PatternDetailsHelper.isEncodedPattern(encodedPattern)) {
48+
this.encodedPatternSlot.set(
49+
InfinityPattern.ITEM_INFINITYPATTERN.toStack(encodedPattern.getCount()));
50+
}
51+
}
52+
public MixinPatternEncodingTermMenu(MenuType<?> menuType, int id, Inventory ip, ITerminalHost host, PatternEncodingLogic encodingLogic) {
53+
super(menuType, id, ip, host);
54+
}
55+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.neofastftl.infinitypattern.mixins;
2+
3+
import appeng.api.crafting.PatternDetailsHelper;
4+
import appeng.api.features.GridLinkables;
5+
import appeng.api.implementations.items.ISpatialStorageCell;
6+
import appeng.api.implementations.items.IStorageComponent;
7+
import appeng.api.inventories.InternalInventory;
8+
import appeng.api.stacks.GenericStack;
9+
import appeng.api.storage.ITerminalHost;
10+
import appeng.api.storage.StorageCells;
11+
import appeng.api.storage.cells.ICellWorkbenchItem;
12+
import appeng.api.upgrades.Upgrades;
13+
import appeng.blockentity.crafting.IMolecularAssemblerSupportedPattern;
14+
import appeng.blockentity.misc.InscriberRecipes;
15+
import appeng.blockentity.misc.VibrationChamberBlockEntity;
16+
import appeng.blockentity.qnb.QuantumBridgeBlockEntity;
17+
import appeng.core.definitions.AEItems;
18+
import appeng.menu.me.common.MEStorageMenu;
19+
import appeng.menu.me.items.PatternEncodingTermMenu;
20+
import appeng.menu.slot.AppEngSlot;
21+
import appeng.menu.slot.RestrictedInputSlot;
22+
import appeng.parts.encoding.PatternEncodingLogic;
23+
import appeng.util.Platform;
24+
import com.llamalad7.mixinextras.sugar.Local;
25+
import com.neofastftl.infinitypattern.InfinityPattern;
26+
import net.minecraft.world.entity.player.Inventory;
27+
import net.minecraft.world.inventory.MenuType;
28+
import net.minecraft.world.item.ItemStack;
29+
import net.minecraft.world.item.Items;
30+
import org.spongepowered.asm.mixin.Final;
31+
import org.spongepowered.asm.mixin.Mixin;
32+
import org.spongepowered.asm.mixin.Shadow;
33+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
34+
35+
import static appeng.api.ids.AEItemIds.BLANK_PATTERN;
36+
37+
@Mixin(RestrictedInputSlot.class)
38+
public class MixinRestrictedInputSlot extends AppEngSlot {
39+
40+
@Final
41+
@Shadow(remap = false)
42+
private RestrictedInputSlot encodedPatternSlot;
43+
44+
private void mayPlace(
45+
CallbackInfoReturnable<ItemStack> cir,
46+
@Local(ordinal = 0) GenericStack[] in,
47+
@Local(ordinal = 1) GenericStack[] out) {
48+
}
49+
}

src/main/resources/assets/examplemod/lang/en_us.json

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"required": true,
3+
"minVersion": "0.8",
4+
"package": "com.neofastftl.infinitypattern.mixins",
5+
"plugin": "com.neofastftl.infinitypattern.mixins.IFPATMixinPlugin",
6+
"refmap": "mixins.infinitypattern.refmap.json",
7+
"compatibilityLevel": "JAVA_21",
8+
"mixins": [
9+
"MixinPatternEncodingTermMenu"
10+
]
11+
}

0 commit comments

Comments
 (0)