Rework dagger into a projectileBase entity!

This commit is contained in:
Bernhard Bonigl committed 2014-10-22 23:42:08 +02:00
1 parent 46059d6913
commit dbc446636f
11 files changed
+83 -74

No files matched your search

@@ -15,6 +15,7 @@ import org.lwjgl.opengl.*;
import tconstruct.tools.entity.ArrowEntity;
@SideOnly(Side.CLIENT)
@Deprecated
public class ArrowRender extends Render
{
private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png");
@@ -13,6 +13,7 @@ import org.lwjgl.opengl.*;
import tconstruct.tools.entity.ArrowEntity;
@SideOnly(Side.CLIENT)
@Deprecated
public class ArrowRenderCustom extends Render
{
private static RenderItem renderer = new RenderItem();
@@ -17,6 +17,7 @@ import org.lwjgl.opengl.*;
import tconstruct.tools.entity.DaggerEntity;
@SideOnly(Side.CLIENT)
@Deprecated
public class DaggerRender extends Render
{
private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png");
@@ -14,6 +14,7 @@ import tconstruct.client.ToolCoreRenderer;
import tconstruct.tools.entity.DaggerEntity;
@SideOnly(Side.CLIENT)
@Deprecated
public class DaggerRenderCustom extends Render
{
private static RenderItem renderer = new RenderItem();
@@ -21,9 +21,10 @@ public class Dagger extends Weapon
ItemStack stack = itemstack.copy();
if (!world.isRemote)
{
DaggerEntity dagger = new DaggerEntity(stack, world, player);
DaggerEntity dagger = new DaggerEntity(world, player, 1.5f, 0, stack);
//dagger.motionY++;
if (player.capabilities.isCreativeMode)
dagger.doNotRetrieve = true;
dagger.canBePickedUp = 2;
world.spawnEntityInWorld(dagger);
}
itemstack.stackSize--;
@@ -36,7 +37,8 @@ public class Dagger extends Weapon
ItemStack stack = itemstack.copy();
if (!world.isRemote)
{
DaggerEntity dagger = new DaggerEntity(stack, world, player);
DaggerEntity dagger = new DaggerEntity(world, player, 1.5f, 0, stack);
//dagger.motionY++;
world.spawnEntityInWorld(dagger);
}
itemstack.stackSize--;
@@ -23,6 +23,7 @@ import tconstruct.library.client.*;
import tconstruct.library.crafting.*;
import tconstruct.library.tools.ToolCore;
import tconstruct.smeltery.TinkerSmeltery;
import tconstruct.tools.client.DaggerEntityRenderer;
import tconstruct.tools.entity.*;
import tconstruct.tools.gui.*;
import tconstruct.tools.logic.*;
@@ -51,8 +52,9 @@ public class ToolProxyClient extends ToolProxyCommon
RenderingRegistry.registerBlockHandler(new BattlesignRender());
RenderingRegistry.registerEntityRenderingHandler(LaunchedPotion.class, new LaunchedItemRender(Items.potionitem, 16384));
RenderingRegistry.registerEntityRenderingHandler(DaggerEntity.class, new DaggerRenderCustom());
RenderingRegistry.registerEntityRenderingHandler(ArrowEntity.class, new ArrowRenderCustom());
RenderingRegistry.registerEntityRenderingHandler(DaggerEntity.class, new DaggerEntityRenderer());
//RenderingRegistry.registerEntityRenderingHandler(DaggerEntity.class, new DaggerRenderCustom());
//RenderingRegistry.registerEntityRenderingHandler(ArrowEntity.class, new ArrowRenderCustom());
RenderingRegistry.registerEntityRenderingHandler(FancyEntityItem.class, new FancyItemRender());
//MinecraftForgeClient.registerItemRenderer(TinkerTools.shortbow, new CustomBowRenderer());
@@ -0,0 +1,25 @@
package tconstruct.tools.client;
import org.lwjgl.opengl.GL11;
import tconstruct.tools.entity.DaggerEntity;
import tconstruct.weaponry.client.entity.ProjectileBaseRenderer;
public class DaggerEntityRenderer extends ProjectileBaseRenderer<DaggerEntity> {
@Override
public void customRendering(DaggerEntity entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) {
// rotate it into the direction we threw it
GL11.glRotatef(entity.rotationYaw, 0f, 1f, 0f);
GL11.glRotatef(-entity.rotationPitch, 1f, 0f, 0f);
// rotate it into a vertical position
GL11.glRotatef(90f, 0f, 1f, 0f);
// it rotates!
GL11.glRotatef(entity.roll, 0f, 0f, 1f);
// also make it a bit thicker
toolCoreRenderer.setDepth(1/20f);
}
}
@@ -17,6 +17,7 @@ import net.minecraft.network.play.server.S2BPacketChangeGameState;
import net.minecraft.util.*;
import net.minecraft.world.World;
@Deprecated
public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnData
{
public ItemStack returnStack;
@@ -6,86 +6,60 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.*;
import net.minecraft.world.World;
import tconstruct.items.tools.Dagger;
import tconstruct.library.entity.ProjectileBase;
import tconstruct.library.tools.*;
public class DaggerEntity extends RotatingBase
public class DaggerEntity extends ProjectileBase
{
public int roll;
public DaggerEntity(World world)
{
public DaggerEntity(World world) {
super(world);
}
public DaggerEntity(ItemStack itemstack, World world, EntityPlayer entityplayer)
{
super(world, entityplayer, 0.75F, 0.8F);
// TConstruct.logger.info("Stack: "+itemstack);
returnStackSlot = entityplayer.inventory.currentItem;
returnStack = itemstack;
public DaggerEntity(World world, double d, double d1, double d2) {
super(world, d, d1, d2);
}
public DaggerEntity(World world, EntityPlayer entityplayer, float f, float g)
{
super(world, entityplayer, f, g);
}
public DaggerEntity(World world, EntityPlayer player, float speed, float accuracy, ItemStack stack) {
super(world, player, speed, accuracy, stack);
/*
* public void entityInit () { super.entityInit(); }
*/
@Override
public void onHit (MovingObjectPosition movingobjectposition)
{
if (movingobjectposition.entityHit != null)
{
if (movingobjectposition.entityHit.attackEntityFrom(DamageSource.causeMobDamage(owner), damageDealt))
{
worldObj.playSoundAtEntity(this, "random.drr", 1.0F, 1.2F / (rand.nextFloat() * 0.2F + 0.9F));
motionX *= -0.1D;
motionY *= -0.1D;
motionZ *= -0.1D;
rotationYaw += 180F;
prevRotationYaw += 180F;
ticksInAir = 0;
if (movingobjectposition.entityHit instanceof EntityLiving)
{
Dagger dagger = (Dagger) returnStack.getItem();
this.hitEntity(returnStack, (EntityLiving) movingobjectposition.entityHit, owner, dagger);
}
}
}
else
{
onGround = true;
xTile = movingobjectposition.blockX;
yTile = movingobjectposition.blockY;
zTile = movingobjectposition.blockZ;
inTile = worldObj.getBlock(xTile, yTile, zTile);
motionX = (float) (movingobjectposition.hitVec.xCoord - posX);
motionY = (float) (movingobjectposition.hitVec.yCoord - posY);
motionZ = (float) (movingobjectposition.hitVec.zCoord - posZ);
float f = MathHelper.sqrt_double(motionX * motionX + motionY * motionY + motionZ * motionZ);
posX -= (motionX / (double) f) * 0.05D;
posY -= (motionY / (double) f) * 0.05D;
posZ -= (motionZ / (double) f) * 0.05D;
worldObj.playSoundAtEntity(this, "random.drr", 1.0F, 1.2F / (rand.nextFloat() * 0.2F + 0.9F));
arrowShake = 7;
if (!worldObj.isRemote)
AbilityHelper.damageTool(returnStack, 1, owner, false);
}
}
public boolean hitEntity (ItemStack stack, EntityLiving mob, EntityPlayer player, ToolCore weapon)
{
if (!worldObj.isRemote && player.canAttackWithItem())
{
AbilityHelper.onLeftClickEntity(stack, player, mob, weapon);
}
return true;
float pitch = Math.max(-90f, player.rotationPitch - 20f);
// same as in the others, but with pitch upped
this.setLocationAndAngles(player.posX, player.posY + (double)player.getEyeHeight(), player.posZ, player.rotationYaw, pitch);
this.posX -= MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F;
this.posY -= 0.10000000149011612D;
this.posZ -= MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F;
this.setPosition(this.posX, this.posY, this.posZ);
this.yOffset = 0.0F;
this.motionX = -MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI);
this.motionZ = +MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI);
this.motionY = -MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI);
this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, speed, accuracy);
}
@Override
protected void dealFireDamage (int i)
{
public void onUpdate() {
// you turn me right round baby
if(this.ticksInGround == 0)
roll = (roll + 20) % 360;
super.onUpdate();
}
@Override
public void onHitEntity(MovingObjectPosition movingobjectposition) {
AbilityHelper.onLeftClickEntity(returnStack, (EntityPlayer)shootingEntity, movingobjectposition.entityHit, (ToolCore)returnStack.getItem());
//super.onHitEntity(movingobjectposition);
}
@Override
protected double getGravity() {
return 0.1;
}
@Override
protected double getSlowdown() {
return 0.02;
}
}
@@ -14,6 +14,7 @@ import net.minecraft.util.*;
import net.minecraft.world.World;
import tconstruct.library.tools.AbilityHelper;
@Deprecated
public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
{
@@ -49,7 +49,7 @@ public class ShurikenEntity extends ProjectileBase {
@Override
protected double getGravity() {
return 0;
return 0; // todo: remove debug code ;)
//return (this.ticksExisted/8) * 0.018d; // integer division. so the first 20 ticks it will have no gravity at all.
}