Jump to content

[SOLVED] Intermadiate Item Issue


Ninoviski

Recommended Posts

So, i am working in a Spear, and it can work like a sword, or like a snowball. And i have a problem beetween these 2 friends.

 

I think you allready know, but, when i right click with the Spear, it generates its Entity, because an Item cant get flying arround out there. But, as it is also a "sword" it has that tool stuff, about its usage.

 

Know comes the issue, if i throw the Spear, i can pick it up, but when i do, it doesnt has the same usage as before i threw it. For example, i saw a zombie, i hitted it, and killed it, and then i saw a creeper, and i trhew the Spear at it, and jnow it is dead \o/... So, i go back to my spear, and when i pick it, its new, like i have never hitted a zombie. Ahhhhhhhhhhh, got it?

 

So, i keep thinking that, if i write to the NBT it will solve, but i dont know if it is the Entity NBT, the Item NBT, both, and i dont know also to how to comunicatw these two.

 

Hope you get it.

 

See ya

 

Link to comment
Share on other sites

The arrow i more a bullet, it is shooted, but mine is it, i dont need any weapon. I dont know the meaning of EntityItem there, but, i saw the ItemArrow (fucking on update,  did you see its size?) and i copied it. Before i doing that i used the snowbalk code, but we cant pick it back, so i used the arrow anyway...

Link to comment
Share on other sites

Hey, i must tell you something bro, i dont know java very well  ;D

 

But i keep trying and trying, until know i did some stuff, just read::

 

ItemDamage = the damage the items has, it is an public static int

 

 

I added too an method at the  EntitySpear that is a public int

 

 public int takeSpearDamage(int x)
Return this.Spear.ItemDamage = this.Speat.ItemDamage - x;

 

Just on the method you can see that i cant make a diference beetween the old and new int

 

 

See ya

Link to comment
Share on other sites

Bump

 

Look,

 

 

SET UP

 

in the Item, we have ItemDamage, that is an int, and is about getting the item life "taken"

 

in the Enttiy we just have this.setDead, so, we dont have half life, or is it dead, or is it life

 

I want to put the ItemDamage to the Entity, so i do

public int ItemDamage

 

At the Entity i do

public ItemSpear Spear

 

Now, i can do Spear.Item

 

 

PART A

 

How to use it?

 

How to every time that the Enttiy Intialize it can get that damage.

 

For initializing we know that we use the entityInit()

 

PART B

 

As a guess, i created a public int, it is

public int getItemDamage(something about x, dont remember)
{ 
return Spear.ItemDamage 
]

 

I think that my guess is a piece of shit, cause we need to teel that this cucker is that sucker so i THINK we must put

(WorldObj remute stuff), but i dont know how to use it, if statement? i dont have anyother condition... I am pretty new to JAVA.

 

PART 3

 

When it hits the target entity, it get "hurts" ( i think that is putting the animal int (public int getMaxHealth this can get hurt, but i think i might not work, cause i belive it can get hurt(red stuff))) but how do i do that? With my noobity of JAVA i kept creating methods with no certain.

public int takeItemDamage(another x stuff)
{
return Spear.ItemDamage - x = Spear.ItemDamage
}

 

For me, the codes makes senses, because thats the algebra i must do, except that cant show that it is a last ItemDamage, we have the last and the new item damage, and also that wordremote stuff

 

END

 

If you red all of this i give you really thanks, really, and if you do help it will be really greatfull

 

 

See ya

 

Link to comment
Share on other sites

Sry, bump

QUADRA POST! (Sorry, I was busy and couldn't help people.)

Ugh, your English as well as your knowledge of Java pains me, but I'll try to help anyway.

 

First of all, you don't want an ItemSpear attribute in your Entity, you want an ItemStack. When you initialize your entity (find the place in your ItemSpear where you call a new instance of EntitySpear), set theEntitySpear.Spear = this;

Now look in your EntitySpear. I assume you copied onUpdate from EntityArrow? There's extra stuff in there you'll want to trim out, but for now, we can say: find the place where it says

if(!(movingobjectposition.entityHit instanceof EntityEnderman)){
    this.setDead();
}

and add these lines (in bold):

if(!(movingobjectposition.entityHit instanceof EntityEnderman)){
    this.setDead();
    [b]this.Stack.setItemDamage(this.Stack.getItemDamage()-whatever);
    this.entityDropItem(this.Stack,yOffset);[/b]
}

Replace "whatever" and "yOffset" with whatever you feel like.

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Link to comment
Share on other sites

---- Minecraft Crash Report ----

// Shall we play a game?

 

Time: 14/06/13 15:28

Description: Ticking entity

 

java.lang.NullPointerException

at Ice_Age.EntitySpear.onUpdate(EntitySpear.java:370)

at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2342)

at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:717)

