Jump to content

[1.10.2] Item model - rotate element on x and z axis


Recommended Posts

Posted

I have an item (Acog Scope) and its model uses eight elements for each round part to make it look a bit more round. Now I have the problem that the Acog Scope's front end is bigger than the back end. To still be able to use eight elements for the roundness I would have to rotate some elements on the x and the z axis. Is there any way to achieve this with the vanilla models or do I have to use some tricks to achieve that?

Posted

JSON models can only rotate at multiples of 22.5 degrees. If you want a rotation value of anything but that, you'd have to use a Wavefront model (.obj).

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

Also: I think that rotation in a JSON file is a single fact having 3 inseparable elements. In other words, you can't use one property to set an 'x' and another property to set 'z' (or 'y'). Instead, you must design one property to set {'x', 'y', 'z'} together. Providing a rotation aggregate such as {x=90} implies { x=90, y=0, z=0 }. Providing a rotation aggregate with any other property means clobbering will occur, with the last applied rotation winning.

 

I think what that means is that your code should first take what you thought were its properties (perhaps based on input) and compose rendering variants according to rendering traits (output). Vanilla properties sometimes get in the way, resulting in ignored properties and other hacks.

 

Beware that some hacks can cause performance penalties (e.g. memory hogging). I must confess that I don't know exactly when memory is or is not wasted by ignored properties in underlying state maps. My mods might be horrible memory hogs, and I am old enough (coming from an era when every memory bit was precious) to almost feel bad about it.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

Actually, I think it only supports X and Y, no Z no matter what you tell it.  Minecraft assumes that rotations on Z are actually rotations on X, plus a 90 degree rotation on Y, and thus ignores it in the json file, as "you really should just simplify that."

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I am not talking about rotation applied in the block state file, I am talking about the rotation of a single element (cube) in the model file. The 22.5 degree steps are also enough, I simply need to rotate an element on two axes.

  • 4 weeks later...
Posted

So, I just got back to this mod and I am still at the point that I can't figure out a way to create the boxes with a rotation on the x and the z axis without needing to make a second model, rotating it in the block state file and combining the two models in code. Does anybody have an idea if this is even possible to do in a single model file? BTW, I am not talking about rotations in the block state file.

Posted

Hi

 

I'm pretty sure you can only specify a vanilla rotation on any one axis, i.e. x or y or z.  You can't rotate on two axes.

 

I'd suggest to use a wavefront model as lars said.  You could use eg blender, or you could just write it out by hand.  The format is very simple

  https://en.wikipedia.org/wiki/Wavefront_.obj_file

and if your object only has around 20 faces, it might be the fastest way.

 

-TGG

Posted

I am too dumb to use blender :/. I already thought about making a second model with the boxes I need, rotating it via a block state file and combining it with the other model in code. Do you know of a way to force a model to be loaded without it being bound to an item via ModelLoader.registerCustomModelResourceLocation()?

Posted
  On 11/7/2016 at 1:26 PM, TheGreyGhost said:

I'm pretty sure you can only specify a vanilla rotation on any one axis, i.e. x or y or z.

 

Actually you can rotate on two Axis at the same time with the json format, as long as you specify them together.

 

BUT

 

Minecraft doesn't know WTF a z-rotation is.

 

It can do X, it can do Y, it can do X and Y, but it assumes that the z-axis is just rotation on the X axis plus a 90 degree rotation on the Y axis.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Draco18s, what you are describing is the rotation in the block state json, but I need two rotations on the same element in the model json.

Posted

Oh that. Yeah no. Not possible. Unfortunately. You will need to use an OBJ.  Use litterally any program you want to.  Sketchup if you have to.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Do you know of a way to force MC to load a model without it being bound to an item or block via block states or ModelLoader.setCustomModelResourceLocation()?

Posted

Actually yes.

 

https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/hardlib/client/ModelsCache.java

 

