Skip to content

Commit 90d2db1

Browse files
server crash fix and automatic tag
1 parent fe3ad36 commit 90d2db1

File tree

14 files changed

+107
-858
lines changed

14 files changed

+107
-858
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Version Check
2+
3+
on:
4+
push:
5+
branches:
6+
- '**' # every branch
7+
paths:
8+
- 'gradle.properties' # only when this file changes
9+
10+
jobs:
11+
check-and-tag:
12+
runs-on: ubuntu-latest
13+
14+
# Allow the job to push the new tag
15+
permissions:
16+
contents: write
17+
18+
steps:
19+
# ── 1. Checkout with enough history to read the previous commit ────────
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 2
24+
25+
# ── 2. Read versions from the CURRENT commit ───────────────────────────
26+
- name: Read current versions
27+
id: current
28+
run: |
29+
MC=$(grep -E '^minecraft_version\s*=' gradle.properties \
30+
| sed 's/.*=\s*//' | tr -d '[:space:]')
31+
MOD=$(grep -E '^mod_version\s*=' gradle.properties \
32+
| sed 's/.*=\s*//' | tr -d '[:space:]')
33+
echo "mc=$MC" >> "$GITHUB_OUTPUT"
34+
echo "mod=$MOD" >> "$GITHUB_OUTPUT"
35+
echo "Current → minecraft: $MC mod: $MOD"
36+
37+
# ── 3. Read mod_version from the PREVIOUS commit ───────────────────────
38+
- name: Read previous mod_version
39+
id: previous
40+
run: |
41+
PREV=$(git show HEAD~1:gradle.properties 2>/dev/null \
42+
| grep -E '^mod_version\s*=' \
43+
| sed 's/.*=\s*//' | tr -d '[:space:]' || echo "none")
44+
echo "mod=$PREV" >> "$GITHUB_OUTPUT"
45+
echo "Previous → mod: $PREV"
46+
47+
# ── 4. Create and push the tag if mod_version changed ─────────────────
48+
- name: Tag new version
49+
if: steps.current.outputs.mod != steps.previous.outputs.mod
50+
run: |
51+
TAG="v${{ steps.current.outputs.mc }}-${{ steps.current.outputs.mod }}"
52+
echo "✅ Version changed → creating tag $TAG"
53+
54+
git config user.name "github-actions[bot]"
55+
git config user.email "github-actions[bot]@users.noreply.github.com"
56+
57+
git tag "$TAG"
58+
git push origin "$TAG"

build.gradle

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ base {
1313
archivesName = mod_id
1414
}
1515

16-
jarJar.enable()
1716

1817
// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
1918
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
@@ -99,8 +98,6 @@ neoForge {
9998

10099

101100

102-
// Include resources generated by data generators.
103-
sourceSets.main.resources { srcDir 'src/generated/resources' }
104101

105102
repositories {
106103
maven { url = "https://maven.createmod.net" } // Create, Ponder, Flywheel
@@ -152,9 +149,7 @@ dependencies {
152149
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.0'
153150
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.0'
154151
//x chart to plot things
155-
jarJar(implementation("org.knowm.xchart:xchart:3.2.2")){
156-
jarJar.ranged(it, '[3.2.2,)')
157-
}
152+
implementation("org.knowm.xchart:xchart:3.2.2")
158153

159154
}
160155

@@ -172,7 +167,7 @@ var generateModMetadata = tasks.register("generateModMetadata", ProcessResources
172167
mod_id : mod_id,
173168
mod_name : mod_name,
174169
mod_license : mod_license,
175-
mod_version : minecraft_version + "_"+ mod_version,
170+
mod_version : mod_version,
176171
mod_authors : mod_authors,
177172
mod_description : mod_description
178173
]
@@ -189,11 +184,8 @@ neoForge.ideSyncTask generateModMetadata
189184

190185
tasks.test {
191186
useJUnitPlatform()
192-
debug = true;
187+
debug = false;
193188
}
194-
195-
jar.finalizedBy('reobfJar')
196-
tasks.jarJar.finalizedBy('reobfJarJar')
197189
// 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:
198190
// tasks.named('publish').configure {
199191
// dependsOn 'reobfJar'
@@ -202,11 +194,9 @@ tasks.jarJar.finalizedBy('reobfJarJar')
202194
publishing {
203195
publications {
204196
mavenJava(MavenPublication) {
205-
artifactId = "FormicAPI" // no spaces or invalid chars
197+
artifactId = "FormicAPI" // no spaces or invalid chars
206198

207199
from components.java
208-
fg.component(it)
209-
jarJar.component(it)
210200
}
211201
}
212202
}

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ mod_id=formicapi
2828
mod_name=Formic API
2929
mod_license=MIT
3030

31-
mod_version=1.6.8
31+
mod_version=1.6.9
3232

3333
create_version = 6.0.6-106
3434
flywheel_version = 1.0.2
@@ -41,4 +41,4 @@ curios_version = 5.2.0-beta.3+1.20.1
4141

4242
mod_group_id=com.rae.formicapi
4343
mod_authors=Real Ant Engineer
44-
mod_description=Example mod description.\nNewline characters can be used and will be replaced properly.
44+
mod_description=Core mod and API used in mods of the Engineer Colony team

src/main/java/com/rae/formicapi/FormicAPI.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package com.rae.formicapi;
22

3+
import com.rae.formicapi.config.FormicAPIConfigs;
34
import com.rae.formicapi.thermal_utilities.FullTableBased;
45
import net.minecraft.resources.ResourceLocation;
56
import net.neoforged.bus.api.IEventBus;
67
import net.neoforged.fml.ModContainer;
8+
import net.neoforged.fml.ModLoadingContext;
79
import net.neoforged.fml.common.Mod;
810
import net.neoforged.neoforge.common.NeoForge;
911
import net.neoforged.neoforge.event.AddReloadListenerEvent;
@@ -17,8 +19,11 @@ public class FormicAPI {
1719

1820
public FormicAPI(IEventBus modEventBus, ModContainer modContainer) {
1921
IEventBus forgeEventBus = NeoForge.EVENT_BUS;
22+
ModLoadingContext modLoadingContext = ModLoadingContext.get();
2023

2124
forgeEventBus.addListener(FormicAPI::onAddReloadListeners);
25+
FormicAPIConfigs.register(modLoadingContext, modContainer);
26+
2227

2328

2429
}

src/main/java/com/rae/formicapi/config/FormicAPIConfigs.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
import java.util.Map;
1616
import java.util.function.Supplier;
1717

18-
// An example config class. This is not required, but it's a good idea to have one to keep your config organized.
19-
// Demonstrates how to use Forge's config APIs
2018
@EventBusSubscriber(bus = EventBusSubscriber.Bus.MOD)
21-
2219
public class FormicAPIConfigs
2320
{
2421
private static final Map<ModConfig.Type, ConfigBase> CONFIGS = new EnumMap<>(ModConfig.Type.class);
@@ -44,7 +41,7 @@ private static <T extends ConfigBase> T register(Supplier<T> factory, ModConfig.
4441
return config;
4542
}
4643

47-
public static void registerConfigs(ModLoadingContext context, ModContainer container) {
44+
public static void register(ModLoadingContext context, ModContainer container) {
4845
CLIENT = register(FormicAPICfgClient::new, ModConfig.Type.CLIENT);
4946
//COMMON = register(CSCfgCommon::new, ModConfig.Type.COMMON);
5047

src/main/java/com/rae/formicapi/multiblock/MBStructureBlock.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
/**
4545
* Structure Block for a MultiBlock, it always as a full hit-box
4646
*/
47+
@NonnullDefault
4748
public class MBStructureBlock extends DirectionalBlock implements IWrenchable, IProxyHoveringInformation {
4849
public MBStructureBlock(Properties properties) {
4950
super(properties);
@@ -57,7 +58,7 @@ protected MapCodec<? extends DirectionalBlock> codec() {
5758

5859
@Override
5960
public VoxelShape getShape(BlockState state, BlockGetter getter, BlockPos pos, CollisionContext context) {
60-
if (!(getter instanceof ClientLevel)) return Shapes.empty();
61+
//if (!(getter instanceof ClientLevel)) return Shapes.empty();
6162
BlockPos masterPos = getMaster(getter, pos);
6263
BlockState masterState = getter.getBlockState(masterPos);
6364
if (masterState.getBlock() instanceof IMBController masterBlock) {
@@ -114,7 +115,7 @@ public InteractionResult onSneakWrenched(BlockState state, UseOnContext context)
114115
return IWrenchable.super.onSneakWrenched(state, context);
115116
}
116117

117-
@NonnullDefault
118+
@Override
118119
public BlockState playerWillDestroy(Level pLevel, BlockPos pPos, BlockState pState, Player pPlayer) {
119120
if (stillValid(pLevel, pPos, pState)) {
120121
BlockPos masterPos = getMaster(pLevel, pPos);
@@ -127,8 +128,7 @@ public BlockState playerWillDestroy(Level pLevel, BlockPos pPos, BlockState pSta
127128
}
128129

129130
@Override
130-
@NonnullDefault
131-
public @NotNull BlockState updateShape(BlockState pState, Direction pFacing, BlockState pFacingState, LevelAccessor pLevel,
131+
public BlockState updateShape(BlockState pState, Direction pFacing, BlockState pFacingState, LevelAccessor pLevel,
132132
BlockPos pCurrentPos, BlockPos pFacingPos) {
133133
if (stillValid(pLevel, pCurrentPos, pState)) {
134134
BlockPos masterPos = getMaster(pLevel, pCurrentPos);
@@ -180,7 +180,6 @@ public static boolean stillValid(BlockGetter level, BlockPos pos, BlockState sta
180180
}
181181

182182
@Override
183-
@NonnullDefault
184183
public void tick(BlockState pState, ServerLevel pLevel, BlockPos pPos, RandomSource pRandom) {
185184
if (!stillValid(pLevel, pPos, pState)) {
186185
pLevel.setBlockAndUpdate(pPos, Blocks.AIR.defaultBlockState());

src/main/java/com/rae/formicapi/thermal_utilities/SpecificRealGazState.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,34 @@
11
package com.rae.formicapi.thermal_utilities;
22

3+
import com.mojang.serialization.Codec;
4+
import com.mojang.serialization.codecs.RecordCodecBuilder;
5+
import io.netty.buffer.ByteBuf;
36
import net.minecraft.nbt.CompoundTag;
7+
import net.minecraft.network.FriendlyByteBuf;
8+
import net.minecraft.network.codec.StreamCodec;
9+
import org.jetbrains.annotations.NotNull;
10+
11+
import java.util.Objects;
412

513
public record SpecificRealGazState(Float temperature, Float pressure, Float specificEnthalpy, Float vaporQuality) {
6-
/*public Codec<SpecificRealGazState> CODEC = RecordCodecBuilder.create(
14+
public static Codec<SpecificRealGazState> CODEC = RecordCodecBuilder.create(i ->
15+
i.group(
16+
Codec.FLOAT.fieldOf("temperature").forGetter(p -> p.temperature),
17+
Codec.FLOAT.fieldOf("pressure").forGetter(p -> p.pressure),
18+
Codec.FLOAT.fieldOf("specific_enthalpy").forGetter(p -> p.specificEnthalpy),
19+
Codec.FLOAT.fieldOf("vapor_quality").forGetter(p -> p.vaporQuality)
20+
)
21+
.apply(i, SpecificRealGazState::new));
722

8-
);*/
23+
public static final StreamCodec<ByteBuf, SpecificRealGazState> STREAM_CODEC = new StreamCodec<>() {
24+
public @NotNull SpecificRealGazState decode(@NotNull ByteBuf buffer) {
25+
return new SpecificRealGazState(Objects.requireNonNull(FriendlyByteBuf.readNbt(buffer)));
26+
}
927

28+
public void encode(@NotNull ByteBuf buffer, SpecificRealGazState state) {
29+
FriendlyByteBuf.writeNbt(buffer, state.serialize());
30+
}
31+
};
1032
public SpecificRealGazState(Float temperature, Float pressure, Float specificEnthalpy, Float vaporQuality){
1133
this.temperature = Math.max(0,temperature);
1234
this.pressure = Math.max(0,pressure);

src/main/resources/META-INF/neoforge.mods.toml renamed to src/main/templates/META-INF/neoforge.mods.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11

22
modLoader="javafml"
33
loaderVersion="[1,)"
4-
license="MIT"
4+
license="${mod_license}"
55

66

77
[[mods]]
8-
modId="formicapi"
9-
version = "1.6.8"
10-
displayName="Formic API"
8+
modId="${mod_id}"
9+
version = "${mod_version}"
10+
displayName="${mod_name}"
1111
logoFile = "logo.png"
1212
credits='''
1313
Source code:
@@ -19,7 +19,7 @@ description='''
1919
Core mod and API used in mods of the Engineer Colony team
2020
'''
2121

22-
[[dependencies.formicapi]]
22+
[[dependencies.${mod_id}]]
2323
modId="create"
2424
mandatory=true
2525
versionRange="[0.6.0.1,)"

0 commit comments

Comments
 (0)