Jump to content

UberAffe

Forge Modder
  • Posts

    316
  • Joined

  • Last visited

Posts posted by UberAffe

  1. I still recommend setting up something like I mentioned where the bullets are tracked in code and only do raytraces on the distance they would have traveled in 1 tick as an entity. If you find that you there are too many checks happening per tick and the game slows down you can split up the bullets into multiple queues and only update/check 1 queue per tick. You could probably get away with updating a bullet once every 4 ticks without it looking laggy

  2. do your really need guns that shoot faster than 1200 bpm, there are very few hand held guns that fire faster 1000. If you do plan on making your guns shoot that fast or faster I recommend you not use actual entities. 10 people firing at the same time for 1 second would spawn 200+ entities.

    I would recommend that you make a handler class that implements ITickable and then have each bullet get added to a list for updates.

     

    something like this:

    class Manager implements ITickable{
       private static List<Bullet> bullets = new ArrayList<Bullet>();
    
       public void shoot(Bullet b){bullets.add(b);}
    
       @Override (I don't recall the exact method name and params)
       public void onUpdate(){
          List<Bullet> toRemove = new ArrayList<Bullet>();
          for(Bullet b : bullets)
          {
             MovingObjectPosition result = customRayTrace((vec3d)b.travel(), b.currentLocation());
             if(result hit entity)
               //do damage
               //add b to toRemove list
             else if(result hit block)
              //add b to toRemove list
             else
                b.updateLocation()
          }
          for(Bullet b : toRemove)
             bullets.remove(b);
       }
    }
    

     

     

    Edit: Entities are effectively using raytrace to detect collision anyways and they have a lot of overhead so if you are going to be making that many you should NOT use entities.

  3. I have something similar to this mostly working but the process is somewhat convoluted.

    You can look at my code here.

     

    You can see most of it in common/draftcore/..., helpers/..., api/

    I can try to come up with a path for you to follow to help you understand what is going on.

     

    Edit:

    this is more or less the path you can follow for looking through the code:

     

    *helpers/CommonProxy #preInit, #registerLuxin, #registerCores, #registerParts, #registerItems

    They lead to my registries in the API for other mods to use,

    a good practice is to use your own api's to accomplish create things.

    If something can't be done with your api then expand it so it can be done.

    *helpers/ClientProxy #init, you can see me registering my models here

    *client/itemrenderers/DraftableModelLoader you will want to use something like this

    *client/itemrenderers/DraftableModel yours should be similar to this

    *client/itemrenderers/DraftableBakedModel #Quads yours you should be able to almost copy from the default one

    *client/itemrenderers/DraftableOverrideList #handleItemState is where you can parse nbt info

     

  4. When you hold an item in your hand right clicking on a block effectively overrides the items onActivated with the blocks onActivated when you are sneaking the items onActivated effectively overrides the blocks onActivated.

     

    So you want a sneak right click interaction you have to put that code in your items onActivated.

     

    BTW the method probably isn't actually call onActivated but I don't recall the actual name right now.

  5. don't forget that you have two options for "bullets" you can actually make an entity that travels through the world like the arrow does or you can just look at what is currently at the target location and damage it.

×
×
  • Create New...

Important Information

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