Separated assets in 3 parts-Condensed rendering code
This commit is contained in:
parent
cd01a41ae1
commit
7cf77cdad0
257 changed files with 536 additions and 1648 deletions
90
common/mysticworld/client/fx/PowerFX.java
Normal file
90
common/mysticworld/client/fx/PowerFX.java
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
package mysticworld.client.fx;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import mysticworld.client.ClientProxy;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class PowerFX extends EntityFX {
|
||||
private ResourceLocation textureFX;
|
||||
|
||||
public PowerFX(World world, double x, double y, double z) {
|
||||
super(world, x, y, z);
|
||||
}
|
||||
|
||||
public PowerFX(World world, double x, double y, double z, float scale) {
|
||||
super(world, x, y, z);
|
||||
this.motionX *= 0.019999999552965164D;
|
||||
this.motionY *= 0.019999999552965164D;
|
||||
this.motionZ *= 0.019999999552965164D;
|
||||
this.motionX += motionX;
|
||||
this.motionY += motionY;
|
||||
this.motionZ += motionZ;
|
||||
this.particleRed = 1.0F;
|
||||
this.particleGreen = 1.0F;
|
||||
this.particleBlue = 1.0F;
|
||||
this.particleScale = scale;
|
||||
this.noClip = true;
|
||||
this.particleMaxAge = 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
this.prevPosX = this.posX;
|
||||
this.prevPosY = this.posY;
|
||||
this.prevPosZ = this.posZ;
|
||||
if (this.particleAge++ >= this.particleMaxAge) {
|
||||
this.setDead();
|
||||
}
|
||||
this.motionY += 0.004D;
|
||||
this.moveEntity(this.motionX, this.motionY, this.motionZ);
|
||||
if (this.posY == this.prevPosY) {
|
||||
this.motionX *= 1.1D;
|
||||
this.motionZ *= 1.1D;
|
||||
}
|
||||
this.motionX *= 0.9599999785423279D;
|
||||
this.motionY *= 0.9599999785423279D;
|
||||
this.motionZ *= 0.9599999785423279D;
|
||||
if (this.onGround) {
|
||||
this.motionX *= 0.699999988079071D;
|
||||
this.motionZ *= 0.699999988079071D;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle(Tessellator tessellator, float par2, float par3, float par4, float par5, float par6, float par7) {
|
||||
tessellator.draw();
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glEnable(3042);
|
||||
GL11.glBlendFunc(770, 1);
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(textureFX);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.75F);
|
||||
float scale = 0.1F * this.particleScale;
|
||||
float xPos = (float) (this.prevPosX + (this.posX - this.prevPosX) * par2 - interpPosX);
|
||||
float yPos = (float) (this.prevPosY + (this.posY - this.prevPosY) * par2 - interpPosY);
|
||||
float zPos = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * par2 - interpPosZ);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setBrightness(240);
|
||||
tessellator.setColorOpaque_F(this.particleRed, this.particleGreen, this.particleBlue);
|
||||
tessellator.addVertexWithUV(xPos - par3 * scale - par6 * scale, yPos - par4 * scale, zPos - par5 * scale - par7 * scale, 0D, 1D);
|
||||
tessellator.addVertexWithUV(xPos - par3 * scale + par6 * scale, yPos + par4 * scale, zPos - par5 * scale + par7 * scale, 1D, 1D);
|
||||
tessellator.addVertexWithUV(xPos + par3 * scale + par6 * scale, yPos + par4 * scale, zPos + par5 * scale + par7 * scale, 1D, 0D);
|
||||
tessellator.addVertexWithUV(xPos + par3 * scale - par6 * scale, yPos - par4 * scale, zPos + par5 * scale - par7 * scale, 0D, 0D);
|
||||
tessellator.draw();
|
||||
GL11.glDisable(3042);
|
||||
GL11.glDepthMask(true);
|
||||
GL11.glPopMatrix();
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(ClientProxy.particle);
|
||||
tessellator.startDrawingQuads();
|
||||
}
|
||||
|
||||
public PowerFX setTexture(String loc) {
|
||||
textureFX = new ResourceLocation("mysticworld", "textures/misc/" + loc + "FX.png");
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -81,6 +81,6 @@ public class ItemHandler {
|
|||
.setUnlocalizedName(Strings.IRIDIUM_CHESTPLATE_NAME);
|
||||
iridiumLeggings = new ItemArmorIridium(ItemIds.IRIDIUM_LEGGINGS, EnumArmor.Iridium, MysticWorld.proxy.addArmor(EnumArmor.Iridium.name()), 2).setUnlocalizedName(Strings.IRIDIUM_LEGGINGS_NAME);
|
||||
iridiumBoots = new ItemArmorIridium(ItemIds.IRIDIUM_BOOTS, EnumArmor.Iridium, MysticWorld.proxy.addArmor(EnumArmor.Iridium.name()), 3).setUnlocalizedName(Strings.IRIDIUM_BOOTS_NAME);
|
||||
voidShard = new ItemVoidShard(ItemIds.VOID_SHARD).setUnlocalizedName(Strings.VOID_SHARD_NAME);
|
||||
voidShard = new ItemVoidShard(ItemIds.VOID_SHARD).setUnlocalizedName(Strings.VOID_SHARD_NAME).setTextureName("mysticworld:ShardVoid");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
39
common/mysticworld/renderer/BaseItemRenderer.java
Normal file
39
common/mysticworld/renderer/BaseItemRenderer.java
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
package mysticworld.renderer;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
public abstract class BaseItemRenderer implements IItemRenderer {
|
||||
protected final ResourceLocation texture;
|
||||
|
||||
public BaseItemRenderer(String loc) {
|
||||
texture = new ResourceLocation("mysticworld", "textures/models/" + loc + ".png");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
switch (type) {
|
||||
case ENTITY:
|
||||
case EQUIPPED:
|
||||
case EQUIPPED_FIRST_PERSON:
|
||||
case INVENTORY:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
switch (type) {
|
||||
case ENTITY:
|
||||
case EQUIPPED:
|
||||
case INVENTORY:
|
||||
case EQUIPPED_FIRST_PERSON:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
47
common/mysticworld/renderer/OrbItemRenderer.java
Normal file
47
common/mysticworld/renderer/OrbItemRenderer.java
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
package mysticworld.renderer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import mysticworld.model.ModelOrb;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class OrbItemRenderer extends BaseItemRenderer {
|
||||
private final ModelOrb modelOrb = new ModelOrb();
|
||||
|
||||
public OrbItemRenderer(String loc) {
|
||||
super("Orb" + loc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
switch (type) {
|
||||
case ENTITY:
|
||||
renderOrb(0.0f, 0.5f, 0.0f, 0.4f);
|
||||
break;
|
||||
case EQUIPPED:
|
||||
renderOrb(0.5f, 1.0f, 0.5f, 0.5f);
|
||||
break;
|
||||
case INVENTORY:
|
||||
renderOrb(0.0f, 0.0f, 0.0f, 0.5f);
|
||||
break;
|
||||
case EQUIPPED_FIRST_PERSON:
|
||||
renderOrb(0.0f, 1.0f, 1.0f, 0.5f);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void renderOrb(float x, float y, float z, float scale) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glTranslatef(x, y, z);
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
GL11.glRotatef(180f, 0f, 1f, 0f);
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(texture);
|
||||
modelOrb.render();
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
71
common/mysticworld/renderer/StaffItemRenderer.java
Normal file
71
common/mysticworld/renderer/StaffItemRenderer.java
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
package mysticworld.renderer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import mysticworld.model.ModelStaff;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class StaffItemRenderer extends BaseItemRenderer {
|
||||
private final ModelStaff model = new ModelStaff();
|
||||
|
||||
public StaffItemRenderer(String loc) {
|
||||
super("Staff" + loc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
switch (type) {
|
||||
case ENTITY:
|
||||
renderModel(0.0F, 1.2F, 0.0F, 1.0F);
|
||||
break;
|
||||
case INVENTORY:
|
||||
renderModel(0.5F, 0.95F, 0.5F, 1.0F);
|
||||
break;
|
||||
case EQUIPPED_FIRST_PERSON:
|
||||
renderModel(1.0F, 1.2f, 0.0f, 1.0f);
|
||||
break;
|
||||
case EQUIPPED:
|
||||
renderModelEquipped(0.0F, 0.9f, 0.0f, 1.0f);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
switch (type) {
|
||||
case ENTITY:
|
||||
case INVENTORY:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void renderModel(float x, float y, float z, float scale) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
GL11.glTranslatef(x, y, z);
|
||||
GL11.glRotatef(180.0F, 0.0F, 0.0F, 0.0F);
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(texture);
|
||||
model.renderModel(0.0625f);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void renderModelEquipped(float x, float y, float z, float scale) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
GL11.glTranslatef(x, y, z);
|
||||
GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(-45.0F, 0.0F, 0.0F, 1.0F);
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(texture);
|
||||
model.renderModel(0.0625f);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue