Skip to content

Commit

Permalink
Port to 1.21.3.
Browse files Browse the repository at this point in the history
  • Loading branch information
Crystal-Spider committed Dec 16, 2024
1 parent 9b72707 commit cc5915e
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 44 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Crystal Nest Semantic Versioning](https://crystalne

- Nothing new.

## [v4.0.1] - 2024/12/16

- Ported to 1.21.3.

## [v4.0.1] - 2024/07/30

- 1.21 and above only.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![Nightworld banner](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/nightworld/banner.png)

---
![Minecraft](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/minecraft.svg)[![1.21.1](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-21-1.svg)](https://modrinth.com/mod/nightworld/versions?g=1.21.1)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![1.21](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-21.svg)](https://modrinth.com/mod/nightworld/versions?g=1.21)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![1.20.4](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-20-4.svg)](https://modrinth.com/mod/nightworld/versions?g=1.20.4)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![1.20.2](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-20-2.svg)](https://modrinth.com/mod/nightworld/versions?g=1.20.2)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![1.20.1](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-20-1.svg)](https://modrinth.com/mod/nightworld/versions?g=1.20.1)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![1.19.4](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-19-4.svg)](https://modrinth.com/mod/nightworld/versions?g=1.19.4)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![1.19.2](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-19-2.svg)](https://modrinth.com/mod/nightworld/versions?g=1.19.2)
![Minecraft](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/minecraft.svg)[![1.21.3](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-21-3.svg)](https://modrinth.com/mod/nightworld/versions?g=1.21.3)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![1.21.1](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-21-1.svg)](https://modrinth.com/mod/nightworld/versions?g=1.21.1)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![1.21](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-21.svg)](https://modrinth.com/mod/nightworld/versions?g=1.21)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![1.20.4](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-20-4.svg)](https://modrinth.com/mod/nightworld/versions?g=1.20.4)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![1.20.2](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-20-2.svg)](https://modrinth.com/mod/nightworld/versions?g=1.20.2)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![1.20.1](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-20-1.svg)](https://modrinth.com/mod/nightworld/versions?g=1.20.1)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![1.19.4](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-19-4.svg)](https://modrinth.com/mod/nightworld/versions?g=1.19.4)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![1.19.2](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-19-2.svg)](https://modrinth.com/mod/nightworld/versions?g=1.19.2)

![Loader](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/loader/loader.svg)[![NeoForge](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/loader/neoforge.svg)](https://modrinth.com/mod/nightworld/versions?l=neoforge)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![Forge](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/loader/forge.svg)](https://modrinth.com/mod/nightworld/versions?l=forge)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![Fabric](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/loader/fabric.svg)](https://modrinth.com/mod/nightworld/versions?l=fabric)

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
id "org.sonarqube" version "4.4.1.3373"
id "com.hypherionmc.modutils.modpublisher" version "2.1.4" apply false
id "net.neoforged.moddev" version "0.1.110" apply false
id "fabric-loom" version "1.7-SNAPSHOT" apply false
id "net.neoforged.moddev" version "2.0.49-beta" apply false
id "fabric-loom" version "1.8-SNAPSHOT" apply false
}

sonar {
Expand Down
4 changes: 0 additions & 4 deletions buildSrc/src/main/groovy/multiloader-common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,8 @@ publisher {
switch (loader) {
case "Fabric":
required "fabric-api"
incompatible "immersiveportals"
break
case "NeoForge":
incompatible "immersive-portals-neoforge"
break
}
}
Expand All @@ -233,10 +231,8 @@ publisher {
switch (loader) {
case "Fabric":
required "fabric-api"
incompatible "immersive-portals-mod"
break
case "NeoForge":
incompatible "immersive-portals-for-forge"
break
}
}
Expand Down
4 changes: 2 additions & 2 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ neoForge {
neoFormVersion = neo_form_version
def at = file("src/main/resources/META-INF/accesstransformer.cfg")
if (at.exists()) {
accessTransformers.add(at.absolutePath)
accessTransformers.from(at.absolutePath)
}
parchment {
minecraftVersion = minecraft_version
minecraftVersion = parchment_minecraft
mappingsVersion = parchment_version
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,31 @@
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntitySpawnReason;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.NetherPortalBlock;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.At.Shift;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

/**
* Injects into {@link NetherPortalBlock} to alter Nightworld Portals mob spawn and dimension travel.
*/
@Mixin(NetherPortalBlock.class)
public abstract class NetherPortalBlockMixin {
public abstract class NetherPortalBlockMixin extends Block {
private NetherPortalBlockMixin() {
super(BlockBehaviour.Properties.of());
}

/**
* Injects into the method {@link NetherPortalBlock#randomTick(BlockState, ServerLevel, BlockPos, RandomSource)} before the call to {@link BlockState#isValidSpawn(BlockGetter, BlockPos, EntityType)}.<br />
* Injects into the method {@link NetherPortalBlock#randomTick(BlockState, ServerLevel, BlockPos, RandomSource)} before the call to {@link BlockState#isValidSpawn(BlockGetter, BlockPos, EntityType)}.<br>
* Allows Zombies and Skeletons spawn when it's a Nightworld Portal.
*
* @param state block state.
Expand All @@ -33,14 +39,18 @@ public abstract class NetherPortalBlockMixin {
* @param random random source.
* @param ci {@link CallbackInfo}.
*/
@Inject(method = "randomTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;isValidSpawn(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/entity/EntityType;)Z", shift = Shift.BEFORE))
@SuppressWarnings({"JavadocReference", "StatementWithEmptyBody"})
@Inject(method = "randomTick", at = @At(value = "HEAD"), cancellable = true)
private void onRandomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random, CallbackInfo ci) {
if (CustomPortalChecker.isPortalForDimension(level, pos.above(), Constants.MOD_ID)) {
if (random.nextInt(0, 100) < 50) {
this.handleSpawnEntity(EntityType.ZOMBIE, level, pos);
if (level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && random.nextInt(500) < level.getDifficulty().getId() && CustomPortalChecker.isPortalForDimension(level, pos.above(), Constants.MOD_ID)) {
BlockPos bottom;
for (bottom = pos; level.getBlockState(bottom).is(this); bottom = bottom.below());
if (random.nextInt(0, 10) < 5) {
this.handleSpawnEntity(EntityType.ZOMBIE, level, bottom);
} else {
this.handleSpawnEntity(EntityType.SKELETON, level, pos);
this.handleSpawnEntity(EntityType.SKELETON, level, bottom);
}
ci.cancel();
}
}

Expand All @@ -54,9 +64,15 @@ private void onRandomTick(BlockState state, ServerLevel level, BlockPos pos, Ran
*/
@Unique
private <T extends EntityType<?>> void handleSpawnEntity(T entityType, ServerLevel level, BlockPos pos) {
Entity entity;
if (level.getBlockState(pos).isValidSpawn(level, pos, entityType) && (entity = entityType.spawn(level, pos.above(), MobSpawnType.STRUCTURE)) != null) {
entity.setPortalCooldown();
if (level.getBlockState(pos).isValidSpawn(level, pos, entityType)) {
Entity entity = entityType.spawn(level, pos.above(), EntitySpawnReason.STRUCTURE);
if (entity != null) {
entity.setPortalCooldown();
Entity vehicle = entity.getVehicle();
if (vehicle != null) {
vehicle.setPortalCooldown();
}
}
}
}
}
2 changes: 1 addition & 1 deletion fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies {
minecraft "com.mojang:minecraft:$minecraft_version"
mappings loom.layered {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-$minecraft_version:$parchment_version@zip")
parchment("org.parchmentmc.data:parchment-$parchment_minecraft:$parchment_version@zip")
}
modImplementation "net.fabricmc:fabric-loader:$fabric_loader_version"
modImplementation "net.fabricmc.fabric-api:fabric-api:$fabric_version"
Expand Down
19 changes: 10 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,24 @@ description = Explore a parallel world!
credits =
github_user = crystal-nest
curseforge_id = 865641
minecraft_version = 1.21
minecraft_version = 1.21.3
# https://parchmentmc.org/docs/getting-started#choose-a-version
parchment_version = 2024.06.23
parchment_minecraft = 1.21.3
parchment_version = 2024.12.07
# https://projects.neoforged.net/neoforged/neoform
neo_form_version = 1.21-20240613.152323
neo_form_version = 1.21.3-20241023.131943

# Fabric
fabric_version = 0.100.6+1.21
fabric_loader_version = 0.15.11
fabric_version = 0.110.0+1.21.3
fabric_loader_version = 0.16.9

# NeoForge
neoforge_version = 21.0.59-beta
neoforge_loader_version_range = [21.0,)
neoforge_version = 21.3.50-beta
neoforge_loader_version_range = [21.3,)

# Dependencies
cobweb_version = 1.1.2
server_sided_portals_version = 1.1.0
cobweb_version = 1.3.0
server_sided_portals_version = 1.1.1

# Gradle
org.gradle.jvmargs = -Xmx4G
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
22 changes: 12 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
4 changes: 2 additions & 2 deletions neoforge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ neoForge {
version = neoforge_version
def at = project(':common').file('src/main/resources/META-INF/accesstransformer.cfg')
if (at.exists()) {
accessTransformers.add(at.absolutePath)
accessTransformers.from(at.absolutePath)
}
parchment {
minecraftVersion = minecraft_version
minecraftVersion = parchment_minecraft
mappingsVersion = parchment_version
}
runs {
Expand Down

0 comments on commit cc5915e

Please sign in to comment.