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.


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • You can try other builds of Quark/Zeta
    • Hello all, I recently tried to upgrade my Minecraft mod to version 1.21.3, and I seem to have a problem with the `RenderSystem#setShaderColor` method. Here is how the screen is usually supposed to look like: Here is how it looks at present: To further explain, the note labels atop of the note buttons are colored cyan (here) using `RenderSystem#setShaderColor`. The note buttons and labels get their colors from their native texture - white. This means that even though I set the coloring to apply to the label (top), it is applied to the button (bottom). What I conclude is happening then, in essence, is that this method (at least for my case) does not color the blit after - but rather the blit before..?  This also blocks me from later resetting the shader, as I need to set it back to white before the blitting is done, and not when it's done. So like... what? I've tested this further with other components that require this method, and this preceding-like behavior seems to be pretty consistent for them too.   I should mention that all the snippets I am about to show have all worked in past versions. In my class `ClientUtil`, the following methods are defined: public static void setShaderColor(final Color color, final float alpha) { RenderSystem.setShaderColor( color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, alpha ); } public static void setShaderColor(final Color color) { setShaderColor(color, 1); } public static void resetShaderColor() { setShaderColor(Color.WHITE); } //... public static RenderType guiRT(final ResourceLocation loc) { return RenderType.guiTextured(loc); } And here is the snippet from `NoteButtonRenderer#renderNote` using it: // "Note" here refers to those symbols in the middle of a note button protected void renderNote(final GuiGraphics gui, final InstrumentThemeLoader themeLoader) { final int noteWidth = noteButton.getWidth()/2, noteHeight = noteButton.getHeight()/2; ClientUtil.setShaderColor((noteButton.isPlaying() && !foreignPlaying) ? themeLoader.notePressed() : themeLoader.noteReleased() ); gui.blit(ClientUtil::guiRT, noteTextureProvider.get(), noteButton.getX() + noteWidth/2, noteButton.getY() + noteHeight/2, 0, 0, noteWidth, noteHeight, noteWidth, noteButton.getHeight()/2 ); ClientUtil.resetShaderColor(); } You may find the full source here. The odd thing is that Minecraft does seem to use this method the regular way I showed, for instance `SkyRenderer#renderSkyDisc` (not sure if I'l allowed to paste it). Could it be that I'm doing something wrong that leads to this issue..? I'm really stumped on this one.  I couldn't really find any change logs or documentation for this rendering API (even in this Fabric blog post), so I'm sorry if this seems obvious or anything.  Either way, any help would be appreciated.
    • This did work. rip Quark Thank you
    • It says Quark Requires zeta. do i just remove Quark? https://mclo.gs/cq799kI
    • It refers to the mod elenaidodge Backup the world and make a test without it
  • Topics

×
×
  • Create New...

Important Information

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