forked from KryptonCaptain/Et-Futurum
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #530 from embeddedt/colored-grass-item-sides
Color the sides of grass blocks rendering in the inventory
- Loading branch information
Showing
3 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...in/java/ganymedes01/etfuturum/mixins/early/coloredgrassitem/client/MixinRenderBlocks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package ganymedes01.etfuturum.mixins.early.coloredgrassitem.client; | ||
|
||
import com.llamalad7.mixinextras.sugar.Local; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockGrass; | ||
import net.minecraft.client.renderer.RenderBlocks; | ||
import net.minecraft.client.renderer.Tessellator; | ||
import net.minecraft.util.IIcon; | ||
import net.minecraftforge.common.util.ForgeDirection; | ||
import org.lwjgl.opengl.GL11; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(RenderBlocks.class) | ||
public abstract class MixinRenderBlocks { | ||
@Shadow public static boolean fancyGrass; | ||
|
||
@Shadow public abstract boolean hasOverrideBlockTexture(); | ||
|
||
@Shadow public boolean useInventoryTint; | ||
|
||
@Shadow public abstract void renderFaceZNeg(Block p_147761_1_, double p_147761_2_, double p_147761_4_, double p_147761_6_, IIcon p_147761_8_); | ||
@Shadow public abstract void renderFaceZPos(Block p_147761_1_, double p_147761_2_, double p_147761_4_, double p_147761_6_, IIcon p_147761_8_); | ||
@Shadow public abstract void renderFaceXNeg(Block p_147761_1_, double p_147761_2_, double p_147761_4_, double p_147761_6_, IIcon p_147761_8_); | ||
@Shadow public abstract void renderFaceXPos(Block p_147761_1_, double p_147761_2_, double p_147761_4_, double p_147761_6_, IIcon p_147761_8_); | ||
|
||
/** | ||
* @author embeddedt | ||
* @reason render the grass overlay texture with the appropriate colors | ||
*/ | ||
@Inject(method = "renderBlockAsItem", at = @At("RETURN")) | ||
private void renderColoredGrassSides(Block block, int meta, float p_147800_3_, CallbackInfo ci, @Local(ordinal = 0) boolean isGrass, @Local(ordinal = 0) Tessellator tessellator) { | ||
if (fancyGrass && isGrass && block.getRenderType() == 0 && this.useInventoryTint && !this.hasOverrideBlockTexture()) { | ||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F); | ||
|
||
// Set render color | ||
int k = block.getRenderColor(meta); | ||
float f2 = (float)(k >> 16 & 255) / 255.0F; | ||
float f3 = (float)(k >> 8 & 255) / 255.0F; | ||
float f4 = (float)(k & 255) / 255.0F; | ||
GL11.glColor4f(f2 * p_147800_3_, f3 * p_147800_3_, f4 * p_147800_3_, 1.0F); | ||
|
||
// Render the four faces | ||
|
||
tessellator.startDrawingQuads(); | ||
tessellator.setNormal(0.0F, 0.0F, -1.0F); | ||
double epsilon = 0.001D; | ||
this.renderFaceZNeg(block, 0.0D, 0.0D, -epsilon, BlockGrass.getIconSideOverlay()); | ||
tessellator.draw(); | ||
tessellator.startDrawingQuads(); | ||
tessellator.setNormal(0.0F, 0.0F, 1.0F); | ||
this.renderFaceZPos(block, 0.0D, 0.0D, epsilon, BlockGrass.getIconSideOverlay()); | ||
tessellator.draw(); | ||
tessellator.startDrawingQuads(); | ||
tessellator.setNormal(-1.0F, 0.0F, 0.0F); | ||
this.renderFaceXNeg(block, -epsilon, 0.0D, 0.0D, BlockGrass.getIconSideOverlay()); | ||
tessellator.draw(); | ||
tessellator.startDrawingQuads(); | ||
tessellator.setNormal(1.0F, 0.0F, 0.0F); | ||
this.renderFaceXPos(block, epsilon, 0.0D, 0.0D, BlockGrass.getIconSideOverlay()); | ||
tessellator.draw(); | ||
|
||
GL11.glColor4f(p_147800_3_, p_147800_3_, p_147800_3_, 1.0F); | ||
GL11.glTranslatef(0.5F, 0.5F, 0.5F); | ||
} | ||
} | ||
} |