Add player animation system!
- Hooks into ModelRenderer by wrapping it in an extended version that allows modification of angles after the model has set them - Is compatible with pretty much everything, yay (even modded armour!) - Adds property overrides to ItemWand so that gets animated too - Adds a system for generating override models from a template at runtime so I don't have to duplicate all the wand models - Tweaks particles and ray spells so they line up with the end of the newly-animated wand - Fixes a long-standing bug where wand usage actions would stop immediately for all non-continuous spells
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package electroblob.wizardry.client.particle;
|
||||
|
||||
import electroblob.wizardry.Wizardry;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
@@ -15,6 +16,8 @@ import javax.annotation.Nullable;
|
||||
/** Superclass for particles with a second target entity or target position. */
|
||||
public abstract class ParticleTargeted extends ParticleWizardry {
|
||||
|
||||
private static final double THIRD_PERSON_AXIAL_OFFSET = 1.2;
|
||||
|
||||
protected double targetX;
|
||||
protected double targetY;
|
||||
protected double targetZ;
|
||||
@@ -79,6 +82,16 @@ public abstract class ParticleTargeted extends ParticleWizardry {
|
||||
float y = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)partialTicks);
|
||||
float z = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)partialTicks);
|
||||
|
||||
// Translates the particle a short distance in front of the entity
|
||||
if(this.entity != null && this.shouldApplyOriginOffset()){ // TODO: Replace with a protected boolean method
|
||||
if(this.entity != viewer || Minecraft.getMinecraft().gameSettings.thirdPersonView != 0){
|
||||
Vec3d look = entity.getLook(partialTicks).scale(THIRD_PERSON_AXIAL_OFFSET);
|
||||
x += look.x;
|
||||
y += look.y;
|
||||
z += look.z;
|
||||
}
|
||||
}
|
||||
|
||||
if(this.target != null){
|
||||
|
||||
this.targetX = this.target.prevPosX + (this.target.posX - this.target.prevPosX) * partialTicks;
|
||||
@@ -133,6 +146,12 @@ public abstract class ParticleTargeted extends ParticleWizardry {
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
/** Returns whether the origin of this particle should be moved a short distance in front of the entity it is
|
||||
* linked to, if any. */
|
||||
protected boolean shouldApplyOriginOffset(){
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Called from {@link ParticleTargeted#renderParticle(BufferBuilder, Entity, float, float, float, float, float, float)},
|
||||
* once the appropriate calculations and transformations have been applied, to actually render the particle. Subclasses
|
||||
* override this <i>instead</i> of overriding {@code renderParticle} directly, and inside render the particle <b>along
|
||||
|
||||
@@ -46,6 +46,11 @@ public class ParticleVine extends ParticleTargeted {
|
||||
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldApplyOriginOffset(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void draw(Tessellator tessellator, double length, float partialTicks){
|
||||
|
||||
|
||||
Reference in New Issue
Block a user