Skip to content

Commit

Permalink
Arrows with knockback :D:D
Browse files Browse the repository at this point in the history
  • Loading branch information
bonii-xx committed Oct 26, 2014
1 parent d96379f commit dc1ecab
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 68 deletions.
2 changes: 1 addition & 1 deletion src/main/java/tconstruct/client/AmmoItemRenderer.java
Expand Up @@ -48,7 +48,7 @@ public void renderAmmoCount(ItemStack item)

GL11.glScalef(0.7f, 0.7f, 0.7f);
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
//fontRenderer.drawStringWithShadow(str, 7 + 19 - 2 - fontRenderer.getStringWidth(str), 7 + 6 + 3, 16777215);
fontRenderer.drawStringWithShadow(str, 7 + 19 - 2 - fontRenderer.getStringWidth(str), 7 + 6 + 3, 16777215);

GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
Expand Down
74 changes: 8 additions & 66 deletions src/main/java/tconstruct/library/entity/ProjectileBase.java
Expand Up @@ -120,20 +120,24 @@ protected void playHitEntitySound()
*/
protected double getStuckDepth() { return 0.5f; }

protected void doLivingHit(EntityLivingBase entityHit)
protected void doLivingHit(EntityLivingBase entityHit)
{
float knockback = returnStack.getTagCompound().getCompoundTag("InfiTool").getFloat("Knockback");
if(shootingEntity instanceof EntityLivingBase)
knockback += EnchantmentHelper.getKnockbackModifier((EntityLivingBase) shootingEntity, entityHit);

if (!this.worldObj.isRemote)
{
entityHit.setArrowCountInEntity(entityHit.getArrowCountInEntity() + 1);
}

if (this.knockbackStrength > 0)
if (knockback > 0)
{
double horizontalSpeed = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);

if (horizontalSpeed > 0.0F)
{
entityHit.addVelocity(this.motionX * (double) this.knockbackStrength * 0.6000000238418579D / (double) horizontalSpeed, 0.1D, this.motionZ * (double) this.knockbackStrength * 0.6000000238418579D / (double) horizontalSpeed);
entityHit.addVelocity(this.motionX * (double) knockback * 0.6000000238418579D / horizontalSpeed, 0.1D, this.motionZ * (double) knockback * 0.6000000238418579D / (double) horizontalSpeed);
}
}

Expand Down Expand Up @@ -550,43 +554,7 @@ public void writeSpawnData(ByteBuf data) {
NBTTagCompound tags = returnStack.getTagCompound().getCompoundTag("InfiTool");
ByteBufUtils.writeItemStack(data, returnStack);
data.writeFloat(rotationYaw);
/*
data.writeInt(tags.getInteger("RenderHandle"));
data.writeInt(tags.getInteger("RenderHead"));
data.writeInt(tags.getInteger("RenderAccessory"));
data.writeInt(tags.getInteger("RenderExtra"));
int effects = 0;
if (tags.hasKey("Effect1"))
effects++;
if (tags.hasKey("Effect2"))
effects++;
if (tags.hasKey("Effect3"))
effects++;
if (tags.hasKey("Effect4"))
effects++;
if (tags.hasKey("Effect5"))
effects++;
if (tags.hasKey("Effect6"))
effects++;
data.writeInt(effects);
switch (effects)
{
case 6:
data.writeInt(tags.getInteger("Effect6"));
case 5:
data.writeInt(tags.getInteger("Effect5"));
case 4:
data.writeInt(tags.getInteger("Effect4"));
case 3:
data.writeInt(tags.getInteger("Effect3"));
case 2:
data.writeInt(tags.getInteger("Effect2"));
case 1:
data.writeInt(tags.getInteger("Effect1"));
}
*/

// shooting entity
int id = shootingEntity == null ? this.getEntityId() : shootingEntity.getEntityId();
data.writeInt(id);
Expand All @@ -596,32 +564,6 @@ public void writeSpawnData(ByteBuf data) {
public void readSpawnData(ByteBuf data) {
returnStack = ByteBufUtils.readItemStack(data);
rotationYaw = data.readFloat();
/*
NBTTagCompound compound = new NBTTagCompound();
NBTTagCompound toolTag = new NBTTagCompound();
toolTag.setInteger("RenderHandle", data.readInt());
toolTag.setInteger("RenderHead", data.readInt());
toolTag.setInteger("RenderAccessory", data.readInt());
toolTag.setInteger("RenderExtra", data.readInt());
switch (data.readInt())
{
case 6:
toolTag.setInteger("Effect6", data.readInt());
case 5:
toolTag.setInteger("Effect5", data.readInt());
case 4:
toolTag.setInteger("Effect4", data.readInt());
case 3:
toolTag.setInteger("Effect3", data.readInt());
case 2:
toolTag.setInteger("Effect2", data.readInt());
case 1:
toolTag.setInteger("Effect1", data.readInt());
}
compound.setTag("InfiTool", toolTag);
returnStack.setTagCompound(compound);
*/
shootingEntity = worldObj.getEntityByID(data.readInt());
}
}
2 changes: 1 addition & 1 deletion src/main/java/tconstruct/modifiers/tools/ModPiston.java
Expand Up @@ -96,6 +96,6 @@ void updateModTag (ItemStack tool, int[] keys)
public boolean validType (ToolCore tool)
{
List list = Arrays.asList(tool.getTraits());
return list.contains("weapon");
return list.contains("weapon") || list.contains("ammo");
}
}

0 comments on commit dc1ecab

Please sign in to comment.