Jump to content

[1.9] Composite Models


Notunknown

Recommended Posts

Ok, so I am working on a mod which requires composite models (item models made from a set of sub-models joined together).

 

Now, I am on track for getting a basic composite model which would fit my minimum requirements, but as I do not know enough at the moment about how models (and mostly quads) work, I am asking about some information regarding the power of models.

 

Composite Models MUST have the following:

*MUST be able to be formed from two or more models, the number and type of which are determiend by an input ItemStack. (This I believe I can do.)

 

Composite Models SHOULD have the following:

*SHOULD be able to define arbitrary rotations relative to "base" rotation, which is determined by the model determined by the input ItemStack.

*SHOULD be able to define arbitrary translations relative to "base" translation, which is determined by the model determined by the input ItemStack. (This I believe I can do.)

 

Composite Models MAY have the following:

*MAY be able to define arbitrary scales relative to "base" scale, which is determined by the model determined by the input ItemStack.  (This I believe I can do.)

*MAY be able to define arbitrary rotations, translations and offsets relative to model relative rotation, translation and offset, which is determined by code determined by the input ItemStack.

*MAY be able to specify a simple hierarchy within models, which is used to allow models to share with their parents relative rotation, translation and scale.

 

For example, I might want to have a magical stone. The stone is made of three models, a core, a glyph and a ring. The core is the base model (determines the rotation, translation and scale relative to the hand), the glyph shares its rotation and translation with the core but has twice the scale (causing it to stick out) and the ring has the same translation and scale as the core but is rotated 90° to the core.

 

The stone also gently floats above the players hand following a sine wave (giving it a floating effect), the core and glyph additionally slowly rotate clockwise at the same rate, and the ring rotates counter-clockwise at a faster rate (giving it a spinning effect). When right clicked the entire model would increase in scale, then decrease again, following a simple curve.

 

So, before I waste time trying something which is impossible, which of those requirements are possible and which aren't?

Link to comment
Share on other sites

Okay, so I believe that I have gotten the basic system set up. Just a few questions:

 

1: How can I have a texture stitched into the texture atlas without an associated item or block to go with it (or does it automatically do this with everything in textures/items?)

 

2: How can I load a model without an associated item or block (for components to be used in composite models) (again, does it automatically do this with everything in the models folder?)

 

3: How can I load non-standard data from a model file (for use in composite models, things like relative translation and scales)?

 

Edit: For (2), I basically want to turn a ModelResourceLocation into an IBakedModel. My attempts are failing... :'(

Link to comment
Share on other sites

I was googling to day for some information today regarding ICustomModelLoader and ran across this mod source. The author does some of the things you are asking about. https://github.com/mrtska/slopeandcorner/tree/1.9

A blog page about the tech used: https://mrtska.net/2016/03/use-icustommodelloader-in-minecraft1-9/

 

It does not answer all your questions I'm sure, but I found it interesting.

Link to comment
Share on other sites

Okay, this is really annoying me. Currently I have managed to do it, but it seems really inefficient.

 

ModelLoaderRegistry.getModel(new ResourceLocation(model_location)).bake(new SimpleModelState(ImmutableMap.<IModelPart, TRSRTransformation>of()), DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter());

 

I have gotten it to work for models which belong to pre-existing items with this, but when I try to load a model which does not belong to an actual item it returns the default model (the pink/black cube thing)

 

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager().getModel(model_location);

 

What am I missing? There must be a method that I have simply overlooked...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
    • It is an issue with quark - update it to this build: https://www.curseforge.com/minecraft/mc-mods/quark/files/3642325
    • Remove Instant Massive Structures Mod from your server     Add new crash-reports with sites like https://paste.ee/  
  • Topics

×
×
  • Create New...

Important Information

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