Skip to content

Commit 70f3bc6

Browse files
committed
Merge branch 'feat/tunnels-api' into 1.16.x
2 parents a1a92c6 + 7c46595 commit 70f3bc6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+694
-456
lines changed

.github/workflows/tagged-release.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ jobs:
137137
uses: actions/upload-artifact@v2
138138
with:
139139
name: libs
140-
path: build/libs/**${{ needs.vars.outputs.mod_version }}**.jar
140+
path: |
141+
build-out/${{ needs.vars.outputs.mod_id }}-${{ needs.vars.outputs.mod_version }}.jar
142+
build-out/${{ needs.vars.outputs.mod_id }}-${{ needs.vars.outputs.mod_version }}-api.jar
141143
142144
view:
143145
name: View Changelog Output
@@ -160,7 +162,7 @@ jobs:
160162
uses: actions/download-artifact@v2
161163
with:
162164
name: libs
163-
path: buildfiles
165+
path: build-out
164166
- name: Download Changelog Results
165167
uses: actions/download-artifact@v2
166168
with:
@@ -179,7 +181,8 @@ jobs:
179181
prerelease: false
180182
files: |
181183
changelog/CHANGELOG.md
182-
buildfiles/**${{ needs.vars.outputs.mod_version }}**.jar
184+
build-out/${{ needs.vars.outputs.mod_id }}-${{ needs.vars.outputs.mod_version }}.jar
185+
build-out/${{ needs.vars.outputs.mod_id }}-${{ needs.vars.outputs.mod_version }}-api.jar
183186
184187
- name: Full File
185188
id: filename

.github/workflows/test-build.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
jobs:
77
vars:
88
name: Get Variables
9-
runs-on: ubuntu-latest
9+
runs-on: ubuntu-20.04
1010
outputs:
1111
release_type: ${{steps.cf_release_type.outputs.value }}
1212
cf_project: ${{steps.cf_project.outputs.value }}
@@ -46,7 +46,7 @@ jobs:
4646

4747
changelog:
4848
name: Generate Changelog (tags)
49-
runs-on: ubuntu-latest
49+
runs-on: ubuntu-20.04
5050
steps:
5151
- name: Checkout
5252
uses: actions/checkout@v2
@@ -95,7 +95,7 @@ jobs:
9595

9696
jar:
9797
name: Publish JAR
98-
runs-on: ubuntu-latest
98+
runs-on: ubuntu-20.04
9999
needs: [vars, changelog]
100100
steps:
101101
- name: Download Changelog Results
@@ -107,10 +107,10 @@ jobs:
107107
- name: Checkout
108108
uses: actions/checkout@v2
109109

110-
- name: Set up JDK 1.8
110+
- name: Set up JDK
111111
uses: actions/setup-java@v1
112112
with:
113-
java-version: 1.8
113+
java-version: "8.0.282"
114114

115115
- name: Cache Gradle packages
116116
uses: actions/cache@v2
@@ -129,15 +129,20 @@ jobs:
129129
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
130130
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
131131

132+
- name: Output Dir Structure
133+
run: ls -lhR build-out
134+
132135
- name: Add Artifact
133136
uses: actions/upload-artifact@v2
134137
with:
135138
name: libs
136-
path: build/libs/**${{ needs.vars.outputs.mod_version }}**.jar
139+
path: |
140+
build-out/${{ needs.vars.outputs.mod_id }}-${{ needs.vars.outputs.mod_version }}.jar
141+
build-out/${{ needs.vars.outputs.mod_id }}-${{ needs.vars.outputs.mod_version }}-api.jar
137142
138143
view:
139144
name: View Changelog Output
140-
runs-on: ubuntu-latest
145+
runs-on: ubuntu-20.04
141146
needs: [changelog]
142147
steps:
143148
- name: Download Build Results

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ forge*changelog.txt
2929

3030
logs/
3131
/mods/
32+
/build-out/

build.gradle

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ buildscript {
1010
}
1111
}
1212

13+
plugins {
14+
id "idea"
15+
}
16+
1317
apply plugin: 'net.minecraftforge.gradle'
1418
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
1519
apply plugin: 'eclipse'
@@ -21,6 +25,15 @@ archivesBaseName = mod_id
2125

2226
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
2327

28+
sourceSets {
29+
main{
30+
resources {
31+
srcDir 'src/generated/resources'
32+
}
33+
}
34+
test
35+
}
36+
2437
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
2538
minecraft {
2639
mappings channel: 'snapshot', version: mappings_version
@@ -85,8 +98,6 @@ minecraft {
8598
}
8699
}
87100

88-
sourceSets.main.resources { srcDir 'src/generated/resources' }
89-
90101
def getModVersion(filename) {
91102
// println(filename);
92103
def pattern = /^(?<modid>[^-]+)(?:-(?<mcversion>[0-9.]+))?(?:-(?<modver>[0-9.\-]+))\.jar$/;
@@ -177,11 +188,23 @@ jar {
177188
}
178189
}
179190

180-
// Example configuration to allow publishing using the maven-publish task
181-
// This is the preferred method to reobfuscate your jar file
182-
jar.finalizedBy('reobfJar')
183-
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
184-
//publish.dependsOn('reobfJar')
191+
jar {
192+
destinationDir = file("$rootDir/build-out")
193+
finalizedBy('reobfJar')
194+
}
195+
196+
task apiJar(type: Jar) {
197+
// Sources included because of MinecraftForge/ForgeGradle#369
198+
from(sourceSets.main.allJava)
199+
from(sourceSets.main.output)
200+
include 'com/robotgryphon/compactmachines/api/**'
201+
classifier = 'api'
202+
destinationDir = file("$rootDir/build-out")
203+
}
204+
205+
artifacts {
206+
archives jar, apiJar
207+
}
185208

186209
publishing {
187210
publications {

src/main/java/com/robotgryphon/compactmachines/tunnels/EnumTunnelSide.java renamed to src/main/java/com/robotgryphon/compactmachines/api/tunnels/EnumTunnelSide.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.robotgryphon.compactmachines.tunnels;
1+
package com.robotgryphon.compactmachines.api.tunnels;
22

33
/**
44
* Represents the side of a tunnel (inside or outside).

src/main/java/com/robotgryphon/compactmachines/tunnels/api/ICapableTunnel.java renamed to src/main/java/com/robotgryphon/compactmachines/api/tunnels/ICapableTunnel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.robotgryphon.compactmachines.tunnels.api;
1+
package com.robotgryphon.compactmachines.api.tunnels;
22

33
import net.minecraft.util.Direction;
44
import net.minecraft.util.math.BlockPos;

src/main/java/com/robotgryphon/compactmachines/tunnels/api/IItemTunnel.java renamed to src/main/java/com/robotgryphon/compactmachines/api/tunnels/IItemTunnel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.robotgryphon.compactmachines.tunnels.api;
1+
package com.robotgryphon.compactmachines.api.tunnels;
22

33
public interface IItemTunnel extends ICapableTunnel {
44

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.robotgryphon.compactmachines.api.tunnels;
2+
3+
import com.robotgryphon.compactmachines.teleportation.DimensionalPosition;
4+
import net.minecraft.block.BlockState;
5+
import net.minecraft.util.Direction;
6+
import net.minecraft.world.IWorldReader;
7+
8+
import javax.annotation.Nonnull;
9+
import java.util.Optional;
10+
11+
public interface ITunnelConnectionInfo {
12+
@Nonnull
13+
Optional<DimensionalPosition> getConnectedPosition(EnumTunnelSide side);
14+
15+
@Nonnull
16+
Optional<BlockState> getConnectedState(EnumTunnelSide side);
17+
18+
Optional<? extends IWorldReader> getConnectedWorld(EnumTunnelSide side);
19+
20+
/**
21+
* Gets the connection information for sidedness.
22+
*
23+
* For inside the machine, gets the side the tunnel was placed on.
24+
* For outside the machine, gets the side of the machine the tunnel is connected to.
25+
*
26+
* @param side Which side of the tunnel to get directional info for.
27+
*/
28+
Direction getConnectedSide(EnumTunnelSide side);
29+
}
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,23 @@
1-
package com.robotgryphon.compactmachines.tunnels;
1+
package com.robotgryphon.compactmachines.api.tunnels;
22

3-
import net.minecraft.item.Item;
43
import net.minecraftforge.registries.ForgeRegistryEntry;
54

6-
public abstract class TunnelDefinition extends ForgeRegistryEntry<TunnelDefinition> {
7-
protected Item item;
8-
5+
public abstract class TunnelDefinition extends ForgeRegistryEntry<TunnelDefinition>
6+
{
97
/**
108
* The color of a non-indicator (the same color as the wall)
119
*/
1210
public static final int NO_INDICATOR_COLOR = 3751749;
1311

14-
public TunnelDefinition(Item item) {
15-
this.item = item;
16-
}
17-
18-
public Item getItem() {
19-
return this.item;
20-
}
21-
2212
public abstract int getTunnelRingColor();
2313

2414
/**
2515
* Gets the color for the indicator at the top-right of the block texture.
2616
*
2717
* @return
2818
*/
29-
public abstract int getTunnelIndicatorColor();
19+
public int getTunnelIndicatorColor() {
20+
return NO_INDICATOR_COLOR;
21+
}
22+
3023
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.robotgryphon.compactmachines.api.tunnels.redstone;
2+
3+
import com.robotgryphon.compactmachines.api.tunnels.ITunnelConnectionInfo;
4+
import net.minecraft.block.BlockState;
5+
import net.minecraft.server.MinecraftServer;
6+
import net.minecraft.util.Direction;
7+
import net.minecraft.util.math.BlockPos;
8+
import net.minecraft.world.IBlockReader;
9+
10+
/**
11+
* A redstone reader reads a redstone value from outside the machine (from a given side).
12+
*/
13+
public interface IRedstoneReaderTunnel extends IRedstoneTunnel {
14+
15+
/**
16+
* Gets the weak (passive) power level from the outside of the machine.
17+
*
18+
* @param connectionInfo
19+
* @return
20+
*/
21+
default int getPowerLevel(ITunnelConnectionInfo connectionInfo) {
22+
return 0;
23+
}
24+
25+
/**
26+
* Called by the tunnel wall blocks to check if a redstone signal can be pulled
27+
* from the outside. This should almost always return true, but if you need custom
28+
* logic then you can implement it here.
29+
*
30+
* @param connectionInfo Connection information for the tunnel instance.
31+
* @return
32+
*/
33+
default boolean canConnectRedstone(ITunnelConnectionInfo connectionInfo) {
34+
return true;
35+
}
36+
37+
default void onPowerChanged(ITunnelConnectionInfo connectionInfo, int latestPower) {}
38+
}

0 commit comments

Comments
 (0)