Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flesh out Warden Posession #672

Open
wants to merge 4 commits into
base: 1.20
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ allprojects {

compileOnly metaLibs.bundles.devAnnotations
}

//Fixes Crash with duplicate QuiltLoader and FAPI
project.configurations.configureEach {
exclude(group: "net.fabricmc", module: "fabric-loader")
exclude(group: "net.fabricmc.fabric-api")
}
}

chenille {
Expand Down Expand Up @@ -183,7 +189,8 @@ dependencies {
// modLocalRuntime compatLibs.biomeMakeover
modCompileOnly (compatLibs.trinkets) { transitive = false }
// modLocalRuntime compatLibs.trinkets
modCompileOnly (compatLibs.pehkui) { transitive = false }
//Doesn't resolve it because Curseforge's Maven times out
//modCompileOnly (compatLibs.pehkui) { transitive = true }
// modApi (compatLibs.pehkui) { transitive = false }

modCompileOnly (compatLibs.snowmercy) { transitive = false }
Expand Down Expand Up @@ -219,6 +226,14 @@ dependencies {

remapJar.dependsOn(project(":requiem-core").tasks.remapJar)

loom {
mods {
"requiem" {
accessWidenerPath = file("src/main/resources/requiem.accesswidener")
}
}
}

jar {
from 'LICENSE-CODE'
from 'LICENSE-ART'
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs = -Xmx4G
org.gradle.parallel=false

# Base properties
mod_version = 2.0.0-beta.17
Expand Down
2 changes: 2 additions & 0 deletions gradle/compat-libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ mobz = { group = "curse.maven", name = "mobz-336554", versi
omegaConfig = { group = "com.github.Draylar.omega-config", name = "omega-config-base", version.ref = "omegaConfig" }
origins = { group = "maven.modrinth", name = "origins", version.ref = "origins" }
patchouli = { group = "vazkii.patchouli", name = "Patchouli", version.ref = "patchouli" }
# The version from Github didn't compile because it couldn't find KanosConfig. According to Jitpack's log, it made a GET request to the Curseforge Maven which was answered with 522: Connection timed out TODO: by:Redfan2: Investigate Pehkui
#pehkui = { module= "maven.modrinth:pehkui", version.ref = "pehkui" }
pehkui = { module= "com.github.Virtuoel:Pehkui", version.ref = "pehkui" }
kano_config = { module= "com.github.Virtuoel:KanosConfig", version.ref = "kano"}
snowmercy = { module = "io.github.ladysnake:Snow-Mercy", version.ref = "snowmercy" }
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
3 changes: 2 additions & 1 deletion requiem-api/src/main/resources/quilt.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"requiem:soul_holder",
"requiem:charged_jump",
"requiem:rift_tracker",
"requiem:dropped_vessel_tracker"
"requiem:dropped_vessel_tracker",
"requiem:warden_sensed"
]
}
2 changes: 2 additions & 0 deletions src/main/java/ladysnake/requiem/client/RequiemClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import ladysnake.requiem.client.particle.CureParticle;
import ladysnake.requiem.client.particle.EntityDustParticle;
import ladysnake.requiem.client.particle.GhostParticle;
import ladysnake.requiem.client.particle.SoundParticle;
import ladysnake.requiem.client.particle.wisp.WispTrailParticle;
import ladysnake.requiem.client.render.block.RunestoneBlockEntityRenderer;
import ladysnake.requiem.client.render.entity.CuredPiglinEntityRenderer;
Expand Down Expand Up @@ -193,6 +194,7 @@ private void registerParticleFactories() {
registry.register(RequiemParticleTypes.OBELISK_SOUL, SoulParticle.Factory::new);
registry.register(RequiemParticleTypes.SOUL_TRAIL, WispTrailParticle.Factory::new);
registry.register(RequiemParticleTypes.PENANCE, SpellParticle.EntityFactory::new);
registry.register(RequiemParticleTypes.SOUND, SoundParticle.Factory::new);
}

private void registerModelPredicates() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.mob.ShulkerEntity;
import net.minecraft.entity.mob.WitchEntity;
import net.minecraft.entity.mob.warden.WardenEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BowItem;
import net.minecraft.item.CrossbowItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import net.minecraft.client.gl.ShaderEffect;
import net.minecraft.entity.Entity;
import net.minecraft.entity.mob.WaterCreatureEntity;
import net.minecraft.entity.mob.warden.WardenEntity;
import net.minecraft.entity.passive.BeeEntity;
import net.minecraft.entity.passive.DolphinEntity;
import net.minecraft.entity.passive.MooshroomEntity;
Expand All @@ -64,6 +65,7 @@ public final class RequiemEntityShaderPicker implements PickEntityShaderCallback
public static final Identifier FISH_EYE_SHADER_ID = shader("fish_eye");

public static final Identifier MOOSHROOM_SHADER_ID = shader("mooshroom");
public static final Identifier WARDEN_SHADER_ID = shader("warden");

public void registerCallbacks() {
PickEntityShaderCallback.EVENT.register(this);
Expand Down Expand Up @@ -91,6 +93,8 @@ public void pickEntityShader(@Nullable Entity camera, Consumer<Identifier> loadS
loadShaderFunc.accept(DOLPHIN_SHADER_ID);
} else if (camera instanceof WaterCreatureEntity) {
loadShaderFunc.accept(FISH_EYE_SHADER_ID);
} else if (camera instanceof WardenEntity) {
loadShaderFunc.accept(WARDEN_SHADER_ID);
}
}
}
Expand Down
191 changes: 191 additions & 0 deletions src/main/java/ladysnake/requiem/client/particle/SoundParticle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
/*
* Requiem
* Copyright (C) 2017-2024 Ladysnake
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses>.
*
* Linking this mod statically or dynamically with other
* modules is making a combined work based on this mod.
* Thus, the terms and conditions of the GNU General Public License cover the whole combination.
*
* In addition, as a special exception, the copyright holders of
* this mod give you permission to combine this mod
* with free software programs or libraries that are released under the GNU LGPL
* and with code included in the standard release of Minecraft under All Rights Reserved (or
* modified versions of such code, with unchanged license).
* You may copy and distribute such a system following the terms of the GNU GPL for this mod
* and the licenses of the other code concerned.
*
* Note that people who make modified versions of this mod are not obligated to grant
* this special exception for their modified versions; it is their choice whether to do so.
* The GNU General Public License gives permission to release a modified version without this exception;
* this exception also makes it possible to release a modified version which carries forward this exception.
*/
package ladysnake.requiem.client.particle;

import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.VertexConsumer;
import ladysnake.requiem.api.v1.possession.PossessionComponent;
import ladysnake.requiem.client.render.RequiemRenderPhases;
import ladysnake.requiem.common.particle.RequiemSoundParticleEffect;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleFactory;
import net.minecraft.client.particle.ParticleTextureSheet;
import net.minecraft.client.particle.SpriteBillboardParticle;
import net.minecraft.client.particle.SpriteProvider;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.Axis;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import org.joml.Quaternionf;
import org.joml.Vector3f;
import org.lwjgl.opengl.GL11;
import org.quiltmc.loader.api.minecraft.ClientOnly;

import java.awt.*;

public class SoundParticle extends SpriteBillboardParticle {
public final SpriteProvider spriteProvider;
private float red;
private float green;
private float blue;
//private final ParticleTextureSheet sheet;
//TODO: by:Redfan2: think about which VertexConsumer to use to not conflict with Darkness fog effect
private static final VertexConsumerProvider.Immediate soundVertexConsumerProvider = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers();
//Tessellator.getInstance().getBufferBuilder()
//Doesnt render: Investigate: VertexConsumerProvider.immediate(new BufferBuilder(RequiemRenderPhases.GHOST_PARTICLE_LAYER.getExpectedBufferSize()));

public SoundParticle(ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ, SpriteProvider spriteProvider, int color) {
super(world, x, y, z, velocityX, velocityY, velocityZ);
this.spriteProvider = spriteProvider;
this.setSpriteForAge(spriteProvider);
//Testing
Color tempColor = Color.BLUE;
this.green = tempColor.getGreen();
//this.sheet=new TextureSheet(spriteProvider);
//Tessellator.getInstance().getBufferBuilder().
this.red = tempColor.getRed();
this.blue = tempColor.getBlue();
this.maxAge = 10;
this.collidesWithWorld = false;
}

@Override
public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float tickDelta) {
if (camera.getFocusedEntity() instanceof PlayerEntity player && player.getComponent(PossessionComponent.KEY).isPossessionOngoing()) {
//TODO Disabled for testing if (player.getComponent(PossessionComponent.KEY).getHost() instanceof WardenEntity) {
VertexConsumer actualConsumer = soundVertexConsumerProvider.getBuffer(RequiemRenderPhases.GHOST_PARTICLE_LAYER);

RenderSystem.disableDepthTest();
RenderSystem.depthFunc(GL11.GL_ALWAYS);


Vec3d vec3d = camera.getPos();
float f = (float) (MathHelper.lerp(tickDelta, this.prevPosX, this.x) - vec3d.getX());
float g = (float) (MathHelper.lerp(tickDelta, this.prevPosY, this.y) - vec3d.getY());
float h = (float) (MathHelper.lerp(tickDelta, this.prevPosZ, this.z) - vec3d.getZ());
Quaternionf quaternion2;
if (this.angle == 0.0F) {
quaternion2 = camera.getRotation();
} else {
quaternion2 = new Quaternionf(camera.getRotation());
float i = MathHelper.lerp(tickDelta, this.prevAngle, this.angle);
hamiltonProduct(quaternion2, Axis.Z_POSITIVE.rotation(i));
}

Vector3f Vec3f = new Vector3f(-1.0F, -1.0F, 0.0F);
Vec3f.rotate(quaternion2);
Vector3f[] Vec3fs = new Vector3f[]{new Vector3f(-1.0F, -1.0F, 0.0F), new Vector3f(-1.0F, 1.0F, 0.0F), new Vector3f(1.0F, 1.0F, 0.0F), new Vector3f(1.0F, -1.0F, 0.0F)};
this.getSize(tickDelta);

for (int k = 0; k < 4; ++k) {
Vector3f Vec3f2 = Vec3fs[k];
Vec3f2.rotate(quaternion2);
Vec3f2.mul((float) new Vec3d(this.x, this.y, this.z).distanceTo(camera.getPos()) / 10f);
Vec3f2.add(f, g, h);
}

float minU = this.getMinU();
float maxU = this.getMaxU();
float minV = this.getMinV();
float maxV = this.getMaxV();
int l = 15728880;
float alpha = 1;

actualConsumer.vertex(Vec3fs[0].x(), Vec3fs[0].y(), Vec3fs[0].z()).uv(maxU, maxV).color(red, green, blue, alpha).light(l).next();
actualConsumer.vertex(Vec3fs[1].x(), Vec3fs[1].y(), Vec3fs[1].z()).uv(maxU, minV).color(red, green, blue, alpha).light(l).next();
actualConsumer.vertex(Vec3fs[2].x(), Vec3fs[2].y(), Vec3fs[2].z()).uv(minU, minV).color(red, green, blue, alpha).light(l).next();
actualConsumer.vertex(Vec3fs[3].x(), Vec3fs[3].y(), Vec3fs[3].z()).uv(minU, maxV).color(red, green, blue, alpha).light(l).next();


soundVertexConsumerProvider.draw();
RenderSystem.enableDepthTest();
RenderSystem.depthFunc(GL11.GL_LEQUAL);
//}
} else {
this.markDead();
}
}

@Override
public ParticleTextureSheet getType() {
return ParticleTextureSheet.CUSTOM;
}

public void tick() {
this.setSpriteForAge(spriteProvider);

if (this.age++ > this.maxAge) {
this.markDead();
}

this.prevPosX = this.x;
this.prevPosY = this.y;
this.prevPosZ = this.z;
}

@ClientOnly
public static class Factory implements ParticleFactory<RequiemSoundParticleEffect> {
private final SpriteProvider factorySpriteProvider;

public Factory(SpriteProvider spriteProvider) {
this.factorySpriteProvider = spriteProvider;
}

@Override
public Particle createParticle(RequiemSoundParticleEffect particleEffect, ClientWorld clientWorld, double d, double e, double f, double g, double h, double i) {
return new SoundParticle(clientWorld, d, e, f, g, h, i, this.factorySpriteProvider, particleEffect.getColor());
}
}

//Stolen using Linkie from Minecraft itself as it doesn't exist on JOML Quaternions
public void hamiltonProduct(Quaternionf first, Quaternionf second) {
float var2 = first.x();
float var3 = first.y();
float var4 = first.z();
float var5 = first.w();
float var6 = second.x();
float var7 = second.y();
float var8 = second.z();
float var9 = second.w();
first.x = var5 * var6 + var2 * var9 + var3 * var8 - var4 * var7;
first.y = var5 * var7 - var2 * var8 + var3 * var9 + var4 * var6;
first.z = var5 * var8 + var2 * var7 - var3 * var6 + var4 * var9;
first.w = var5 * var9 - var2 * var6 - var3 * var7 - var4 * var8;
}
}
2 changes: 2 additions & 0 deletions src/main/java/ladysnake/requiem/common/RequiemComponents.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import ladysnake.requiem.common.entity.cure.SimpleCurableEntityComponent;
import ladysnake.requiem.common.entity.effect.PenanceComponent;
import ladysnake.requiem.common.entity.effect.StatusEffectReapplicatorImpl;
import ladysnake.requiem.common.entity.warden.WardenSensedComponent;
import ladysnake.requiem.common.gamerule.RequiemSyncedGamerules;
import ladysnake.requiem.common.possession.LootingPossessedData;
import ladysnake.requiem.common.remnant.DroppedVesselTracker;
Expand Down Expand Up @@ -123,6 +124,7 @@ public void registerEntityComponentFactories(EntityComponentFactoryRegistry regi
registry.registerFor(HorseBaseEntity.class, ExternalJumpingMount.KEY, e -> new DummyHorseJumpingMount(e, SoundEvents.ENTITY_HORSE_STEP, getPossessor));
registry.registerForPlayers(RiftTracker.KEY, PlayerRiftTracker::new, RespawnCopyStrategy.ALWAYS_COPY);
registry.registerForPlayers(DroppedVesselTracker.KEY, DroppedVesselTracker::new, RespawnCopyStrategy.LOSSLESS_ONLY);
registry.registerForPlayers(WardenSensedComponent.KEY, WardenSensedComponent::new,RespawnCopyStrategy.NEVER_COPY);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Requiem
* Copyright (C) 2017-2024 Ladysnake
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses>.
*
* Linking this mod statically or dynamically with other
* modules is making a combined work based on this mod.
* Thus, the terms and conditions of the GNU General Public License cover the whole combination.
*
* In addition, as a special exception, the copyright holders of
* this mod give you permission to combine this mod
* with free software programs or libraries that are released under the GNU LGPL
* and with code included in the standard release of Minecraft under All Rights Reserved (or
* modified versions of such code, with unchanged license).
* You may copy and distribute such a system following the terms of the GNU GPL for this mod
* and the licenses of the other code concerned.
*
* Note that people who make modified versions of this mod are not obligated to grant
* this special exception for their modified versions; it is their choice whether to do so.
* The GNU General Public License gives permission to release a modified version without this exception;
* this exception also makes it possible to release a modified version which carries forward this exception.
*/
package ladysnake.requiem.common.entity.internal;

import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;

import java.util.Set;

public interface WardenExtension {
Set<Entity> requiem$getVisibleEntities();
Set<PlayerEntity> requiem$getVisiblePlayers();
}
Loading
Loading