Jump to content

simicats

Members
  • Posts

    13
  • Joined

  • Last visited

Posts posted by simicats

  1. Hi there, 

    I've been working on tickable TileEntities which operate on inventories of neighboring blocks.

    To reduce the occupied tick-time it would be fantastic to have the observer only update whenever the inventory had been changed.

    I've heard that filled Hoppers attached to large inventories with no remaining space can cause quite an impact, therefore I wondered if there was common practice in the world of Forge for listening to another TEs' IItemHandler efficiently.

     

    Example: Some detector circuit similar to a Comparator emitting a signal when the contents of a chest next to it match a number of conditions. The conditions would only have to be checked whenever the contents changed.

     

    Thanks for your time!

  2. Hi outflows,

    I remember running into a similar problem a while ago. The native Mouse cursor did not appear whenever I called mc.displayGuiScreen() at unfortunate times in the game loop.

    What fixed it for me was to delay the actual call to open the gui to a ClientTickEvent subscriber - something like this:

     

    	private static GuiScreen openedGuiNextTick;
    
    	@SubscribeEvent
    	public static void onClientTick(ClientTickEvent event) {
    		if (openedGuiNextTick != null) {
    			Minecraft.getMinecraft().displayGuiScreen(openedGuiNextTick);
    			openedGuiNextTick = null;
    		}
    	}

     

    Please correct me if this is bad design, I'm suggesting this because it helped fix my issue back when I ran into it.

    (This was done in 1.12.2)

     

    Thanks and good luck! ?

    • Like 1
  3. Very true, the baked model stays the same but transforms its quads every frame. I wonder if caching the rotated quads for each angle would be sensible...

    Edit: In fact, not only for every frame but for each instance as well, as they can have different rotation speeds. This is probably why it scales so badly.

  4. Thank you Cadiboo, I appreciate the help.

     

    The Issue seemed to arise from trying to bake models with rotations other than 0, 90, 180 and -90. 

    My current approach uses a wrapped IBakedModel that modifies getQuads() in such a way that it rotates the individual quads of the original model before passing them over.

    This works fantastically, but the performance is questionable - about 150 of these lowered my FPS from ~320 to ~70 and it only gets worse from there.

    I'm still open to suggestions for performance improvements, but consider the original problem solved. ?

     

    Cheers!~

  5. Good evening all,

     

    I've been looking into block animation with the help of a Fast TESR, putting together a simple stone pillar rotating smoothly around its axis.

    The underlying TileEntity has a speed value, which is supposed to affect the visual rotation speed of the model.

    This is the relevant snippet of renderTileEntityFast() in its current state:

    [...]
    
    final BlockPos pos = te.getPos();
    final IBlockState state = te.getBlockState();
    float time = Animation.getWorldTime(getWorld(), partialTicks);
    		
    // Rotation matrix based on rotation speed
    Matrix4f rot = new Matrix4f();
    rot.setIdentity();
    rot.rotY((float) ((time * speed % 360) * Math.PI / 180));
    		
    // Bake rotated model
    TRSRTransformation transform = TRSRTransformation.blockCenterToCorner(new TRSRTransformation(rot));
    IBakedModel model = this.model.bake(modelGetter, textureGetter, transform, false, DefaultVertexFormats.BLOCK);
    		
    // Render it
    buffer.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ());
    blockModelRenderer.renderModel(this.getWorld(), model, state, pos, buffer, true, new Random(), 42);

     

    It's not far off, however the rotation doesn't quite work out the way you'd expect it to:

    https://i.imgur.com/GXLP0Cn.gifv

    It appears the faces are locked into being orthogonal to the main axes.

    I would like to ask if anyone here has solved this with a Fast TESR before, knows a better way to approach this, or knows of a good place to look further. 

    Any suggestions are welcome, thanks a lot!~

  6. Hi David, 

    For me, this mod serves as a tool for designing Buildings quickly. It works as follows:

    1. You draw and arrange cuboids that specify the parts of the building. 

    2. The mod goes through its collection of walls / corners / roofs / etc. to decorate the specified rooms with. 

    3. Afterwards you choose or create a palette of Blocks to be used in the building.

     

    I figured, in order to make this tool portable into whatever pack I'd like to play or share it with others,

    I need the mod, all of its designs and the pre-defined block palettes shipped within the jar for convenience.

    Cheers!

  7. Greetings,

     

    having built my mostly client-side Mod into a jar, I soon noticed that it lost access to custom JSON and other text files I had placed in sub-folders of the resource directory.

    I've tried several approaches to getting an InputStream for both file listing and reading, yet most of them - if at all - only worked when running it within the IDE. 

    -> My question is: Is there a common way to read custom files shipped in the Mod jar, but not part of what belongs to actual resources (textures, models, ...).

     

    Some of the things I've tried so far:

    Mod.class.getClassLoader().getResourceAsStream(path);

    Stopped working once jarred (even with the target files sitting next to the class files).

    Minecraft.getMinecraft().getResourceManager().getResource(loc).getInputStream();

    Throws a java.io.FileNotFoundException and will most likely not work for iterating over folder contents either way.

     

    Apologies if this counts more as a java question, I'm just hoping to find someone who has done this in their work here.
    Thanks for your time!~

     

    [Edit] by future Simi:

    Thanks again to draco for the reference below. The ClassLoader approach seems to be working for known file locations.

    I have not gotten file listings to work, but for now I will resort to naming all the files I need uniformly with just an index appended.

    Have a good day!

     

     

  8. Good day,

     

    I've recently hit a wall playing around with the rendering hooks: 
    Suppose you have a fairly large (~500) collection of BlockStates and want to render them as a preview in the client world only - calling

    BlockRendererDispatcher.renderBlock(IBlockState, BlockPos, IBlockAccess, BufferBuilder)

    this many times during a

    RenderWorldLastEvent

    works in a way, but doesn't seem like the way to go, especially concerning optimization. 
    I've had a look at some alternatives, those used by the mod Schematica for instance. However before I look into extending from RenderGlobal with my limited understanding of the engine itself,

    I was interested in whether I've missed any obvious / recommended ways to go about this, as I am sure this has been done many times before. ?


    Any suggestions are welcome, thanks for your time.~

×
×
  • Create New...

Important Information

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