-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
378 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
Common/src/main/java/dev/cammiescorner/camsbackpacks/util/BackpackEventHooks.java
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
Common/src/main/java/dev/cammiescorner/camsbackpacks/util/platform/service/MenuHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
package dev.cammiescorner.camsbackpacks.util.platform.service; | ||
|
||
import dev.cammiescorner.camsbackpacks.block.entity.BackpackBlockEntity; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.MenuProvider; | ||
|
||
public interface MenuHelper { | ||
|
||
MenuProvider getMenuProvider(BackpackBlockEntity backpack); | ||
|
||
void openMenu(ServerPlayer player, MenuProvider menu, BackpackBlockEntity backpack); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
plugins { | ||
id 'idea' | ||
alias neoforge.plugins.neogradle | ||
alias neoforge.plugins.mixingradle | ||
} | ||
|
||
dependencies { | ||
minecraft "${neoforge.neoforge.get()}" | ||
compileOnly project(":Common") | ||
annotationProcessor "${libs.mixin.asProvider().get()}:processor" | ||
|
||
implementation fg.deobf(libs.resourcefulconfig.forge.get()) | ||
} | ||
|
||
minecraft { | ||
mappings channel: 'official', version: libs.versions.minecraft.get() | ||
|
||
copyIdeResources = true //Calls processResources when in dev | ||
|
||
// Automatically enable forge AccessTransformers if the file exists | ||
// This location is hardcoded in Forge and can not be changed. | ||
// https://github.com/MinecraftForge/MinecraftForge/blob/be1698bb1554f9c8fa2f58e32b9ab70bc4385e60/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java#L123 | ||
if (file('src/main/resources/META-INF/accesstransformer.cfg').exists()) { | ||
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') | ||
} | ||
|
||
runs { | ||
configureEach { | ||
property 'forge.logging.markers', 'REGISTRIES' | ||
property 'forge.logging.console.level', 'debug' | ||
} | ||
client { | ||
workingDirectory project.file('run') | ||
ideaModule "${rootProject.name}.${project.name}.main" | ||
mods { | ||
modClientRun { | ||
source sourceSets.main | ||
source project(":Common").sourceSets.main | ||
} | ||
} | ||
|
||
if (rootProject.hasProperty('mc_uuid')) { | ||
args("--uuid", rootProject.mc_uuid) | ||
} | ||
|
||
if (rootProject.hasProperty('mc_username')) { | ||
args("--username", rootProject.mc_username) | ||
} | ||
|
||
if (rootProject.hasProperty('mc_java_agent_path')) { | ||
jvmArg("-javaagent:${rootProject.mc_java_agent_path}") | ||
} | ||
} | ||
|
||
server { | ||
workingDirectory project.file('run') | ||
ideaModule "${rootProject.name}.${project.name}.main" | ||
args '--nogui' | ||
mods { | ||
modServerRun { | ||
source sourceSets.main | ||
source project(":Common").sourceSets.main | ||
} | ||
} | ||
} | ||
|
||
data { | ||
workingDirectory project.file('run') | ||
ideaModule "${rootProject.name}.${project.name}.main" | ||
args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') | ||
mods { | ||
modDataRun { | ||
source sourceSets.main | ||
source project(":Common").sourceSets.main | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
sourceSets.main.resources { srcDir 'src/generated/resources' } | ||
|
||
// NeoGradle compiles the game, but we don't want to add our common code to the game's code | ||
Spec<Task> notNeoTask = { Task it -> !it.name.startsWith("neo") } as Spec<Task> | ||
|
||
tasks.withType(JavaCompile).matching(notNeoTask).configureEach { | ||
source(project(":Common").sourceSets.main.allSource) | ||
} | ||
|
||
tasks.withType(Javadoc).matching(notNeoTask).configureEach { | ||
source(project(":Common").sourceSets.main.allJava) | ||
} | ||
|
||
tasks.named("sourcesJar", Jar) { | ||
from(project(":Common").sourceSets.main.allSource) | ||
} | ||
|
||
tasks.withType(ProcessResources).matching(notNeoTask).configureEach { | ||
from project(":Common").sourceSets.main.resources | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
[versions] | ||
neoforge = "47.1.65" | ||
neogradle = "6.+" | ||
mixingradle = "0.7-SNAPSHOT" | ||
|
||
neoforge = "1.20.1-47.1.65" | ||
|
||
[libraries] | ||
neoforge = { module = "net.neoforged:forge", version.ref = "neoforge" } | ||
|
||
[plugins] | ||
neogradle = { id = "net.neoforged.gradle", version.ref = "neogradle" } | ||
mixingradle = { id = "org.spongepowered.mixin", version.ref = "mixingradle" } |
21 changes: 21 additions & 0 deletions
21
NeoForge/src/main/java/dev/cammiescorner/camsbackpacks/neoforge/EventHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package dev.cammiescorner.camsbackpacks.neoforge; | ||
|
||
import dev.cammiescorner.camsbackpacks.CamsBackpacks; | ||
import dev.cammiescorner.camsbackpacks.network.s2c.UpdateConfigurationPacket; | ||
import net.minecraftforge.event.OnDatapackSyncEvent; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
import net.minecraftforge.fml.common.Mod; | ||
|
||
@Mod.EventBusSubscriber(modid = CamsBackpacks.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE) | ||
public class EventHandler { | ||
|
||
@SubscribeEvent | ||
public static void onDatapackReload(OnDatapackSyncEvent event) { | ||
if(event.getPlayer() != null) { | ||
UpdateConfigurationPacket.sendTo(event.getPlayer()); | ||
} | ||
else { | ||
UpdateConfigurationPacket.sendTo(event.getPlayerList().getPlayers()); | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
NeoForge/src/main/java/dev/cammiescorner/camsbackpacks/neoforge/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package dev.cammiescorner.camsbackpacks.neoforge; | ||
|
||
import dev.cammiescorner.camsbackpacks.CamsBackpacks; | ||
import dev.cammiescorner.camsbackpacks.neoforge.services.NFRegistryHelper; | ||
import dev.cammiescorner.camsbackpacks.util.platform.Services; | ||
import net.minecraft.world.item.CreativeModeTabs; | ||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent; | ||
import net.minecraftforge.eventbus.api.IEventBus; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; | ||
|
||
@Mod(CamsBackpacks.MOD_ID) | ||
public class Main { | ||
|
||
public Main() { | ||
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); | ||
NFRegistryHelper.BLOCKS.register(bus); | ||
NFRegistryHelper.ITEMS.register(bus); | ||
NFRegistryHelper.BLOCK_ENTITY_TYPES.register(bus); | ||
NFRegistryHelper.MENU_TYPES.register(bus); | ||
bus.register(this); | ||
CamsBackpacks.init(); | ||
} | ||
|
||
@SubscribeEvent | ||
public void onCreativeTabSetup(BuildCreativeModeTabContentsEvent event) { | ||
if(event.getTabKey() == CreativeModeTabs.TOOLS_AND_UTILITIES) { | ||
Services.REGISTRY.getModBlocks().forEach(event::accept); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
NeoForge/src/main/java/dev/cammiescorner/camsbackpacks/neoforge/services/NFMenuHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package dev.cammiescorner.camsbackpacks.neoforge.services; | ||
|
||
import dev.cammiescorner.camsbackpacks.block.entity.BackpackBlockEntity; | ||
import dev.cammiescorner.camsbackpacks.util.platform.service.MenuHelper; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.MenuProvider; | ||
import net.minecraft.world.SimpleMenuProvider; | ||
import net.minecraftforge.network.NetworkHooks; | ||
|
||
public class NFMenuHelper implements MenuHelper { | ||
@Override | ||
public MenuProvider getMenuProvider(BackpackBlockEntity backpack) { | ||
return new SimpleMenuProvider(backpack::createMenu, backpack.getDisplayName()); | ||
} | ||
|
||
@Override | ||
public void openMenu(ServerPlayer player, MenuProvider menu, BackpackBlockEntity backpack) { | ||
NetworkHooks.openScreen(player, menu, buf -> backpack.writeInitMenuData(player, buf)); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...rge/src/main/java/dev/cammiescorner/camsbackpacks/neoforge/services/NFPlatformHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package dev.cammiescorner.camsbackpacks.neoforge.services; | ||
|
||
import dev.cammiescorner.camsbackpacks.CamsBackpacks; | ||
import dev.cammiescorner.camsbackpacks.util.platform.service.PlatformHelper; | ||
import net.minecraftforge.fml.ModList; | ||
|
||
public class NFPlatformHelper implements PlatformHelper { | ||
@Override | ||
public boolean isModLoaded(String modid) { | ||
return ModList.get().isLoaded(modid); | ||
} | ||
|
||
@Override | ||
public String getIssuesUrl() { | ||
return ModList.get().getModContainerById(CamsBackpacks.MOD_ID).orElseThrow().getModInfo().getOwningFile().getFileProperties().get("issueTrackerURL") instanceof String value ? value : CamsBackpacks.MOD_ID; | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...rge/src/main/java/dev/cammiescorner/camsbackpacks/neoforge/services/NFRegistryHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package dev.cammiescorner.camsbackpacks.neoforge.services; | ||
|
||
import dev.cammiescorner.camsbackpacks.CamsBackpacks; | ||
import dev.cammiescorner.camsbackpacks.util.platform.service.RegistryHelper; | ||
import net.minecraft.world.inventory.AbstractContainerMenu; | ||
import net.minecraft.world.inventory.MenuType; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.entity.BlockEntity; | ||
import net.minecraft.world.level.block.entity.BlockEntityType; | ||
import net.minecraftforge.common.extensions.IForgeMenuType; | ||
import net.minecraftforge.registries.DeferredRegister; | ||
import net.minecraftforge.registries.ForgeRegistries; | ||
|
||
import java.util.function.Supplier; | ||
import java.util.function.UnaryOperator; | ||
import java.util.stream.Stream; | ||
|
||
public class NFRegistryHelper implements RegistryHelper { | ||
|
||
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, CamsBackpacks.MOD_ID); | ||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, CamsBackpacks.MOD_ID); | ||
public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, CamsBackpacks.MOD_ID); | ||
public static final DeferredRegister<MenuType<?>> MENU_TYPES = DeferredRegister.create(ForgeRegistries.MENU_TYPES, CamsBackpacks.MOD_ID); | ||
|
||
@Override | ||
public <T extends BlockEntity> Supplier<BlockEntityType<T>> createBlockEntityType(String name, Supplier<BlockEntityType.BlockEntitySupplier<T>> factory, Supplier<Block>[] supportedBlocks) { | ||
return BLOCK_ENTITY_TYPES.register(name, () -> { | ||
var blocks = new Block[supportedBlocks.length]; | ||
for (int i = 0; i < supportedBlocks.length; i++) { | ||
blocks[i] = supportedBlocks[i].get(); | ||
} | ||
//noinspection DataFlowIssue | ||
return BlockEntityType.Builder.of(factory.get(), blocks).build(null); | ||
}); | ||
} | ||
|
||
@Override | ||
public Stream<Supplier<? extends Block>> getModBlocks() { | ||
return BLOCKS.getEntries().stream().map(UnaryOperator.identity()); | ||
} | ||
|
||
@Override | ||
public <T extends Item> Supplier<T> createItem(String name, Supplier<T> item) { | ||
return ITEMS.register(name, item); | ||
} | ||
|
||
@Override | ||
public <T extends Block> Supplier<T> createBlock(String name, Supplier<T> block) { | ||
return BLOCKS.register(name, block); | ||
} | ||
|
||
@Override | ||
public <T extends AbstractContainerMenu> Supplier<MenuType<T>> registerMenu(String name, Supplier<MenuExtendedFactory<T>> factory) { | ||
return MENU_TYPES.register(name, () -> IForgeMenuType.create((windowId, inv, data) -> factory.get().create(windowId, inv, data))); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
NeoForge/src/main/resources/META-INF/accesstransformer.cfg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copied from accesswidener file | ||
#TODO find a way to automate this | ||
|
||
public net.minecraft.client.gui.screens.MenuScreens m_96206_(Lnet/minecraft/world/inventory/MenuType;Lnet/minecraft/client/gui/screens/MenuScreens$ScreenConstructor;)V # register | ||
public net.minecraft.world.level.block.entity.BlockEntityType$BlockEntitySupplier | ||
public net.minecraft.client.gui.screens.MenuScreens$ScreenConstructor | ||
|
||
public net.minecraft.world.inventory.InventoryMenu f_39699_ # TEXTURE_EMPTY_SLOTS | ||
public net.minecraft.world.inventory.InventoryMenu m_269535_(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/entity/EquipmentSlot;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/item/ItemStack;)V # onEquipItem | ||
public net.minecraft.world.inventory.CraftingMenu m_150546_(Lnet/minecraft/world/inventory/AbstractContainerMenu;Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/inventory/CraftingContainer;Lnet/minecraft/world/inventory/ResultContainer;)V # slotChangedCraftingGrid |
Oops, something went wrong.