diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/WorldRenderDelegate.java b/src/main/java/com/minelittlepony/unicopia/client/render/WorldRenderDelegate.java index 4d710778..b4e52272 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/WorldRenderDelegate.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/WorldRenderDelegate.java @@ -2,7 +2,9 @@ package com.minelittlepony.unicopia.client.render; import javax.annotation.Nullable; +import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell; +import com.minelittlepony.unicopia.entity.Living; import com.minelittlepony.unicopia.entity.behaviour.Disguise; import com.minelittlepony.unicopia.entity.player.Pony; @@ -30,7 +32,7 @@ import net.minecraft.util.math.Vec3d; public class WorldRenderDelegate { public static final WorldRenderDelegate INSTANCE = new WorldRenderDelegate(); - public boolean onEntityRender(EntityRenderDispatcher dispatcher, Pony pony, + public boolean onEntityRender(EntityRenderDispatcher dispatcher, Living pony, double x, double y, double z, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) { @@ -42,7 +44,7 @@ public class WorldRenderDelegate { float roll = negative ? 180 : 0; - roll = pony.getInterpolator().interpolate("g_roll", roll, 15); + roll = pony instanceof Pony ? ((Pony)pony).getInterpolator().interpolate("g_roll", roll, 15) : roll; if (negative) { matrices.translate(x, y, z); @@ -55,29 +57,34 @@ public class WorldRenderDelegate { matrices.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(roll)); } - int fireTicks = pony.getMaster().doesRenderOnFire() ? 1 : 0; + if (pony instanceof Caster) { - return pony.getSpellOrEmpty(DisguiseSpell.class, true).map(effect -> { - effect.update(pony, false); + int fireTicks = pony.getMaster().doesRenderOnFire() ? 1 : 0; - Disguise ve = effect.getDisguise(); - Entity e = ve.getAppearance(); + return ((Caster)pony).getSpellOrEmpty(DisguiseSpell.class, true).map(effect -> { + effect.update(pony, false); - if (e != null) { - renderDisguise(dispatcher, ve, e, x, y, z, fireTicks, tickDelta, matrices, vertexConsumers, light); - ve.getAttachments().forEach(ee -> { - Vec3d difference = ee.getPos().subtract(e.getPos()); - renderDisguise(dispatcher, ve, ee, x + difference.x, y + difference.y, z + difference.z, fireTicks, tickDelta, matrices, vertexConsumers, light); - }); + Disguise ve = effect.getDisguise(); + Entity e = ve.getAppearance(); - afterEntityRender(pony, matrices); - return true; - } - return false; - }).orElse(false); + if (e != null) { + renderDisguise(dispatcher, ve, e, x, y, z, fireTicks, tickDelta, matrices, vertexConsumers, light); + ve.getAttachments().forEach(ee -> { + Vec3d difference = ee.getPos().subtract(e.getPos()); + renderDisguise(dispatcher, ve, ee, x + difference.x, y + difference.y, z + difference.z, fireTicks, tickDelta, matrices, vertexConsumers, light); + }); + + afterEntityRender(pony, matrices); + return true; + } + return false; + }).orElse(false); + } + + return false; } - public void afterEntityRender(Pony pony, MatrixStack matrices) { + public void afterEntityRender(Living pony, MatrixStack matrices) { matrices.pop(); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ItemImpl.java b/src/main/java/com/minelittlepony/unicopia/entity/ItemImpl.java index 35a7fe70..53029bcc 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ItemImpl.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ItemImpl.java @@ -8,6 +8,7 @@ import com.minelittlepony.unicopia.item.enchantment.UEnchantments; import com.minelittlepony.unicopia.util.VecHelper; import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.Entity; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.MovementType; import net.minecraft.entity.data.DataTracker; @@ -20,6 +21,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.particle.ParticleEffect; import net.minecraft.particle.ParticleTypes; import net.minecraft.util.ActionResult; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; public class ItemImpl implements Equine, Owned { @@ -90,6 +92,21 @@ public class ItemImpl implements Equine, Owned { } } + if (physics.isGravityNegative()) { + owner.setNoGravity(true); + owner.setOnGround(owner.verticalCollision); + + float g = 0.98f; + if (owner.isOnGround()) { + g *= owner.world.getBlockState(owner.getBlockPos().up()).getBlock().getSlipperiness(); + } + + owner.setVelocity(owner.getVelocity() + .add(0, physics.calcGravity(-0.04D), 0) + .multiply(g, 1, g)); + + } + return false; } diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerEntity.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerEntity.java index aa8975e0..ed7c3cc3 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerEntity.java @@ -78,6 +78,7 @@ abstract class MixinPlayerEntity extends LivingEntity implements PonyContainer

info) { PonyContainer.of(info.getReturnValue()).ifPresent(container -> { container.get().setSpecies(get().getSpecies()); + container.get().getPhysics().setBaseGravityModifier(get().getPhysics().getGravityModifier()); }); } diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinEntityRenderDispatcher.java b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinEntityRenderDispatcher.java index 2b7e7f3b..7d21563f 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinEntityRenderDispatcher.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinEntityRenderDispatcher.java @@ -6,13 +6,13 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.minelittlepony.unicopia.client.render.WorldRenderDelegate; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.entity.Equine; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.LivingEntity; @Mixin(EntityRenderDispatcher.class) abstract class MixinEntityRenderDispatcher { @@ -21,21 +21,19 @@ abstract class MixinEntityRenderDispatcher { @Inject(method = RENDER, at = @At("HEAD"), cancellable = true) private void beforeRender(E entity, double x, double y, double z, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo info) { - if (!(entity instanceof PlayerEntity)) { + if (!(entity instanceof LivingEntity)) { return; } - - if (WorldRenderDelegate.INSTANCE.onEntityRender((EntityRenderDispatcher)(Object)this, Pony.of((PlayerEntity)entity), x, y, z, yaw, tickDelta, matrices, vertexConsumers, light)) { + if (WorldRenderDelegate.INSTANCE.onEntityRender((EntityRenderDispatcher)(Object)this, Equine.of(entity), x, y, z, yaw, tickDelta, matrices, vertexConsumers, light)) { info.cancel(); } } @Inject(method = RENDER, at = @At("RETURN")) private void afterRender(E entity, double x, double y, double z, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo info) { - if (!(entity instanceof PlayerEntity)) { + if (!(entity instanceof LivingEntity)) { return; } - - WorldRenderDelegate.INSTANCE.afterEntityRender(Pony.of((PlayerEntity)entity), matrices); + WorldRenderDelegate.INSTANCE.afterEntityRender(Equine.of(entity), matrices); } }