How do I make my mob drop a modded item/ my item, It says that it cannot be resolved or is not a field
the fix that eclipse offers is to create a field for it in item.java but I don't want to edit base classes
this is just your tut with added stuff on it
WHERE IS SAYS TO DROP A BOW, THAT IS WHERE I WANT MY CUSTOM ITEM TO BE.
A couple of lines under that one is the item that says it cant be resolved or is not a field (khopesh)
EntityMummy file
package net.minecraft.src;
import java.util.Random;
public class EntityMummy extends EntityMob
{
private static final ItemStack defaultHeldItem;
public EntityMummy(World par1World)
{
super(par1World);
texture = "/egyptian/mummy.png";
moveSpeed = 0.23F;
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAIWander(this, moveSpeed));
this.tasks.addTask(3, new EntityAIWatchClosest(this, net.minecraft.src.EntityPlayer.class, 8F));
this.tasks.addTask(4, new EntityAILookIdle(this));
this.targetTasks.addTask(5, new EntityAIHurtByTarget(this, false));
this.targetTasks.addTask(6, new EntityAINearestAttackableTarget(this, net.minecraft.src.EntityPlayer.class, 16F, 0, true));
}
public int func_82193_c(Entity par1Entity)
{
return 4;
}
public boolean isAIEnabled()
{
return true;
}
public int getMaxHealth()
{
return 30;
}
protected float getSoundVolume()
{
return 0.8F;
}
public ItemStack getHeldItem()
{
return defaultHeldItem;
}
public void onLivingUpdate()
{
super.onLivingUpdate();
}
public void onDeath(DamageSource par1DamageSource)
{
super.onDeath(par1DamageSource);
if ((par1DamageSource.getSourceOfDamage() instanceof EntityArrow) && (par1DamageSource.getEntity() instanceof EntityPlayer))
{
EntityPlayer entityplayer = (EntityPlayer)par1DamageSource.getEntity();
double d = entityplayer.posX - posX;
double d1 = entityplayer.posZ - posZ;
if (d * d + d1 * d1 >= 2500D);
}
}
protected void dropFewItems(boolean par1, int par2)
{
int i = rand.nextInt(3 + par2);
for (int j = 0; j < i; j++)
{
dropItem(Item.ingotGold.shiftedIndex, 1);
}
i = rand.nextInt(3 + par2);
for (int k = 0; k < i; k++)
{
dropItem(Item.bow.shiftedIndex, 1);
}
}
static
{
defaultHeldItem = new ItemStack(Item.khopesh, 1);
}
protected boolean canDespawn()
{
return false;
}
protected String getHurtSound()
{
return "mob.zombie.hurt";
}
protected String getDeathSound()
{
return "mob.zombie.death";
}
}
How do I make my mob drop a modded item/ my item, It says that it cannot be resolved or is not a field
this is just your tut with added stuff on it
WHERE IS SAYS TO DROP A BOW, THAT IS WHERE I WANT MY CUSTOM ITEM TO BE.
A couple of lines under that one is the item that says it cant be resolved or is not a field (khopesh)
EntityMummy file
package net.minecraft.src;
import java.util.Random;
public class EntityMummy extends EntityMob
{
private static final ItemStack defaultHeldItem;
public EntityMummy(World par1World)
{
super(par1World);
texture = "/egyptian/mummy.png";
moveSpeed = 0.23F;
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAIWander(this, moveSpeed));
this.tasks.addTask(3, new EntityAIWatchClosest(this, net.minecraft.src.EntityPlayer.class, 8F));
this.tasks.addTask(4, new EntityAILookIdle(this));
this.targetTasks.addTask(5, new EntityAIHurtByTarget(this, false));
this.targetTasks.addTask(6, new EntityAINearestAttackableTarget(this, net.minecraft.src.EntityPlayer.class, 16F, 0, true));
}
public int func_82193_c(Entity par1Entity)
{
return 4;
}
public boolean isAIEnabled()
{
return true;
}
public int getMaxHealth()
{
return 30;
}
protected float getSoundVolume()
{
return 0.8F;
}
public ItemStack getHeldItem()
{
return defaultHeldItem;
}
public void onLivingUpdate()
{
super.onLivingUpdate();
}
public void onDeath(DamageSource par1DamageSource)
{
super.onDeath(par1DamageSource);
if ((par1DamageSource.getSourceOfDamage() instanceof EntityArrow) && (par1DamageSource.getEntity() instanceof EntityPlayer))
{
EntityPlayer entityplayer = (EntityPlayer)par1DamageSource.getEntity();
double d = entityplayer.posX - posX;
double d1 = entityplayer.posZ - posZ;
if (d * d + d1 * d1 >= 2500D);
}
}
protected void dropFewItems(boolean par1, int par2)
{
int i = rand.nextInt(3 + par2);
for (int j = 0; j < i; j++)
{
dropItem(Item.ingotGold.shiftedIndex, 1);
}
i = rand.nextInt(3 + par2);
for (int k = 0; k < i; k++)
{
dropItem(Item.bow.shiftedIndex, 1);
}
}
static
{
defaultHeldItem = new ItemStack(Item.khopesh, 1);
}
protected boolean canDespawn()
{
return false;
}
protected String getHurtSound()
{
return "mob.zombie.hurt";
}
protected String getDeathSound()
{
return "mob.zombie.death";
}
}
Like normal coming through out your custom classes. (mod_"yourmodname"."yourItem/block".shiftedIndex, 1)
How do I make my mob drop a modded item/ my item, It says that it cannot be resolved or is not a field
the fix that eclipse offers is to create a field for it in item.java but I don't want to edit base classes
this is just your tut with added stuff on it
WHERE IS SAYS TO DROP A BOW, THAT IS WHERE I WANT MY CUSTOM ITEM TO BE.
A couple of lines under that one is the item that says it cant be resolved or is not a field (khopesh)
EntityMummy file
package net.minecraft.src;
import java.util.Random;
public class EntityMummy extends EntityMob
{
private static final ItemStack defaultHeldItem;
public EntityMummy(World par1World)
{
super(par1World);
texture = "/egyptian/mummy.png";
moveSpeed = 0.23F;
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAIWander(this, moveSpeed));
this.tasks.addTask(3, new EntityAIWatchClosest(this, net.minecraft.src.EntityPlayer.class, 8F));
this.tasks.addTask(4, new EntityAILookIdle(this));
this.targetTasks.addTask(5, new EntityAIHurtByTarget(this, false));
this.targetTasks.addTask(6, new EntityAINearestAttackableTarget(this, net.minecraft.src.EntityPlayer.class, 16F, 0, true));
}
public int func_82193_c(Entity par1Entity)
{
return 4;
}
public boolean isAIEnabled()
{
return true;
}
public int getMaxHealth()
{
return 30;
}
protected float getSoundVolume()
{
return 0.8F;
}
public ItemStack getHeldItem()
{
return defaultHeldItem;
}
public void onLivingUpdate()
{
super.onLivingUpdate();
}
public void onDeath(DamageSource par1DamageSource)
{
super.onDeath(par1DamageSource);
if ((par1DamageSource.getSourceOfDamage() instanceof EntityArrow) && (par1DamageSource.getEntity() instanceof EntityPlayer))
{
EntityPlayer entityplayer = (EntityPlayer)par1DamageSource.getEntity();
double d = entityplayer.posX - posX;
double d1 = entityplayer.posZ - posZ;
if (d * d + d1 * d1 >= 2500D);
}
}
protected void dropFewItems(boolean par1, int par2)
{
int i = rand.nextInt(3 + par2);
for (int j = 0; j < i; j++)
{
dropItem(Item.ingotGold.shiftedIndex, 1);
}
i = rand.nextInt(3 + par2);
for (int k = 0; k < i; k++)
{
dropItem(Item.bow.shiftedIndex, 1);
}
}
static
{
defaultHeldItem = new ItemStack(Item.khopesh, 1);
}
protected boolean canDespawn()
{
return false;
}
protected String getHurtSound()
{
return "mob.zombie.hurt";
}
protected String getDeathSound()
{
return "mob.zombie.death";
}
}
when you use a item that u made in a mod you dont put Item. in front of the item name
Hey, I have a suggestion for a tutorial, because I've never ever seen it anywhere, and it's really difficult:
State Changes
Basically, I'm trying to get a mod where you use an item, which changes the character's state. More specifically, your speed increases and jump increases, and so forth. However, these are not just potion effects. What I want is to use an item that leaves your body behind, and your "spirit" runs around faster and jumps higher, while your body remains where it was until you right click it. Can you think of any way to do this?
P.S. If you don't want to make a whole tutorial, could you just PM me if you have any ideas of how to achieve this? Thanks
So, basically, I'm trying to make a ball of yarn. An actual entity with a model that the cat can play with. I haven't even been able to touch on having the cat interact with it because I can't get the stupid thing to show up. It obviously shouldn't be an EntityLIving because it's not alive and doesn't need all of those methods, but I can't seem to get it to work; I've investigated EntityMinecart and EntityBoat and ItemMinecart and ItemBoat to try to figure out how to get it to work, but with no success. I guess I'll just plop my code here and hope that you can post a tutorial on making non-living entities or just give me specific help.
mod_catAdditions.java:
package net.minecraft.src;
import java.util.Map;
public class mod_catAdditions extends BaseMod
{
public static final Item yarnBall = new ItemYarnBall(4096);
public void load()
{
ModLoader.registerEntityID(EntityYarnBall.class, "Yarn Ball", ModLoader.getUniqueEntityId());
ModLoader.addName(yarnBall, "Yarn Ball");
}
public void addRenderer(Map map)
{
map.put(EntityYarnBall.class, new RenderYarnBall(new ModelYarnBall()));
}
public String getVersion()
{
return "Cat Additions rev 1 for MC ver 1.4.2";
}
}
ItemYarnBall.java:
package net.minecraft.src;
public class ItemYarnBall extends Item
{
public int yarnBallColor = 0;
public ItemYarnBall(int par1)
{
super(par1);
this.maxStackSize = 16;
this.iconIndex = ModLoader.addOverride("/gui/items.png", "/catAdditions/yarnBall.png");
this.setCreativeTab(CreativeTabs.tabDecorations);
this.setItemName("yarnBall");
}
public ItemYarnBall(int par1, int par2)
{
this(par1);
yarnBallColor = par2;
}
//code for colorizing the icon for the item, currently unused
public int getColorFromItemStack(ItemStack par1ItemStack, int par2)
{
switch (yarnBallColor)
{
default: return 16777215;
case 0: return 2631720;
case 1: return 12464176;
case 2: return 4877080;
case 3: return 9001014;
case 4: return 5931746;
case 5: return 10769358;
case 6: return 3968688;
case 7: return 13158600;
case 8: return 8684676;
case 9: return 14388148;
case 10: return 7783952;
case 11: return 14538023;
case 12: return 9419252;
case 13: return 13330885;
case 14: return 15113780;
case 15: return 16777215;
}
}
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
if(!par3World.isRemote)
{
par3World.spawnEntityInWorld(new EntityYarnBall(par3World, par4, par5, par6));
--par1ItemStack.stackSize;
return true;
}
else
{
return false;
}
}
}
EntityYarnBall.java:
package net.minecraft.src;
import java.util.ArrayList;
public class EntityYarnBall extends Entity
{
protected String texture = "/catAdditions/ModelYarnBall.png";
public EntityYarnBall(World par1World)
{
super(par1World);
this.preventEntitySpawning = true;
this.setSize(0.25F, 0.25F);
this.yOffset = this.height / 2.0F;
}
public EntityYarnBall(World par1World, double par2, double par3, double par4)
{
this(par1World);
this.setPosition(par2, (double)(par3 + this.yOffset), par4);
this.motionX = 0.0D;
this.motionY = 0.0D;
this.motionZ = 0.0D;
this.prevPosX = par2;
this.prevPosY = par3;
this.prevPosZ = par4;
}
public String getTexture()
{
return texture;
}
public boolean canBePushed()
{
return true;
}
public boolean canBeCollidedWith()
{
return !this.isDead;
}
public AxisAlignedBB getCollisionBox(Entity par1Entity)
{
return par1Entity.boundingBox;
}
public AxisAlignedBB getBoundingBox()
{
return this.boundingBox;
}
protected void entityInit() {}
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {}
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {}
public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
{
if (!this.isDead && !this.worldObj.isRemote)
{
this.setDead();
this.setBeenAttacked();
EntityPlayer entityPlayer = null;
if (par1DamageSource.getEntity() instanceof EntityPlayer)
{
entityPlayer = (EntityPlayer)par1DamageSource.getEntity();
}
if (entityPlayer != null && entityPlayer.capabilities.isCreativeMode)
{
return true;
}
this.dropItemStack();
}
return true;
}
public void dropItemStack()
{
this.entityDropItem(new ItemStack(mod_catAdditions.yarnBall), 0.0F);
}
}
well their is a problem with adding non mob entities in 1.4.2 you have 3 choices
1. If you don't mind editing base classes just add it in entity tracker.java and other related classes
2. Extend entity snowball and just make some changes thats what i did in my mod
3. Switch to forge
4. Give up
Thanks, I had no idea that it was doomed not to work, it may seem like a minor effort but you saved me hours of useless troubleshooting. I knew I'd have to end up learning forge... eventually
Rollback Post to RevisionRollBack
↑It makes sense if you don't think about it.↑
Creepers only explode because they want to hug you, but when they reach you, they realize they have no arms, and then explode with anger.
EDIT: It Worked after I edited some code from "Entity" file. Thanks again
the fix that eclipse offers is to create a field for it in item.java but I don't want to edit base classes
this is just your tut with added stuff on it
WHERE IS SAYS TO DROP A BOW, THAT IS WHERE I WANT MY CUSTOM ITEM TO BE.
A couple of lines under that one is the item that says it cant be resolved or is not a field (khopesh)
EntityMummy file
I eat creepers for breakfast, lunch, dinner and I have it bacon style!
Like normal coming through out your custom classes. (mod_"yourmodname"."yourItem/block".shiftedIndex, 1)
when you use a item that u made in a mod you dont put Item. in front of the item name
Item.monsterplacer, how many, mob ID
State Changes
Basically, I'm trying to get a mod where you use an item, which changes the character's state. More specifically, your speed increases and jump increases, and so forth. However, these are not just potion effects. What I want is to use an item that leaves your body behind, and your "spirit" runs around faster and jumps higher, while your body remains where it was until you right click it. Can you think of any way to do this?
P.S. If you don't want to make a whole tutorial, could you just PM me if you have any ideas of how to achieve this? Thanks
Bleach Mod
Alright thanks. I'm kinda new to modding, so any help is welcome
Bleach Mod
mod_catAdditions.java:
ItemYarnBall.java:
EntityYarnBall.java:
RenderYarnBall.java:
ModelYarnBall.java:
EDIT: Images in case you wanted to test
ModelYarnBall.png:
yarnBall.png:
1. If you don't mind editing base classes just add it in entity tracker.java and other related classes
2. Extend entity snowball and just make some changes thats what i did in my mod
3. Switch to forge
4. Give up
5. Read this and solve your problems. http://www.minecraft...ted-with-forge/
Btw, I been using Forges Event hook to bypass any base class edits.