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.

Ubalube

Members
  • Joined

  • Last visited

  1. 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"); } }
  2. Well, its also that my other mob has a sword and just the way I wan't it to work is a little better.
  3. So I have a mob but when I right click it with an iron chestplate, the mob changes to my other mob that has the gear and stuff on. (It is custom gear I made that it is wearing, not minecraft gear) So my original thought was to replace this mob with that one. I right click the mob with a chestplate, and the mob I right clicked will be replaced with the mob with armor. Help would be appreciated! @Override public boolean processInteract(EntityPlayer player, EnumHand hand) { ItemStack itemstack = player.getHeldItem(hand); if (this.isTamed()) { if (this.isOwner(player) && !this.world.isRemote && itemstack == new ItemStack (Items.IRON_CHESTPLATE)) { //Im stuck here :( } } return super.processInteract(player, hand); } My code ^

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.