Skip to content

Commit

Permalink
better 1.18.2 port
Browse files Browse the repository at this point in the history
  • Loading branch information
HollowHorizon committed Feb 6, 2024
1 parent 8146580 commit 09d719f
Show file tree
Hide file tree
Showing 58 changed files with 482 additions and 1,003 deletions.
17 changes: 6 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,12 @@ dependencies {
implementation("thedarkcolour:kotlinforforge:$kffVersion")
implementation(fg.deobf("ru.hollowhorizon:kotlinscript:${ksffVersion}"))
implementation(fg.deobf("ru.hollowhorizon:hc:${mcVersion}-${hcVersion}"))
implementation(fg.deobf("curse.maven:ftb-teams-forge-404468:4611938"))
implementation(fg.deobf("curse.maven:ftb-library-forge-404465:4661834"))
implementation(fg.deobf("curse.maven:architectury-api-419699:4555749"))
implementation(fg.deobf("curse.maven:jei-238222:4712866"))
implementation(fg.deobf("curse.maven:wthit-forge-455982:4819215"))
implementation(fg.deobf("curse.maven:badpackets-615134:4784364"))
implementation(fg.deobf("curse.maven:embeddium-908741:4984830"))
implementation(fg.deobf("curse.maven:oculus-581495:4763262"))
implementation(fg.deobf("curse.maven:spark-361579:4505309"))
implementation(fg.deobf("curse.maven:item-filters-309674:4553326"))
implementation(fg.deobf("curse.maven:ftb-quests-forge-289412:5060506"))
implementation(fg.deobf("curse.maven:ftb-teams-forge-404468:4579981"))
implementation(fg.deobf("curse.maven:ftb-library-forge-404465:4396792"))
implementation(fg.deobf("curse.maven:architectury-api-419699:4521465"))
implementation(fg.deobf("curse.maven:jei-238222:4593548"))
implementation(fg.deobf("curse.maven:item-filters-309674:4553322"))
implementation(fg.deobf("curse.maven:ftb-quests-forge-289412:4760361"))

implementation(kotlin("script-runtime"))
implementation(kotlin("scripting-jvm-host"))
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

mcVersion=1.19.2
forgeVersion=43.3.7
modVersion=1.3.5
mappingsVersion=2022.11.27
mcVersion=1.18.2
modVersion=1.3.4
mappingsVersion=2022.11.06
hcVersion=1.4.1
forgeVersion=40.2.17
kffVersion=3.12.0
ksffVersion=1.0
Binary file modified hc/firstperson-2.3.2.jar
Binary file not shown.
Binary file added hc/hc-1.18.2-1.4.1.jar
Binary file not shown.
10 changes: 2 additions & 8 deletions src/main/java/ru/hollowhorizon/hollowengine/HollowEngine.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ru.hollowhorizon.hollowengine

import net.minecraft.network.chat.Component
import net.minecraft.network.chat.TranslatableComponent
import net.minecraft.server.packs.metadata.pack.PackMetadataSection
import net.minecraft.server.packs.repository.Pack
import net.minecraft.server.packs.repository.PackSource
Expand Down Expand Up @@ -34,9 +35,6 @@ import ru.hollowhorizon.hollowengine.common.files.DirectoryManager
import ru.hollowhorizon.hollowengine.common.files.DirectoryManager.getModScripts
import ru.hollowhorizon.hollowengine.common.network.NetworkHandler
import ru.hollowhorizon.hollowengine.common.recipes.RecipeReloadListener
import ru.hollowhorizon.hollowengine.common.registry.worldgen.structures.ModStructurePieces
import ru.hollowhorizon.hollowengine.common.registry.worldgen.structures.ModStructureSets
import ru.hollowhorizon.hollowengine.common.registry.worldgen.structures.ModStructures
import ru.hollowhorizon.hollowengine.common.scripting.mod.runModScript
import thedarkcolour.kotlinforforge.forge.MOD_BUS

Expand Down Expand Up @@ -73,10 +71,6 @@ class HollowEngine {

MOD_BUS.addListener(this::registerPacks)

ModStructures.STRUCTURES.register(MOD_BUS)
ModStructures.STRUCTURE_TYPES.register(MOD_BUS)
ModStructureSets.STRUCTURE_SETS.register(MOD_BUS)
ModStructurePieces.STRUCTURE_PIECES.register(MOD_BUS)
RegistryLoader.registerAll()
//ModDimensions
}
Expand All @@ -86,7 +80,7 @@ class HollowEngine {
adder.accept(
creator.create(
HollowStoryPack.name, HollowStoryPack.name.mcText, true, { HollowStoryPack },
PackMetadataSection(Component.translatable("fml.resources.modresources"), 9),
PackMetadataSection(TranslatableComponent("fml.resources.modresources"), 9),
Pack.Position.TOP, PackSource.BUILT_IN, false
)
)
Expand Down
33 changes: 12 additions & 21 deletions src/main/java/ru/hollowhorizon/hollowengine/client/ClientEvents.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@ import com.mojang.blaze3d.platform.InputConstants
import net.minecraft.client.KeyMapping
import net.minecraft.client.Minecraft
import net.minecraft.network.chat.Component
import net.minecraft.world.effect.MobEffectInstance
import net.minecraft.world.effect.MobEffects
import net.minecraft.world.food.FoodProperties
import net.minecraft.world.item.Item
import net.minecraftforge.client.ClientRegistry
import net.minecraftforge.client.event.InputEvent
import net.minecraftforge.client.event.RegisterKeyMappingsEvent
import net.minecraftforge.client.event.RenderGuiOverlayEvent
import net.minecraftforge.client.event.RenderGameOverlayEvent
import net.minecraftforge.client.event.RenderPlayerEvent
import net.minecraftforge.client.gui.overlay.VanillaGuiOverlay
import net.minecraftforge.client.gui.ForgeIngameGui
import net.minecraftforge.event.entity.player.ItemTooltipEvent
import net.minecraftforge.fml.ModList
import net.minecraftforge.fml.loading.moddiscovery.ModInfo
import net.minecraftforge.registries.DeferredRegister
import net.minecraftforge.registries.ForgeRegistries
import org.lwjgl.glfw.GLFW
import ru.hollowhorizon.hc.client.models.gltf.manager.AnimatedEntityCapability
import ru.hollowhorizon.hc.client.utils.get
Expand All @@ -33,10 +28,8 @@ import ru.hollowhorizon.hollowengine.client.screen.recording.StartRecordingScree
import ru.hollowhorizon.hollowengine.common.network.KeybindPacket
import ru.hollowhorizon.hollowengine.common.network.MouseButton
import ru.hollowhorizon.hollowengine.common.network.MouseClickedPacket
import ru.hollowhorizon.hollowengine.common.tabs.HOLLOWENGINE_TAB
import ru.hollowhorizon.hollowengine.common.util.Keybind
import ru.hollowhorizon.hollowengine.cutscenes.replay.PauseRecordingPacket
import thedarkcolour.kotlinforforge.forge.MOD_BUS

object ClientEvents {
const val HE_CATEGORY = "key.categories.hollowengine.keys"
Expand Down Expand Up @@ -81,14 +74,14 @@ object ClientEvents {
}

@JvmStatic
fun renderOverlay(event: RenderGuiOverlayEvent.Post) {
if (event.overlay != VanillaGuiOverlay.HOTBAR.type()) return
fun renderOverlay(event: RenderGameOverlayEvent.Post) {
if (event.type != ForgeIngameGui.HOTBAR_ELEMENT) return

val window = event.window
val width = window.guiScaledWidth
val height = window.guiScaledHeight
MouseOverlay.draw(event.poseStack, width / 2, height / 2 + 16, event.partialTick)
RecordingDriver.draw(event.poseStack, 10, 10, event.partialTick)
MouseOverlay.draw(event.matrixStack, width / 2, height / 2 + 16, event.partialTicks)
RecordingDriver.draw(event.matrixStack, 10, 10, event.partialTicks)
}

@JvmStatic
Expand All @@ -99,7 +92,7 @@ object ClientEvents {
}

@JvmStatic
fun onClicked(event: InputEvent.MouseButton.Pre) {
fun onClicked(event: InputEvent.MouseInputEvent) {
if (event.action != 1) return

if (event.button > 2) return
Expand All @@ -109,7 +102,7 @@ object ClientEvents {
}

@JvmStatic
fun onKeyPressed(event: InputEvent.Key) {
fun onKeyPressed(event: InputEvent.KeyInputEvent) {
val key = InputConstants.getKey(
event.key,
event.scanCode
Expand All @@ -123,7 +116,7 @@ object ClientEvents {

if (TOGGLE_RECORDING.isActiveAndMatches(key) && event.action == 0) {
val player = Minecraft.getInstance().player ?: return
if (!player.hasPermissions(2)) player.sendSystemMessage("hollowengine.no_permissions".mcTranslate)
if (!player.hasPermissions(2)) player.sendMessage("hollowengine.no_permissions".mcTranslate, player.uuid)
else {
if (RecordingDriver.enable || player[AnimatedEntityCapability::class].model != "%NO_MODEL%") {
RecordingDriver.enable = false
Expand All @@ -142,9 +135,7 @@ object ClientEvents {
}

fun initKeys() {
MOD_BUS.addListener { event: RegisterKeyMappingsEvent ->
event.register(OPEN_EVENT_LIST)
event.register(TOGGLE_RECORDING)
}
ClientRegistry.registerKeyBinding(OPEN_EVENT_LIST)
ClientRegistry.registerKeyBinding(TOGGLE_RECORDING)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import net.minecraft.client.Minecraft
import net.minecraft.client.renderer.GameRenderer
import net.minecraft.client.renderer.RenderType
import net.minecraft.world.entity.player.Player
import net.minecraftforge.client.event.EntityViewRenderEvent.CameraSetup
import net.minecraftforge.client.event.InputEvent
import net.minecraftforge.client.event.RenderLevelStageEvent
import net.minecraftforge.client.event.ViewportEvent.ComputeCameraAngles
import net.minecraftforge.eventbus.api.SubscribeEvent
import ru.hollowhorizon.hc.client.math.Spline3D
import ru.hollowhorizon.hc.client.utils.math.Interpolation
Expand Down Expand Up @@ -74,7 +74,7 @@ object CameraHandler {
}

@SubscribeEvent
fun onClicked(event: InputEvent.MouseButton.Post) {
fun onClicked(event: InputEvent.MouseInputEvent) {
val player = mc.player ?: return
if (player.mainHandItem.item != ModItems.CAMERA.get() || event.action != 0) return

Expand All @@ -100,7 +100,7 @@ object CameraHandler {
}

@SubscribeEvent
fun onKeyPressed(event: InputEvent.Key) {
fun onKeyPressed(event: InputEvent.KeyInputEvent) {
if (mc.player?.mainHandItem?.item != ModItems.CAMERA.get()) return

val key = Keybind.fromCode(event.key)
Expand All @@ -113,7 +113,7 @@ object CameraHandler {
}

@SubscribeEvent
fun onComputeAngles(event: ComputeCameraAngles) {
fun onComputeAngles(event: CameraSetup) {
if (mc.player?.mainHandItem?.item != ModItems.CAMERA.get()) return
event.roll = zRot
}
Expand All @@ -123,8 +123,8 @@ object CameraHandler {
val x = player.x
val y = player.y + player.eyeHeight
val z = player.z
val xRot = player.getViewXRot(mc.partialTick)
val yRot = player.getViewYRot(mc.partialTick)
val xRot = player.getViewXRot(mc.deltaFrameTime)
val yRot = player.getViewYRot(mc.deltaFrameTime)

points += Point(x, y, z, xRot, yRot, zRot)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ package ru.hollowhorizon.hollowengine.client.camera
import kotlinx.serialization.Serializable
import net.minecraft.client.Minecraft
import net.minecraft.util.Mth
import net.minecraft.util.RandomSource

import net.minecraft.world.entity.player.Player
import net.minecraftforge.client.event.EntityViewRenderEvent.CameraSetup
import net.minecraftforge.client.event.RenderHandEvent
import net.minecraftforge.client.event.ViewportEvent.ComputeCameraAngles

import net.minecraftforge.eventbus.api.SubscribeEvent
import ru.hollowhorizon.hc.HollowCore
import ru.hollowhorizon.hc.client.handlers.ClientTickHandler
import ru.hollowhorizon.hc.client.utils.math.Interpolation
import ru.hollowhorizon.hc.common.network.HollowPacketV2
import ru.hollowhorizon.hc.common.network.HollowPacketV3
import ru.hollowhorizon.hollowengine.mixins.CameraInvoker
import java.util.Random


object ScreenShakeHandler {
Expand All @@ -26,11 +28,11 @@ object ScreenShakeHandler {
}

@SubscribeEvent
fun cameraUpdate(event: ComputeCameraAngles) {
fun cameraUpdate(event: CameraSetup) {
if (!enabled) return
val random = Minecraft.getInstance().player?.random ?: return

val percent = ((ClientTickHandler.ticksNotPaused - startTime + event.partialTick.toFloat()) / config.duration)
val percent = ((ClientTickHandler.ticksNotPaused - startTime + event.partialTicks.toFloat()) / config.duration)
.coerceAtLeast(0f)
.coerceAtMost(1f)

Expand Down Expand Up @@ -65,7 +67,7 @@ object ScreenShakeHandler {
if (!enabled) return
val random = Minecraft.getInstance().player?.random ?: return

val percent = ((ClientTickHandler.ticksNotPaused - startTime + event.partialTick) / config.duration)
val percent = ((ClientTickHandler.ticksNotPaused - startTime + event.partialTicks) / config.duration)
val intensity = config.updateIntensity(percent).coerceAtLeast(0f)

if (config.targets.contains(ShakeTarget.HAND)) {
Expand All @@ -77,7 +79,7 @@ object ScreenShakeHandler {
}
}

fun RandomSource.offset(intensity: Float): Float {
fun Random.offset(intensity: Float): Float {
return Mth.nextFloat(this, -intensity * 2, intensity * 2)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ object PlayerRenderer {

stack.pushPose()

preRender(event.entity, capability, model.animationPlayer, stack)
preRender(event.player, capability, model.animationPlayer, stack)

val lerpBodyRot = Mth.rotLerp(event.partialTick, event.entity.yBodyRotO, event.entity.yBodyRot)
val lerpBodyRot = Mth.rotLerp(event.partialTick, event.player.yBodyRotO, event.player.yBodyRot)
stack.mulPose(Vector3f.YP.rotationDegrees(-lerpBodyRot))

model.visuals = ::drawVisuals

model.update(capability, event.entity.tickCount, event.partialTick)
model.entityUpdate(event.entity, capability, event.partialTick)
model.entityUpdate(event.player, capability, event.partialTick)

model.render(
stack,
ModelData(event.entity.offhandItem, event.entity.mainHandItem, null, event.entity),
ModelData(event.player.offhandItem, event.player.mainHandItem, null, event.player),
{ texture: ResourceLocation ->
val result = capability.textures[texture.path]?.let {
if (it.startsWith("skins/")) SkinDownloader.downloadSkin(it.substring(6))
Expand All @@ -65,7 +65,7 @@ object PlayerRenderer {
Minecraft.getInstance().textureManager.getTexture(result).id
}.memoize(),
event.packedLight,
OverlayTexture.pack(0, if (event.entity.hurtTime > 0 || !event.entity.isAlive) 3 else 10)
OverlayTexture.pack(0, if (event.player.hurtTime > 0 || !event.player.isAlive) 3 else 10)
)
stack.popPose()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import net.minecraft.client.Minecraft
import net.minecraft.client.gui.screens.inventory.InventoryScreen
import net.minecraft.network.chat.Component
import net.minecraft.network.chat.Style
import net.minecraft.network.chat.TextComponent
import ru.hollowhorizon.hc.client.screens.HollowScreen
import ru.hollowhorizon.hc.client.screens.util.Alignment
import ru.hollowhorizon.hc.client.screens.util.WidgetPlacement
Expand Down Expand Up @@ -85,7 +86,7 @@ object ChoiceScreen : HollowScreen() {
)

font.drawShadow(
stack, Component.literal(text.string).apply {
stack, TextComponent(text.string).apply {
if (isHovered) style = Style.EMPTY.withUnderlined(true)
},
0f, 0f,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
Expand Down Expand Up @@ -37,25 +38,25 @@ protected void init() {
int halfWidth = this.width / 2;

ArrayList<ListElement> elements = new ArrayList<>();
elements.add(new ListElement(new ResourceLocation(MODID, "public"), Component.translatable("hollowengine.npc_creation.public"), new ResourceLocation(MODID, "textures/gui/planet.png")));
elements.add(new ListElement(new ResourceLocation(MODID, "private"), Component.translatable("hollowengine.npc_creation.private"), new ResourceLocation(MODID, "textures/gui/private.png")));
elements.add(new ListElement(new ResourceLocation(MODID, "companion"), Component.translatable("hollowengine.npc_creation.companion"), new ResourceLocation(MODID, "textures/gui/heart.png")));
elements.add(new ListElement(new ResourceLocation(MODID, "public"), new TranslatableComponent("hollowengine.npc_creation.public"), new ResourceLocation(MODID, "textures/gui/planet.png")));
elements.add(new ListElement(new ResourceLocation(MODID, "private"), new TranslatableComponent("hollowengine.npc_creation.private"), new ResourceLocation(MODID, "textures/gui/private.png")));
elements.add(new ListElement(new ResourceLocation(MODID, "companion"), new TranslatableComponent("hollowengine.npc_creation.companion"), new ResourceLocation(MODID, "textures/gui/heart.png")));

this.addRenderableWidget(new SliderWidget(halfWidth + 100, startY + 60, 50, 20, this::setShouldDespawn));
this.addRenderableWidget(new SliderWidget(halfWidth + 100, startY + 80, 50, 20, this::setUndead));
this.addRenderableWidget(new SizedButton(halfWidth - 150, startY + 40, 300, 20, Component.translatable("hollowengine.npc_creation.model"), button -> Minecraft.getInstance().setScreen(new NPCModelChoicerScreen(this)), GUIHelper.TEXT_FIELD, GUIHelper.TEXT_FIELD_LIGHT));
this.addRenderableWidget(new SizedButton(halfWidth - 150, startY + 40, 300, 20, new TranslatableComponent("hollowengine.npc_creation.model"), button -> Minecraft.getInstance().setScreen(new NPCModelChoicerScreen(this)), GUIHelper.TEXT_FIELD, GUIHelper.TEXT_FIELD_LIGHT));

this.list = new DropListWidget(Component.translatable("hollowengine.npc_creation.choice_type"), elements, (element -> System.out.println(element.getTextComponent().getString())), halfWidth - 150, startY + 20, 300, 20);
this.list = new DropListWidget(new TranslatableComponent("hollowengine.npc_creation.choice_type"), elements, (element -> System.out.println(element.getTextComponent().getString())), halfWidth - 150, startY + 20, 300, 20);
}

@Override
public void render(PoseStack stack, int p_230430_2_, int p_230430_3_, float p_230430_4_) {
this.renderBackground(stack);
int halfWidth = this.width / 2;

GUIHelper.drawTextInBox(stack, Component.translatable("hollowengine.npc_creation"), halfWidth - 150, startY, 300);
GUIHelper.drawTextInBox(stack, Component.translatable("hollowengine.npc_creation.undead"), halfWidth - 150, startY + 60, 250);
GUIHelper.drawTextInBox(stack, Component.translatable("hollowengine.npc_creation.despawn"), halfWidth - 150, startY + 80, 250);
GUIHelper.drawTextInBox(stack, new TranslatableComponent("hollowengine.npc_creation"), halfWidth - 150, startY, 300);
GUIHelper.drawTextInBox(stack, new TranslatableComponent("hollowengine.npc_creation.undead"), halfWidth - 150, startY + 60, 250);
GUIHelper.drawTextInBox(stack, new TranslatableComponent("hollowengine.npc_creation.despawn"), halfWidth - 150, startY + 80, 250);

super.render(stack, p_230430_2_, p_230430_3_, p_230430_4_);

Expand Down
Loading

0 comments on commit 09d719f

Please sign in to comment.