Skip to content

Commit

Permalink
feat: Update to Minecraft 1.21.2
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Oct 10, 2024
1 parent 59c561b commit 76b7ebb
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 37 deletions.
4 changes: 1 addition & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
- Reduced default rescueDistance to 3 instead of 5
- Require Line of Sight for rescuing to initiate
- Require the player to be looking towards the downed player for rescuing to initiate
- Updated to Minecraft 1.21.2
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.damagesource.DamageType;
import net.minecraft.world.effect.MobEffectInstance;
Expand All @@ -37,7 +38,7 @@ public HardcoreRevivalData getRevivalData(Player player) {
return provider != null ? provider : InvalidHardcoreRevivalData.INSTANCE;
}

public void knockout(Player player, DamageSource source) {
public void knockout(ServerPlayer player, DamageSource source) {
HardcoreRevivalData revivalData = getRevivalData(player);
if (revivalData.isKnockedOut()) {
return;
Expand Down Expand Up @@ -72,7 +73,7 @@ public void knockout(Player player, DamageSource source) {
Balm.getEvents().fireEvent(new PlayerKnockedOutEvent(player, source));

// If enabled, show a death message
if (player.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES)) {
if (player.serverLevel().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES)) {
MinecraftServer server = player.getServer();
if (server != null) {
Team team = player.getTeam();
Expand Down Expand Up @@ -111,7 +112,7 @@ public void wakeup(Player player, boolean applyEffects) {
String[] parts = effectString.split("\\|");
ResourceLocation registryName = ResourceLocation.tryParse(parts[0]);
if (registryName != null) {
final var holder = BuiltInRegistries.MOB_EFFECT.getHolder(registryName);
final var holder = BuiltInRegistries.MOB_EFFECT.get(registryName);
if (holder.isPresent()) {
int duration = tryParseInt(parts.length >= 2 ? parts[1] : null, 600);
int amplifier = tryParseInt(parts.length >= 3 ? parts[2] : null, 0);
Expand Down Expand Up @@ -179,8 +180,8 @@ public void notRescuedInTime(Player player) {
accessor.setSpawnInvulnerableTime(0);
}

final var damageTypes = player.level().registryAccess().registryOrThrow(Registries.DAMAGE_TYPE);
final var damageSource = new DamageSource(damageTypes.getHolderOrThrow(NOT_RESCUED_IN_TIME));
final var damageTypes = player.level().registryAccess().lookupOrThrow(Registries.DAMAGE_TYPE);
final var damageSource = new DamageSource(damageTypes.getOrThrow(NOT_RESCUED_IN_TIME));
final var revivalData = getRevivalData(player);
revivalData.setLastKnockoutTicksPassed(0);
reset(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@

import net.blay09.mods.hardcorerevival.api.InternalMethods;
import net.blay09.mods.hardcorerevival.config.HardcoreRevivalConfig;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.player.Player;

public class InternalMethodsImpl implements InternalMethods {
@Override
public void knockout(Player player, DamageSource damageSource) {
public void knockout(ServerPlayer player, DamageSource damageSource) {
HardcoreRevival.getManager().knockout(player, damageSource);
}

@Override
public void wakeup(Player player, boolean applyEffects) {
public void wakeup(ServerPlayer player, boolean applyEffects) {
HardcoreRevival.getManager().wakeup(player, applyEffects);
}

@Override
public boolean isKnockedOut(Player player) {
public boolean isKnockedOut(ServerPlayer player) {
return HardcoreRevival.getManager().isKnockedOut(player);
}

@Override
public int getKnockoutTicksPassed(Player player) {
public int getKnockoutTicksPassed(ServerPlayer player) {
return HardcoreRevival.getManager().getRevivalData(player).getKnockoutTicksPassed();
}

@Override
public int getKnockoutTicksLeft(Player player) {
public int getKnockoutTicksLeft(ServerPlayer player) {
final var maxTicksUntilDeath = HardcoreRevivalConfig.getActive().secondsUntilDeath * 20;
return Math.max(0, maxTicksUntilDeath - getKnockoutTicksPassed(player));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.blay09.mods.hardcorerevival.api;

import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.player.Player;

import java.lang.reflect.InvocationTargetException;

Expand All @@ -18,23 +18,23 @@ private static InternalMethods loadInternalMethods() {
}
}

public static void knockout(Player player, DamageSource damageSource) {
public static void knockout(ServerPlayer player, DamageSource damageSource) {
internalMethods.knockout(player, damageSource);
}

public static void wakeup(Player player, boolean applyEffects) {
public static void wakeup(ServerPlayer player, boolean applyEffects) {
internalMethods.wakeup(player, applyEffects);
}

public static boolean isKnockedOut(Player player) {
public static boolean isKnockedOut(ServerPlayer player) {
return internalMethods.isKnockedOut(player);
}

public static int getKnockoutTicksPassed(Player player) {
public static int getKnockoutTicksPassed(ServerPlayer player) {
return internalMethods.getKnockoutTicksPassed(player);
}

public static int getKnockoutTicksLeft(Player player) {
public static int getKnockoutTicksLeft(ServerPlayer player) {
return internalMethods.getKnockoutTicksLeft(player);
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package net.blay09.mods.hardcorerevival.api;

import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.player.Player;

public interface InternalMethods {
void knockout(Player player, DamageSource damageSource);
void knockout(ServerPlayer player, DamageSource damageSource);

void wakeup(Player player, boolean applyEffects);
void wakeup(ServerPlayer player, boolean applyEffects);

boolean isKnockedOut(Player player);
boolean isKnockedOut(ServerPlayer player);

int getKnockoutTicksPassed(Player player);
int getKnockoutTicksPassed(ServerPlayer player);

int getKnockoutTicksLeft(Player player);
int getKnockoutTicksLeft(ServerPlayer player);
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private static boolean isKnockoutEnabledFor(ServerPlayer player, DamageSource da
}

boolean canDamageSourceKnockout = !damageSource.is(DamageTypes.FELL_OUT_OF_WORLD) && !damageSource.is(HardcoreRevivalManager.NOT_RESCUED_IN_TIME);
final var damageSourceId = player.getServer().registryAccess().registryOrThrow(Registries.DAMAGE_TYPE).getKey(damageSource.type());
final var damageSourceId = player.getServer().registryAccess().lookupOrThrow(Registries.DAMAGE_TYPE).getKey(damageSource.type());
if (!canDamageSourceKnockout || HardcoreRevivalConfig.getActive().instantDeathSources.contains(damageSourceId)) {
return false;
}
Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod_id = hardcorerevival
mod_name = Hardcore Revival
mod_main=HardcoreRevival
description=Help your friends back up after they die (if you can make it in time).
version = 21.1.1
version = 21.2.0
group = net.blay09.mods
homepage=https://mods.twelveiterations.com/mc/hardcore-revival
sources=https://github.com/TwelveIterationMods/HardcoreRevival
Expand All @@ -18,16 +18,16 @@ modrinth_release_type = release
modrinth_project_id = HqKoXaXz

# Minecraft
minecraft_version = 1.21.1
minecraft_version = 1.21.2-pre1
minimum_minecraft_version = 1.21
minecraft_versions = 1.21,1.21.1
minecraft_versions = 1.21,1.21.1,1.21.2-pre1
minecraft_version_range = [1.21,)
pack_format_number = 18
java_version = 21

# Balm
balm_version = 21.0.14-SNAPSHOT
balm_version_range = [21.0.0,)
balm_version = 21.2.1-SNAPSHOT
balm_version_range = [21.2.0,)

# Forge
forge_version = 52.0.2
Expand All @@ -40,8 +40,8 @@ neoforge_version_range = [21-beta,)
neoforge_loader_version_range = [1,)

# Fabric
fabric_version = 0.102.1+1.21.1
fabric_loader_version = 0.15.11
fabric_version = 0.105.3+1.21.2
fabric_loader_version = 0.16.5

# Dependencies
mixin_version=0.8.5
Expand All @@ -53,6 +53,6 @@ org.gradle.daemon=false
mod_author = BlayTheNinth
credits = BlayTheNinth
kuma_version = [21.0,22)
neo_form_version = 1.21.1-20240808.144430
neo_form_version = 1.21.2-pre1-20241008.174159
parchment_minecraft = 1.21
parchment_version = 2024.06.23
19 changes: 19 additions & 0 deletions repositories.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ repositories {
url = 'https://jitpack.io'
content {
includeGroup "com.github.BlueMap-Minecraft"
includeGroup "com.github.mattidragon"
}
}

Expand All @@ -65,4 +66,22 @@ repositories {
includeGroup "de.siphalor"
}
}

maven {
url = "https://dl.cloudsmith.io/public/novamachina-mods/release/maven/"
content {
includeGroup "novamachina.novacore"
includeGroup "novamachina.exnihilosequentia"
}
}

exclusiveContent {
forRepository {
maven {
name = 'Minecraft'
url = 'https://libraries.minecraft.net/'
}
}
filter { includeGroupAndSubgroups("com.mojang") }
}
}
4 changes: 2 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ plugins {

include("common")
include("fabric")
include("neoforge")
include("forge")
//include("neoforge")
//include("forge")

0 comments on commit 76b7ebb

Please sign in to comment.