Skip to content

Commit 5e6eadf

Browse files
committed
Set up API package
1 parent 78a4874 commit 5e6eadf

File tree

15 files changed

+88
-16
lines changed

15 files changed

+88
-16
lines changed

build.gradle

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
buildscript {
22
repositories {
33
maven { url = 'https://files.minecraftforge.net/maven' }
4-
jcenter()
54
mavenCentral()
65
}
76

@@ -31,9 +30,25 @@ println("Version: ${version}");
3130
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
3231

3332
sourceSets {
33+
api {
34+
java {
35+
srcDir "src/api/java"
36+
}
37+
compileClasspath += configurations.getByName("minecraft")
38+
}
39+
3440
main {
35-
resources.srcDir "src/generated/resources"
41+
java {
42+
srcDir "src/api/java"
43+
srcDir "src/main/java"
44+
}
45+
46+
resources {
47+
srcDir "src/main/resources"
48+
srcDir 'src/generated/resources'
49+
}
3650
}
51+
3752
test
3853
}
3954

@@ -114,19 +129,22 @@ minecraft {
114129
unitTests {
115130
parent runs.server // This run config inherits settings from the server config
116131
workingDirectory project.file('run/test')
117-
main 'com.alcatrazescapee.mcjunitlib.DedicatedTestServerLauncher' // The main class which launches a customized server which then runs JUnit tests
132+
main 'com.alcatrazescapee.mcjunitlib.DedicatedTestServerLauncher'
133+
// The main class which launches a customized server which then runs JUnit tests
118134
ideaModule "${project.name}.test" // Tell IDEA to use the classpath of the test module
119-
property 'forge.logging.console.level', 'unittest' // This logging level prevents any other server information messages and leaves only the unit test output
135+
property 'forge.logging.console.level', 'unittest'
136+
// This logging level prevents any other server information messages and leaves only the unit test output
120137
environment 'MOD_CLASSES', String.join(File.pathSeparator,
121138
"${mod_id}%%${sourceSets.main.output.resourcesDir}",
122139
"${mod_id}%%${sourceSets.main.output.classesDirs[0]}",
123140
"${mod_id}%%${sourceSets.test.output.resourcesDir}",
124141
"${mod_id}%%${sourceSets.test.output.classesDirs[0]}",
125142
) // Forge will ignore all test sources unless we explicitly tell it to include them as mod sources
126-
environment 'target', 'fmltestserver' // This is a custom service used to launch with ModLauncher's transforming class loader
143+
environment 'target', 'fmltestserver'
144+
// This is a custom service used to launch with ModLauncher's transforming class loader
127145
mods {
128146
compactmachines { // The mod that is being tested - Replace this with your mod ID!
129-
sources sourceSets.main
147+
sources sourceSets.api, sourceSets.main
130148
}
131149
}
132150
}
@@ -191,6 +209,14 @@ repositories {
191209
name 'MCUnitTests'
192210
url 'https://jitpack.io'
193211
}
212+
213+
// Curseforge stuff
214+
maven {
215+
url "https://cursemaven.com"
216+
content {
217+
includeGroup "curse.maven"
218+
}
219+
}
194220
}
195221

196222
def dev_mods = fileTree(dev_mods_dir).filter { it -> it.isFile() }.files.name.collect({ getModVersion(it) })
@@ -203,10 +229,7 @@ dependencies {
203229

204230

205231
// Deobfuscate each dev mod for runtime
206-
dev_mods.each {
207-
compileOnly fg.deobf(it)
208-
runtimeOnly fg.deobf(it)
209-
}
232+
dev_mods.each { implementation(fg.deobf(it)) }
210233

211234

212235
// JEI
@@ -219,30 +242,37 @@ dependencies {
219242

220243
testImplementation(fg.deobf("com.github.alcatrazEscapee:mcjunitlib:1.3.3-${minecraft_version}"))
221244

245+
// Nicephore - Screenshots and Stuff
246+
runtimeOnly(fg.deobf("curse.maven:nicephore-401014:3318114"))
247+
248+
// Mekanism + Mek Generators - Tunnel testing
249+
runtimeOnly(fg.deobf("curse.maven:mekanism-268560:3206392"))
250+
runtimeOnly(fg.deobf("curse.maven:mekanismgenerators-268566:3206395"))
222251
}
223252

224253
// Example for how to get properties into the manifest for reading by the runtime..
225254
jar {
255+
from sourceSets.api.output
256+
from sourceSets.main.output
226257
destinationDirectory = file("$rootDir/build-out")
258+
227259
finalizedBy('reobfJar')
228260
manifest {
229261
attributes([
230262
"Specification-Title" : "compactmachines",
231263
"Specification-Vendor" : "",
232264
"Specification-Version" : "1", // We are version 1 of ourselves
233265
"Implementation-Title" : project.name,
234-
"Implementation-Version": isRelease ? archiveVersion : "nightly-${gitCommitHash}",
266+
"Implementation-Version" : isRelease ? archiveVersion : "nightly-${gitCommitHash}",
235267
"Implementation-Vendor" : "",
236268
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
237269
])
238270
}
239271
}
240272

241273
task apiJar(type: Jar) {
274+
from sourceSets.api.output
242275
// Sources included because of MinecraftForge/ForgeGradle#369
243-
from(sourceSets.main.allJava)
244-
from(sourceSets.main.output)
245-
include 'com/robotgryphon/compactmachines/api/**'
246276
archiveClassifier = 'api'
247277
destinationDirectory = file("$rootDir/build-out")
248278
}

src/main/java/dev/compactmods/machines/api/core/Advancements.java renamed to src/api/java/dev/compactmods/machines/api/core/Advancements.java

File renamed without changes.

src/main/java/dev/compactmods/machines/api/core/Constants.java renamed to src/api/java/dev/compactmods/machines/api/core/Constants.java

File renamed without changes.

src/main/java/dev/compactmods/machines/api/core/JeiInfo.java renamed to src/api/java/dev/compactmods/machines/api/core/JeiInfo.java

File renamed without changes.

src/main/java/dev/compactmods/machines/api/core/Messages.java renamed to src/api/java/dev/compactmods/machines/api/core/Messages.java

File renamed without changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package dev.compactmods.machines.api.core;
2+
3+
import net.minecraft.util.ResourceLocation;
4+
5+
public abstract class Tooltips {
6+
7+
public static final ResourceLocation UNKNOWN_PLAYER_NAME = new ResourceLocation(Constants.MOD_ID, "unknown_player");
8+
9+
public static abstract class Machines {
10+
public static final ResourceLocation ID = new ResourceLocation(Constants.MOD_ID, "machine.id");
11+
public static final ResourceLocation OWNER = new ResourceLocation(Constants.MOD_ID, "machine.owner");
12+
public static final ResourceLocation SIZE = new ResourceLocation(Constants.MOD_ID, "machine.size");
13+
}
14+
15+
//#region Hints and Details
16+
public static final ResourceLocation HINT_HOLD_SHIFT = new ResourceLocation(Constants.MOD_ID, "hint.hold_shift");
17+
18+
public static abstract class Details {
19+
public static final ResourceLocation PERSONAL_SHRINKING_DEVICE = new ResourceLocation(Constants.MOD_ID, "details.psd");
20+
public static final ResourceLocation SOLID_WALL = new ResourceLocation(Constants.MOD_ID, "details.solid_wall");
21+
}
22+
//#endregion
23+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package dev.compactmods.machines.api.teleportation;
2+
3+
import java.util.Optional;
4+
import net.minecraft.server.MinecraftServer;
5+
import net.minecraft.util.math.BlockPos;
6+
import net.minecraft.world.server.ServerWorld;
7+
8+
public interface IDimensionalPosition {
9+
BlockPos getBlockPosition();
10+
11+
Optional<ServerWorld> getWorld(MinecraftServer server);
12+
}

src/main/java/dev/compactmods/machines/api/tunnels/EnumTunnelSide.java renamed to src/api/java/dev/compactmods/machines/api/tunnels/EnumTunnelSide.java

File renamed without changes.

src/main/java/dev/compactmods/machines/api/tunnels/ICapableTunnel.java renamed to src/api/java/dev/compactmods/machines/api/tunnels/ICapableTunnel.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package dev.compactmods.machines.api.tunnels;
22

3+
import dev.compactmods.machines.api.teleportation.IDimensionalPosition;
34
import net.minecraft.util.Direction;
45
import net.minecraft.util.math.BlockPos;
56
import net.minecraft.world.server.ServerWorld;
67
import net.minecraftforge.common.capabilities.Capability;
78
import net.minecraftforge.common.util.LazyOptional;
89

910
import javax.annotation.Nonnull;
11+
import javax.annotation.Nullable;
12+
import java.util.Map;
1013

1114
/**
1215
* A base interface that marks a tunnel as supporting capabilities (items, fluids, etc.)
@@ -18,4 +21,6 @@ public interface ICapableTunnel {
1821

1922
@Nonnull
2023
<T> LazyOptional<T> getExternalCapability(ServerWorld world, BlockPos tunnelPos, @Nonnull Capability<T> cap, Direction side);
24+
25+
Map<Capability<?>, LazyOptional<?>> rebuildCapabilityCache(ServerWorld compactLevel, BlockPos tunnelPos, BlockPos inside, @Nullable IDimensionalPosition external);
2126
}

src/main/java/dev/compactmods/machines/api/tunnels/IItemTunnel.java renamed to src/api/java/dev/compactmods/machines/api/tunnels/IItemTunnel.java

File renamed without changes.

0 commit comments

Comments
 (0)