Jump to content

Custom bow not spawning arrow entity (or any entity for that matter)


yorkeMC

Recommended Posts

My custom bow is not spawning an entity when I call world.spawnEntityInWorld(entity). I have even tried with other entities that are not arrows and they are still not spawning in the world. Help please?

 

CLASS

 

 

public class ItemAlfbow extends ItemBow implements IRelic, ICraftSoundEffect, IAethericActivity

{

// HUD

public static boolean inside = false;

public static float ticksHovered = 0F;

public static List<String> HUDData = new ArrayList<String>();

 

private static IIcon[] icons = new IIcon[3];

public static IIcon iconArrow;

 

public ItemAlfbow ()

{

super();

this.setCreativeTab(Alfhomancy.tabAlfhomancy);

this.setUnlocalizedName("ItemAlfbow");

this.setFull3D();

this.setMaxDamage(-1);

}

 

public EnumRarity getRarity (ItemStack s)

{

return AlfhomancyAPI.rarityAlfheim;

}

 

@Override

public void addInformation (ItemStack s, EntityPlayer p, List l, boolean f)

{

int atk = 0;

switch (getMode(s))

{

case 0 :

atk = 20;

break;

case 1 :

atk = 20;

break;

case 2 :

atk = 5;

break;

case 3 :

atk = 5;

break;

}

 

l.add(" ");

l.add(getModeString(s));

l.add("\u00A7b(" + StatCollector.translateToLocal("text.relic.mode.clickToChange") + ")");

l.add("\u00A79+" + atk + " " + StatCollector.translateToLocal("text.attackDamage"));

}

 

@Override

@SideOnly (Side.CLIENT)

public void registerIcons (IIconRegister ir)

{

this.itemIcon = ir.registerIcon("alfhomancy:ItemAlfbow");

this.iconArrow = ir.registerIcon("alfhomancy:ItemAlfbow_arrow");

 

for (int i = 0; i < 3; i++)

this.icons = ir.registerIcon("alfhomancy:ItemAlfbow_pulling" + i);

}

 

@Override

public IIcon getIcon (ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)

{

if (stack != usingItem) return itemIcon;

 

int j = (int) ( (getMaxItemUseDuration(stack) - useRemaining) * chargeVelocityMultiplier());

if (j >= 18) return icons[2];

if (j > 13) return icons[1];

if (j > 0) return icons[0];

 

return itemIcon;

}

 

boolean canFire (ItemStack s, World w, EntityPlayer p)

{

return AetherHandler.consumeAetherFromInventory(1, p, false);

}

 

float chargeVelocityMultiplier ()

{

return 1F;

}

 

@Override

public int getMaxItemUseDuration (ItemStack s)

{

return 72000;

}

 

@Override

public ItemStack onItemRightClick (ItemStack s, World w, EntityPlayer p)

{

ArrowNockEvent event = new ArrowNockEvent(p, s);

MinecraftForge.EVENT_BUS.post(event);

event.setCanceled(true);

 

if (!w.isRemote && p.isSneaking()) toggleMode(s);

if (!p.isSneaking() && canFire(s, w, p)) p.setItemInUse(s, getMaxItemUseDuration(s));

 

return s;

}

 

@Override

public void onPlayerStoppedUsing (ItemStack s, World w, EntityPlayer p, int i)

{

super.onPlayerStoppedUsing(s, w, p, i);

 

ArrowLooseEvent event = new ArrowLooseEvent(p, s, i);

MinecraftForge.EVENT_BUS.post(event);

event.setCanceled(true);

 

int j = (int) ( (getMaxItemUseDuration(s) - i) * chargeVelocityMultiplier());

 

boolean flag = canFire(s, w, p);

 

if (flag && AetherHandler.consumeAetherFromInventory(1, p, true) && !w.isRemote)

{

float f = j / 20.0F;

f = (f * f + f * 2.0F) / 3.0F;

 

if (f < 0.1D) return;

 

if (f > 1.0F) f = 1.0F;

 

boolean cor = (getMode(s) == 1) || (getMode(s) == 3);

boolean aoe = (getMode(s) == 2) || (getMode(s) == 3);

 

spawnArrow(s, w, cor, aoe, 0.0F);

w.playSoundAtEntity(p, "alfhomancy:swing", 1.0F, 0.3F + (float) Math.random());

}

}

 

private void spawnArrow (ItemStack s, World w, boolean cor, boolean aoe, float f)

{

EntityAlfbowArrow e = new EntityAlfbowArrow(w, cor, aoe, f);

w.spawnEntityInWorld(e);

}

 

@Override

public String getCreator (ItemStack s)

{

if (s.getTagCompound() != null) return s.getTagCompound().getString("creator");

else return null;

}

 

@Override

public boolean isBound (ItemStack s)

{

if (s.getTagCompound() != null) return s.getTagCompound().getBoolean("bound");

else return false;

}

 

@Override

public void bindToCreator (ItemStack s, String n)

{

if (s.stackTagCompound == null) s.stackTagCompound = new NBTTagCompound();

 

if (s.stackTagCompound != null)

{

s.stackTagCompound.setBoolean("bound", true);

s.stackTagCompound.setString("creator", n);

}

}

 

public void toggleMode (ItemStack s)

{

if (s.stackTagCompound == null)

{

s.setTagCompound(new NBTTagCompound());

}

s.stackTagCompound.setInteger("mode", getMode(s) < 3 ? getMode(s) + 1 : 0);

}

 

public static int getMode (ItemStack s)

{

if (s.stackTagCompound == null)

{

return 0;

}

return s.stackTagCompound.getInteger("mode");

}

 

public static String getModeString (ItemStack s)

{

String str = null;

switch (getMode(s))

{

case 0 :

str = StatCollector.translateToLocal("text.relic.mode.normal");

break;

case 1 :

str = StatCollector.translateToLocal("text.relic.mode.normal") + " \u00A79(" + StatCollector.translateToLocal("text.relic.mode.corrosive") + ")";

break;

case 2 :

str = StatCollector.translateToLocal("text.relic.mode.AoE");

break;

case 3 :

str = StatCollector.translateToLocal("text.relic.mode.AoE") + " \u00A79(" + StatCollector.translateToLocal("text.relic.mode.corrosive") + ")";

break;

}

 

return "\u00A76" + StatCollector.translateToLocal("text.relic.mode") + " \u00A7a" + str;

}

 

@Override

public boolean hasAethericActivity ()

{

return true;

}

 

@Override

public boolean isItemPlural ()

{

return false;

}

 

@Override

public String getVerbForAethericActivity ()

{

return StatCollector.translateToLocal("text.aether.activity.bursting");

}

 

@Override

public boolean soundEffectOnCraft ()

{

return true;

}

}

 

 

while(awake)

{

    coffee++;

}

Link to comment
Share on other sites

1.7 is not supported on this forum anymore once a moderator sees this thread it will be locked and asked to update so please update.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.