Skip to content

Commit 8c16c6a

Browse files
Add Draconicevolution energy core block compat (#135)
* de energy core block compat * docs * remap=false * steal from nomi labs * suggestion Co-authored-by: Waiting Idly <25394029+WaitingIdly@users.noreply.github.com> * reviews & config --------- Co-authored-by: Waiting Idly <25394029+WaitingIdly@users.noreply.github.com>
1 parent 6837ebf commit 8c16c6a

22 files changed

+1719
-14
lines changed

build.gradle

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//version: 1707604215
1+
//version: 1707682661
22
/*
33
* DO NOT CHANGE THIS FILE!
44
* Also, you may replace this file at any time if there is an update available.
@@ -24,9 +24,9 @@ plugins {
2424
id 'eclipse'
2525
id 'maven-publish'
2626
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.1.7'
27-
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.28'
28-
id 'net.darkhax.curseforgegradle' version '1.1.17' apply false
29-
id 'com.modrinth.minotaur' version '2.8.6' apply false
27+
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.33'
28+
id 'net.darkhax.curseforgegradle' version '1.1.18' apply false
29+
id 'com.modrinth.minotaur' version '2.8.7' apply false
3030
id 'com.diffplug.spotless' version '6.13.0' apply false
3131
id 'com.palantir.git-version' version '3.0.0' apply false
3232
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
@@ -495,7 +495,7 @@ configurations {
495495
testRuntimeClasspath.extendsFrom(runtimeOnlyNonPublishable)
496496
}
497497

498-
String mixinProviderSpec = 'zone.rong:mixinbooter:8.9'
498+
String mixinProviderSpec = 'zone.rong:mixinbooter:9.1'
499499
dependencies {
500500
if (usesMixins.toBoolean()) {
501501
annotationProcessor 'org.ow2.asm:asm-debug-all:5.2'
@@ -523,8 +523,8 @@ dependencies {
523523
}
524524

525525
if (enableModernJavaSyntax.toBoolean()) {
526-
annotationProcessor 'com.github.bsideup.jabel:jabel-javac-plugin:1.0.0'
527-
compileOnly('com.github.bsideup.jabel:jabel-javac-plugin:1.0.0') {
526+
annotationProcessor 'com.github.bsideup.jabel:jabel-javac-plugin:1.0.1'
527+
compileOnly('com.github.bsideup.jabel:jabel-javac-plugin:1.0.1') {
528528
transitive = false
529529
}
530530
// workaround for https://github.com/bsideup/jabel/issues/174
@@ -533,8 +533,8 @@ dependencies {
533533
patchedMinecraft 'me.eigenraven.java8unsupported:java-8-unsupported-shim:1.0.0'
534534

535535
// allow Jabel to work in tests
536-
testAnnotationProcessor "com.github.bsideup.jabel:jabel-javac-plugin:1.0.0"
537-
testCompileOnly("com.github.bsideup.jabel:jabel-javac-plugin:1.0.0") {
536+
testAnnotationProcessor "com.github.bsideup.jabel:jabel-javac-plugin:1.0.1"
537+
testCompileOnly("com.github.bsideup.jabel:jabel-javac-plugin:1.0.1") {
538538
transitive = false // We only care about the 1 annotation class
539539
}
540540
testCompileOnly "me.eigenraven.java8unsupported:java-8-unsupported-shim:1.0.0"
@@ -547,9 +547,13 @@ dependencies {
547547
}
548548

549549
if (includeCommonDevEnvMods.toBoolean()) {
550-
implementation 'mezz.jei:jei_1.12.2:4.16.1.302'
551-
//noinspection DependencyNotationArgument
552-
implementation rfg.deobf('curse.maven:top-245211:2667280') // TOP 1.4.28
550+
if (!(modId.equals('jei'))) {
551+
implementation 'mezz.jei:jei_1.12.2:4.16.1.302'
552+
}
553+
if (!(modId.equals('theoneprobe'))) {
554+
//noinspection DependencyNotationArgument
555+
implementation rfg.deobf('curse.maven:top-245211:2667280') // TOP 1.4.28
556+
}
553557
}
554558
}
555559

examples/postInit/draconicevolution.groovy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44

55
println 'mod \'draconicevolution\' detected, running script'
66

7+
// Energy Core:
8+
// A multiblock which stores energy
9+
10+
mods.draconicevolution.energy_core.setInnerBlock(7, blockstate('minecraft:stone', 1))
11+
mods.draconicevolution.energy_core.setOuterBlock(2, blockstate('minecraft:diamond_block'))
12+
mods.draconicevolution.energy_core.setOuterBlock(7, blockstate('minecraft:diamond_block'))
13+
714
// Fusion:
815
// Consumes items and power from up to 54 pedestals of at least a given tier pointing towards a Fusion Crafting Core
916
// containing a catalyst to produce an output item.

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ modGroup = com.cleanroommc.groovyscript
4444
modVersion = 0.8.0
4545
groovy_version = 4.0.13
4646
debug_use_examples_folder = true
47-
debug_run_ls = true
47+
debug_run_ls = false
4848

4949
# Whether to use the old jar naming structure (modid-mcversion-version) instead of the new version (modid-version)
5050
includeMCVersionJar = false

src/main/java/com/cleanroommc/groovyscript/GroovyScriptConfig.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,12 @@ public class GroovyScriptConfig {
1212

1313
@Config.Comment("Port for the VSC connection. Default: 25564")
1414
public static int languageServerPort = 25564;
15+
16+
public static Compat compat = new Compat();
17+
18+
public static class Compat {
19+
20+
@Config.Comment("Enables DE energy core compat. Config is mainly for other mods compat.")
21+
public boolean draconicEvolutionEnergyCore = true;
22+
}
1523
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package com.cleanroommc.groovyscript.compat.mods.draconicevolution;
22

3+
import com.cleanroommc.groovyscript.GroovyScriptConfig;
34
import com.cleanroommc.groovyscript.compat.mods.ModPropertyContainer;
45

56
public class DraconicEvolution extends ModPropertyContainer {
67

78
public final Fusion fusion = new Fusion();
9+
public final EnergyCore energyCore;
810

911
public DraconicEvolution() {
12+
this.energyCore = GroovyScriptConfig.compat.draconicEvolutionEnergyCore ? new EnergyCore() : null;
1013
addRegistry(fusion);
14+
if (this.energyCore != null) addRegistry(energyCore);
1115
}
1216
}
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
package com.cleanroommc.groovyscript.compat.mods.draconicevolution;
2+
3+
import com.cleanroommc.groovyscript.api.GroovyBlacklist;
4+
import com.cleanroommc.groovyscript.api.GroovyLog;
5+
import com.cleanroommc.groovyscript.api.IScriptReloadable;
6+
import com.cleanroommc.groovyscript.api.documentation.annotations.Example;
7+
import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription;
8+
import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription;
9+
import com.cleanroommc.groovyscript.compat.mods.draconicevolution.helpers.BlockStateEnergyCoreStructure;
10+
import com.cleanroommc.groovyscript.compat.mods.draconicevolution.helpers.BlockStateMultiblockStorage;
11+
import com.cleanroommc.groovyscript.compat.mods.draconicevolution.helpers.BlockStates;
12+
import com.cleanroommc.groovyscript.helper.Alias;
13+
import com.cleanroommc.groovyscript.helper.ArrayUtils;
14+
import net.minecraft.block.state.IBlockState;
15+
import org.jetbrains.annotations.ApiStatus;
16+
17+
import java.util.Arrays;
18+
import java.util.Collection;
19+
20+
@RegistryDescription
21+
public class EnergyCore implements IScriptReloadable {
22+
23+
private int version = 0;
24+
private BlockStates[][][][] original;
25+
private BlockStates[][][][] edited;
26+
private BlockStates[] inner;
27+
private BlockStates[] outer;
28+
29+
private void init() {
30+
if (this.original != null) return;
31+
BlockStateEnergyCoreStructure bsecs = new BlockStateEnergyCoreStructure(null);
32+
this.original = new BlockStates[bsecs.getStructureTiers().length][][][];
33+
BlockStateMultiblockStorage[] structureTiers = bsecs.getStructureTiers();
34+
// deep copy structure
35+
for (int i = 0; i < structureTiers.length; i++) {
36+
this.original[i] = ArrayUtils.deepCopy3d(structureTiers[i].getStructure(), null);
37+
}
38+
this.inner = new BlockStates[this.original.length];
39+
this.outer = new BlockStates[this.original.length];
40+
onReload(); // increases version to 1
41+
}
42+
43+
@Override
44+
public Collection<String> getAliases() {
45+
return Alias.generateOfClass(EnergyCore.class);
46+
}
47+
48+
@Override
49+
public void onReload() {
50+
if (this.original == null) return;
51+
this.edited = ArrayUtils.deepCopy4d(this.original, this.edited);
52+
Arrays.fill(this.inner, BlockStates.redstone());
53+
Arrays.fill(this.outer, BlockStates.draconium());
54+
this.inner[this.inner.length - 1] = BlockStates.draconium();
55+
this.outer[this.outer.length - 1] = BlockStates.draconic();
56+
this.version++;
57+
}
58+
59+
@Override
60+
public void afterScriptLoad() {}
61+
62+
@GroovyBlacklist
63+
public int getVersion() {
64+
return version;
65+
}
66+
67+
@GroovyBlacklist
68+
@ApiStatus.Internal
69+
public void applyEdit(BlockStateMultiblockStorage[] mbs) {
70+
for (int i = 0; i < mbs.length; i++) {
71+
mbs[i].setStructure(this.edited[i]);
72+
}
73+
}
74+
75+
private void replaceBlock(int tier, BlockStates edit, boolean inner) {
76+
if (tier < 1 || tier > 8) {
77+
GroovyLog.msg("Error setting block of Draconic Evolution Energy Core")
78+
.add("Tier {} is invalid. Must be between 1 and 8")
79+
.error()
80+
.post();
81+
return;
82+
}
83+
init();
84+
BlockStates old = inner ? this.inner[tier - 1] : this.outer[tier - 1];
85+
BlockStates[][][] blocks = this.edited[tier - 1];
86+
for (int i = 0; i < blocks.length; i++) {
87+
for (int j = 0; j < blocks[i].length; j++) {
88+
for (int k = 0; k < blocks[i][j].length; k++) {
89+
if (old == blocks[i][j][k]) {
90+
blocks[i][j][k] = edit;
91+
}
92+
}
93+
}
94+
}
95+
(inner ? this.inner : this.outer)[tier - 1] = edit;
96+
}
97+
98+
@MethodDescription(description = "groovyscript.wiki.draconicevolution.inner_block", type = MethodDescription.Type.VALUE, example = {
99+
@Example("7, blockstate('minecraft:stone', 1)")
100+
})
101+
public EnergyCore setInnerBlock(int tier, IBlockState... blockStates) {
102+
if (blockStates == null || blockStates.length == 0) {
103+
GroovyLog.msg("Error setting inner block of tier {} Draconic Evolution Energy Core", tier)
104+
.add("block states must not be null or empty")
105+
.error()
106+
.post();
107+
return this;
108+
}
109+
replaceBlock(tier, BlockStates.of(blockStates), true);
110+
return this;
111+
}
112+
113+
@MethodDescription(description = "groovyscript.wiki.draconicevolution.outer_block", type = MethodDescription.Type.VALUE, example = {
114+
@Example("7, blockstate('minecraft:diamond_block')"),
115+
@Example("2, blockstate('minecraft:diamond_block')")
116+
})
117+
public EnergyCore setOuterBlock(int tier, IBlockState... blockStates) {
118+
if (blockStates == null || blockStates.length == 0) {
119+
GroovyLog.msg("Error setting outer block of tier {} Draconic Evolution Energy Core", tier)
120+
.add("block states must not be null or empty")
121+
.error()
122+
.post();
123+
return this;
124+
}
125+
replaceBlock(tier, BlockStates.of(blockStates), false);
126+
return this;
127+
}
128+
}

0 commit comments

Comments
 (0)