mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-03-30 16:27:43 +02:00
Add some improvements to seaponies
This commit is contained in:
parent
b4632c7358
commit
7c099cd0b1
2 changed files with 49 additions and 7 deletions
|
@ -1,11 +1,14 @@
|
||||||
package com.minelittlepony.api.pony;
|
package com.minelittlepony.api.pony;
|
||||||
|
|
||||||
import com.minelittlepony.api.pony.meta.Race;
|
import com.minelittlepony.api.pony.meta.Race;
|
||||||
|
import com.minelittlepony.client.SkinsProxy;
|
||||||
|
import com.minelittlepony.client.render.entity.PlayerSeaponyRenderer;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.StairsBlock;
|
import net.minecraft.block.StairsBlock;
|
||||||
|
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.registry.tag.FluidTags;
|
import net.minecraft.registry.tag.FluidTags;
|
||||||
|
@ -83,4 +86,12 @@ public final class PonyPosture {
|
||||||
public static boolean isRidingAPony(LivingEntity entity) {
|
public static boolean isRidingAPony(LivingEntity entity) {
|
||||||
return isSitting(entity) && getMountPony(entity).map(IPony::race).orElse(Race.HUMAN) != Race.HUMAN;
|
return isSitting(entity) && getMountPony(entity).map(IPony::race).orElse(Race.HUMAN) != Race.HUMAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isSeaponyModifier(LivingEntity entity) {
|
||||||
|
return IPony.getManager().getPony(entity).filter(pony -> {
|
||||||
|
return (pony.race() == Race.SEAPONY
|
||||||
|
|| (entity instanceof AbstractClientPlayerEntity player && SkinsProxy.instance.getSkin(PlayerSeaponyRenderer.SKIN_TYPE_ID, player).isPresent())
|
||||||
|
) && PonyPosture.isPartiallySubmerged(entity);
|
||||||
|
}).isPresent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.minelittlepony.client.render.entity;
|
||||||
|
|
||||||
import com.minelittlepony.api.pony.IPony;
|
import com.minelittlepony.api.pony.IPony;
|
||||||
import com.minelittlepony.api.pony.PonyPosture;
|
import com.minelittlepony.api.pony.PonyPosture;
|
||||||
import com.minelittlepony.api.pony.meta.Race;
|
|
||||||
import com.minelittlepony.client.SkinsProxy;
|
import com.minelittlepony.client.SkinsProxy;
|
||||||
import com.minelittlepony.client.model.*;
|
import com.minelittlepony.client.model.*;
|
||||||
import com.minelittlepony.util.MathUtil;
|
import com.minelittlepony.util.MathUtil;
|
||||||
|
@ -44,8 +43,42 @@ public class PlayerSeaponyRenderer extends PlayerPonyRenderer {
|
||||||
public void render(AbstractClientPlayerEntity player, float entityYaw, float tickDelta, MatrixStack stack, VertexConsumerProvider renderContext, int light) {
|
public void render(AbstractClientPlayerEntity player, float entityYaw, float tickDelta, MatrixStack stack, VertexConsumerProvider renderContext, int light) {
|
||||||
updateSeaponyState(player);
|
updateSeaponyState(player);
|
||||||
super.render(player, entityYaw, tickDelta, stack, renderContext, light);
|
super.render(player, entityYaw, tickDelta, stack, renderContext, light);
|
||||||
|
|
||||||
|
if (wet && player.getVelocity().length() > 0.1F) {
|
||||||
|
double x = player.getEntityWorld().getRandom().nextTriangular(player.getX(), 1);
|
||||||
|
double y = player.getEntityWorld().getRandom().nextTriangular(player.getY(), 1);
|
||||||
|
double z = player.getEntityWorld().getRandom().nextTriangular(player.getZ(), 1);
|
||||||
|
|
||||||
|
player.getEntityWorld().addParticle(ParticleTypes.BUBBLE, x, y, z, 0, 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setupTransforms(AbstractClientPlayerEntity entity, MatrixStack stack, float ageInTicks, float rotationYaw, float partialTicks) {
|
||||||
|
if (wet) {
|
||||||
|
stack.translate(0, 0.6, 0);
|
||||||
|
boolean sneaking = entity.isInSneakingPose();
|
||||||
|
float state = sneaking ? 100 : 0;
|
||||||
|
float interpolated = getEntityPony(entity).metadata().getInterpolator(entity.getUuid()).interpolate("seapony_splashing", state, 5);
|
||||||
|
|
||||||
|
if (sneaking) {
|
||||||
|
stack.translate(0, 0.125, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!MathUtil.compareFloats(interpolated, state)) {
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
double x = entity.getEntityWorld().getRandom().nextTriangular(entity.getX(), 1);
|
||||||
|
double y = entity.getY() + 0.6;
|
||||||
|
double z = entity.getEntityWorld().getRandom().nextTriangular(entity.getZ(), 1);
|
||||||
|
|
||||||
|
entity.getEntityWorld().addParticle(ParticleTypes.BUBBLE, x, y, z, 0, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.setupTransforms(entity, stack, ageInTicks, rotationYaw, partialTicks);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void renderArm(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, AbstractClientPlayerEntity player, Arm side) {
|
protected void renderArm(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, AbstractClientPlayerEntity player, Arm side) {
|
||||||
updateSeaponyState(player);
|
updateSeaponyState(player);
|
||||||
super.renderArm(stack, renderContext, lightUv, player, side);
|
super.renderArm(stack, renderContext, lightUv, player, side);
|
||||||
|
@ -53,18 +86,16 @@ public class PlayerSeaponyRenderer extends PlayerPonyRenderer {
|
||||||
|
|
||||||
private void updateSeaponyState(AbstractClientPlayerEntity player) {
|
private void updateSeaponyState(AbstractClientPlayerEntity player) {
|
||||||
IPony pony = getEntityPony(player);
|
IPony pony = getEntityPony(player);
|
||||||
wet = (pony.race() == Race.SEAPONY || SkinsProxy.instance.getSkin(SKIN_TYPE_ID, player).isPresent())
|
wet = PonyPosture.isSeaponyModifier(player);
|
||||||
&& PonyPosture.isPartiallySubmerged(player);
|
|
||||||
|
|
||||||
model = manager.setModel(wet ? wetPony : dryPony).body();
|
model = manager.setModel(wet ? wetPony : dryPony).body();
|
||||||
|
|
||||||
float state = wet ? 100 : 0;
|
float state = wet ? 100 : 0;
|
||||||
float interpolated = pony.metadata().getInterpolator(player.getUuid()).interpolate("seapony_state", state, 5);
|
float interpolated = pony.metadata().getInterpolator(player.getUuid()).interpolate("seapony_state", state, 5);
|
||||||
|
|
||||||
if (!MathUtil.compareFloats(interpolated, state)) {
|
if (!MathUtil.compareFloats(interpolated, state)) {
|
||||||
double x = player.getX() + (player.getEntityWorld().getRandom().nextFloat() * 2) - 1;
|
double x = player.getEntityWorld().getRandom().nextTriangular(player.getX(), 1);
|
||||||
double y = player.getY() + (player.getEntityWorld().getRandom().nextFloat() * 2);
|
double y = player.getEntityWorld().getRandom().nextTriangular(player.getY() + player.getHeight() * 0.5F, 1);
|
||||||
double z = player.getZ() + (player.getEntityWorld().getRandom().nextFloat() * 2) - 1;
|
double z = player.getEntityWorld().getRandom().nextTriangular(player.getZ(), 1);
|
||||||
|
|
||||||
player.getEntityWorld().addParticle(ParticleTypes.END_ROD, x, y, z, 0, 0, 0);
|
player.getEntityWorld().addParticle(ParticleTypes.END_ROD, x, y, z, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue