Shader fixer

Shader fixer

3.4k Downloads

Code change request: annotate the entire `ItemRenderWeaponBase`, instead of each weapon individually

Darek505 opened this issue · 2 comments

commented

Title, Indeed, why not just annotate the entire ItemRenderWeaponBase in MixinItemRenderWeaponBase?

Right now we're annotating each weapon individually, which means that when bob makes new weapons, they'll still render the old way unless you just add a mixin for it and include that annotation.

If you annotate the entire ItemRenderWeaponBase, then any weapon that extends that class (which is all weapons, since they all extend the base class) will also have that annotation.

That way you don't even have to do anything, since all weapons will inherit that annotation themselves, and the fix will apply to them.

commented

I thought so at first, but then I came to another way as you can see.

The thing is: the annotation, as such, is a kind of confirmation that the weapon is fully tested, and therefore fixed correctly.

If we blindly give an annotation to all weapons ItemRenderWeaponBase, then it will use our fix immediately, without checking how this fix will affect it.

Take a look for example at MixinItemRenderAtlas, MixinItemRenderDANI, MixinItemRenderHenry, MixinItemRenderMaresleg, they all have the fixAfterSmoke method. The thing is that some weapons run the smoke render AFTER the weapon texture is applied, but BEFORE the weapon itself is rendered. Because of this, the weapon texture becomes simply white, due to the specifics of the fix. Thus, some weapons require a so-called post-fix. Therefore, it is important to set the annotation manually to confirm that the weapon works correctly, and if not, then fix it in the same mixin where we give the annotation.

Plus, this method:

public static float getGunsMagnitude(ItemStack stack) {
//DJ ИВАН ФРОСТ
if (Loader.isModLoaded("hbm")) {
if(stack != null) {
//TODO Manual values, use with attention
if (stack.getItem() == ModItems.gun_am180) return ItemGunBaseNT.getIsAiming(stack) ? 2.5F : -0.5F;
if (stack.getItem() == ModItems.gun_light_revolver) return ItemGunBaseNT.getIsAiming(stack) ? 2.5F : -0.25F;
if (stack.getItem() == ModItems.gun_carbine) return ItemGunBaseNT.getIsAiming(stack) ? 2.5F : -0.5F;
if (stack.getItem() == ModItems.gun_congolake) return ItemGunBaseNT.getIsAiming(stack) ? 2.5F : -0.25F;
if (stack.getItem() == ModItems.gun_light_revolver_dani) return ItemGunBaseNT.getIsAiming(stack) ? 2.5F : -0.25F;
if (stack.getItem() == ModItems.gun_debug) return ItemGunBaseNT.getIsAiming(stack) ? 2.5F : -0.25F;
if (stack.getItem() == ModItems.gun_flamer) return ItemGunBaseNT.getIsAiming(stack) ? 2.5F : -0.5F;
if (stack.getItem() == ModItems.gun_flaregun) return ItemGunBaseNT.getIsAiming(stack) ? 2.5F : -0.25F;
if (stack.getItem() == ModItems.gun_greasegun) return ItemGunBaseNT.getIsAiming(stack) ? 2.5F : -0.5F;
if (stack.getItem() == ModItems.gun_heavy_revolver) return ItemGunBaseNT.getIsAiming(stack) ? 2.5F : -0.25F;
if (stack.getItem() == ModItems.gun_henry) return ItemGunBaseNT.getIsAiming(stack) ? 2.5F : -0.5F;
if (stack.getItem() == ModItems.gun_liberator) return ItemGunBaseNT.getIsAiming(stack) ? 2.5F : -0.25F;
if (stack.getItem() == ModItems.gun_maresleg) return ItemGunBaseNT.getIsAiming(stack) ? 2.5F : -0.5F;
if (stack.getItem() == ModItems.gun_pepperbox) return ItemGunBaseNT.getIsAiming(stack) ? 2.5F : -0.5F;
}
}
return 2.75F;
}

Here, we manually set turnMagnitude, depending on the weapon. Accordingly, we already need to get into the render code, at least because we need to take the value for turnMagnitude from there, so in any case, we will have to do something manually.

commented

Although, I think this quite significantly reduces the number of mixins in general, in the end I will only have to add mixins for fixes, not for everything. I'll look into this again