Better way for doing bullets

Discussion in 'Spigot Plugin Development' started by Brainmix, Jun 8, 2016.

  1. So, i am trying to make a simple gun.
    I don't have learnd about vectors etc. in school yet.
    I tried my best, to make a bullet. The bullet is working, but i don't think, it is a good way.
    Here is my code:

    Code (Text):
     @Override
        protected void handleItemClick(PlayerInteractEvent event) {

            final Player player = event.getPlayer();

            player.getWorld().getEntitiesByClass(ArmorStand.class).stream().forEach(as -> {
                if(as.getCustomName().equals("bullet")) as.remove();
                task.cancel();
            });

            Location loc = player.getLocation();
            loc.setY(loc.getY() + 1);

            final ArmorStand bullet = (ArmorStand) player.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND);
            bullet.setCustomName("bullet");
            bullet.setCustomNameVisible(false);
            bullet.setArms(true);
            bullet.setItemInHand(new ItemStack(Material.STONE));
            bullet.setGravity(false);
            bullet.setVisible(false);
            bullet.setSmall(true);
            bullet.setMarker(true);

            Bukkit.getOnlinePlayers().stream().forEach(p -> {
                p.playSound(player.getLocation(), Sound.ENDERDRAGON_HIT, 1, 1);
            });

            task = new BukkitRunnable() {

                int c = 1;
                Location loc = player.getLocation();
                Vector dir;
                boolean stop = false;

                @Override
                public void run() {

                    for(int i = 0; i < 6; i++) {

                        if(stop) break;

                        if(c == 1) {
                            loc.setY(loc.getY() + 1.5);
                            dir = loc.getDirection().multiply(0.6);
                        }

                        c+= 1;

                        if(loc.getBlock().getType().isSolid()) stop = true;

                        loc = loc.add(dir);

                        bullet.teleport(loc);

                        if(c >= 200) stop = true;

                        for(Entity entity : bullet.getNearbyEntities(0.5, 0.5, 0.5)) {

                            if(!(entity instanceof Player)) continue;
                            Player tPlayer = (Player) entity;
                            if(tPlayer == player) continue;

                            Main.a().killPlayer(tPlayer,player);
                            stop = true;
                        }

                        if(stop) {
                            Bukkit.getScheduler().scheduleSyncDelayedTask(murder, () -> {
                                bullet.remove();
                            }, 5);
                            this.cancel();
                        }

                    }

                }
            }.runTaskTimer(Main.a(), 0, 0);

        }
    Do anyone have a better way to make working bullets or is it the best, i could do?
     
  2. 4chan

    Supporter

    wow!
    it's as if you write in human obfuscation mode!
     
    • Winner Winner x 2
    • Funny Funny x 1
  3. use raytracing.. iterate through blocks and kills players from online list who is in his way
     
  4. You wont be learning about vectors in school anytime soon (most likely never).

    I would advise using an instant raytrace instead of a moving projectile, minecraft dislikes very fast-moving objects.
    This would also be less complex and less laggy if a lot of them are being fired. Teleporting it that fast is going to spam people with packets and look extremely strange on slow internet or slow server conditions.
     
    • Agree Agree x 1
  5. Best explanation :D
     
  6. Thank you, i will try it out ;)
     
  7. A While ago i made a Skillshot Class (For Skillshots like in League of Legends), its based on ArmorStands and a scheduler, you can adjust the hitbox for (X,Y,Z), the speed and so on, when you are interested tell me i will send you the class then.
     
  8. Do you really have a hard time reading that? Perhaps you need to study more
     
    • Agree Agree x 1
    • Optimistic Optimistic x 1
  9. 4chan

    Supporter

    You didn't get the joke. You need to study basic fucking knowledge more.
    He used "Main.a()", and then calls some variables "p", and "as".

    It's readable, but he calls some of his shit as if it were obfuscated.
     
  10. That is a pretty ambiguous method name, I didn't mean to be offensive lol
     
  11. 4chan

    Supporter

    You literally sounded like all those reddit fucks (and Spigot fucks) that never understood my blatantly obvious sarcasm, simply due to the fact that they never read the entire damn post.

    I am happy that you finally got your eyes off their arses and saw what I was talking about. I respect you for that.
     
    • Friendly Friendly x 1
  12. Everyone gets angry on occasion. If you're experiencing overwhelming rage, though, it could be damaging your mental and physical health as well as your relationships with others. Uncontrolled anger can be indicative of underlying problems, such as anger management issues or mental disorder. It's important to control your emotions and calm yourself down for your own sake as well as for the sake of those around you.
     
  13. 4chan

    Supporter

    I suppose we're now doing copy/pasta.
    I sexually Identify as an Attack Helicopter. Ever since I was a boy I dreamed of soaring over the oilfields dropping hot sticky loads on disgusting foreigners. People say to me that a person being a helicopter is Impossible and I’m fucking retarded but I don’t care, I’m beautiful. I’m having a plastic surgeon install rotary blades, 30 mm cannons and AMG-114 Hellfire missiles on my body. From now on I want you guys to call me “Apache” and respect my right to kill from above and kill needlessly. If you can’t accept me you’re a heliphobe and need to check your vehicle privilege. Thank you for being so understanding.
     
    • Funny Funny x 1
  14. Didn't you learn about it at school? He's German and 16 years old according to his profile. I'm German and learned about vectors when I was 17. We actually spent nearly a whole semester on vectors, planes and coordinate systems with three dimensions in general.
     
  15. I was reading your Reader’s Feedback section, which I do every week, and I noticed the comment about your use of “Down’s Syndrome”. The reader is only partially correct. It is generally called Down Syndrome now, but originally, it was Down’s Syndrome (after John Langdon Down) and it is just as correct to call it such.

    My geometry teacher skipped it in my sophomore year. I read the chapter, it was so simple that it seemed to be common sense. The book really had no important information.
     
  16. 4chan

    Supporter

    Hmm. Not sure how to top that.
    What the fuck did you just fucking say about me, you little bitch? I’ll have you know I graduated top of my class in the Navy Seals, and I’ve been involved in numerous secret raids on Al-Quaeda, and I have over 300 confirmed kills. I am trained in gorilla warfare and I’m the top sniper in the entire US armed forces. You are nothing to me but just another target. I will wipe you the fuck out with precision the likes of which has never been seen before on this Earth, mark my fucking words. You think you can get away with saying that shit to me over the Internet? Think again, fucker. As we speak I am contacting my secret network of spies across the USA and your IP is being traced right now so you better prepare for the storm, maggot. The storm that wipes out the pathetic little thing you call your life. You’re fucking dead, kid. I can be anywhere, anytime, and I can kill you in over seven hundred ways, and that’s just with my bare hands. Not only am I extensively trained in unarmed combat, but I have access to the entire arsenal of the United States Marine Corps and I will use it to its full extent to wipe your miserable ass off the face of the continent, you little shit. If only you could have known what unholy retribution your little “clever” comment was about to bring down upon you, maybe you would have held your fucking tongue. But you couldn’t, you didn’t, and now you’re paying the price, you goddamn idiot. I will shit fury all over you and you will drown in it. You’re fucking dead, kiddo.
     
    • Creative Creative x 1
  17. Yes. While it is possible for infections to spread from one part of the body to another, this is fortunately somewhat rare. It is important for you to speak with your doctor. Some of the signs that this could be happening include a high fever and chills, and some of the other signs of a serious and widespread infection. If you are having these and suffering from one infection, and then another body part becomes infected, it is possible that the two are related. The best way to know for sure that the two infections are related is to culture the same species of bacteria from each site of infection (although even this is never quite certain). As with most situations, your doctor will be using his or her best judgment to determine if the two infections are indeed related, and will use this information to decide if the treatment should be more or less aggressive to make sure that the infection is completely eradicated. Regardless, it is important to treat both infections to make sure that you are well. Often, dental infections require dental extractions in order to make sure that all of the infection is cleaned out. Kidney infections generally can be treated with appropriate antibiotics. Please speak with your doctor about this.
     
    • Funny Funny x 1
  18. 4chan

    Supporter

    pm me you racist no off-the-topic
     
  19. Can i move to europe now?