at net.minecraft.world.World.updateEntity(World.java:2304)

at net.minecraft.world.World.updateEntities(World.java:2150)

at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:546)

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:652)

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:571)

at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:127)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:469)

at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- Head --

Stacktrace:

at Ice_Age.EntitySpear.onUpdate(EntitySpear.java:370)

at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2342)

at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:717)

at net.minecraft.world.World.updateEntity(World.java:2304)

 

-- Entity being ticked --

Details:

Entity Type: IceAge.Spear (Ice_Age.EntitySpear)

Entity ID: 277

Entity Name: entity.IceAge.Spear.name

Entity's Exact location: 624,50, 65,52, 511,64

Entity's Block location: World: (624,65,511), Chunk: (at 0,4,15 in 39,31; contains blocks 624,0,496 to 639,255,511), Region: (1,0; contains chunks 32,0 to 63,31, blocks 512,0,0 to 1023,255,511)

Entity's Momentum: -4,70, -0,35, -3,62

Stacktrace:

at net.minecraft.world.World.updateEntities(World.java:2150)

at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:546)

 

-- Affected level --

Details:

Level name: New World

All players: 1 total; [EntityPlayerMP['Player241'/1, l='New World', x=624,40, y=64,00, z=511,76]]

Chunk stats: ServerChunkCache: 541 Drop: 0

Level seed: 1140525424060041215

Level generator: ID 01 - flat, ver 0. Features enabled: true

Level generator options: 2;7,59x1,3x3,2,78;12;biome_1,village

Level spawn location: World: (670,4,525), Chunk: (at 14,0,13 in 41,32; contains blocks 656,0,512 to 671,255,527), Region: (1,1; contains chunks 32,32 to 63,63, blocks 512,0,512 to 1023,255,1023)

Level time: 159635 game time, 33508 day time

Level dimension: 0

Level storage version: 0x04ABD - Anvil

Level weather: Rain time: 56891 (now: false), thunder time: 1450 (now: false)

Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true

Stacktrace:

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:652)

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:571)

at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:127)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:469)

at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)

 

-- System Details --

Details:

Minecraft Version: 1.5.2

Operating System: Windows 7 (amd64) version 6.1

Java Version: 1.7.0_21, Oracle Corporation

Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

Memory: 792879760 bytes (756 MB) / 1056309248 bytes (1007 MB) up to 1056309248 bytes (1007 MB)

JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

AABB Pool Size: 285 (15960 bytes; 0 MB) allocated, 25 (1400 bytes; 0 MB) used

Suspicious classes: FML and Forge are installed

IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0

FML: MCP v7.51 FML v5.2.12.712 Minecraft Forge 7.8.0.712 4 mods loaded, 4 mods active

mcp{7.44} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

FML{5.2.12.712} [Forge Mod Loader] (coremods) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Forge{7.8.0.712} [Minecraft Forge] (coremods) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

IceAge{1.0} [ice Age] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Profiler Position: N/A (disabled)

Vec3 Pool Size: 25 (1400 bytes; 0 MB) allocated, 25 (1400 bytes; 0 MB) used

Player Count: 1 / 8; [EntityPlayerMP['Player241'/1, l='New World', x=624,40, y=64,00, z=511,76]]

Type: Integrated Server (map_client.txt)

Is Modded: Definitely; Client brand changed to 'fml,forge'

 

 

Sorry for the "sec'"  :B

Link to comment
Share on other sites

There was something about ItemStack, but not with yoffset param..

 

The third line

 

if(!(movingobjectposition.entityHit instanceof EntityEnderman)){

    this.setDead();

    this.Stack.setItemDamage(this.Stack.getItemDamage()-whatever);

    this.entityDropItem(this.Stack,yOffset);

}

 

 

I will think a little bit more,

 

See ya

Link to comment
Share on other sites

So, i will follow the main idea of the creator of the mod, and will use these codes

 

Item

 

 

    public boolean onBlockDestroyed(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, EntityLiving par7EntityLiving)
    {
    	par1ItemStack.damageItem(0, par7EntityLiving);
    	
    	if(this.itemRand.nextInt(3) == 0)
    	{
    		par1ItemStack.damageItem(10000000, par7EntityLiving);
    	}

        return true;
    }

    public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
    {
    	par1ItemStack.damageItem(0, par2EntityLiving);
    	
    	if(this.itemRand.nextInt(6) == 0)
  		 {
    		par1ItemStack.damageItem(10000000, par2EntityLiving);
  		 }

        return true;
    }

 

 

 

Entity

 

 

if (movingobjectposition.entityHit instanceof EntityCreature)
                        {
                        	if(this.rand.nextInt(6) == 0)
                     		 {
                                this.setDead();
                     		 }

                        }
[/spoiler]

 

 

Thanks ObsequiousNewt

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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