mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 03:26:44 +01:00
Fixed passenger rendering and fixed passenger players not looking the direction their captor is facing. Closes #155
This commit is contained in:
parent
ed3c0f9609
commit
cd0a58f27f
5 changed files with 34 additions and 40 deletions
|
@ -6,13 +6,11 @@ import org.jetbrains.annotations.Nullable;
|
|||
import com.minelittlepony.unicopia.*;
|
||||
import com.minelittlepony.unicopia.ability.*;
|
||||
import com.minelittlepony.unicopia.ability.magic.SpellPredicate;
|
||||
import com.minelittlepony.unicopia.ability.magic.spell.AbstractDisguiseSpell;
|
||||
import com.minelittlepony.unicopia.ability.magic.spell.TimedSpell;
|
||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.CustomisedSpellType;
|
||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
||||
import com.minelittlepony.unicopia.client.sound.*;
|
||||
import com.minelittlepony.unicopia.entity.ItemTracker;
|
||||
import com.minelittlepony.unicopia.entity.behaviour.EntityAppearance;
|
||||
import com.minelittlepony.unicopia.entity.effect.SunBlindnessStatusEffect;
|
||||
import com.minelittlepony.unicopia.entity.effect.UEffects;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
|
@ -24,9 +22,7 @@ import net.minecraft.client.MinecraftClient;
|
|||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.hud.InGameHud;
|
||||
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.EntityDimensions;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
|
@ -160,29 +156,6 @@ public class UHud {
|
|||
}
|
||||
|
||||
RenderSystem.disableBlend();
|
||||
|
||||
if (pony.getSpecies() == Race.CHANGELING && !client.player.isSneaking()) {
|
||||
pony.getSpellSlot().get(SpellType.CHANGELING_DISGUISE, false).map(AbstractDisguiseSpell::getDisguise)
|
||||
.map(EntityAppearance::getAppearance)
|
||||
.ifPresent(appearance -> {
|
||||
|
||||
float baseHeight = 20;
|
||||
|
||||
EntityDimensions dims = appearance.getDimensions(appearance.getPose());
|
||||
|
||||
float entityHeight = Math.max(dims.height, dims.width);
|
||||
int scale = (int)(baseHeight / entityHeight);
|
||||
|
||||
int x = scaledWidth / 2 + xDirection * 67;
|
||||
int y = (int)(scaledHeight - 18 - dims.height/2F);
|
||||
|
||||
matrices.push();
|
||||
matrices.translate(x, y, 0);
|
||||
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(xDirection * 45));
|
||||
InventoryScreen.drawEntity(context, 0, 0, scale, 0, -20, client.player);
|
||||
matrices.pop();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void renderSpell(DrawContext context, CustomisedSpellType<?> spell, double x, double y) {
|
||||
|
|
|
@ -59,11 +59,9 @@ public class HeldEntityFeatureRenderer<E extends LivingEntity> implements Access
|
|||
float h = -0.2f * MathHelper.sin(swingProgress * (float)Math.PI);
|
||||
matrices.push();
|
||||
matrices.translate(f, g, h);
|
||||
matrices.translate(0, -1.3F, -1.3F);
|
||||
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(13));
|
||||
if (!(passenger instanceof Pony)) {
|
||||
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(90));
|
||||
}
|
||||
matrices.translate(0, -1.3F, passenger instanceof Pony ? -1.9F : -1.3F);
|
||||
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(passenger instanceof Pony ? 33 : 13));
|
||||
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(passenger instanceof Pony ? 180 : 90));
|
||||
|
||||
renderCarriedEntity(passenger.asEntity(), matrices, vertexConsumers, light, tickDelta);
|
||||
matrices.pop();
|
||||
|
@ -76,7 +74,7 @@ public class HeldEntityFeatureRenderer<E extends LivingEntity> implements Access
|
|||
matrices.push();
|
||||
sender.invokeRenderArmHoldingItem(matrices, vertexConsumers, light, equipProgress, swingProgress, Arm.RIGHT);
|
||||
matrices.pop();
|
||||
return true;
|
||||
return false;
|
||||
}).isPresent();
|
||||
}
|
||||
|
||||
|
@ -86,23 +84,38 @@ public class HeldEntityFeatureRenderer<E extends LivingEntity> implements Access
|
|||
|
||||
p.prevBodyYaw = 0;
|
||||
p.bodyYaw = 0;
|
||||
|
||||
float oldHeadYaw = p.headYaw;
|
||||
float oldPrevHeadYaw = p.prevHeadYaw;
|
||||
float oldPrevYaw = p.prevYaw;
|
||||
float oldYaw = p.getYaw();
|
||||
boolean onGround = p.isOnGround();
|
||||
p.headYaw = 0;
|
||||
p.prevHeadYaw = 0;
|
||||
p.prevYaw = 0;
|
||||
p.setYaw(0);
|
||||
p.setBodyYaw(0);
|
||||
p.setOnGround(true);
|
||||
@SuppressWarnings("unchecked")
|
||||
EntityRenderer<LivingEntity> renderer = (EntityRenderer<LivingEntity>)MinecraftClient.getInstance().getEntityRenderDispatcher().getRenderer(p);
|
||||
renderer.render(p, 0, tickDelta, matrices, vertexConsumers, light);
|
||||
|
||||
p.headYaw = oldHeadYaw;
|
||||
p.prevHeadYaw = oldPrevHeadYaw;
|
||||
p.prevYaw = oldPrevYaw;
|
||||
p.setYaw(oldYaw);
|
||||
p.setOnGround(onGround);
|
||||
|
||||
((EntityDuck)p).setVehicle(vehicle);
|
||||
}
|
||||
|
||||
protected Vec3d getCarryPosition(Living<E> entity, Living<?> passenger) {
|
||||
float passengerHeight = MineLPDelegate.getInstance().getPonyHeight(passenger.asEntity()) / 2F;
|
||||
float carrierHeight = entity.asEntity().getHeight() / 5F;
|
||||
float carrierHeight = MineLPDelegate.getInstance().getPonyHeight(entity.asEntity()) / 5F;
|
||||
|
||||
if (entity instanceof Pony pony && MineLPDelegate.getInstance().getPlayerPonyRace(pony.asEntity()).isEquine() && pony.getPhysics().isFlying()) {
|
||||
if (entity instanceof Pony pony
|
||||
&& MineLPDelegate.getInstance().getPlayerPonyRace(pony.asEntity()).isEquine()
|
||||
&& pony.getPhysics().isFlying()) {
|
||||
return new Vec3d(0,
|
||||
-carrierHeight * 10 - passengerHeight * 2,
|
||||
0
|
||||
|
|
|
@ -108,7 +108,7 @@ public class WorldRenderDelegate {
|
|||
double x, double y, double z, float yaw,
|
||||
float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) {
|
||||
|
||||
if (pony.isBeingCarried() && !(pony instanceof Pony && ((Pony)pony).isClientPlayer())) {
|
||||
if (pony.isBeingCarried()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -216,6 +216,7 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
|
|||
entity.refreshPositionAfterTeleport(carrier.getOriginVector());
|
||||
Living.transmitPassengers(carrier.asEntity());
|
||||
}
|
||||
entity.setYaw(carrier.asEntity().getYaw());
|
||||
}
|
||||
|
||||
updateDragonBreath();
|
||||
|
|
|
@ -106,7 +106,11 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
|||
|
||||
@Override
|
||||
public boolean isFlying() {
|
||||
return isFlyingSurvival && !entity.isFallFlying() && !entity.hasVehicle();
|
||||
return isFlyingSurvival
|
||||
&& !entity.isFallFlying()
|
||||
&& !entity.hasVehicle()
|
||||
&& !entity.getAbilities().creativeMode
|
||||
&& !entity.isSpectator();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -274,9 +278,12 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if (!pony.isClient()) {
|
||||
lastFlightType = type;
|
||||
isFlyingSurvival = entity.getAbilities().flying && !creative;
|
||||
isFlyingEither = isFlyingSurvival || (creative && entity.getAbilities().flying);
|
||||
}
|
||||
|
||||
if (typeChanged || startedFlyingCreative) {
|
||||
entity.calculateDimensions();
|
||||
|
|
Loading…
Reference in a new issue