Skip to content

Commit

Permalink
rewrite Disable Hand Item Lighting
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyvest committed Jun 4, 2022
1 parent d41c2ff commit 2a86474
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 135 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ org.gradle.jvmargs=-Xmx2G

# Define project properties.
mod_name=REDACTION
mod_ver=1.3.4
mod_ver=1.3.5

loom.platform = forge
34 changes: 24 additions & 10 deletions src/main/java/net/wyvest/redaction/mixin/EntityRendererMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,34 @@ private void setOverrideHand() {
Redaction.INSTANCE.setOverrideHand(true);
}

@Inject(method = "renderHand", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ItemRenderer;renderItemInFirstPerson(F)V"))
private void setHookTrue(float partialTicks, int xOffset, CallbackInfo ci) {
setHookTrue();
}

@Dynamic("I HATE OPTIFINE")
@Redirect(method = {"renderHand*", "func_78476_b"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/EntityRenderer;enableLightmap()V", remap = true), remap = false)
private void redirectLightmap(EntityRenderer instance) {
if (!RedactionConfig.INSTANCE.getDisableHandLighting()) {
instance.enableLightmap();
}
@Inject(method = "renderHand*", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ItemRenderer;renderItemInFirstPerson(F)V", remap = true), remap = false)
private void setHookTrue(float f, int n, boolean bl, boolean bl2, boolean bl3, CallbackInfo ci) {
setHookTrue();
}

private void setHookTrue() {
Redaction.INSTANCE.setRenderingHand(true);
}

@Inject(method = "renderHand", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ItemRenderer;renderItemInFirstPerson(F)V", shift = At.Shift.AFTER))
private void setHookFalse(float partialTicks, int xOffset, CallbackInfo ci) {
setHookFalse();
}

@Dynamic("I HATE OPTIFINE")
@Redirect(method = {"renderHand*", "func_78476_b"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/EntityRenderer;disableLightmap()V", remap = true), remap = false)
private void redirectLightmap2(EntityRenderer instance) {
if (!RedactionConfig.INSTANCE.getDisableHandLighting()) {
instance.disableLightmap();
}
@Inject(method = "renderHand*", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ItemRenderer;renderItemInFirstPerson(F)V", shift = At.Shift.AFTER, remap = true), remap = false)
private void setHookFalse(float f, int n, boolean bl, boolean bl2, boolean bl3, CallbackInfo ci) {
setHookFalse();
}

private void setHookFalse() {
Redaction.INSTANCE.setRenderingHand(false);
}

@Inject(method = "renderHand", at = @At(value = "FIELD", target = "Lnet/minecraft/client/settings/GameSettings;thirdPersonView:I", opcode = Opcodes.GETFIELD, ordinal = 1))
Expand Down
36 changes: 0 additions & 36 deletions src/main/java/net/wyvest/redaction/mixin/ItemRendererMixin.java

This file was deleted.

This file was deleted.

35 changes: 25 additions & 10 deletions src/main/java/net/wyvest/redaction/mixin/RenderItemMixin.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package net.wyvest.redaction.mixin;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.resources.model.IBakedModel;
import net.minecraft.item.ItemStack;
import net.wyvest.redaction.Redaction;
import net.wyvest.redaction.config.RedactionConfig;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -12,17 +13,31 @@

@Mixin(RenderItem.class)
public class RenderItemMixin {
@Inject(method = "renderEffect", at = @At("HEAD"))
private void beforeRenderEffect(IBakedModel model, CallbackInfo ci) {
if (RedactionConfig.INSTANCE.getDisableHandLighting()) {
RenderHelper.enableStandardItemLighting();
@Inject(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/resources/model/IBakedModel;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RenderItem;renderModel(Lnet/minecraft/client/resources/model/IBakedModel;Lnet/minecraft/item/ItemStack;)V"))
private void beforeModelRender(ItemStack stack, IBakedModel model, CallbackInfo ci) {
if (RedactionConfig.INSTANCE.getDisableHandLighting() && Redaction.INSTANCE.getRenderingHand()) {
GlStateManager.disableLighting();
}
}

@Inject(method = "renderEffect", at = @At("TAIL"))
private void afterRenderEffect(IBakedModel model, CallbackInfo ci) {
if (RedactionConfig.INSTANCE.getDisableHandLighting()) {
RenderHelper.disableStandardItemLighting();
@Inject(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/resources/model/IBakedModel;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RenderItem;renderModel(Lnet/minecraft/client/resources/model/IBakedModel;Lnet/minecraft/item/ItemStack;)V", shift = At.Shift.AFTER))
private void afterModelRender(ItemStack stack, IBakedModel model, CallbackInfo ci) {
if (RedactionConfig.INSTANCE.getDisableHandLighting() && Redaction.INSTANCE.getRenderingHand()) {
GlStateManager.enableLighting();
}
}

@Inject(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/resources/model/IBakedModel;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/tileentity/TileEntityItemStackRenderer;renderByItem(Lnet/minecraft/item/ItemStack;)V"))
private void beforeTileModelRender(ItemStack stack, IBakedModel model, CallbackInfo ci) {
if (RedactionConfig.INSTANCE.getDisableHandLighting() && Redaction.INSTANCE.getRenderingHand()) {
GlStateManager.disableLighting();
}
}

@Inject(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/resources/model/IBakedModel;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/tileentity/TileEntityItemStackRenderer;renderByItem(Lnet/minecraft/item/ItemStack;)V", shift = At.Shift.AFTER))
private void afterTileModelRender(ItemStack stack, IBakedModel model, CallbackInfo ci) {
if (RedactionConfig.INSTANCE.getDisableHandLighting() && Redaction.INSTANCE.getRenderingHand()) {
GlStateManager.enableLighting();
}
}
}

This file was deleted.

3 changes: 2 additions & 1 deletion src/main/kotlin/net/wyvest/redaction/Redaction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ object Redaction {


const val NAME = "REDACTION"
const val VERSION = "1.3.4"
const val VERSION = "1.3.5"
const val ID = "redaction"
val modDir = File(File("./W-OVERFLOW"), NAME)
val isPatcher by lazy {
Expand All @@ -39,6 +39,7 @@ object Redaction {
}
}
var overrideHand = false
var renderingHand = false

@Mod.EventHandler
private fun onFMLPreInitialization(event: FMLPreInitializationEvent) {
Expand Down
5 changes: 1 addition & 4 deletions src/main/resources/mixins.redaction.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@
"GuiIngameMixin",
"GuiMainMenuMixin",
"GuiScreenServerListMixin",
"ItemRendererMixin",
"OverflowGlintHandlerMixin",
"PatcherEntityRendererHookMixin",
"PatcherFontRendererMixin",
"RenderItemMixin",
"RenderManagerMixin",
"Sk1erAnimationHandlerMixin"
"RenderManagerMixin"
],
"verbose": true
}

0 comments on commit 2a86474

Please sign in to comment.