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

Hello, I have a gun and I am trying to figure out how to get it to aim. I looked at the bow code but.. I don't understand it. I have 2 jsons, A version of my gun that IS aiming and a version of my gun that IS NOT aiming. How do I switch between them?

 

public class M16A4 extends Item implements IHasModel
{
	
	int Firerate = 8;
	int clipsize = 25;
	int kick = 5;
	int ReloadTime = 30;
	
	
	public M16A4(String name, CreativeTabs tab) 
	{
		setUnlocalizedName(name);
		setRegistryName(name);
		setCreativeTab(tab);
		setMaxStackSize(1);
		setMaxDamage(clipsize + 1);
		
		ModItems.ITEMS.add(this);
	}
	
	@Override
	public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) 
	{
		tooltip.add(TextFormatting.YELLOW + "Impact: " + TextFormatting.GREEN + "::::" + TextFormatting.RED + "::::::");
		tooltip.add(TextFormatting.YELLOW + "Range:  " + TextFormatting.GREEN + ":::::" + TextFormatting.RED + ":::::");
		tooltip.add(TextFormatting.YELLOW + "Clipsize: " + TextFormatting.GREEN + "25");
		super.addInformation(stack, worldIn, tooltip, flagIn);
	}
	
	@Override
	public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) 
	{
		
		ItemStack itemstack = playerIn.getHeldItem(handIn);
		
		if (!playerIn.capabilities.isCreativeMode)
		{
			if(itemstack.isItemDamaged())
			{
				if(itemstack.getItemDamage() >= clipsize)
				{
					if(playerIn.inventory.hasItemStack(new ItemStack(ModItems.M16AMMO)))
					{
						EntityBullet entity = new EntityBullet(worldIn, playerIn, 2.0F, 50);
						itemstack.setItemDamage(-clipsize - 1);
						playerIn.inventory.clearMatchingItems(ModItems.M16AMMO, 0, 1, null);
						playerIn.getCooldownTracker().setCooldown(this, ReloadTime);
						worldIn.playSound(playerIn,	playerIn.posX, playerIn.posY, playerIn.posZ, SoundHandler.RELOAD_RIFLERELOAD, SoundCategory.MASTER, 1, 1);
					}
				}
				else
				{
					playerIn.getCooldownTracker().setCooldown(this, Firerate);
					if (!worldIn.isRemote)
					{
						EntityBullet entity = new EntityBullet(worldIn, playerIn, 3.5F, 200);
						entity.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 0.0F);
						worldIn.spawnEntity(entity);
						itemstack.damageItem(1, playerIn);
						
					}
					worldIn.playSound(playerIn,	playerIn.posX, playerIn.posY, playerIn.posZ, SoundHandler.GUN_RIFLE_SHOOT, SoundCategory.MASTER, 1, 1);
				}
				
			}
			else
			{
				//First Bullet
				playerIn.getCooldownTracker().setCooldown(this, Firerate);
				if(!worldIn.isRemote)
				{
					EntityBullet entity = new EntityBullet(worldIn, playerIn, 3.5F, 200);
					entity.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 0.0F);
					worldIn.spawnEntity(entity);
					itemstack.damageItem(1, playerIn);
					
				}
				worldIn.playSound(playerIn,	playerIn.posX, playerIn.posY, playerIn.posZ, SoundHandler.GUN_RIFLE_SHOOT, SoundCategory.MASTER, 1, 1);
				
			}
		}
		else
		{
			//Creative Move
			playerIn.getCooldownTracker().setCooldown(this, Firerate);
			if(!worldIn.isRemote)
			{
				EntityBullet entity = new EntityBullet(worldIn, playerIn, 3.5F, 200);
				entity.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 0.0F);
				worldIn.spawnEntity(entity);
				itemstack.damageItem(1, playerIn);
				
			}
			worldIn.playSound(playerIn,	playerIn.posX, playerIn.posY, playerIn.posZ, SoundHandler.GUN_RIFLE_SHOOT, SoundCategory.MASTER, 1, 1);
			
		}
		
		
		
		return new ActionResult(EnumActionResult.PASS, itemstack);
	}
	
	
	
	@SideOnly(Side.CLIENT)
	@Override
	public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack) {
		
		int SingleFire = 8;
		int Automatic = 2;
		
		World worldIn = ((EntityPlayer)entityLiving).getEntityWorld();
		
		worldIn.playSound(((EntityPlayer)entityLiving),	((EntityPlayer)entityLiving).posX, ((EntityPlayer)entityLiving).posY, ((EntityPlayer)entityLiving).posZ, SoundHandler.RELOAD_FIREMODE, SoundCategory.MASTER, 1, 1);
		
		if(entityLiving instanceof EntityPlayer)
		{
			if(!entityLiving.world.isRemote)
			{
				if(Firerate == SingleFire)
				{
					((EntityPlayer)entityLiving).sendMessage(new TextComponentString("Firemode Set to " + TextFormatting.YELLOW + "AUTOMATIC"));
					Firerate = Automatic;
				}
				else
				{
					((EntityPlayer)entityLiving).sendMessage(new TextComponentString("Firemode Set to " + TextFormatting.YELLOW + "Semi-Automatic"));
					Firerate = SingleFire;
				}
			}
		}
		return super.onEntitySwing(entityLiving, stack);
	}
	
	@Override
	public void registerModels() 
	{
		main.proxy.registerItemRender(this, 0, "inventory");
		
	}

}

 

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.