Skip to content

Commit

Permalink
Use cache for slot renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
ktpatient committed Dec 6, 2024
1 parent 42b5b2e commit 4a1f4d6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,27 @@ public void clientTick(PlayerTickEvent.Post event) {
this.clientLaserTime = 0;
}

double d5 = (double) this.getLaserScale(0.0F);
double d0 = targetEntity.getX() - player.getX();
double d1 = targetEntity.getY(0.5) - player.getEyeY();
double d2 = targetEntity.getZ() - player.getZ();
double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
d0 /= d3;
d1 /= d3;
d2 /= d3;
double d4 = player.getRandom().nextDouble();

while (d4 < d3) {
d4 += 1.8 - d5 + player.getRandom().nextDouble() * (1.7 - d5);
player.level()
.addParticle(ParticleTypes.BUBBLE, player.getX() + d0 * d4, player.getEyeY() + d1 * d4, player.getZ() + d2 * d4, 0.0, 0.0, 0.0);
double laserScale = this.getLaserScale(0.0F);
double dx = targetEntity.getX() - player.getX();
double dy = targetEntity.getY(0.5) - player.getEyeY();
double dz = targetEntity.getZ() - player.getZ();

double dist = Math.sqrt(dx * dx + dy * dy + dz * dz);

double nx = dx / dist;
double ny = dy / dist;
double nz = dz / dist;

double rOffset = player.getRandom().nextDouble();
double particleDist = 0.0;

while (particleDist < dist) {
particleDist += 1.8 - laserScale + rOffset * (1.7-laserScale);
player.level().addParticle(ParticleTypes.BUBBLE,
player.getX() + nx * particleDist,
player.getEyeY() + ny * particleDist,
player.getZ() + nz * particleDist,
0.0,0.0,0.0);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public static void onRenderPlayer(RenderPlayerEvent.Post event) {
if (!NTConfig.allowAugmentRendering) return;
PlayerRenderer renderer = event.getRenderer();
renderer.addLayer(new AugmentLayerRenderer(renderer));
// Needs to be outside the augment renderer cuz pose stacks
// Needs to be outside the augment renderer cuz pose stacksA

Map<AugmentSlot, Augment> augments = AugmentHelper.getAugments(event.getEntity());
for (Augment augment : augments.values()) {
if (augment instanceof GuardianEyeAugment eyeAugment && eyeAugment.getTargetEntity() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public static ModelPartGetter modelPartBySlot(AugmentSlot slot) {
}

public static void render(RenderPlayerEvent.Pre event) {
Map<AugmentSlot, Augment> augments = AugmentHelper.getAugments(event.getEntity());

Map<AugmentSlot, Augment> augments = AugmentLayerRenderer.AUGMENTS_CACHE;
for (AugmentSlot slot : augments.keySet()) {
Augment augment = augments.get(slot);
if (augment.replaceBodyPart()) {
Expand Down

0 comments on commit 4a1f4d6

Please sign in to comment.