if (!playerIn.capabilities.isCreativeMode) {
--itemStackIn.stackSize;
}
remove it and your itemstack will not decrease
That worked! Thanks, how do I shoot a projectile like the bow does with the arrows. But I don't want 3 (or is it 4?) animations, just a blast to shoot like the snowball one. Sorry if I confused whoever can help.
I followed the snowball rendering, and now I'm stuck at rendering registry. I will show you the code. It's easier to see than explain(it's hard to).
Rendering repulsor:
package com.spyeedy.heroesplus.classes.ironman;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
public class RenderRepulsorBolt extends RenderSnowball {
public static final ResourceLocation repulsortexture = new ResourceLocation("psm:textures/items/ironman/items/repulsor.png");
public RenderRepulsorBolt(RenderManager p_i46137_1_, Item p_i46137_2_, RenderItem p_i46137_3_) {
super(p_i46137_1_, p_i46137_2_, p_i46137_3_);
}
@Override
public ResourceLocation getEntityTexture(Entity entity) {
return null;
}
}
RenderingRegistry:
RenderingRegistry.registerEntityRenderingHandler(EntityRepulsorBolt.class, new RenderRepulsorBolt(Minecraft.getMinecraft().getRenderManager(), null, null));
What do I need to fill in place of the 2 nulls in rendering registry? I let Eclipse implement the method for me in my rendering repulsor's class. I've no idea what those values do.
Edit #1: I changed those 3 values to renderManager, item and renderItem, in the respective order.
You need to register your entity and item. For me, I registered my entity in a single class where I register any entities I might/will create in the future along with renderingregistry.
My item repulsor class:
package com.spyeedy.heroesplus.classes.ironman;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.world.World;
import com.spyeedy.heroesplus.HeroesPlus;
public class ItemRepulsor extends Item {
public ItemRepulsor(String unlocalizedName)
{
this.maxStackSize = 1;
this.setUnlocalizedName(unlocalizedName);
this.setCreativeTab(HeroesPlus.tabIronmanPlus);
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
worldIn.playSoundAtEntity(playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!worldIn.isRemote)
{
worldIn.spawnEntityInWorld(new EntityRepulsorBolt(worldIn, playerIn));
}
playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
return itemStackIn;
}
}
EntityRepulsor class:
package com.spyeedy.heroesplus.classes.ironman;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.IThrowableEntity;
public class EntityRepulsorBolt extends EntityThrowable implements IProjectile {
public double explosionRadius = 1.0F;
public EntityRepulsorBolt(World worldIn) {
super(worldIn);
};
public EntityRepulsorBolt(World worldIn, double x, double y, double p_i1778_6_) {
super(worldIn, x, y, p_i1778_6_);
}
public EntityRepulsorBolt(World worldIn, EntityLivingBase throwerIn) {
super(worldIn, throwerIn);
}
@Override
protected void onImpact(MovingObjectPosition MovingObjectPosition) {
this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)this.explosionRadius, true);
this.setDead();
}
}
My entity registry:
package com.spyeedy.heroesplus;
import net.minecraft.client.Minecraft;
import net.minecraft.item.Item;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
import com.spyeedy.heroesplus.classes.ironman.EntityRepulsorBolt;
import com.spyeedy.heroesplus.classes.ironman.ItemRepulsor;
import com.spyeedy.heroesplus.classes.ironman.RenderRepulsorBolt;
import com.spyeedy.heroesplus.classes.lanterns.fear.EntityFearArrow;
import com.spyeedy.heroesplus.classes.lanterns.fear.RenderFearArrow;
import com.spyeedy.heroesplus.classes.lanterns.hope.EntityHopeArrow;
import com.spyeedy.heroesplus.classes.lanterns.hope.RenderHopeArrow;
import com.spyeedy.heroesplus.classes.lanterns.rage.EntityRageArrow;
import com.spyeedy.heroesplus.classes.lanterns.rage.RenderRageArrow;
import com.spyeedy.heroesplus.classes.lanterns.will.EntityWillArrow;
import com.spyeedy.heroesplus.classes.lanterns.will.RenderWillArrow;
import com.spyeedy.heroesplus.items.Ironman;
public class CustomEntities {
private static int id = 0;
public static String repulsor;
public static String WillArrow;
public static String FearArrow;
public static String RageArrow;
public static void init() {
System.out.println("calling #init");
}
public static void register() {
System.out.println("calling #register");
EntityRegistry.registerModEntity(EntityWillArrow.class, "will_arrow", id++, HeroesPlus.instance, 64, 20, false);
EntityRegistry.registerModEntity(EntityFearArrow.class, "fear_arrow", id++, HeroesPlus.instance, 64, 20, false);
EntityRegistry.registerModEntity(EntityRageArrow.class, "rage_arrow", id++, HeroesPlus.instance, 64, 20, false);
EntityRegistry.registerModEntity(EntityHopeArrow.class, "hope_arrow", id++, HeroesPlus.instance, 64, 20, false);
EntityRegistry.registerModEntity(EntityRepulsorBolt.class, "repulsor", id++, HeroesPlus.instance, 64, 10, true);
}
public static void registerRenders()
{
System.out.println("calling #registerRenders");
RenderingRegistry.registerEntityRenderingHandler(EntityWillArrow.class, new RenderWillArrow(Minecraft.getMinecraft().getRenderManager()));
RenderingRegistry.registerEntityRenderingHandler(EntityFearArrow.class, new RenderFearArrow(Minecraft.getMinecraft().getRenderManager()));
RenderingRegistry.registerEntityRenderingHandler(EntityRageArrow.class, new RenderRageArrow(Minecraft.getMinecraft().getRenderManager()));
RenderingRegistry.registerEntityRenderingHandler(EntityHopeArrow.class, new RenderHopeArrow(Minecraft.getMinecraft().getRenderManager()));
}
}
One problem though, my projectile shoots a white block instead of my item. Can't seem to fix it.
Edit #1: I've yet to add the renderingregistry as I can't figure out which nulls I should replace with.
RenderingRegistry.registerEntityRenderingHandler(EntityRepulsorBolt.class, new RenderRepulsorBolt(Minecraft.getMinecraft().getRenderManager(), null, null));
RenderRepulsor class:
package com.spyeedy.heroesplus.classes.ironman;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
public class RenderRepulsorBolt extends RenderSnowball {
public static final ResourceLocation repulsortexture = new ResourceLocation("psm:textures/items/ironman/items/repulsor.png");
public RenderRepulsorBolt(RenderManager renderManager, Item item, RenderItem renderItem) {
super(renderManager, item, renderItem);
}
@Override
public ResourceLocation getEntityTexture(Entity entity) {
return repulsortexture;
}
}
How to do I make my greenlantern ring fire a ball of light at the npcs? Does it uses the implementation IProjectile?
Check the code for the Bow and Arrow, it should be very similar to what you want to do.
Check out my mod, Placeable Items!
If my comment helped you or you just like me, hit the green arrow down there!
How do I make my item not consume itself? I'm "borrowing" the snowball code to help me out
if you mean the item to don't be consumed or damaged, the code is in Item.onItemRightClick
else if you mean the entity to don't being destroyed on impact the code is in EntitySnowball.onImpact
sorry for my bad english I'm Italian
How do I do that?
Here's my code:
I hope I'm not bumping the thread.
this code decrease the itemstack size:
remove it and your itemstack will not decrease
sorry for my bad english I'm Italian
That worked! Thanks, how do I shoot a projectile like the bow does with the arrows. But I don't want 3 (or is it 4?) animations, just a blast to shoot like the snowball one. Sorry if I confused whoever can help.
your code already do what you want. it shoots an EntityRepulsorBolt when you right click it
sorry for my bad english I'm Italian
It doesn't shoot an EntityRepulsorBolt projectile like the snowball does, but the explosion occurs.
Here's my item code:
And the Entity code:
Is there anything I'm missing in my code?
What about your rendering for the projectile?
I need to render my projectile? Using rendringregistry? Render it like the arrow?
Here's the rendering for one of my custom arrow:
Do I follow the same thing as how the arrow is rendered except I extend RenderSnowball instead?
if you want it to look like an arrow, follow the arrow's rendering class, otherwise follow the snowball rendering class or fireball
I followed the snowball rendering, and now I'm stuck at rendering registry. I will show you the code. It's easier to see than explain(it's hard to).
Rendering repulsor:
RenderingRegistry:
What do I need to fill in place of the 2 nulls in rendering registry? I let Eclipse implement the method for me in my rendering repulsor's class. I've no idea what those values do.
Edit #1: I changed those 3 values to renderManager, item and renderItem, in the respective order.
But what do I have to type for the 2 nulls?
Hey did you get this to work? because I have my own projectile and I was wondering if this would work
Mine is not working please help
It's finally shooting a projectile, but instead of my own texture, it fires a white block.
I registered the entity and item of the projectile, I still can't figure out what I should replace the 2 nulls with.
can I see your code? mine wont work it doesn't even do anything
What do you want your projectile to spawn from? From a gun sort of or like ironman's repulsor which I'm doing?
yes do you need to see my code?
You need to register your entity and item. For me, I registered my entity in a single class where I register any entities I might/will create in the future along with renderingregistry.
My item repulsor class:
EntityRepulsor class:
My entity registry:
One problem though, my projectile shoots a white block instead of my item. Can't seem to fix it.
Edit #1: I've yet to add the renderingregistry as I can't figure out which nulls I should replace with.
RenderRepulsor class: