Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

TheGreyGhost

Members
  • Posts

    3280
  • Joined

  • Last visited

  • Days Won

    8

Posts posted by TheGreyGhost

  1. 2 hours ago, diesieben07 said:

    A TESR is not necessary for rendering OBJs.

    That is true, but if DrachenBauer wants this

    Quote

    And how can i control, how such an item looks in an inventory-slot, thrown on the ground, pinned in an item-frame and equipped in first and third person view?

    then (s)he may need to use an ItemStackTileEntityRenderer.

     

    mbe81 uses item json for wavefront rendering (no TER), eg

     

    mbe81b_boomerang_registry_name.json

    {
      "loader": "forge:obj",
      "model" : "minecraftbyexample:models/entity/mbe81b_boomerang.obj",
      "flip-v": true,
      "detectCullableFaces": false,
      "diffuseLighting": true,
      "ambientToFullbright": false,
      "materialLibraryOverride": "minecraftbyexample:models/entity/mbe81b_boomerang.mtl",
      "__comment": "flip-v may be required if your texture appears mirrored.  See OBJloader::read() for other flags.  currently the available options are",
      "__comment1": "detectCullableFaces (default true) = try to convert faces to Directional Quads (EAST, WEST, etc) instead of just general quads",
      "__comment2": "diffuseLighting (default false) = attempt to apply the direction-dependent lighting as per vanilla blocks.  Currently does nothing.",
      "__comment3": "flipV (default false) = mirror the texture sheet top-->bottom (if your textures appear upside-down)",
      "__comment4": "ambientToFullbright (default true) = always render at maximum world illumination (combinedLight) regardless of the actual skylight or blocklight present",
      "__comment5": "materialLibraryOverrideLocation (default null) = use this path/filename for the material library file .mtl",
      "display": {
        "thirdperson_righthand": {
          "rotation": [ 180, 0, 90 ],
          "translation": [ 0.00, 3.50, -1.75 ],
          "scale": [ 0.04, 0.04, 0.04]
        },
        "thirdperson_lefthand": {
          "rotation": [ 90, 0, 90 ],
          "translation": [ 0.00, 3.50, -1.75 ],
          "scale": [ 0.04, 0.04, 0.04]
        },
        "firstperson_righthand": {
          "rotation": [ 188, 0, 90 ],
          "translation": [ 0.00, 5.25, -2.25 ],
          "scale": [ 0.05, 0.05, 0.05]
        },
        "firstperson_lefthand": {
          "rotation": [ 90, 0, 90 ],
          "translation": [ 0.00, 5.25, -2.25 ],
          "scale": [ 0.05, 0.05, 0.05]
        },
        "gui": {
          "rotation": [ 82, 0, 0 ],
          "translation": [ 0.75, -1.00, 0.00 ],
          "scale": [ 0.06, 0.06, 0.06]
        },
        "head": {
          "rotation": [ 0, 0, 0 ],
          "translation": [ 0.00, 0.00, 0.00 ],
          "scale": [ 0.05, 0.05, 0.05]
        },
        "fixed": {
          "rotation": [ 270, 162, 0 ],
          "translation": [ 0.00, 0.00, 0.25 ],
          "scale": [ 0.06, 0.06, 0.06]
        },
        "ground": {
          "rotation": [ 90, 278, 0 ],
          "translation": [ 0.00, 9.00, 0.00 ],
          "scale": [ 0.05, 0.05, 0.05]
        }
      }
    }

     

  2. Howdy

     

    You might find these working examples useful

    https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe81_entity_projectile

    Quote

    Key points to note:

    You need to have:

    • RenderingRegistry.registerEntityRenderingHandler
    • public IPacket<?> createSpawnPacket() {return NetworkHooks.getEntitySpawningPacket(this);}
    • public static void onEntityTypeRegistration(RegistryEvent.Register<EntityType<?>> entityTypeRegisterEvent) {...}
      If you forget any of these or get them incorrect, your code won't work and might fail silently.

     

    Quote

    Common errors

    • My entity doesn't appear on the client; no errors in the console
      You may have incorrectly implemented createSpawnPacket for your Entity

    • My entity doesn't appear on the client; there is a renderinghandler not found error in the console
      Your renderer is not registered properly.

    Useful tips for debugging entity rendering:

    1. Does the entity exist on the client? Put a breakpoint into YourEntity::tick()
    2. Press F3+B to show entity outline (hitbox) and facing direction
    3. WorldRenderer::updateCameraAndRender() breakpoint at the iprofiler.endStartSection("entities");
      --> entity is present, is associated with the correct renderer, is within the viewing frustrum, is at the [x,y,z] that you expect

    -TGG

  3. Hi

    public class RangePlacement extends SimplePlacement<TopSolidRangeConfig> {
       public RangePlacement(Codec<TopSolidRangeConfig> codec) {
          super(codec);
       }
    
       public Stream<BlockPos> getPositions(Random random, TopSolidRangeConfig config, BlockPos pos) {
          int i = pos.getX();
          int j = pos.getZ();
          int k = random.nextInt(config.maximum - config.topOffset) + config.bottomOffset;
          return Stream.of(new BlockPos(i, k, j));
       }
    }

     

    Beats me why they found it necessary to have both config.maximum and config.topOffset in there.  Probably it means something, eg maximum is the highest y value of this feature but don't use the topmost topOffset rows.

     

    TopSolidRangeConfig(int bottomOffset, int topOffset, int maximum)

    means (5, 0, 37) gives you nextInt(37  - 0) + 5 = 5 to 41 inclusive

    and (5,10, 37) gives you nextint(37 - 10) + 5 = 5 to 31 inclusive

     

    -TGG

    • Thanks 1
  4. 8 hours ago, Tavi007 said:

    I know about your github. It is one of my references. What is the difference between the IITemHandler and an IIventory? And when am I supposed to use which?

    Hi

    IInventory is the vanilla implementation used for containers

    IItemHandler is a Forge extension

     

    You can use either one, they will both work fine if you implement them correctly:

    The vanilla IInventory has some extra methods which are used by the slots to communicate with the container, but you can nearly always safely ignore those.

    IItemHandler is more flexible; you can (for example) use it to implement an inventory on an item.  In some ways it is also stylistically preferable ("composition instead of inheritance").  As Kiou said it is more "automation friendly" in some ways.

     

    In practice, just pick one and go with it, don't worry too much about which one is "optimum".  The users of your mod are highly unlikely to ever notice the difference, and if you do ever need to change it to IItemHandler in the future, it's easy to refactor.

     

    Cheers

      TGG

     

     

     

     

  5. Howdy

    GL11.glEnable(GL11.GL_MAX_LIGHTS) and all those don't work any more, they're incorporated into your RenderTypeBuffer.  The reason is that the drawing is no longer done in-line, it is accumulated into the appropriate buffer (eg transparent blocks, entities, lines, etc) and each buffer is then drawn in one shot.

    If you want to mess with the rendering settings, you need to choose a different RenderTypeBuffer or create your own custom.

     

    Some more information here:

    https://gist.github.com/williewillus/30d7e3f775fe93c503bddf054ef3f93e

     

    If you need every face of the entity model to be lit up the same, you can modify your renderer to render all of the faces more brightly?  I'm not sure why that's a problem?

     

    -TGG

  6. From memory; All the packets that  your client could send are named CXXXXXPacket

    eg CInputPacket

     

    IServerPlayNetHandler also lists the interesting ones (that is the class on the server that processes the incoming packets).

     

    -TGG

     

     

     

     

     

     

     

     

     

     

     

     

  7. Hello

     

    How I find the new name when it has changed version (eg from 1.12  to 1.16):

    1) Find the code in 1.12 which calls .isMaterialInBB(); for example

    EntityLlamaSpit:onUpdate....->
    
    if (!this.world.isMaterialInBB(this.getEntityBoundingBox(), Material.AIR))
    {
        this.setDead();
    }
    else if (this.isInWater())
    {
        this.setDead();
    }

     

    2) Look at EntityLlamaSpit in 1.16.4: (LlamaSpitEntity::tick )

          if (this.world.func_234853_a_(this.getBoundingBox()).noneMatch(AbstractBlock.AbstractBlockState::isAir)) {
             this.remove();
          } else if (this.isInWaterOrBubbleColumn()) {
             this.remove();
          } else {

     

    -TGG

    • Thanks 1
  8. 34 minutes ago, diesieben07 said:

    I am not sure how you expect this to work. If you send a custom network message to the server, but nobody is there to receive it (vanilla Minecraft certainly won't care about it), it will just be dropped. If you want to send custom network messages, you have to have the mod installed on the server to handle them.

    I'm on the same line of thought as DieSieben - or do you mean that your client-side-only mod sends vanilla messages (or "custom" messages that masquerade as vanilla messages)?

     

    Could you implement your desired functionality using vanilla packets only?  The use-cases you described sound like it might be possible (eg changes to controls, placing blocks, etc)

     

    -TGG

  9. Hi

    Off the top of my head I don't recall, but you might get some way forward looking at this:

    https://github.com/TheGreyGhost/MinecraftByExample/blob/master/src/main/java/minecraftbyexample/mbe81_entity_projectile/BoomerangRenderer.java

     

    packedlightIn is probably the parameter of interest I think (i.e. in the render method)

     

    packedLight is the skylight+blocklight value

    https://greyminecraftcoder.blogspot.com/2020/04/lighting-1144.html  (used to be called "mixedBrightness")

     

    -TGG

  10. Hi

    I haven't tried that before however you might find the easiest way (if combining multiple models together eg pommel, hilt, etc) is to use an ItemStackTileEntityRenderer instead of a json block model, and then rebind the appropriate texture before rendering the object models.

     

    see 

    Item.Properties.setISTER

     

    Alternatively you could create a new model file for each one, which is identical except for the materialLibrary Override texture; eg

     

    Quote
    
    {
      "loader": "forge:obj",
      "model" : "minecraftbyexample:models/entity/mbe81b_boomerang.obj",
      "flip-v": true,
      "detectCullableFaces": false,
      "diffuseLighting": true,
      "ambientToFullbright": false,
      "materialLibraryOverride": "minecraftbyexample:models/entity/mbe81b_boomerang.mtl",
      "__comment": "flip-v may be required if your texture appears mirrored.  See OBJloader::read() for other flags.  currently the available options are",
      "__comment1": "detectCullableFaces (default true) = try to convert faces to Directional Quads (EAST, WEST, etc) instead of just general quads",
      "__comment2": "diffuseLighting (default false) = attempt to apply the direction-dependent lighting as per vanilla blocks.  Currently does nothing.",
      "__comment3": "flipV (default false) = mirror the texture sheet top-->bottom (if your textures appear upside-down)",
      "__comment4": "ambientToFullbright (default true) = always render at maximum world illumination (combinedLight) regardless of the actual skylight or blocklight present",
      "__comment5": "materialLibraryOverrideLocation (default null) = use this path/filename for the material library file .mtl",
      "overrides": [
        { "predicate": { "chargefraction": 0.000 }, "model": "minecraftbyexample:item/mbe81b_boomerang_charge_0" },
        { "predicate": { "chargefraction": 0.001 }, "model": "minecraftbyexample:item/mbe81b_boomerang_charge_1" },
        { "predicate": { "chargefraction": 0.333 }, "model": "minecraftbyexample:item/mbe81b_boomerang_charge_2" },
        { "predicate": { "chargefraction": 0.666 }, "model": "minecraftbyexample:item/mbe81b_boomerang_charge_3" }
      ]
    }

     

    and charge_0 for example is

    {
      "loader": "forge:obj",
      "model" : "minecraftbyexample:models/entity/mbe81b_boomerang.obj",
      "flip-v": true,
      "detectCullableFaces": false,
      "diffuseLighting": true,
      "ambientToFullbright": false,
      "materialLibraryOverride": "minecraftbyexample:models/entity/mbe81b_boomerang_texture0.mtl",
      "__comment": "flip-v may be required if your texture appears mirrored.  See OBJloader::read() for other flags.  currently the available options are",
      "__comment1": "detectCullableFaces (default true) = try to convert faces to Directional Quads (EAST, WEST, etc) instead of just general quads",
      "__comment2": "diffuseLighting (default false) = attempt to apply the direction-dependent lighting as per vanilla blocks.  Currently does nothing.",
      "__comment3": "flipV (default false) = mirror the texture sheet top-->bottom (if your textures appear upside-down)",
      "__comment4": "ambientToFullbright (default true) = always render at maximum world illumination (combinedLight) regardless of the actual skylight or blocklight present",
      "__comment5": "materialLibraryOverrideLocation (default null) = use this path/filename for the material library file .mtl",

     

    The full source code for that example is here, if you want to see the context.

    https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/resources/assets/minecraftbyexample/models/item

    Look at the jsons which start with mbe81b

    Disclaimer: it works fine for the item transforms but I'm not sure it works for the materialLibraryOverride.

     

    -TGG

     

     

  11. Howdy.

    Is there any reason you can't create your own IInventory?

    Or a Container to wrap your ItemStackHandler?

    For example like this:

    https://github.com/TheGreyGhost/MinecraftByExample/blob/master/src/main/java/minecraftbyexample/mbe30_inventory_basic/ChestContents.java

    or this:

    https://github.com/TheGreyGhost/MinecraftByExample/blob/master/src/main/java/minecraftbyexample/mbe30_inventory_basic/ContainerBasic.java

     

    You might also find it helpful to make a copy of the vanilla code and refactor it (change the obfuscated method and variable names to something meaningful) to help you understand how it works and perhaps find a shortcut if you don't need the full CraftingInventory functionality.

     

    -TGG

     

     

     

     

     

  12. Howdy

    To be honest I've never done that.  The container method will work but if you want to strip it down, you could try Minecraft::displayGuiScreen on the client only.

      You could try looking at the code for a Vanilla GUI-only screen and seeing how it works.

     

    -TGG

     

  13.  

    21 hours ago, loordgek said:

    we dont give sample code

    Some of us do.

     

    Try this

    https://github.com/TheGreyGhost/MinecraftByExample/blob/master/src/main/java/minecraftbyexample/usefultools/debugging/DebugBlockVoxelShapeHighlighter.java

     

    You will need to find the srg name for the fields you are interested in.

    This tool can help you find it: https://mcp.thiakil.com/#/search

     

    Some useful background info here too:

    https://jamieswhiteshirt.github.io/resources/know-your-tools/

     

    -TGG

     

     

     

     

     

    • Thanks 1
  14. Hi.

    The first problem appears to be that you are creating beam segments on the server and then trying to render them on the client without transmitting them from client to server.

    If they're purely cosmetic then you only need to create them on the client, not the server actually.

     

    I changed them to create on the client and your renderer was at least called (it crashed due to index out of bounds) but hopefully that gets you a step further at least.

     

    -TGG

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.