Jump to content

BenGBoo

Members
  • Posts

    5
  • Joined

  • Last visited

Posts posted by BenGBoo

  1. 5 minutes ago, diesieben07 said:

    This is not correct in so many ways.

    1. mc.theWorld implies two things:
      1. mc is a Minecraft instance, meaning this is the client. Which does not do mob spawning. As such this would be reaching across logical sides.
      2. theWorld has not been the name for this field in forever.
    2. getChunkFromChunkCoords is an ancient name.
    3. getPosX and getPosZ are block coordinates, getChunkFromChunkCoords requires chunk coordinates.

    The correct way would be either World#getChunk(int, int) (which requries chunk coordinates) or World#getChunk(BlockPos) (which obviously requires block coordinates.

     

    LivingSpawnEvent.CheckSpawn is the best you can do to achieve this. There is nothing built-in.

    Awesome, thanks a bunch for the thorough answer, I really appreciate it!

  2. Hey all, I'm looking to make a simple mod that disables mobs from spawning in a square around a chunk. I'm new to Java (and therefore Minecraft Modding), so I poked around last night to come up with a simple Event Listener that intercepts new spawns and entity.remove()s the new entity before it can spawn. This seems inefficient because of game mechanics and ongoing spawns, so I was hoping that there was a way to simply disable spawns in a given Chunk. Is this possible?

     

    I suppose I'm a bit overwhelmed with the vast amount of classes and methods of Forge's documentation. Anyone have a good recommendation as to where I should start? Or is my code (below) a sufficient place to start?

     

        @SubscribeEvent
        public static void spawnEntity(LivingSpawnEvent event) {
            LivingEntity entity = event.getEntityLiving();
            double deltaX = entity.getPosX() - 50;
            double deltaY = entity.getPosY() - 4;
            double deltaZ = entity.getPosZ() - 50;
    
            double distance = (Math.sqrt((deltaX * deltaX) + (deltaY * deltaY) + (deltaZ * deltaZ)));
    
            if (distance < 100) {
                entity.remove();
                NoSpawn.LOGGER.info("DELETED");
            } else {
                NoSpawn.LOGGER.info(distance);
            }
        }

     

  3. 14 minutes ago, Draco18s said:

    Capabilities.

     

    They really aren't that hard to work with, but do require creating a few classes that don't seem to make a lot of sense.

     

    You can see an example I did for TE machines here, but the process will be the same for player capabilities. The only difference is how you attach the capability (for a player, I believe you would use the AttachCapabilityEvent, though I'm not 100% sure on that)

    Thank you very much! I don't know exactly what capabilities are but that's a great starting point, I'll do some research. Thanks again!

  4. Hello everyone, this is my first modding attempt and I've gotten down making items, tools, blocks, and crafting recipes. I have a decent grasp on Java as a programming language but I'm still very new and unsure of Minecraft's modding. The mod I want to make relies heavily on a skill sort of system, where repeating an action like chopping down a tree gives you experience towards that skill, and leveling up increases your efficiency at that skill, so chopping just a tiny bit faster or maybe a chance at getting an extra log. I want this to be a feature of every part of the game, like a skill for farming, tree chopping, mining, etc., but I don't know exactly how to accomplish this. I was thinking that advancements would be a great way to track and see progress on these levels, but how would I go about tracking "blocks mined/xp gained", and how would I reward the player with a constant and permanent stat buff?

     

    Thank you all very much for your help.

×
×
  • Create New...

Important Information

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