-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Deeper Darker compatibility, closes #132
- Loading branch information
1 parent
e4689a7
commit 462205c
Showing
14 changed files
with
312 additions
and
65 deletions.
There are no files selected for viewing
59 changes: 0 additions & 59 deletions
59
...llusivesoulworks/elytraslot/common/integration/deeperdarker/DeeperDarkerClientModule.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...llusivesoulworks/elytraslot/common/integration/deeperdarker/DeeperDarkerClientPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.illusivesoulworks.elytraslot.common.integration.deeperdarker; | ||
|
||
import com.illusivesoulworks.elytraslot.platform.Services; | ||
import com.kyanite.deeperdarker.DeeperDarker; | ||
import com.kyanite.deeperdarker.client.Keybinds; | ||
import com.kyanite.deeperdarker.content.DDItems; | ||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; | ||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; | ||
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; | ||
import net.minecraft.ChatFormatting; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.network.chat.Style; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.util.Mth; | ||
import net.minecraft.world.item.ItemStack; | ||
|
||
public class DeeperDarkerClientPlugin { | ||
|
||
public static void setup() { | ||
ClientTickEvents.START_WORLD_TICK.register(world -> { | ||
Minecraft client = Minecraft.getInstance(); | ||
|
||
if (client.player == null) { | ||
return; | ||
} | ||
ItemStack itemStack = Services.ELYTRA.getEquipped(client.player); | ||
|
||
if (itemStack.is(DDItems.SOUL_ELYTRA) && client.player.getCooldowns() | ||
.getCooldownPercent(DDItems.SOUL_ELYTRA, | ||
(float) (Minecraft.getInstance().getFrameTimeNs() / 1000000000.0)) == 0 && | ||
client.player.isFallFlying() && Keybinds.BOOST.isDown()) { | ||
ClientPlayNetworking.send(SoulElytraBoostPayload.INSTANCE); | ||
} | ||
}); | ||
HudRenderCallback.EVENT.register((drawContext, tickDelta) -> { | ||
ResourceLocation texture = DeeperDarker.rl("textures/gui/soul_elytra_overlay_large.png"); | ||
Minecraft client = Minecraft.getInstance(); | ||
|
||
if (client.player == null || DeeperDarker.CONFIG.server.soulElytraCooldown() == -1) { | ||
return; | ||
} | ||
ItemStack itemStack = Services.ELYTRA.getEquipped(client.player); | ||
|
||
if (itemStack.is(DDItems.SOUL_ELYTRA)) { | ||
float f = client.player.getCooldowns().getCooldownPercent(DDItems.SOUL_ELYTRA, | ||
(float) (Minecraft.getInstance().getFrameTimeNs() / 1000000000.0)); | ||
drawContext.blit(texture, 5, client.getWindow().getGuiScaledHeight() - 37, 0, 0, 0, 12, | ||
Mth.floor(32 * f), 32, 32); | ||
drawContext.blit(texture, 5, | ||
client.getWindow().getGuiScaledHeight() - 37 + Mth.floor(32 * f), 0, 12, | ||
Mth.floor(32 * f), 12, Mth.ceil(32 * (1.0f - f)), 32, 32); | ||
|
||
if (f == 0.0f && client.player.isFallFlying()) { | ||
|
||
for (BlockPos blockPos : BlockPos.betweenClosed(client.player.getOnPos(), | ||
client.player.getOnPos().below(5))) { | ||
|
||
if (client.player.level().getBlockState(blockPos).isAir()) { | ||
continue; | ||
} | ||
drawContext.drawString(client.font, | ||
Component.translatable(DDItems.SOUL_ELYTRA.getDescriptionId() + ".boost", | ||
Keybinds.BOOST.getTranslatedKeyMessage()) | ||
.setStyle(Style.EMPTY.withColor(ChatFormatting.YELLOW)), 20, | ||
client.getWindow().getGuiScaledHeight() - 37, 0); | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
.../com/illusivesoulworks/elytraslot/common/integration/deeperdarker/DeeperDarkerPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.illusivesoulworks.elytraslot.common.integration.deeperdarker; | ||
|
||
import com.illusivesoulworks.elytraslot.platform.Services; | ||
import com.kyanite.deeperdarker.DeeperDarker; | ||
import com.kyanite.deeperdarker.content.DDItems; | ||
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; | ||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; | ||
import net.minecraft.ChatFormatting; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.network.chat.Style; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.entity.projectile.FireworkRocketEntity; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.Items; | ||
import net.minecraft.world.level.Level; | ||
|
||
public class DeeperDarkerPlugin { | ||
|
||
public static void setup() { | ||
registerPayloads(); | ||
} | ||
|
||
public static void registerPayloads() { | ||
PayloadTypeRegistry.playC2S() | ||
.register(SoulElytraBoostPayload.TYPE, SoulElytraBoostPayload.CODEC); | ||
ServerPlayNetworking.registerGlobalReceiver(SoulElytraBoostPayload.TYPE, (payload, ctx) -> { | ||
ServerPlayer player = ctx.player(); | ||
Level level = player.level(); | ||
|
||
if (DeeperDarker.CONFIG.server.soulElytraCooldown() == -1) { | ||
player.displayClientMessage( | ||
Component.translatable(DDItems.SOUL_ELYTRA.getDescriptionId() + ".boost_disabled") | ||
.setStyle(Style.EMPTY.withColor(ChatFormatting.RED)), true); | ||
return; | ||
} | ||
|
||
if (player.isFallFlying() && Services.ELYTRA.getEquipped(player).is(DDItems.SOUL_ELYTRA) && | ||
!player.getCooldowns().isOnCooldown(DDItems.SOUL_ELYTRA) && | ||
DeeperDarker.CONFIG.server.soulElytraCooldown() != -1) { | ||
FireworkRocketEntity rocket = | ||
new FireworkRocketEntity(level, new ItemStack(Items.FIREWORK_ROCKET), player); | ||
level.addFreshEntity(rocket); | ||
player.getCooldowns() | ||
.addCooldown(DDItems.SOUL_ELYTRA, DeeperDarker.CONFIG.server.soulElytraCooldown()); | ||
} | ||
}); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
.../illusivesoulworks/elytraslot/common/integration/deeperdarker/SoulElytraBoostPayload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.illusivesoulworks.elytraslot.common.integration.deeperdarker; | ||
|
||
import com.illusivesoulworks.elytraslot.ElytraSlotConstants; | ||
import javax.annotation.Nonnull; | ||
import net.minecraft.network.RegistryFriendlyByteBuf; | ||
import net.minecraft.network.codec.StreamCodec; | ||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload; | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
public record SoulElytraBoostPayload() implements CustomPacketPayload { | ||
|
||
public static final CustomPacketPayload.Type<SoulElytraBoostPayload> TYPE = | ||
new CustomPacketPayload.Type<>( | ||
ResourceLocation.fromNamespaceAndPath(ElytraSlotConstants.MOD_ID, "soul_elytra_boost")); | ||
public static final SoulElytraBoostPayload INSTANCE = new SoulElytraBoostPayload(); | ||
public static final StreamCodec<RegistryFriendlyByteBuf, SoulElytraBoostPayload> CODEC = | ||
StreamCodec.unit(INSTANCE); | ||
|
||
@Override | ||
@Nonnull | ||
public Type<? extends CustomPacketPayload> type() { | ||
return TYPE; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...llusivesoulworks/elytraslot/common/integration/deeperdarker/DeeperDarkerClientPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.illusivesoulworks.elytraslot.common.integration.deeperdarker; | ||
|
||
import com.kyanite.deeperdarker.client.Keybinds; | ||
import net.neoforged.bus.api.EventPriority; | ||
import net.neoforged.neoforge.client.event.InputEvent; | ||
import net.neoforged.neoforge.common.NeoForge; | ||
import net.neoforged.neoforge.network.PacketDistributor; | ||
|
||
public class DeeperDarkerClientPlugin { | ||
|
||
public static void setup() { | ||
NeoForge.EVENT_BUS.addListener(EventPriority.LOW, DeeperDarkerClientPlugin::keyInput); | ||
} | ||
|
||
private static void keyInput(final InputEvent.Key evt) { | ||
|
||
if (evt.getKey() == Keybinds.BOOST.getKey().getValue()) { | ||
PacketDistributor.sendToServer(new SoulElytraBoostPayload(true)); | ||
} | ||
} | ||
} |
Oops, something went wrong.