Add mind control overlay

This commit is contained in:
Electroblob77
2020-06-29 21:16:10 +01:00
parent a25b642164
commit 68dad2a148
5 changed files with 77 additions and 2 deletions
@@ -712,6 +712,7 @@ public class ClientProxy extends CommonProxy {
public void initialiseLayers(){
LayerTiledOverlay.initialiseLayers(LayerStone::new);
LayerTiledOverlay.initialiseLayers(LayerFrost::new);
LayerTiledOverlay.initialiseLayers(LayerMindControl::new);
LayerTiledOverlay.initialiseLayers(LayerSummonAnimation::new);
LayerTiledOverlay.initialiseLayers(LayerDisintegrateAnimation::new);
}
@@ -0,0 +1,59 @@
package electroblob.wizardry.client.renderer.entity.layers;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.registry.WizardryPotions;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.GlStateManager.DestFactor;
import net.minecraft.client.renderer.GlStateManager.SourceFactor;
import net.minecraft.client.renderer.entity.RenderLivingBase;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ResourceLocation;
/**
* Layer used to render the mind control overlay on creatures with the mind control effect.
*
* @author Electroblob
* @since Wizardry 4.3
*/
public class LayerMindControl extends LayerTiledOverlay<EntityLivingBase> {
private static final ResourceLocation TEXTURE = new ResourceLocation(Wizardry.MODID, "textures/entity/mind_control_overlay.png");
public LayerMindControl(RenderLivingBase<?> renderer){
super(renderer);
}
@Override
public boolean shouldRender(EntityLivingBase entity, float partialTicks){
return !entity.isInvisible() && entity.isPotionActive(WizardryPotions.mind_control);
}
@Override
public ResourceLocation getTexture(EntityLivingBase entity, float partialTicks){
return TEXTURE;
}
@Override
public void doRenderLayer(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float partialTicks,
float ageInTicks, float netHeadYaw, float headPitch, float scale){
GlStateManager.enableBlend();
GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE);
PotionEffect effect = entity.getActivePotionEffect(WizardryPotions.mind_control);
if(effect != null){
GlStateManager.color(1, 1, 1, Math.min(1, (effect.getDuration() - partialTicks) / 20));
}
super.doRenderLayer(entity, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale);
GlStateManager.disableBlend();
}
@Override
protected void applyTextureSpaceTransformations(EntityLivingBase entity, float partialTicks){
float f = entity.ticksExisted + partialTicks;
GlStateManager.translate(f * 0.003f, f * 0.003f, 0);
}
}
@@ -82,6 +82,16 @@ public abstract class LayerTiledOverlay<T extends EntityLivingBase> implements L
return false; // Normally it looks kind of weird because second layers typically have holes in them
}
/**
* Allows subclasses to perform additional transformations in the texture space before the model is rendered. This
* can be used for a creeper-charge-like effect. To do this, simply override this method and call the appropriate
* transformation method(s) (translate, rotate, scale) in {@link GlStateManager}. This method does nothing by
* default.
* @param entity The entity being rendered
* @param partialTicks The current partial tick time
*/
protected void applyTextureSpaceTransformations(T entity, float partialTicks){}
@Override
public void doRenderLayer(T entity, float limbSwing, float limbSwingAmount, float partialTicks,
float ageInTicks, float netHeadYaw, float headPitch, float scale){
@@ -143,6 +153,8 @@ public abstract class LayerTiledOverlay<T extends EntityLivingBase> implements L
GlStateManager.scale(scaleX, scaleY, 1);
applyTextureSpaceTransformations(entity, partialTicks);
GlStateManager.matrixMode(GL11.GL_MODELVIEW); // Switch back to the 3D model space
boolean headWearHidden = false;