Jump to content

Recommended Posts

Posted

Hiya, I am trying to make a gun, or a musket more. I am currently messign around and I have encountered a strange problem. The bullet does not appear, I have other items that spawns it and even detects it where I shot the gun (as I haven't added movement yet) but it is not visible

 

this is the spawning code I have in the musket, where it does not appear, I DO get the message that a bullet has been fired (and hear the sound)

    public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int i)
    {
    	if (!world.isRemote){
    		if (needReload){
                this.reloading=false;
                int j = this.getMaxItemUseDuration(stack) - i;
    		}else{
    			double x = player.posX;
    			double y = player.posY+player.eyeHeight;
    			double z = player.posZ;
    			world.playSoundEffect(x, y, z, "random.explode", 3.0F, 1.0F / (0.7F));
    			ProjectileBullet bullet = new ProjectileBullet(world);
    			bullet.setPosition(player.posX, player.posY, player.posZ);
    			world.spawnEntityInWorld(bullet);
            	System.out.println("bullet at-" + bullet.posX + "," + bullet.posY + "," + bullet.posZ);
    			
    		}
        	System.out.println("stopped-" + this.needReload);
            this.needReload=!this.needReload;    			
    		
    	}
    }

This is my "wrench" which I use for various tasks as I need it, it locates the bullet that was recently spawned AND spawns another one, when THIS item spawns a bullet it appears visible.

	public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
    {
	System.out.println("Item Right Click");
	List near = world.getLoadedEntityList();
        for (int i = 0; i < near.size(); ++i)
        {
            Entity entity = (Entity)near.get(i);
            if (entity instanceof ProjectileBullet){
            	System.out.println("There's a bullet!: " + entity.posX + ":"+ entity.posY + ":" + entity.posZ);
            }
            
            
        }
	/*if (world.getBlock(x, y, z) instanceof Gases){
		System.out.println("Gas Meta: " + world.getBlockMetadata(x, y, z));
		System.out.println("X Y Z: " + x + ";" + y + ";" + z);
	}*/
	ProjectileBullet bullet = new ProjectileBullet(world);
	bullet.setPosition( player.posX, player.posY, player.posZ);
	world.spawnEntityInWorld(bullet);
        return stack;
    }

What could be the culprit?

Posted

Do you tell the client anywhere you spawned it, because from what I can see is your only spawning it on the server ans the server isn't responsible for rendering.

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.

Announcements



×
×
  • Create New...

Important Information

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