Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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?

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.

Are you registering a bullet renderer?

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.