[1.8.1] Throwable Explosive
+2
lcass
Strengthowns
6 posters
MC Modding :: Modding :: Singleplayer Modding :: Tutorials
Page 1 of 1
[1.8.1] Throwable Explosive
Throwable Explosive
- Spoiler:
- mod_Namehere
- Code:
package net.minecraft.src;
public class mod_Namehere extends BaseMod
{
public static Item Namehere = (new ItemNamehere(9000)).setItemName("Namehere");
public mod_Namehere()
{
Namehere.iconIndex = ModLoader.addOverride("/gui/items.png", "/Namehere.png");
ModLoader.AddName(Namehere, "Namehere");
ModLoader.AddRecipe((new ItemStack(Namehere, 1)), new Object[] {
"###", "###", "###", Character.valueOf('#'), Block.dirt
});
}
public String Version()
{
return "1.7.3";
}
}
ItemNamehere- Code:
package net.minecraft.src;
public class ItemNamehere extends Item
{
public ItemNamehere(int i)
{
super(i);
maxStackSize = 64;
NamehereID = shiftedIndex;
}
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
{
world.entityJoinedWorld(new EntityNamehere(world, entityplayer));
--itemstack.stackSize;
return itemstack;
}
public static int NamehereID;
}
EntityNamehere- Code:
package net.minecraft.src;
public class EntityNamehere extends EntityItem
{
public EntityNamehere(World world)
{
super(world);
setSize(0.5F, 0.5F);
yOffset = height / 2.0F;
item = new ItemStack(Item.itemsList[ItemNamehere.NamehereID]);
bounceFactor = 0.6;
exploded = false;
stopped = false;
fuse = 0;
}
public EntityNamehere(World world, double x, double y, double z, float yaw, float pitch, double force, int fuseLength)
{
this(world);
setRotation(yaw, 0);
double xHeading = -MathHelper.sin((yaw * 3.141593F) / 180F);
double zHeading = MathHelper.cos((yaw * 3.141593F) / 180F);
motionX = force*xHeading*MathHelper.cos((pitch / 180F) * 3.141593F);
motionY = -force*MathHelper.sin((pitch / 180F) * 3.141593F);
motionZ = force*zHeading*MathHelper.cos((pitch / 180F) * 3.141593F);
setPosition(x+xHeading*0.8, y, z+zHeading*0.8);
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
fuse = fuseLength;
}
public EntityNamehere(World world, Entity entity)
{
this(world, entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch, 0.5, 50);
}
protected boolean canTriggerWalking()
{
return false;
}
public void onUpdate()
{
if(fuse-- <= 0)
{
explode();
}
if(!(stopped) && !(exploded))
{
double prevVelX = motionX;
double prevVelY = motionY;
double prevVelZ = motionZ;
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
moveEntity(motionX, motionY, motionZ);
boolean collided = false;
if(motionX!=prevVelX)
{
motionX = -prevVelX;
collided = true;
}
if(motionZ!=prevVelZ)
{
motionZ = -prevVelZ;
}
if(motionY!=prevVelY)
{
motionY = -prevVelY;
collided = true;
}
else
{
motionY -= 0.04;
}
if(collided)
{
motionX *= bounceFactor;
motionY *= bounceFactor;
motionZ *= bounceFactor;
}
motionX *= 0.99;
motionY *= 0.99;
motionZ *= 0.99;
if(onGround && (motionX*motionX+motionY*motionY+motionZ*motionZ)<0.02)
{
stopped = true;
motionX = 0;
motionY = 0;
motionZ = 0;
}
}
}
public void onCollideWithPlayer(EntityPlayer entityplayer)
{
}
protected void explode()
{
if(!exploded)
{
exploded = true;
worldObj.createExplosion(null, posX, posY, posZ, 5F);
}
}
public boolean attackEntity(Entity entity, int i)
{
super.attackEntityFrom(DamageSource.causeThrownDamage(entity, entity), i);
explode();
return false;
}
public void writeEntityToNBT(NBTTagCompound nbttagcompound)
{
super.writeEntityToNBT(nbttagcompound);
nbttagcompound.setByte("Fuse", (byte)fuse);
}
public void readEntityFromNBT(NBTTagCompound nbttagcompound)
{
super.readEntityFromNBT(nbttagcompound);
fuse = nbttagcompound.getByte("Fuse");
}
double bounceFactor;
int fuse;
boolean exploded;
boolean collided;
boolean stopped;
}
Help: mod_Namehere
1. Everything here is the same as normal.Help: ItemNamehere
1. Same as normal, change all the Namehere's.Help: EntityNamehere
1. I won't explain everything here, as after looking at it closely you should understand the idea of it.
2. First off, change the bounce factor at the top to whatever you want.
3. More advanced modders can mess around with the other stuff.
4. Towards the bottom where it has this:- Code:
protected void explode()
{
if(!exploded)
{
exploded = true;
worldObj.createExplosion(null, posX, posY, posZ, 5F);
}
}
5. Leave the rest and...Done! Enjoy your new throwable explosive!
Re: [1.8.1] Throwable Explosive
when i try this the causethrowndamage bit goes red and dosn't work !!!!
Re: [1.8.1] Throwable Explosive
how do i make i glow and not explode like a glowstick
bottz2- Member
- Posts : 14
Join date : 2011-10-24
Re: [1.8.1] Throwable Explosive
Shouldn`t be looking at throwable explosive you should look at the items tutorial and i suggest putting this is requests.
breakyorself- Member
- Posts : 60
Join date : 2011-10-19
Re: [1.8.1] Throwable Explosive
well i want to be able to through the glowstick
bottz2- Member
- Posts : 14
Join date : 2011-10-24
Re: [1.8.1] Throwable Explosive
You should still put it in help or requests.
breakyorself- Member
- Posts : 60
Join date : 2011-10-19
Re: [1.8.1] Throwable Explosive
remove the causethrowdamage part it dosn't work also the glowstick Idea seems nice
Re: [1.8.1] Throwable Explosive
You would also have to remove the code where it blows up .
breakyorself- Member
- Posts : 60
Join date : 2011-10-19
Re: [1.8.1] Throwable Explosive
acctually no here is the code you need if you want to fix it
- Code:
package net.minecraft.src;
public class Entitynukethrow extends EntityItem
{
public Entitynukethrow(World world)
{
super(world);
setSize(0.5F, 0.5F);
yOffset = height / 2.0F;
item = new ItemStack(Item.itemsList[nukethrow.nukethrowID]);
bounceFactor = 0.9;
exploded = false;
stopped = false;
fuse = 120;
}
public Entitynukethrow(World world, double x, double y, double z, float yaw, float pitch, double force, int fuseLength)
{
this(world);
setRotation(yaw, 0);
double xHeading = -MathHelper.sin((yaw * 3.141593F) / 180F);
double zHeading = MathHelper.cos((yaw * 3.141593F) / 180F);
motionX = force*xHeading*MathHelper.cos((pitch / 180F) * 3.141593F);
motionY = -force*MathHelper.sin((pitch / 180F) * 3.141593F);
motionZ = force*zHeading*MathHelper.cos((pitch / 180F) * 3.141593F);
setPosition(x+xHeading*0.8, y, z+zHeading*0.8);
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
fuse = fuseLength;
}
public Entitynukethrow(World world, Entity entity)
{
this(world, entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch, 0.5, 50);
}
protected boolean canTriggerWalking()
{
return false;
}
public void onUpdate()
{
if(fuse-- <= 0)
{
explode();
}
if(!(stopped) && !(exploded))
{
double prevVelX = motionX;
double prevVelY = motionY;
double prevVelZ = motionZ;
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
moveEntity(motionX, motionY, motionZ);
boolean collided = false;
if(motionX!=prevVelX)
{
motionX = -prevVelX;
collided = true;
}
if(motionZ!=prevVelZ)
{
motionZ = -prevVelZ;
}
if(motionY!=prevVelY)
{
motionY = -prevVelY;
collided = true;
}
else
{
motionY -= 0.04;
}
if(collided)
{
motionX *= bounceFactor;
motionY *= bounceFactor;
motionZ *= bounceFactor;
}
motionX *= 0.99;
motionY *= 0.99;
motionZ *= 0.99;
if(onGround && (motionX*motionX+motionY*motionY+motionZ*motionZ)<0.02)
{
stopped = true;
motionX = 0;
motionY = 0;
motionZ = 0;
}
}
}
public void onCollideWithPlayer(EntityPlayer entityplayer)
{
}
protected void explode()
{
if(!exploded)
{
exploded = true;
worldObj.createExplosion(null, posX, posY, posZ, 50F);
}
}
public boolean attackEntity(Entity entity, int i)
{
return false;
}
public void writeEntityToNBT(NBTTagCompound nbttagcompound)
{
super.writeEntityToNBT(nbttagcompound);
nbttagcompound.setByte("Fuse", (byte)fuse);
}
public void readEntityFromNBT(NBTTagCompound nbttagcompound)
{
super.readEntityFromNBT(nbttagcompound);
fuse = nbttagcompound.getByte("Fuse");
}
double bounceFactor;
int fuse;
boolean exploded;
boolean collided;
boolean stopped;
}
Re: [1.8.1] Throwable Explosive
Still need it to glow.
breakyorself- Member
- Posts : 60
Join date : 2011-10-19
Re: [1.8.1] Throwable Explosive
you want the item to glow. add this code then I think it will work add it to the
mod_item.class
mod_item.class
- Code:
public static item namehere = new namehere(ID,0).setLightValue(1.0F)
Re: [1.8.1] Throwable Explosive
I ment he still wants it to glow but that should help him
breakyorself- Member
- Posts : 60
Join date : 2011-10-19
Re: [1.8.1] Throwable Explosive
yer I think it will work like that but what exactly do you mean by "glow" you mean like a texture around it if your going to do that you will need to declare a new item entity and a new void that makes it follow on click or just add it o the texture
Re: [1.8.1] Throwable Explosive
I`m not the one who wanted it -.-.
breakyorself- Member
- Posts : 60
Join date : 2011-10-19
Re: [1.8.1] Throwable Explosive
hey I'm having trouble getting the spoilers work!! They never open and I want to make a creeper bomb for my mod. I don't get why its not that popular when it has 10 new blocks, rainbow soup, a tool set, and 3 mobs?? I think people like explosives so this will help my mod a lot.
MrCreeper07- Member
- Posts : 18
Join date : 2011-10-23
Re: [1.8.1] Throwable Explosive
by glow i mean like give of light
bottz2- Member
- Posts : 14
Join date : 2011-10-24
Re: [1.8.1] Throwable Explosive
@MrCreeper07 Wow, that's a lot of stuff! and rainbow soup! MMM Rainbow soup...
I think your mod isn't popular because nobody knows about it! Put a link in your signature! Put your modHere!
Back on topic!
I likely won't use this but its just cool to know its here!
I think your mod isn't popular because nobody knows about it! Put a link in your signature! Put your modHere!
Back on topic!
I likely won't use this but its just cool to know its here!
mastereric- Member
- Posts : 30
Join date : 2011-10-26
Re: [1.8.1] Throwable Explosive
icass ur light code only works for blocks
bottz2- Member
- Posts : 14
Join date : 2011-10-24
Re: [1.8.1] Throwable Explosive
It's lcass I will see if I can get it fixed nut from what I know no such block has worked
MC Modding :: Modding :: Singleplayer Modding :: Tutorials
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum