small framework for new kinds of arrows, and a test. Item has not been added.
Recipe for flatbread addedmain
parent
a170a43026
commit
e79d1bb319
@ -0,0 +1,13 @@
|
||||
package com.zivilon.cinder_loe.client.render.projectile;
|
||||
|
||||
import net.minecraft.client.renderer.entity.RenderArrow;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class RenderElvenArrow extends RenderArrow {
|
||||
private static final ResourceLocation arrowPoisonTexture = new ResourceLocation("lotr:item/arrowPoisoned.png");
|
||||
|
||||
protected ResourceLocation getEntityTexture(Entity entity) {
|
||||
return arrowPoisonTexture;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package com.zivilon.cinder_loe.entity.projectile;
|
||||
|
||||
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityElvenArrow extends EntityArrow implements IEntityAdditionalSpawnData {
|
||||
public EntityElvenArrow(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
public EntityElvenArrow(World world, double d, double d1, double d2) {
|
||||
super(world, d, d1, d2);
|
||||
}
|
||||
|
||||
public EntityElvenArrow(World world, EntityLivingBase shooter, EntityLivingBase target, float charge, float inaccuracy) {
|
||||
super(world, shooter, target, charge, inaccuracy);
|
||||
}
|
||||
|
||||
public EntityElvenArrow(World world, EntityLivingBase shooter, float charge) {
|
||||
super(world, shooter, charge);
|
||||
}
|
||||
|
||||
public void writeSpawnData(ByteBuf data) {
|
||||
data.writeDouble(this.motionX);
|
||||
data.writeDouble(this.motionY);
|
||||
data.writeDouble(this.motionZ);
|
||||
data.writeInt(this.shootingEntity == null ? -1 : this.shootingEntity.getEntityId());
|
||||
}
|
||||
|
||||
public void readSpawnData(ByteBuf data) {
|
||||
Entity entity;
|
||||
this.motionX = data.readDouble();
|
||||
this.motionY = data.readDouble();
|
||||
this.motionZ = data.readDouble();
|
||||
int id = data.readInt();
|
||||
if (id >= 0 && (entity = this.worldObj.getEntityByID(id)) != null) {
|
||||
this.shootingEntity = entity;
|
||||
}
|
||||
}
|
||||
|
||||
public void onCollideWithPlayer(EntityPlayer entityplayer) {
|
||||
boolean isInGround;
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
this.writeEntityToNBT(nbt);
|
||||
boolean bl = isInGround = nbt.getByte("inGround") == 1;
|
||||
if (!this.worldObj.isRemote && isInGround && this.arrowShake <= 0) {
|
||||
boolean pickup;
|
||||
boolean bl2 = pickup = this.canBePickedUp == 1 || this.canBePickedUp == 2 && entityplayer.capabilities.isCreativeMode;
|
||||
//Need to add it as an item first
|
||||
// if (this.canBePickedUp == 1 && !entityplayer.inventory.addItemStackToInventory(new ItemStack(LOTRMod.arrowPoisoned, 1))) {
|
||||
// pickup = false;
|
||||
// }
|
||||
if (pickup) {
|
||||
this.playSound("random.pop", 0.2f, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7f + 1.0f) * 2.0f);
|
||||
entityplayer.onItemPickup((Entity)this, 1);
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.zivilon.cinder_loe.util;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
|
||||
public class RangedDamageUtil {
|
||||
public static void applyExtraDamage(LivingHurtEvent event, float multiplier) {
|
||||
EntityLivingBase target = event.entityLiving;
|
||||
float base = event.ammount;
|
||||
float extra = base * multiplier;
|
||||
float currentHealth = target.getHealth();
|
||||
if (currentHealth > extra) {
|
||||
target.setHealth(currentHealth - extra);
|
||||
event.setCanceled(true);
|
||||
} else {
|
||||
event.ammount = currentHealth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue