Jump to content

imadnsn

Members
  • Posts

    186
  • Joined

  • Last visited

Posts posted by imadnsn

  1. Guess how Minecraft ticks? It's already in a loop, when the server gets launched, it gets into a snippet

    while (this.serverRunning) { // this is the server
          // This is where Minecraft server code happens, including running tick handlers' code every relevant tick depending on what they subscribed for, then it sleeps for at most 50 milliseconds before the loop goes on
    }
    

     

    This means that wherever you are in Minecraft, you are on a loop (one of 2 actually, one for server and one for client, but that's not the point). If a lot happens on the same tick, the game lags because the game loop doesn't go on.

    Forge added tick handling events so mods can run their code on each relevant tick, if modders want to tick without pausing the game they start counting their ticks (on a global variable you still didn't make) and each time the tick counter reaches certain amount the mod runs its code.

  2. Post the error that logs in the console.

    It wouldn't use the black and purple unless it either can't find the model or can't find the texture. So make sure your textures are at

    assets.modid.textures.items

    and at

    assets.modid.textures.armor

    (as you specified in your json file) and your model at

    assets.modid.models.item/plasticlegs.json

    (as you specified in setCustomModelResourceLocation).

     

    also unrelated but use setUnlocalisedName when registering your item so you can give it a name in gui

  3. If you want you can tidy it up by putting these conditions in a function that returns a boolean, where it returns false whenever any of the armor pieces isn't present. That won't make much of a change, however.

     

    As for the hurting, check if the entity is instance of

    EntityLivingBase

    (super class for all entities with health even players) then use

    EntityLivingBase#attackEntityFrom

    with DamageSource being

    DamageSource.causePlayerDamage(player)

  4. Well i know how to do this but 1rst. Would you like to work on a mod together 2nd Provide Your main Mod File and your blocks file

     

    We offer help for free here in this forum, don't ask for anything to give the answer. What you did is intolerable!

     

    As for op, A lot of things are quite similar but here's what you should change:

    • Make sure the class implements
      IWorldGenerator


    • The fifth parameter of generate should be of type
      IChunkGenerator

      not

      IChunkProvider


    • world.provider.getDimensionType()

      instead of

      world.provider.dimensionId

      and the cases are

      DimensionType.NETHER

      ,

      DimensionType.OVERWORLD

      and/or

      DimensionType.THE_END


    • new WorldGenMinable()

      now takes

      IBlockState

      which would indicate the block and the metadata. It also takes

      IPredicate<IBlockstate>

      to get the blocks that can surround the ore, you can get that using

      BlockMatcher.forBlock(Blocks.STONE)


    • WorldGenMinable#generate()

      takes

      BlockPos

      instead of

      x

      ,

      y

      and

      z

      which is easily made by

      new BlockPos(x, y, z)


  5. I dont know most of the terms you just explaned

     

    if you mean

    • Storage: how much something can possibly have
    • I/O: How much can enter/leave a suitable storage
    • Generator: A way to get this energy
    • Transport: How to move this energy from point A to point B

     

    then that's not java-related but explaining what you might want to do.

  6. The reason is when you r.doRender() it invokes the RenderLivingEvent.Pre event, so recursion happens, where the method keeps calling itself, until the stack overflows. I don't know how you'd fix it but maybe you'd have to render it yourself.

     

    If you look at RenderLivingBase, which your renderer extends, and look at its doRender(), you see the first line is

    public void doRender(T entity, double x, double y, double z, float entityYaw, float partialTicks)
        {
            // This is how forge invokes the event.
            if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Pre<T>(entity, this, x, y, z))) return;
            .....
        }

  7. Well not really, the thing is it's all about the implementation of the handling. If a mod decided to destroy the world when a client presses a button it will happen, but that's because it was hard-coded to do so. However, the way Minecraft works really gives the client little chance to do things. Almost everything that happens in the world where direct player interaction isn't needed (such as ticking tile entities) happens automatically on the server side.

    As a modder, one must always consider the first rule when handling packets, don't let the client be in control of doing big things directly.

×
×
  • Create New...

Important Information

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