I've been looking all around the internet on how to do this all day, how would I make a continuing beam? (Like an actual laser) I've made regular laser bolts in my mod, and now I'm actually trying to make a projectile that is instantaneous. I have looked in both the beacon and lightning render files, but the beacon beam is a tile entity render, and lightning is a weather effect render. Does anyone have any ideas on how this would be done?
@SideOnly(Side.CLIENT)
public class RenderDevastationBeam
extends Render
{
int red = 255;
int green = 35;
int blue = 255;
int alpha = 255;
private static final ResourceLocation arrowTextures = new ResourceLocation("textures/entity/arrow.png");
I've been looking all around the internet on how to do this all day, how would I make a continuing beam? (Like an actual laser) I've made regular laser bolts in my mod, and now I'm actually trying to make a projectile that is instantaneous. I have looked in both the beacon and lightning render files, but the beacon beam is a tile entity render, and lightning is a weather effect render. Does anyone have any ideas on how this would be done?
My Code:
EntityDevastationBeam
package com.stormarmory.projectiles;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public class EntityDevastationBeam extends EntityThrowable
{
private float damage = 100F;
public EntityDevastationBeam(World p_i1703_1_, double p_i1703_2_, double p_i1703_4_, double p_i1703_6_)
{
super(p_i1703_1_);
}
public EntityDevastationBeam(World par1World)
{
super(par1World);
}
public EntityDevastationBeam(World par1World, EntityLivingBase par2EntityLivingBase)
{
super(par1World, par2EntityLivingBase);
}
@Override
protected void onImpact(MovingObjectPosition movingobjectposition)
{
if (movingobjectposition.entityHit != null) {
movingobjectposition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, getThrower()), this.damage);
for (int var3 = 0; var3 < 8; ++var3)
{
this.worldObj.spawnParticle("magicCrit", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
}
if (!this.worldObj.isRemote)
{
this.setDead();
}
}
}
@Override
protected float getGravityVelocity()
{
return 0.00015F;
}
@Override
protected float func_70182_d() {
return 4.5F;
}
@Override
public void onUpdate()
{
super.onUpdate();
if (this.ticksExisted >= 500)
{
this.setDead();
}
for (int var1 = 0; var1 < 10; ++var1)
{
double motionX = rand.nextGaussian() * 0.02D;
double motionY = rand.nextGaussian() * 0.02D;
double motionZ = rand.nextGaussian() * 0.02D;
worldObj.spawnParticle(
"fireworksSpark",
posX + rand.nextFloat() * width * 2.0F - width,
posY + 0.0D + rand.nextFloat() * height,
posZ + rand.nextFloat() * width * 2.0F - width,
motionX,
motionY,
motionZ);
}
for (int var1 = 0; var1 < 0.0001; ++var1)
{
worldObj.playSoundAtEntity(this, "stormarmory:boss.dropship.fire3", 1.0F, 1.0F);
}
}
}
RenderDevastationBeam
package com.stormarmory.projectiles;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class RenderDevastationBeam
extends Render
{
int red = 255;
int green = 35;
int blue = 255;
int alpha = 255;
private static final ResourceLocation arrowTextures = new ResourceLocation("textures/entity/arrow.png");
public void doRender(EntityDevastationBeam par1EntityLaserBlast, double par2, double par4, double par6, float par8, float par9)
{
GL11.glPushMatrix();
GL11.glTranslatef((float)par2, (float)par4, (float)par6);
GL11.glRotatef(par1EntityLaserBlast.prevRotationYaw + (par1EntityLaserBlast.rotationYaw - par1EntityLaserBlast.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(par1EntityLaserBlast.prevRotationPitch + (par1EntityLaserBlast.rotationPitch - par1EntityLaserBlast.prevRotationPitch) * par9, 0.0F, 0.0F, 1.0F);
GL11.glScaled(3.5, 3.5, 3.5);
GL11.glDisable(3553);
GL11.glDisable(2896);
GL11.glEnable(3042);
GL11.glBlendFunc(770, 1);
GL11.glEnable(32826);
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setColorRGBA(this.red, this.green, this.blue, this.alpha);
tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, par2, par4);
tessellator.draw();
byte b0 = 0;
float f2 = 0.0F;
float f3 = 0.5F;
float f4 = (0 + b0 * 10) / 32.0F;
float f5 = (5 + b0 * 10) / 32.0F;
float f10 = 0.02625F;
GL11.glEnable(32826);
float f11 = par9;
if (f11 > 0.0F)
{
float f12 = -MathHelper.sin(f11 * 3.0F) * f11;
GL11.glRotatef(f12, 0.0F, 0.0F, 1.0F);
}
GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F);
GL11.glScalef(f10, f10, f10);
GL11.glTranslatef(-4.0F, 0.0F, 0.0F);
for (int i = 0; i < 4; i++)
{
GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
GL11.glNormal3f(0.0F, 0.0F, f10);
tessellator.startDrawingQuads();
tessellator.setColorRGBA(this.red, this.green, this.blue, this.alpha);
tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, f2, f4);
tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, f3, f4);
tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, f3, f5);
tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, f2, f5);
tessellator.draw();
}
tessellator.setColorRGBA(this.red, this.green, this.blue, this.alpha);
GL11.glDisable(32826);
GL11.glEnable(3042);
GL11.glEnable(2896);
GL11.glEnable(3553);
GL11.glPopMatrix();
}
protected ResourceLocation getEntityTexture(EntityDevastationBeam par1EntityLaserBlast)
{
return arrowTextures;
}
protected ResourceLocation getEntityTexture(Entity par1Entity)
{
return getEntityTexture((EntityDevastationBeam)par1Entity);
}
public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
{
doRender((EntityDevastationBeam)par1Entity, par2, par4, par6, par8, par9);
}
}
Devastation (Weapon)
package com.stormarmory.item;
import com.stormarmory.creativetabs.MCreativeTabs;
import com.stormarmory.lib.RefStrings;
import com.stormarmory.projectiles.EntityDevastationBeam;
import com.stormarmory.projectiles.EntityGenesisBossPulse;
import com.stormarmory.projectiles.EntityLightBullet;
import com.stormarmory.projectiles.EntityOriginationBullet;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntitySnowball;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBow;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.ArrowNockEvent;
@SuppressWarnings("unused")
public class Devastation extends ItemBow
{
private int firetick;
///This is my Weapon's cooldown time, in ticks.
private int firemax;
public Devastation()
{
super();
setUnlocalizedName("Origination");
setMaxStackSize(1);
setMaxDamage(150);
setCreativeTab(MCreativeTabs.tabNaturesRevenge);
this.firemax = 10;
this.firetick = this.firemax;
}
@SideOnly(Side.CLIENT)
public boolean isFull3D(){
return true;
}
public int getBrightnessForRender(float p_70070_1_)
{
return 15728880;
}
public float getBrightness(float p_70013_1_)
{
return 1.0F;
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World,EntityPlayer par3EntityPlayer) {
if(!par2World.isRemote) {
if (this.firetick == this.firemax && this.firemax != 0) {
if(!par2World.isRemote) {
par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
par2World.playSoundAtEntity(par3EntityPlayer, "stormarmory:boss.dropship.fire3", 10.0F, 1.0F);
par2World.spawnEntityInWorld(new EntityDevastationBeam(par2World, par3EntityPlayer));
par1ItemStack.damageItem(1, par3EntityPlayer);
}
this.firetick = 0;
} else {
++this.firetick;
}
if (this.firemax == 0) {
par2World.playSoundAtEntity(par3EntityPlayer, "stormarmory:boss.dropship.fire3", 10.0F, 1.0F);
par2World.spawnEntityInWorld(new EntityDevastationBeam(par2World, par3EntityPlayer));
}
}
return par1ItemStack;
}
@Override
public void onPlayerStoppedUsing(ItemStack var1, World var2, EntityPlayer var3, int var4) {
this.firetick = this.firemax;
}
public static void mainRegistry() {
}
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister reg){
this.itemIcon = reg.registerIcon(RefStrings.MODID + ":" + this.getUnlocalizedName());
}
}
Solved! Turns out all I needed to do was stretch the vertex of the projectile!