Which I shamelessly stole from someone else (uh...sorry, I've now forgotten who, one sec...) edit: Elix_x.

 

And here's a usage, it must occur in this event

https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/ores/client/OreClientEventHandler.java#L18

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Awesome, I'll check that out right now and come back to you as soon as I have results.

Posted

Soooo... I seem to have done something really wrong because this is not what I expected: http://imgur.com/a/2EeUB.

This is my implementation of what you linked me:

public enum ModelCache implements IResourceManagerReloadListener
{
    INSTANCE;

    ModelCache()
    {
        ((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener(this);
    }

    public static final IModelState DEFAULTMODELSTATE = new IModelState()
    {
        @Override
        @SuppressWarnings("OptionalUsedAsFieldOrParameterType")
        public Optional<TRSRTransformation> apply(Optional<? extends IModelPart> opt)
        {
            return Optional.absent();
        }
    };
    public static final Function<ResourceLocation, TextureAtlasSprite> DEFAULTTEXTUREGETTER = new Function<ResourceLocation, TextureAtlasSprite>()
    {
        @Override
        public TextureAtlasSprite apply(ResourceLocation texture)
        {
            return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(texture.toString());
        }
    };

    private final Map<ResourceLocation, IModel> cache = new HashMap<>();
    private final Map<ResourceLocation, IBakedModel> bakedCache = new HashMap<>();

    public IBakedModel getOrLoadBakedModel(ResourceLocation location)
    {
        IBakedModel model = bakedCache.get(location);
        if(model == null)
        {
            model = getOrLoadModel(location).bake(DEFAULTMODELSTATE, DefaultVertexFormats.ITEM, DEFAULTTEXTUREGETTER);
            bakedCache.put(location, model);
        }
        return model;
    }

    private IModel getOrLoadModel(ResourceLocation location)
    {
        IModel model = cache.get(location);
        if(model == null)
        {
            try
            {
                model = ModelLoaderRegistry.getModel(location);
            }
            catch(Exception e)
            {
                LogHelper.info("Couldn't load model for location %s, allocating missing model!", location);
                e.printStackTrace();
                model = ModelLoaderRegistry.getMissingModel();
            }
            cache.put(location, model);
        }
        return model;
    }

    @Override
    public void onResourceManagerReload(IResourceManager resourceManager)
    {
        cache.clear();
        bakedCache.clear();
    }
}

 

This is the ModelBakeEventHandler:

@SubscribeEvent
public void onModelBake(ModelBakeEvent event)
{
        IRegistry<ModelResourceLocation, IBakedModel> registry = event.getModelRegistry();

        //ItemAttachment_Acog_Scope
        IBakedModel scope = registry.getObject(new ModelResourceLocation(new ResourceLocation(Reference.MOD_ID, "attachment/itemAttachment_acog_sight"), "inventory"));
        IBakedModel extra = ModelCache.INSTANCE.getOrLoadBakedModel(new ModelResourceLocation(new ResourceLocation(Reference.MOD_ID, "attachment/itemAttachment"), "acog_extra"));
        IBakedModel newModel = new ModelAcogScope(scope, extra);
        registry.putObject(new ModelResourceLocation(new ResourceLocation(Reference.MOD_ID, "attachment/itemAttachment_acog_sight"), "inventory"), newModel);
}

 

The blockstate file:

{
    "variants": {
        "acog_extra": { "model": "rssmc:special/itemAttachment_acog_sight_angled_rotated", "x": 45, "y": 90 }
    }
}

 

The model to be loaded this way:

{
    "textures": {
    },
    "elements": [
        {
            "name": "BottomAngled",
            "from": [ 7.0, 12.500000022351742, 6.000000014901161 ], 
            "to": [ 9.0, 13.000000014901161, 10.000000014901161 ], 
            "rotation": { "origin": [ 8.0, 13.000000014901161, 10.0 ], "axis": "x", "angle": -22.5 },
            "faces": {
                "north": { "texture": "#-1", "uv": [ 0.0, 0.0, 2.0, 0.4999999925494194 ] },
                "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 4.0, 0.4999999925494194 ] },
                "south": { "texture": "#-1", "uv": [ 0.0, 0.0, 2.0, 0.4999999925494194 ] },
                "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 4.0, 0.4999999925494194 ] },
                "up": { "texture": "#-1", "uv": [ 0.0, 0.0, 2.0, 4.0 ] },
                "down": { "texture": "#-1", "uv": [ 0.0, 0.0, 2.0, 4.0 ] }
            }
        },
        {
            "name": "TopAngled",
            "from": [ 7.0, 16.00000001490116, 6.0 ], 
            "to": [ 9.0, 16.50000000745058, 10.0 ], 
            "rotation": { "origin": [ 8.0, 16.0, 10.0 ], "axis": "x", "angle": 22.5 },
            "faces": {
                "north": { "texture": "#-1", "uv": [ 0.0, 0.0, 2.0, 0.4999999925494194 ] },
                "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 4.0, 0.4999999925494194 ] },
                "south": { "texture": "#-1", "uv": [ 0.0, 0.0, 2.0, 0.4999999925494194 ] },
                "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 4.0, 0.4999999925494194 ] },
                "up": { "texture": "#-1", "uv": [ 0.0, 0.0, 2.0, 4.0 ] },
                "down": { "texture": "#-1", "uv": [ 0.0, 0.0, 2.0, 4.0 ] }
            }
        },
        {
            "name": "RightAngled",
            "from": [ 9.49999999254942, 13.50000000745058, 6.0 ], 
            "to": [ 9.999999985098839, 15.50000000745058, 10.0 ], 
            "rotation": { "origin": [ 9.49999999254942, 13.0, 10.0 ], "axis": "y", "angle": -22.5 },
            "faces": {
                "north": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.4999999925494194, 2.0 ] },
                "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 4.0, 2.0 ] },
                "south": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.4999999925494194, 2.0 ] },
                "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 4.0, 2.0 ] },
                "up": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.4999999925494194, 4.0 ] },
                "down": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.4999999925494194, 4.0 ] }
            }
        },
        {
            "name": "LeftAngled",
            "from": [ 5.999999985098839, 13.50000000745058, 6.0 ], 
            "to": [ 6.499999977648258, 15.50000000745058, 10.0 ], 
            "rotation": { "origin": [ 6.500000007450581, 13.0, 10.0 ], "axis": "y", "angle": 22.5 },
            "faces": {
                "north": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.4999999925494194, 2.0 ] },
                "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 4.0, 2.0 ] },
                "south": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.4999999925494194, 2.0 ] },
                "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 4.0, 2.0 ] },
                "up": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.4999999925494194, 4.0 ] },
                "down": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.4999999925494194, 4.0 ] }
            }
        }
    ],
    "display": {
        "thirdperson_righthand": {
            "rotation": [ 90, 180, 0 ],
            "translation": [ 0, 1, -3 ],
            "scale": [ 0.55, 0.55, 0.55 ]
        },
        "firstperson_righthand": {
            "rotation": [ 0, -60, 25 ],
            "translation": [ 0, 4, 2 ],
            "scale": [ 0.55, 0.55, 0.55 ]
        },
        "thirdperson_lefthand": {
            "rotation": [ 90, 180, 0 ],
            "translation": [ 0, 1, -3 ],
            "scale": [ 0.55, 0.55, 0.55 ]
        },
        "firstperson_lefthand": {
            "rotation": [ 0, -60, 25 ],
            "translation": [ 0, 4, 2 ],
            "scale": [ 0.55, 0.55, 0.55 ]
        },
        "gui": {
            "rotation": [ 30, 45, 0 ],
            "translation": [ 0, 0, 0],
            "scale":[ 0.625, 0.625, 0.625 ]
        },
        "ground": {
            "rotation": [ 0, 0, 0 ],
            "translation": [ 0, 3, 0],
            "scale":[ 0.35, 0.35, 0.35 ]
        },
        "fixed": {
            "rotation": [ 0, 0, 0 ],
            "translation": [ 0, 0, 0],
            "scale":[ 0.5, 0.5, 0.5 ]
        }
    }
}

Posted

Not sure, honestly. I started by merging the model I was already using (the one that I specified via ModelLoader.setCustomModelResourceLocation) and combined it with an existing vanilla model (in my case, carpet).  Oh, and only for one variant, too.

 

Once I had that working I did all the variants.  Once that worked I replaced the carpet with a new, custom model.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

OK, so far I found out that the model doesn't even get loaded via ModelLoader.setCustomModelResourceLocation(). Still searching for the error.

Posted

Found the error, it was the rotation in the blockstate file ("x": 45, "y": 90). Putting "z": 45 got ignored as expected. How am I supposed to define a rotation on the z axis?

Posted
  On 11/7/2016 at 6:16 PM, XFactHD said:

Found the error, it was the rotation in the blockstate file ("x": 45, "y": 90). Putting "z": 45 got ignored as expected. How am I supposed to define a rotation on the z axis?

 

As I said earlier, Minecraft assumes that all rotation around the Z axis is actually rotation around X plus a 90 degree rotation around Y.

i.e. models should not be able to define a different axial tilt East-West than North-South.  Instead, rotate around the North-South line, then rotate to face East.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I just tried only defining x and putting the 45 degree into x and it seems like you can only define those angles in 90 degree steps which is bullshit in my opinion.

Also, the north-south axis is the z axis.

