From 092c6c180c9acf5fccf905f03a5723c3370be796 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Sat, 11 May 2013 22:51:16 +1000 Subject: [PATCH] Made the dart blower use actual darts --- src/minecraft/biomesoplenty/ClientProxy.java | 18 ++-- src/minecraft/biomesoplenty/CommonProxy.java | 5 + .../configuration/BOPConfiguration.java | 7 ++ .../configuration/BOPEntities.java | 4 +- .../biomesoplenty/items/ItemDartBlower.java | 9 +- .../items/projectiles/EntityDart.java | 97 ++++++++---------- .../items/projectiles/RenderDart.java | 87 ++++++++++++++++ .../textures/projectiles/dart.png | Bin 0 -> 355 bytes 8 files changed, 155 insertions(+), 72 deletions(-) create mode 100644 src/minecraft/biomesoplenty/items/projectiles/RenderDart.java create mode 100644 src/minecraft/mods/BiomesOPlenty/textures/projectiles/dart.png diff --git a/src/minecraft/biomesoplenty/ClientProxy.java b/src/minecraft/biomesoplenty/ClientProxy.java index 5b923f719..92d43d197 100644 --- a/src/minecraft/biomesoplenty/ClientProxy.java +++ b/src/minecraft/biomesoplenty/ClientProxy.java @@ -5,12 +5,12 @@ import net.minecraft.client.particle.EntityBreakingFX; import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.entity.RenderSnowball; import net.minecraft.world.World; -import net.minecraftforge.client.MinecraftForgeClient; import biomesoplenty.api.Items; import biomesoplenty.blocks.renderers.FoliageRenderer; import biomesoplenty.blocks.renderers.PlantsRenderer; import biomesoplenty.items.projectiles.EntityDart; import biomesoplenty.items.projectiles.EntityMudball; +import biomesoplenty.items.projectiles.RenderDart; import cpw.mods.fml.client.registry.RenderingRegistry; public class ClientProxy extends CommonProxy { @@ -20,13 +20,8 @@ public class ClientProxy extends CommonProxy { @Override public void registerRenderers() { - MinecraftForgeClient.preloadTexture(ARMOR_MUD1_PNG); - MinecraftForgeClient.preloadTexture(ARMOR_MUD2_PNG); - MinecraftForgeClient.preloadTexture(ARMOR_AMETHYST1_PNG); - MinecraftForgeClient.preloadTexture(ARMOR_AMETHYST2_PNG); - RenderingRegistry.registerEntityRenderingHandler(EntityMudball.class, new RenderSnowball(Items.mudball.get(), 0)); - RenderingRegistry.registerEntityRenderingHandler(EntityDart.class, new RenderSnowball(Items.dart.get(), 0)); + RenderingRegistry.registerEntityRenderingHandler(EntityDart.class, new RenderDart()); RenderingRegistry.registerBlockHandler(new FoliageRenderer()); RenderingRegistry.registerBlockHandler(new PlantsRenderer()); @@ -39,6 +34,15 @@ public class ClientProxy extends CommonProxy { entityfx = new EntityBreakingFX(mc.theWorld, x, y, z, Items.mudball.get(), mc.renderEngine); mc.effectRenderer.addEffect(entityfx); + } + + @Override + public void spawnDart(World world, double x, double y, double z, double xVel, double yVel, double zVel) + { + EntityFX entityfx = null; + + entityfx = new EntityBreakingFX(mc.theWorld, x, y, z, Items.dart.get(), mc.renderEngine); + mc.effectRenderer.addEffect(entityfx); } @Override diff --git a/src/minecraft/biomesoplenty/CommonProxy.java b/src/minecraft/biomesoplenty/CommonProxy.java index 2d8d072d9..9c17286a9 100644 --- a/src/minecraft/biomesoplenty/CommonProxy.java +++ b/src/minecraft/biomesoplenty/CommonProxy.java @@ -21,5 +21,10 @@ public class CommonProxy { public void spawnMud(World world, double x, double y, double z, double xVel, double yVel, double zVel) { + } + + public void spawnDart(World world, double x, double y, double z, double xVel, double yVel, double zVel) + { + } } \ No newline at end of file diff --git a/src/minecraft/biomesoplenty/configuration/BOPConfiguration.java b/src/minecraft/biomesoplenty/configuration/BOPConfiguration.java index 79ed7951b..e0c589c3a 100644 --- a/src/minecraft/biomesoplenty/configuration/BOPConfiguration.java +++ b/src/minecraft/biomesoplenty/configuration/BOPConfiguration.java @@ -311,6 +311,9 @@ public class BOPConfiguration { public static int jungleNewID; public static int jungleHillsNewID; + public static int entityMudballID; + public static int entityDartID; + public static int jungleSpiderID; public static int rosesterID; @@ -689,6 +692,10 @@ public class BOPConfiguration { //Mob IDs jungleSpiderID = config.get("Mob IDs", "Jungle Spider ID", 101, null).getInt(); rosesterID = config.get("Mob IDs", "Rosester ID", 102, null).getInt(); + + //Projectile IDs + entityMudballID = config.get("Entity IDs", "Mudball ID", 103, null).getInt();; + entityDartID = config.get("Entity IDs", "Dart ID", 104, null).getInt();; System.out.println("Generating Biome ID's"); diff --git a/src/minecraft/biomesoplenty/configuration/BOPEntities.java b/src/minecraft/biomesoplenty/configuration/BOPEntities.java index eec2cb6aa..9362343b6 100644 --- a/src/minecraft/biomesoplenty/configuration/BOPEntities.java +++ b/src/minecraft/biomesoplenty/configuration/BOPEntities.java @@ -39,8 +39,8 @@ public class BOPEntities { public static void init() { - EntityRegistry.registerModEntity(EntityMudball.class, "MudBall", EntityRegistry.findGlobalUniqueEntityId(), BiomesOPlenty.instance, 80, 3, true); - EntityRegistry.registerModEntity(EntityDart.class, "Dart", EntityRegistry.findGlobalUniqueEntityId(), BiomesOPlenty.instance, 80, 3, true); + EntityRegistry.registerModEntity(EntityMudball.class, "MudBall", BOPConfiguration.entityMudballID, BiomesOPlenty.instance, 80, 3, true); + EntityRegistry.registerModEntity(EntityDart.class, "Dart", BOPConfiguration.entityDartID, BiomesOPlenty.instance, 80, 3, true); EntityRegistry.registerModEntity(EntityJungleSpider.class, "JungleSpider", BOPConfiguration.jungleSpiderID, BiomesOPlenty.instance, 80, 3, true); EntityRegistry.registerModEntity(EntityRosester.class, "Rosester", BOPConfiguration.rosesterID, BiomesOPlenty.instance, 80, 3, true); diff --git a/src/minecraft/biomesoplenty/items/ItemDartBlower.java b/src/minecraft/biomesoplenty/items/ItemDartBlower.java index 7e8917394..960df7815 100644 --- a/src/minecraft/biomesoplenty/items/ItemDartBlower.java +++ b/src/minecraft/biomesoplenty/items/ItemDartBlower.java @@ -34,8 +34,8 @@ public class ItemDartBlower extends Item if (flag || par3EntityPlayer.inventory.hasItem(Items.dart.get().itemID)) { - EntityArrow entitydart = new EntityArrow(par2World, par3EntityPlayer, 2.0F); - //EntityDart entitydart = new EntityDart(par2World, par3EntityPlayer, 2.0F); + //EntityArrow entitydart = new EntityArrow(par2World, par3EntityPlayer, 2.0F); + EntityDart entitydart = new EntityDart(par2World, par3EntityPlayer, 2.0F); itemStack.damageItem(1, par3EntityPlayer); par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1.0F, 2.0F / (1.0F * 0.4F + 1.2F) + 1.0F * 0.5F); @@ -45,14 +45,9 @@ public class ItemDartBlower extends Item if (!par2World.isRemote) - { par2World.spawnEntityInWorld(entitydart); - } } -// if (!par2World.isRemote) -// par2World.spawnEntityInWorld(new EntityDart(par2World, par3EntityPlayer)); - return itemStack; } } diff --git a/src/minecraft/biomesoplenty/items/projectiles/EntityDart.java b/src/minecraft/biomesoplenty/items/projectiles/EntityDart.java index 993898a73..f5c94d6fb 100644 --- a/src/minecraft/biomesoplenty/items/projectiles/EntityDart.java +++ b/src/minecraft/biomesoplenty/items/projectiles/EntityDart.java @@ -75,31 +75,31 @@ public class EntityDart extends EntityArrow } } -// if (this.inGround) -// { -// int j = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile); -// int k = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile); -// -// if (j == this.inTile && k == this.inData) -// { -// ++this.ticksInGround; -// -// if (this.ticksInGround == 1) -// { -// this.setDead(); -// } -// } -// else -// { -// this.inGround = false; -// this.motionX *= (double)(this.rand.nextFloat() * 0.2F); -// this.motionY *= (double)(this.rand.nextFloat() * 0.2F); -// this.motionZ *= (double)(this.rand.nextFloat() * 0.2F); -// this.ticksInGround = 0; -// this.ticksInAir = 0; -// } -// } -// else + if (this.inGround) + { + int j = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile); + int k = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile); + + if (j == this.inTile && k == this.inData) + { + ++this.ticksInGround; + + if (this.ticksInGround == 1) + { + this.setDead(); + } + } + else + { + this.inGround = false; + this.motionX *= (double)(this.rand.nextFloat() * 0.2F); + this.motionY *= (double)(this.rand.nextFloat() * 0.2F); + this.motionZ *= (double)(this.rand.nextFloat() * 0.2F); + this.ticksInGround = 0; + this.ticksInAir = 0; + } + } + else { ++this.ticksInAir; Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ); @@ -216,11 +216,11 @@ public class EntityDart extends EntityArrow } else { -// this.xTile = movingobjectposition.blockX; -// this.yTile = movingobjectposition.blockY; -// this.zTile = movingobjectposition.blockZ; -// this.inTile = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile); -// this.inData = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile); + this.xTile = movingobjectposition.blockX; + this.yTile = movingobjectposition.blockY; + this.zTile = movingobjectposition.blockZ; + this.inTile = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile); + this.inData = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile); this.motionX = (double)((float)(movingobjectposition.hitVec.xCoord - this.posX)); this.motionY = (double)((float)(movingobjectposition.hitVec.yCoord - this.posY)); this.motionZ = (double)((float)(movingobjectposition.hitVec.zCoord - this.posZ)); @@ -228,13 +228,19 @@ public class EntityDart extends EntityArrow this.posX -= this.motionX / (double)f2 * 0.05000000074505806D; this.posY -= this.motionY / (double)f2 * 0.05000000074505806D; this.posZ -= this.motionZ / (double)f2 * 0.05000000074505806D; + + for (int p = 0; i < 16; ++i) + { + BiomesOPlenty.proxy.spawnDart(this.worldObj, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); + } + this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); this.setDead(); -// if (this.inTile != 0) -// { -// Block.blocksList[this.inTile].onEntityCollidedWithBlock(this.worldObj, this.xTile, this.yTile, this.zTile, this); -// } + if (this.inTile != 0) + { + Block.blocksList[this.inTile].onEntityCollidedWithBlock(this.worldObj, this.xTile, this.yTile, this.zTile, this); + } } } @@ -285,28 +291,7 @@ public class EntityDart extends EntityArrow this.motionZ *= (double)f4; this.motionY -= (double)f1; this.setPosition(this.posX, this.posY, this.posZ); - //this.doBlockCollisions(); + this.doBlockCollisions(); } } - -// @Override -// protected void onImpact(MovingObjectPosition par1MovingObjectPosition) -// { -// -// if (par1MovingObjectPosition.entityHit != null) -// { -// par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 2); -// //((EntityLiving)par1MovingObjectPosition.entityHit).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 300)); -// } -// -// for (int i = 0; i < 16; ++i) -// { -// //BiomesOPlenty.proxy.spawnMud(this.worldObj, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); -// } -// -// if (!this.worldObj.isRemote) -// { -// this.setDead(); -// } -// } } \ No newline at end of file diff --git a/src/minecraft/biomesoplenty/items/projectiles/RenderDart.java b/src/minecraft/biomesoplenty/items/projectiles/RenderDart.java new file mode 100644 index 000000000..3db9df5de --- /dev/null +++ b/src/minecraft/biomesoplenty/items/projectiles/RenderDart.java @@ -0,0 +1,87 @@ +package biomesoplenty.items.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.entity.projectile.EntityArrow; +import net.minecraft.util.MathHelper; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class RenderDart extends Render +{ + public void renderArrow(EntityArrow par1EntityArrow, double par2, double par4, double par6, float par8, float par9) + { + this.loadTexture("/mods/BiomesOPlenty/textures/projectiles/dart.png"); + GL11.glPushMatrix(); + GL11.glTranslatef((float)par2, (float)par4, (float)par6); + GL11.glRotatef(par1EntityArrow.prevRotationYaw + (par1EntityArrow.rotationYaw - par1EntityArrow.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(par1EntityArrow.prevRotationPitch + (par1EntityArrow.rotationPitch - par1EntityArrow.prevRotationPitch) * par9, 0.0F, 0.0F, 1.0F); + Tessellator tessellator = Tessellator.instance; + byte b0 = 0; + float f2 = 0.0F; + float f3 = 0.5F; + float f4 = (float)(0 + b0 * 10) / 32.0F; + float f5 = (float)(5 + b0 * 10) / 32.0F; + float f6 = 0.0F; + float f7 = 0.15625F; + float f8 = (float)(5 + b0 * 10) / 32.0F; + float f9 = (float)(10 + b0 * 10) / 32.0F; + float f10 = 0.05625F; + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + float f11 = (float)par1EntityArrow.arrowShake - 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); + GL11.glNormal3f(f10, 0.0F, 0.0F); + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f8); + tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f8); + tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f9); + tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f9); + tessellator.draw(); + GL11.glNormal3f(-f10, 0.0F, 0.0F); + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f8); + tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f8); + tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f9); + tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f9); + tessellator.draw(); + + 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.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double)f2, (double)f4); + tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, (double)f3, (double)f4); + tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, (double)f3, (double)f5); + tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double)f2, (double)f5); + tessellator.draw(); + } + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then + * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic + * (Render!lvI6;>1s;*b3=DjSL74G){)!Z!pj3%#L`iUdT1k0gQ7S_~VrE{6o}X)oLYc9i zsh**M!Iz?iKvkDKT^vIq+}}<)$a~0u$8|F=^94?eg2#PUY{mu*;d+UjVjV|RB9B}N z)NxfTmEC&C_J?PD>1wb4-_?6}%kqD);s3C6-hs@6tsIIDJ%+aP@BO@(75CjcNHS?x z`}bs@@b|U>9k*n*a>g)AFtiru_C=l5`^M1Z_-O_6wh71oJ9#?&6$31D$*M%`J;;VtaWAJqKb6Mw<&;$U2Ab%79 literal 0 HcmV?d00001