Jump to content

Recommended Posts

Posted

Hi,

 

I was about to publish my mod, but i noticed that after i updated to the latest Forge, the PerspectiveAwareModel got messed up.

 

Neither the vanilla(RenderItem.applyVanillaTransform) or the Forge(ForgeClientHooks.getMatrix) transform got applied. Basically if i change the .json file the model is still the default.

 

I really dont want to use GlStateManager to rotate it back.

 

Thanks!

 

 

Posted

Is this a mod help plea or a bug report?

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

Supply code and example, I'll yell at fry to fix it. He's the one dealing with this crap

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

Okay, here you go.

 

Model class

public class ModelLanternOn implements ISmartItemModel, IPerspectiveAwareModel{
public static final ModelResourceLocation modelLanternOn = new ModelResourceLocation(AmnesiaLights.ModID + ":LanternOn", "inventory");
public IBakedModel LanternOn;
public Minecraft mc;

public ModelLanternOn(IBakedModel LanternOn){
	this.LanternOn = LanternOn;
	this.mc = Minecraft.getMinecraft();
}

@Override
public IBakedModel handleItemState(ItemStack stack){
	return this;
}

@Override
public List getFaceQuads(EnumFacing p_177551_1_){
	return LanternOn.getFaceQuads(p_177551_1_);
}

@Override
public List getGeneralQuads(){
	return LanternOn.getGeneralQuads();
}

@Override
public boolean isAmbientOcclusion(){
	return LanternOn.isAmbientOcclusion();
}

@Override
public boolean isGui3d(){
	return LanternOn.isGui3d();
}

@Override
public boolean isBuiltInRenderer(){
	return false;
}

@Override
public TextureAtlasSprite getTexture(){
	return LanternOn.getTexture();
}

@Override
@Deprecated
public ItemCameraTransforms getItemCameraTransforms(){
	return LanternOn.getItemCameraTransforms();
}

@Override
public Pair<IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType){
	switch (cameraTransformType){
	case FIRST_PERSON:
		this.renderFirstPersonArm();//Not the problem, same without this!!!
		RenderItem.applyVanillaTransform(LanternOn.getItemCameraTransforms().firstPerson);
		return Pair.of(LanternOn, null);
	case THIRD_PERSON:
		RenderItem.applyVanillaTransform(LanternOn.getItemCameraTransforms().thirdPerson);
		return Pair.of(LanternOn, null);
	case GUI:
		RenderItem.applyVanillaTransform(LanternOn.getItemCameraTransforms().gui);
		return Pair.of(LanternOn, null);
	case HEAD:
		RenderItem.applyVanillaTransform(LanternOn.getItemCameraTransforms().head);
		return Pair.of(LanternOn, null);
	default:
		return Pair.of(LanternOn, null);
	}
}

 

ModelBakeEvent

Object LanternOn = event.modelRegistry.getObject(ModelLanternOn.modelLanternOn);
if(LanternOn instanceof IBakedModel){
IBakedModel newLanternOn = (IBakedModel)LanternOn;
ModelLanternOn customModel = new ModelLanternOn(newLanternOn);
event.modelRegistry.putObject(ModelLanternOn.modelLanternOn, customModel);
}

 

Yes i dont combine models, because im doing additional rendering based on perspectives!

But thats not the problem!

So "RenderItem.applyVanillaTransform" does nothing!

 

Thanks Lex!

Posted

I assume the inner model for your lantern is a normal vanilla model - build 1529 fixed loading of perspective transformations for them, now they implement IPerspectiveAwareModel too, instead of relying on getItemCameraTransforms, so you need to use that. cast inner model to the IPerspectiveAwareModel, call handlePerspective, and return Pair.of(LanternOn, <second element of the result of inner model's handle perspective here>).

 

Vanilla models should have correct value in getItemCameraTransforms again in the next build, when possible (not using Forge Blockstate Json).

Posted

Well, my model has nothing to do with vanilla models.

Its builded up with elements.

Here is a snippet:

{
"__comment": "Designed by FLUFFY2",
"textures": {
        "LanternTop": "amnesialights:models/LanternTop",
        "LanternOffSide": "amnesialights:models/LanternOffSide"
},
"elements": [ 
{
    "__comment": "Lantern",
    "from": [ 5.25, 0, 6.5 ],
    "to": [ 10.25, 1.5, 9.5 ],
    "faces": {
        "down":  { "uv": [ 10.75, 9.5, 5.75, 6.5 ], "texture": "#LanternTop", "cullface": "down" },
        "up":    { "uv": [ 5.25, 6.5, 10.25, 9.5 ], "texture": "#LanternTop" },
        "north": { "uv": [ 5.75, 14.5, 10.75, 16 ], "texture": "#LanternOffSide" },
        "south": { "uv": [ 5.25, 14.5, 10.25, 16 ], "texture": "#LanternOffSide" },
        "west":  { "uv": [ 6.5, 14.5, 9.5, 16 ], "texture": "#LanternOffSide" },
        "east":  { "uv": [ 6.5, 14.5, 9.5, 16 ], "texture": "#LanternOffSide" }
    }
},
//Bunch more elements here
],
"display": {
    "thirdperson": {
        "rotation": [ 180, -90, 30 ],
        "translation": [ 0, 3.6, 0.8 ],
        "scale": [ 0.8, 0.8, 0.8 ]
    },
    "ground": {
        "rotation": [ 0, 0, 0 ],
        "translation": [ 0, -1, 0 ],
        "scale": [ 1.5, 1.5, 1.5 ]
    },
    "fixed": {
        "rotation": [ 0, 90, 0 ],
        "translation": [ 0, 0, -0.2 ],
        "scale": [ 1.5, 1.5, 1.5 ]
    },
    "firstperson": {
        "rotation": [ 0, -137, 0 ],
        "translation": [ -2.4, 0.1, -1.4 ],
        "scale": [ 2, 2, 2 ]
    },
    "gui": {
        "rotation": [ 0, 0, 0 ],
        "translation": [ 0, 0, 0 ],
        "scale": [ 1, 1, 1 ]
    }
}
}

Posted

Thank you, it does fix the issue!

 

Its not related here, but what changes happend to the lighting algorithm?

Just because i have dynamic lighting and in 1.7.10 it dosent drop that much FPS, but in 1.8 it makes it unplayable.

Optifin does fix this, but im just curious.

 

Thanks again!

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



×
×
  • Create New...

Important Information

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