Posted
  On 11/7/2016 at 6:22 PM, XFactHD said:

Also, the north-south axis is the z axis.

 

And backwards, because Minecraft is weird.

(Positive X, Positive Z is South East, rather than the expected cartesian planar direction of North East)

 

Anyway, point was "you have to rotate around X, then y" in order to rotate around z.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Makes sense to me but if I define x as 90 degree and y as 90 degree, the model gets its northern face turned down and then rotated around the y axis making it display at a different position because the model isn't centered vertically within the 16x16x16 area. And defining x as 45 degree makes the model not load at all and throw a MissingVariantException.

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

    • I never imagined I would be writing this kind of testimony, but I feel it’s important to share my experience with Malice Cyber Recovery and how they helped me recover $230,000 I lost to crypto scammers. A few months ago, I got involved in a crypto investment opportunity that seemed legitimate at first. The scammers were incredibly convincing. They showed me impressive returns, sent regular updates, and even gave me access to what looked like a real trading platform. I was initially cautious, but after seeing the returns, I began to invest more, ultimately transferring over $230,000. Unfortunately, after a few weeks, when I tried to withdraw my funds, I found that the platform had disappeared, and I could no longer contact anyone involved. It was clear I had been scammed, and I felt completely helpless. For weeks, I tried everything to get my money back—contacting the authorities, reaching out to the platform’s so-called support team (who of course were unreachable), and trying to trace the transactions myself. But everything led to dead ends. The more I researched, the more I realized just how hard it was to recover stolen crypto. I began to lose hope. That’s when I came across Malice Cyber Recovery. At first, I was skeptical. Could they really help me recover my funds after everything I had been through? I decided to reach out anyway, just to see if they could offer any guidance. From the very first conversation, their team was not only professional but also deeply empathetic. They understood exactly how I was feeling and immediately made it clear that they were dedicated to helping me recover my lost funds. Malice Cyber Recovery’s team got to work quickly. They walked me through every step of the process, explaining the methods they would use to track down my stolen crypto. Their knowledge of blockchain technology and how to trace crypto transactions was incredibly impressive. They didn’t just give me vague promises they showed me the action they were taking and the progress they were making, which gave me hope that my money wasn’t gone forever. One of the most reassuring aspects of working with Malice Cyber Recovery was their transparency. They kept me updated regularly, letting me know what they were doing, what obstacles they encountered, and how they were overcoming them. It wasn’t an easy process; tracing funds through blockchain and dealing with scammers who hide behind fake identities and complex networks is incredibly difficult. But Malice Cyber Recovery’s team was relentless. They used advanced tools and techniques to trace the flow of my funds, and within just a few weeks, they managed to locate a significant portion of my lost funds. I couldn’t believe it when they informed me that they had successfully recovered a large chunk of my money. I never thought I’d see that $230,000 again. The recovery process wasn’t instantaneous it  took time, patience, and persistence but Malice Cyber Recovery delivered on their promise.  
    • Almost, just the java -server -Xmx4G -Xms4G -Dlog4j.configurationFile=log4jformattingfix.xml -jar forge-1.12.2-14.23.5.2860.jar nogui and if that doesn't work, try java --version
    • What so just copy and paste " java -server -Xmx4G -Xms4G -Dlog4j.configurationFile=log4jformattingfix.xml -jar forge-1.12.2-14.23.5.2860.jar nogui Pause >nul " into a cmd terminal? If that's what you mean, nothing happens
    • The networking has been far simplified in 1.20.5+ The docs could be old, as Ash has said feel free to submit a PR updating the community docs. However the only real up-to-date reference would be the code itself. So your best bet is to just read the code and give it want it wants.
    • No matter how many mods I disable it keeps giving the same error. https://paste.ee/p/1fBHCe9O
  • Topics

×
×
  • Create New...

Important Information

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