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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • There's a scheme I got into where they promised to trade Bitcoin for me and take a cut as a commission. Seemed like a good idea at the time. But then, things went south real fast. They ended up transferring   $190,000 worth of my Bitcoin. I was devastated and felt completely helpless. That's when I stumbled upon the Wizard Web Recovery Tool. It was like a beacon of hope amid chaos. With this tool, I could finally start digging into what went wrong and hopefully get my Bitcoin back. Using Wizard Web was surprisingly easy. I just had to plug in some details about my Bitcoin account and let it do its thing. It started scanning the internet, looking for any clues about what happened to my Bitcoin. It felt like having a detective on my side, searching for answers. And guess what? Wizard Web found some leads. It uncovered evidence of the scheme's shady dealings and helped me track down the people responsible for losing my Bitcoin. Armed with this information, I took the case to court. After a long and hard-fought legal battle, the court ruled in my favor. The perpetrators were held accountable for their actions and faced criminal charges for their involvement in the scheme. It was a victory not just for me, but for anyone who's been taken advantage of by these kinds of scams. Thanks to Wizard Web Recovery, I was able to get justice and reclaim what was rightfully mine. It showed me that even in the face of adversity, there's always a way to fight back. And with the right tools and determination, anything is possible.   The following is the contact information for Wizard Web Recovery.   Email: wizard web recovery((@))programmer . net
    • Hello, good morning. I know some programming and I'm interested in mod creation. That's why I've decided to follow a tutorial guide on YouTube by TurtyWurty. https://www.youtube.com/watch?v=DhoX9cmAZqA&t=160s&ab_channel=TurtyWurty I've followed the tutorial perfectly. The problem is that when checking the food, the texture doesn't load for me. However, everything seems fine no matter how much I check. I'm sure it's something trivial, the problem is that I can't find it. Could you help me solve it, please? I leave a zip of my file so you can edit it freely. forge-1.20-Civicraft.rar
    • If you have nvidia graphics, it's important that you make sure Minecraft (and anything Minecraft-related) is set to prefer high performance graphics first. If you only update your AMD drivers it might fix the issue but cause severe performance loss vs Vanilla as it'll be running on the integrated graphics instead of dedicated nvidia graphics
    • Update your drivers: https://www.amd.com/en/support/downloads/drivers.html/processors/ryzen/ryzen-5000-series/amd-ryzen-5-5600g.html
  • Topics

×
×
  • Create New...

Important Information

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