Skip to content

Commit

Permalink
projection
Browse files Browse the repository at this point in the history
  • Loading branch information
RadonCoding committed Nov 3, 2023
1 parent 2e73e89 commit cc5f8bb
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 53 deletions.
18 changes: 11 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,28 @@ buildscript {
}

plugins {
id 'java-library'
id 'eclipse'
id 'idea'
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
id 'maven-publish'
id 'net.neoforged.gradle' version '[6.0.18,6.2)'
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
}

apply plugin: 'org.spongepowered.mixin'

group = mod_group_id
version = mod_version
group = mod_group_id

repositories {
mavenLocal()
}

base {
archivesName = mod_id
}

java {
toolchain.languageVersion = JavaLanguageVersion.of(17)
}
java.toolchain.languageVersion = JavaLanguageVersion.of(17)

mixin {
add sourceSets.main, "${mod_id}.refmap.json"
Expand Down Expand Up @@ -101,15 +105,15 @@ repositories {
}

dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
minecraft "net.neoforged:forge:${minecraft_version}-${neo_version}"
implementation fg.deobf("software.bernie.geckolib:geckolib-forge-${minecraft_version}:${geckolib_version}")
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
}

tasks.named('processResources', ProcessResources).configure {
var replaceProperties = [
minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
forge_version: forge_version, forge_version_range: forge_version_range,
neo_version: neo_version, neo_version_range: neo_version_range,
loader_version_range: loader_version_range,
mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
mod_authors: mod_authors, mod_description: mod_description,
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ org.gradle.daemon=false

minecraft_version=1.20.1
minecraft_version_range=[1.20.1,1.21)
forge_version=47.2.1
forge_version_range=[47,)
neo_version=47.1.79
neo_version_range=[47,)
loader_version_range=[47,)

mapping_channel=parchment
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pluginManagement {
repositories {
gradlePluginPortal()
maven { url = 'https://maven.minecraftforge.net/' }
maven { url = 'https://maven.neoforged.net/releases/' }
maven { url = 'https://maven.parchmentmc.org' }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,15 @@ public static void onProjectileImpact(ProjectileImpactEvent event) {
if (!Infinity.canBlock(target, projectile)) return;

if (projectile.getOwner() == target) {
event.setImpactResult(ProjectileImpactEvent.ImpactResult.SKIP_ENTITY);
event.setCanceled(true);
return;
}

if (projectile instanceof JujutsuProjectile) {
projectile.discard();
} else {
data.add(target, projectile);
event.setImpactResult(ProjectileImpactEvent.ImpactResult.SKIP_ENTITY);
event.setCanceled(true);
}
}
}
Expand Down
26 changes: 13 additions & 13 deletions src/main/java/radon/jujutsu_kaisen/ability/misc/Dash.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,6 @@ public void run(LivingEntity owner) {
if (!(owner.level() instanceof ServerLevel level)) return;

Vec3 look = owner.getLookAngle();
Vec3 pos = owner.position().add(0.0D, owner.getBbHeight() / 2.0F, 0.0D);

for (int i = 0; i < 32; i++) {
double theta = HelperMethods.RANDOM.nextDouble() * 2 * Math.PI;
double phi = HelperMethods.RANDOM.nextDouble() * Math.PI;
double r = HelperMethods.RANDOM.nextDouble() * 0.8D;
double x = r * Math.sin(phi) * Math.cos(theta);
double y = r * Math.sin(phi) * Math.sin(theta);
double z = r * Math.cos(phi);
Vec3 speed = look.add(x, y, z).reverse();
Vec3 offset = pos.add(look);
level.sendParticles(ParticleTypes.CLOUD, offset.x(), offset.y(), offset.z(), 0, speed.x(), speed.y(), speed.z(), 1.0D);
}

if (HelperMethods.getLookAtHit(owner, RANGE) instanceof EntityHitResult hit) {
Entity target = hit.getEntity();
Expand All @@ -87,6 +74,19 @@ public void run(LivingEntity owner) {
return;
}

Vec3 pos = owner.position().add(0.0D, owner.getBbHeight() / 2.0F, 0.0D);

for (int i = 0; i < 32; i++) {
double theta = HelperMethods.RANDOM.nextDouble() * 2 * Math.PI;
double phi = HelperMethods.RANDOM.nextDouble() * Math.PI;
double r = HelperMethods.RANDOM.nextDouble() * 0.8D;
double x = r * Math.sin(phi) * Math.cos(theta);
double y = r * Math.sin(phi) * Math.sin(theta);
double z = r * Math.cos(phi);
Vec3 speed = look.add(x, y, z).reverse();
Vec3 offset = pos.add(look);
level.sendParticles(ParticleTypes.CLOUD, offset.x(), offset.y(), offset.z(), 0, speed.x(), speed.y(), speed.z(), 1.0D);
}
owner.level().playSound(null, owner.getX(), owner.getY(), owner.getZ(), JJKSounds.DASH.get(), SoundSource.MASTER, 1.0F, 1.0F);
owner.addEffect(new MobEffectInstance(MobEffects.INVISIBILITY, 5, 0, false, false, false));
level.sendParticles(new MirageParticle.MirageParticleOptions(owner.getId()), owner.getX(), owner.getY(), owner.getZ(),
Expand Down
28 changes: 13 additions & 15 deletions src/main/java/radon/jujutsu_kaisen/ability/misc/WaterWalking.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package radon.jujutsu_kaisen.ability.misc;

import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.ai.navigation.GroundPathNavigation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
Expand Down Expand Up @@ -36,6 +38,17 @@ public void run(LivingEntity owner) {
owner.setDeltaMovement(owner.getDeltaMovement().x(), 0.01D, owner.getDeltaMovement().z());
owner.setOnGround(true);
}

if (owner instanceof Player player) {
float f;

if (owner.onGround() && !owner.isDeadOrDying() && !owner.isSwimming()) {
f = Math.min(0.1F, (float) owner.getDeltaMovement().horizontalDistance());
} else {
f = 0.0F;
}
player.bob += (f - player.bob) * 0.4F;
}
}

@Override
Expand All @@ -57,19 +70,4 @@ public void onDisabled(LivingEntity owner) {
public MenuType getMenuType() {
return MenuType.NONE;
}

@Mod.EventBusSubscriber(modid = JujutsuKaisen.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE)
public static class ForgeEvents {
@SubscribeEvent
public static void onLivingTick(LivingEvent.LivingTickEvent event) {
LivingEntity owner = event.getEntity();

if (JJKAbilities.hasToggled(owner, JJKAbilities.WATER_WALKING.get())) {
if (owner.isInFluidType()) {
Vec3 movement = owner.getDeltaMovement();
owner.setDeltaMovement(movement.x(), 0.1D, movement.z());
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ public void tick(LivingEntity owner) {
if (this.speedStacks > 0) {
this.applyModifier(owner, Attributes.MOVEMENT_SPEED, PROJECTION_SORCERY_MOVEMENT_SPEED_UUID, "Movement speed", this.speedStacks * 2.0D, AttributeModifier.Operation.MULTIPLY_TOTAL);
this.applyModifier(owner, Attributes.ATTACK_SPEED, PROJECTION_ATTACK_SPEED_UUID, "Attack speed", this.speedStacks, AttributeModifier.Operation.MULTIPLY_TOTAL);
this.applyModifier(owner, ForgeMod.STEP_HEIGHT_ADDITION.get(), STEP_HEIGHT_ADDITION_UUID, "Step height addition", 2.0F, AttributeModifier.Operation.ADDITION);
this.applyModifier(owner, ForgeMod.STEP_HEIGHT.get(), STEP_HEIGHT_ADDITION_UUID, "Step height addition", 2.0F, AttributeModifier.Operation.ADDITION);

if (owner.walkDist == owner.walkDistO) {
this.noMotionTime++;
Expand All @@ -462,7 +462,7 @@ public void tick(LivingEntity owner) {
} else {
this.removeModifier(owner, Attributes.MOVEMENT_SPEED, PROJECTION_SORCERY_MOVEMENT_SPEED_UUID);
this.removeModifier(owner, Attributes.ATTACK_SPEED, PROJECTION_ATTACK_SPEED_UUID);
this.removeModifier(owner, ForgeMod.STEP_HEIGHT_ADDITION.get(), STEP_HEIGHT_ADDITION_UUID);
this.removeModifier(owner, ForgeMod.STEP_HEIGHT.get(), STEP_HEIGHT_ADDITION_UUID);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.*;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import radon.jujutsu_kaisen.client.MixinData;
Expand Down Expand Up @@ -88,8 +91,6 @@ public void render(@NotNull VertexConsumer pBuffer, @NotNull Camera pRenderInfo,
if (this.entity != null) {
PoseStack stack = new PoseStack();

MultiBufferSource.BufferSource buffer = Minecraft.getInstance().renderBuffers().bufferSource();

float yRot = this.entity.getYRot();
float yRotO = this.entity.yRotO;

Expand Down Expand Up @@ -123,12 +124,18 @@ public void render(@NotNull VertexConsumer pBuffer, @NotNull Camera pRenderInfo,
this.entity.setYRot(this.yRot);
this.entity.yRotO = this.yRot0;

RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, this.alpha);

EntityRenderDispatcher manager = Minecraft.getInstance().getEntityRenderDispatcher();
manager.render(this.entity, this.x - pRenderInfo.getPosition().x(), this.y - pRenderInfo.getPosition().y(), this.z - pRenderInfo.getPosition().z(), 0.0F, pPartialTicks, stack, buffer, manager.getPackedLightCoords(this.entity, pPartialTicks));
EntityRenderer<? super Entity> renderer = manager.getRenderer(this.entity);

MultiBufferSource.BufferSource buffer = Minecraft.getInstance().renderBuffers().bufferSource();

Vec3 offset = renderer.getRenderOffset(this.entity, pPartialTicks);
stack.translate((this.x - pRenderInfo.getPosition().x()) + offset.x(), (this.y - pRenderInfo.getPosition().y()) + offset.y(), (this.z - pRenderInfo.getPosition().z()) + offset.z());
renderer.render(this.entity, 0.0F, pPartialTicks, stack, buffer, manager.getPackedLightCoords(this.entity, pPartialTicks));

buffer.getBuffer(RenderType.translucent());

RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,39 @@
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.CrashReport;
import net.minecraft.CrashReportCategory;
import net.minecraft.ReportedException;
import net.minecraft.client.Camera;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.*;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.joml.Vector3f;
import radon.jujutsu_kaisen.ability.JJKAbilities;
import radon.jujutsu_kaisen.client.MixinData;

Expand Down Expand Up @@ -69,8 +86,6 @@ public void render(@NotNull VertexConsumer pBuffer, @NotNull Camera pRenderInfo,
if (this.entity != null) {
PoseStack stack = new PoseStack();

MultiBufferSource.BufferSource buffer = Minecraft.getInstance().renderBuffers().bufferSource();

float yRot = this.entity.getYRot();
float yRotO = this.entity.yRotO;

Expand All @@ -97,12 +112,18 @@ public void render(@NotNull VertexConsumer pBuffer, @NotNull Camera pRenderInfo,
this.entity.yBodyRot = this.yaw;
this.entity.yBodyRotO = this.yaw;

RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, this.alpha);

EntityRenderDispatcher manager = Minecraft.getInstance().getEntityRenderDispatcher();
manager.render(this.entity, this.x - pRenderInfo.getPosition().x(), this.y - pRenderInfo.getPosition().y(), this.z - pRenderInfo.getPosition().z(), 0.0F, pPartialTicks, stack, buffer, manager.getPackedLightCoords(this.entity, pPartialTicks));
EntityRenderer<? super Entity> renderer = manager.getRenderer(this.entity);

MultiBufferSource.BufferSource buffer = Minecraft.getInstance().renderBuffers().bufferSource();

Vec3 offset = renderer.getRenderOffset(this.entity, pPartialTicks);
stack.translate((this.x - pRenderInfo.getPosition().x()) + offset.x(), (this.y - pRenderInfo.getPosition().y()) + offset.y(), (this.z - pRenderInfo.getPosition().z()) + offset.z());
renderer.render(this.entity, 0.0F, pPartialTicks, stack, buffer, manager.getPackedLightCoords(this.entity, pPartialTicks));

buffer.getBuffer(RenderType.translucent());

RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description='''${mod_description}'''
[[dependencies.${mod_id}]]
modId="forge"
mandatory=true
versionRange="${forge_version_range}"
versionRange="${neo_version_range}"
ordering="NONE"
side="BOTH"
[[dependencies.${mod_id}]]
Expand Down

0 comments on commit cc5f8bb

Please sign in to comment.