1.19.2
This commit is contained in:
parent
4e02f61903
commit
cbe7c959f7
9 changed files with 23 additions and 22 deletions
|
@ -1,5 +1,6 @@
|
|||
package ru.octol1ttle.knockdowns.common;
|
||||
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import ru.octol1ttle.knockdowns.common.api.IKnockableDown;
|
||||
|
@ -25,7 +26,7 @@ public class KnockdownsUtils {
|
|||
public static void hurtTenacity(PlayerEntity player, float damage) {
|
||||
player.setInvulnerable(false);
|
||||
//DamageSource recent = player.getRecentDamageSource();
|
||||
player.damage(/*Objects.requireNonNullElse(recent, */player.getDamageSources().generic()/*)*/, damage);
|
||||
player.damage(/*Objects.requireNonNullElse(recent, */DamageSource.GENERIC/*)*/, damage);
|
||||
player.velocityModified = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ public class KnockdownsClientEvents {
|
|||
}
|
||||
|
||||
private static void registerOnHudRender() {
|
||||
ClientGuiEvent.RENDER_HUD.register((drawContext, tickDelta) -> {
|
||||
ClientGuiEvent.RENDER_HUD.register((matrices, tickDelta) -> {
|
||||
IKnockableDown reviving = (IKnockableDown) KnockdownsClient.reviving;
|
||||
MinecraftClient client = MinecraftClient.getInstance();
|
||||
if (reviving == null) {
|
||||
|
@ -27,17 +27,17 @@ public class KnockdownsClientEvents {
|
|||
TextRenderer renderer = client.textRenderer;
|
||||
|
||||
String timerText = String.format("%.1f", reviving.get_ReviveTimer() / (float) SharedConstants.TICKS_PER_SECOND);
|
||||
int timerX = (drawContext.getScaledWindowWidth() - renderer.getWidth(timerText)) / 2;
|
||||
int timerX = (client.getWindow().getScaledWidth() - renderer.getWidth(timerText)) / 2;
|
||||
|
||||
int reviverCount = reviving.get_ReviverCount();
|
||||
Integer color = reviverCount > 1 ? Formatting.GREEN.getColorValue() : Formatting.WHITE.getColorValue();
|
||||
|
||||
String reviverCountText = "x" + reviverCount;
|
||||
int reviveCountX = (drawContext.getScaledWindowWidth() - renderer.getWidth(reviverCountText)) / 2;
|
||||
int reviveCountX = (client.getWindow().getScaledWidth() - renderer.getWidth(reviverCountText)) / 2;
|
||||
|
||||
if (color != null) {
|
||||
drawContext.drawTextWithShadow(renderer, timerText, timerX, drawContext.getScaledWindowHeight() / 2 + 5, color);
|
||||
drawContext.drawTextWithShadow(renderer, reviverCountText, reviveCountX, drawContext.getScaledWindowHeight() / 2 + 14, color);
|
||||
renderer.drawWithShadow(matrices, timerText, timerX, client.getWindow().getScaledHeight() / 2.0f + 5, color);
|
||||
renderer.drawWithShadow(matrices, reviverCountText, reviveCountX, client.getWindow().getScaledHeight() / 2.0f + 14, color);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public class KnockdownsEvents {
|
|||
knockable.set_ReviveTimer(KnockdownsCommon.REVIVE_WAIT_TIME);
|
||||
knockable.set_KnockedAge(0);
|
||||
|
||||
KnockdownsNetwork.sendToWorld(player.getServerWorld(), new PlayKnockedDownSoundS2CPacket(player.getX(), player.getY(), player.getZ()));
|
||||
KnockdownsNetwork.sendToWorld(player.getWorld(), new PlayKnockedDownSoundS2CPacket(player.getX(), player.getY(), player.getZ()));
|
||||
|
||||
Text deathMessage = entity.getDamageTracker().getDeathMessage();
|
||||
TranslatableTextContent deathContent = (TranslatableTextContent) deathMessage.getContent();
|
||||
|
|
|
@ -3,7 +3,7 @@ package ru.octol1ttle.knockdowns.common.network;
|
|||
import dev.architectury.networking.NetworkChannel;
|
||||
import dev.architectury.networking.NetworkManager;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
|
|
@ -2,15 +2,15 @@ package ru.octol1ttle.knockdowns.common.registries;
|
|||
|
||||
import dev.architectury.registry.registries.DeferredRegister;
|
||||
import dev.architectury.registry.registries.RegistrySupplier;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import ru.octol1ttle.knockdowns.common.KnockdownsCommon;
|
||||
|
||||
public class KnockdownsSoundEvents {
|
||||
private static final DeferredRegister<SoundEvent> SOUND_EVENTS = DeferredRegister.create(KnockdownsCommon.MOD_ID, RegistryKeys.SOUND_EVENT);
|
||||
private static final DeferredRegister<SoundEvent> SOUND_EVENTS = DeferredRegister.create(KnockdownsCommon.MOD_ID, Registry.SOUND_EVENT_KEY);
|
||||
public static final RegistrySupplier<SoundEvent> KNOCKED_DOWN = SOUND_EVENTS.register(KnockdownsCommon.MOD_ID,
|
||||
() -> SoundEvent.of(new Identifier(KnockdownsCommon.MOD_ID, "knocked_down")));
|
||||
() -> new SoundEvent(new Identifier(KnockdownsCommon.MOD_ID, "knocked_down")));
|
||||
|
||||
public static void register() {
|
||||
SOUND_EVENTS.register();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue