-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add forge support. Signed-off-by: 秋雨落 <[email protected]>
- Loading branch information
Showing
29 changed files
with
616 additions
and
88 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
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
45 changes: 0 additions & 45 deletions
45
catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/client/CatsPlusFabricClient.java
This file was deleted.
Oops, something went wrong.
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
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
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,62 @@ | ||
plugins { | ||
id 'com.github.johnrengelman.shadow' version "${shadow_plugin_version}" | ||
id 'me.shedaniel.unified-publishing' version "${unified_publishing_version}" | ||
} | ||
|
||
architectury { | ||
platformSetupLoomIde() | ||
forge() | ||
} | ||
|
||
loom { | ||
accessWidenerPath = project(':').loom.accessWidenerPath | ||
|
||
forge { | ||
convertAccessWideners = true | ||
extraAccessWideners.add loom.accessWidenerPath.get().asFile.name | ||
} | ||
} | ||
|
||
dependencies { | ||
forge "net.minecraftforge:forge:${rootProject.minecraft_version}-${rootProject.forge_version}" | ||
modApi "dev.architectury:architectury-forge:${project.architectury_version}" | ||
|
||
common(project(path: ':', configuration: 'namedElements')) { transitive = false } | ||
shadowCommon(project(path: ':', configuration: 'transformProductionFabric')) { transitive = false } | ||
} | ||
|
||
shadowJar { | ||
exclude 'fabric.mod.json' | ||
exclude 'architectury.common.json' | ||
|
||
configurations = [project.configurations.shadowCommon] | ||
archiveClassifier = 'dev-shadow' | ||
} | ||
|
||
remapJar { | ||
injectAccessWidener = true | ||
input.set shadowJar.archiveFile | ||
dependsOn shadowJar | ||
} | ||
|
||
sourcesJar { | ||
def commonSources = project(':').sourcesJar | ||
dependsOn commonSources | ||
from commonSources.archiveFile.map { zipTree(it) } | ||
} | ||
|
||
components.java { | ||
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { | ||
skip() | ||
} | ||
} | ||
|
||
publishing { | ||
publications { | ||
mavenFabric(MavenPublication) { | ||
artifactId = project.name | ||
version = "true".equalsIgnoreCase(System.getenv("MOD_RELEASE")) ? version : "${version}-SNAPSHOT" | ||
from components.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 @@ | ||
loom.platform=forge |
17 changes: 17 additions & 0 deletions
17
catsplus-forge/src/main/java/cuteneko/catsplus/forge/CatsPlusDataImpl.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 cuteneko.catsplus.forge; | ||
|
||
import cuteneko.catsplus.data.ICatPlayer; | ||
import cuteneko.catsplus.data.IGeniusCat; | ||
import cuteneko.catsplus.forge.capability.ModCapabilities; | ||
import net.minecraft.entity.passive.CatEntity; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
|
||
public class CatsPlusDataImpl { | ||
public static ICatPlayer getCatPlayer(PlayerEntity player) { | ||
return player.getCapability(ModCapabilities.CAT_PLAYER).orElseThrow(RuntimeException::new); | ||
} | ||
|
||
public static IGeniusCat getGeniusCat(CatEntity cat) { | ||
return cat.getCapability(ModCapabilities.GENIUS_CAT).orElseThrow(RuntimeException::new); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
catsplus-forge/src/main/java/cuteneko/catsplus/forge/CatsPlusForge.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,33 @@ | ||
package cuteneko.catsplus.forge; | ||
|
||
import cuteneko.catsplus.CatsPlus; | ||
import dev.architectury.platform.forge.EventBuses; | ||
import net.minecraftforge.common.capabilities.CapabilityManager; | ||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; | ||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; | ||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; | ||
|
||
@Mod(CatsPlus.MODID) | ||
public class CatsPlusForge { | ||
private final CatsPlus mod; | ||
|
||
public CatsPlusForge() { | ||
mod = new CatsPlus(); | ||
|
||
var bus = FMLJavaModLoadingContext.get().getModEventBus(); | ||
|
||
bus.addListener(this::onSetup); | ||
bus.addListener(this::onClientSetup); | ||
|
||
EventBuses.registerModEventBus(CatsPlus.MODID, bus); | ||
} | ||
|
||
public void onSetup(FMLCommonSetupEvent event) { | ||
mod.init(); | ||
} | ||
|
||
public void onClientSetup(FMLClientSetupEvent event) { | ||
event.enqueueWork(mod::initClient); | ||
} | ||
} |
Oops, something went wrong.