Advertisement
Telinc1

Meteor Bomb is doing stuff...

Nov 9th, 2012
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.69 KB | None | 0 0
  1. *** TelicraftCommonProxy.java ***
  2.  
  3. package telinc.telicraft.common.core;
  4.  
  5. public class TelicraftCommonProxy {
  6.     public void registerRenderThings() {}
  7. }
  8.  
  9.  
  10. *** TelicraftClientProxy.java ***
  11.  
  12. package telinc.telicraft.client;
  13.  
  14. import net.minecraftforge.client.MinecraftForgeClient;
  15. import telinc.telicraft.client.entities.RenderMeteorBomb;
  16. import telinc.telicraft.client.entities.RenderPetrify;
  17. import telinc.telicraft.common.TelicraftMain;
  18. import telinc.telicraft.common.core.TelicraftCommonProxy;
  19. import telinc.telicraft.common.entities.EntityMeteorBombPrimed;
  20. import telinc.telicraft.common.entities.EntityPetrify;
  21. import cpw.mods.fml.client.registry.RenderingRegistry;
  22.  
  23. public class TelicraftClientProxy extends TelicraftCommonProxy {
  24.     @Override
  25.     public void registerRenderThings() {
  26.         MinecraftForgeClient.preloadTexture("/telinc/telicraft/textures/blocks.png");
  27.         MinecraftForgeClient.preloadTexture("/telinc/telicraft/textures/items.png");
  28.        
  29.         RenderingRegistry.registerEntityRenderingHandler(EntityMeteorBombPrimed.class, new RenderMeteorBomb());
  30.     }
  31. }
  32.  
  33.  
  34. *** RenderMeteorBomb.java ***
  35.  
  36. package telinc.telicraft.client.entities;
  37.  
  38. import net.minecraft.src.Block;
  39. import net.minecraft.src.Entity;
  40. import net.minecraft.src.EntityTNTPrimed;
  41. import net.minecraft.src.Render;
  42. import net.minecraft.src.RenderBlocks;
  43.  
  44. import org.lwjgl.opengl.GL11;
  45.  
  46. import telinc.telicraft.common.TelicraftMain;
  47. import telinc.telicraft.common.entities.EntityMeteorBombPrimed;
  48.  
  49. import cpw.mods.fml.common.Side;
  50. import cpw.mods.fml.common.asm.SideOnly;
  51.  
  52. @SideOnly(Side.CLIENT)
  53. public class RenderMeteorBomb extends Render
  54. {
  55.     private RenderBlocks blockRenderer = new RenderBlocks();
  56.  
  57.     public RenderMeteorBomb()
  58.     {
  59.         this.shadowSize = 0.5F;
  60.     }
  61.  
  62.     public void renderPrimedMeteorBomb(EntityMeteorBombPrimed par1Entity, double par2, double par4, double par6, float par8, float par9)
  63.     {
  64.         GL11.glPushMatrix();
  65.         GL11.glTranslatef((float)par2, (float)par4, (float)par6);
  66.         float var10;
  67.  
  68.         if ((float)par1Entity.fuse - par9 + 1.0F < 10.0F)
  69.         {
  70.             var10 = 1.0F - ((float)par1Entity.fuse - par9 + 1.0F) / 10.0F;
  71.  
  72.             if (var10 < 0.0F)
  73.             {
  74.                 var10 = 0.0F;
  75.             }
  76.  
  77.             if (var10 > 1.0F)
  78.             {
  79.                 var10 = 1.0F;
  80.             }
  81.  
  82.             var10 *= var10;
  83.             var10 *= var10;
  84.             float var11 = 1.0F + var10 * 0.3F;
  85.             GL11.glScalef(var11, var11, var11);
  86.         }
  87.  
  88.         var10 = (1.0F - ((float)par1Entity.fuse - par9 + 1.0F) / 100.0F) * 0.8F;
  89.         this.loadTexture("/telinc/telicraft/textures/blocks.png");
  90.         this.blockRenderer.renderBlockAsItem(TelicraftMain.meteorBomb, 0, par1Entity.getBrightness(par9));
  91.  
  92.         if (par1Entity.fuse / 5 % 2 == 0)
  93.         {
  94.             GL11.glDisable(GL11.GL_TEXTURE_2D);
  95.             GL11.glDisable(GL11.GL_LIGHTING);
  96.             GL11.glEnable(GL11.GL_BLEND);
  97.             GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA);
  98.             GL11.glColor4f(1.0F, 1.0F, 1.0F, var10);
  99.             this.blockRenderer.renderBlockAsItem(Block.tnt, 0, 1.0F);
  100.             GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
  101.             GL11.glDisable(GL11.GL_BLEND);
  102.             GL11.glEnable(GL11.GL_LIGHTING);
  103.             GL11.glEnable(GL11.GL_TEXTURE_2D);
  104.         }
  105.  
  106.         GL11.glPopMatrix();
  107.     }
  108.  
  109.     /**
  110.      * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
  111.      * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
  112.      * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
  113.      * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
  114.      */
  115.     public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
  116.     {
  117.         this.renderPrimedMeteorBomb((EntityMeteorBombPrimed)par1Entity, par2, par4, par6, par8, par9);
  118.     }
  119. }
  120.  
  121.  
  122. *** EntityMeteorBombPrimed.java ***
  123.  
  124. package telinc.telicraft.common.entities;
  125.  
  126. import cpw.mods.fml.common.Side;
  127. import cpw.mods.fml.common.asm.SideOnly;
  128. import net.minecraft.src.Entity;
  129. import net.minecraft.src.NBTTagCompound;
  130. import net.minecraft.src.World;
  131.  
  132. public class EntityMeteorBombPrimed extends Entity {
  133.    
  134.     public int fuse;
  135.    
  136.     public EntityMeteorBombPrimed(World par1World) {
  137.         super(par1World);
  138.         this.fuse = 0;
  139.         this.preventEntitySpawning = true;
  140.         this.setSize(0.98F, 0.98F);
  141.         this.yOffset = this.height / 2.0F;
  142.     }
  143.  
  144.     public EntityMeteorBombPrimed(World par1World, double par2, double par4,
  145.             double par6) {
  146.         this(par1World);
  147.         this.setPosition(par2, par4, par6);
  148.         float var8 = (float) (Math.random() * Math.PI * 2.0D);
  149.         this.motionX = (double) (-((float) Math.sin((double) var8)) * 0.02F);
  150.         this.motionY = 0.20000000298023224D;
  151.         this.motionZ = (double) (-((float) Math.cos((double) var8)) * 0.02F);
  152.         this.fuse = 200;
  153.         this.prevPosX = par2;
  154.         this.prevPosY = par4;
  155.         this.prevPosZ = par6;
  156.     }
  157.  
  158.     @Override
  159.     protected void entityInit() {}
  160.  
  161.     @Override
  162.     protected boolean canTriggerWalking() {
  163.         return false;
  164.     }
  165.  
  166.     @Override
  167.     public boolean canBeCollidedWith() {
  168.         return !isDead;
  169.     }
  170.  
  171.     @Override
  172.     public void onUpdate() {
  173.         this.prevPosX = this.posX;
  174.         this.prevPosY = this.posY;
  175.         this.prevPosZ = this.posZ;
  176.         this.motionY -= 0.03999999910593033D;
  177.         this.moveEntity(this.motionX, this.motionY, this.motionZ);
  178.         this.motionX *= 0.9800000190734863D;
  179.         this.motionY *= 0.9800000190734863D;
  180.         this.motionZ *= 0.9800000190734863D;
  181.  
  182.         if (this.onGround) {
  183.             this.motionX *= 0.699999988079071D;
  184.             this.motionZ *= 0.699999988079071D;
  185.             this.motionY *= -0.5D;
  186.         }
  187.  
  188.         if (this.fuse-- <= 0) {
  189.             this.setDead();
  190.  
  191.             if (!this.worldObj.isRemote) {
  192.                 this.explode();
  193.             }
  194.         } else {
  195.             this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D);
  196.             this.worldObj.spawnParticle("flame", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D);
  197.             this.worldObj.spawnParticle("lava", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D);
  198.         }
  199.     }
  200.  
  201.     @Override
  202.     protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
  203.         fuse = par1NBTTagCompound.getByte("Fuse");
  204.     }
  205.  
  206.     @Override
  207.     protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {
  208.         par1NBTTagCompound.setByte("Fuse", (byte)fuse);
  209.     }
  210.    
  211.     @Override
  212.     @SideOnly(Side.CLIENT)
  213.     public float getShadowSize(){
  214.         return 0.0F;
  215.     }
  216.    
  217.     private void explode() {
  218.         float var1 = 45.69F;
  219.         this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, var1, true);
  220.     }
  221. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement