-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/20.1/forge' into 21.0/neoforge
- Loading branch information
Showing
12 changed files
with
161 additions
and
24 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
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
43 changes: 43 additions & 0 deletions
43
src/main/java/org/embeddedt/embeddium/impl/mixin/core/model/quad/BakedQuadFactoryMixin.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,43 @@ | ||
package org.embeddedt.embeddium.impl.mixin.core.model.quad; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyReturnValue; | ||
import com.llamalad7.mixinextras.sugar.Local; | ||
import net.minecraft.client.renderer.block.model.BakedQuad; | ||
import net.minecraft.client.renderer.block.model.BlockElementFace; | ||
import net.minecraft.client.renderer.block.model.FaceBakery; | ||
import net.minecraft.client.renderer.texture.SpriteContents; | ||
import net.minecraft.client.renderer.texture.TextureAtlasSprite; | ||
import org.embeddedt.embeddium.impl.model.quad.BakedQuadView; | ||
import org.embeddedt.embeddium.impl.model.quad.properties.ModelQuadFlags; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
@Mixin(FaceBakery.class) | ||
public class BakedQuadFactoryMixin { | ||
/** | ||
* @author embeddedt | ||
* @reason Check if quad's UVs are contained within the sprite's boundaries; if so, mark it as having a trusted sprite | ||
* (meaning the particle sprite matches the encoded UVs) | ||
*/ | ||
@ModifyReturnValue(method = "bakeQuad", at = @At("RETURN")) | ||
private BakedQuad setMaterialClassification(BakedQuad quad, @Local(ordinal = 0, argsOnly = true) BlockElementFace face, @Local(ordinal = 0, argsOnly = true) TextureAtlasSprite sprite) { | ||
if (sprite.getClass() == TextureAtlasSprite.class && sprite.contents().getClass() == SpriteContents.class) { | ||
float[] uvs = face.uv().uvs; | ||
float minUV = Float.MAX_VALUE, maxUV = Float.MIN_VALUE; | ||
|
||
for (float uv : uvs) { | ||
minUV = Math.min(minUV, uv); | ||
maxUV = Math.max(maxUV, uv); | ||
} | ||
|
||
if (minUV >= 0 && maxUV <= 16) { | ||
// Quad UVs do not extend outside texture boundary, we can trust the given sprite | ||
BakedQuadView view = (BakedQuadView)quad; | ||
view.setFlags(view.getFlags() | ModelQuadFlags.IS_TRUSTED_SPRITE); | ||
} | ||
|
||
} | ||
|
||
return quad; | ||
} | ||
} |
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
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
14 changes: 14 additions & 0 deletions
14
src/main/java/org/embeddedt/embeddium/impl/render/chunk/sprite/SpriteTransparencyLevel.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,14 @@ | ||
package org.embeddedt.embeddium.impl.render.chunk.sprite; | ||
|
||
public enum SpriteTransparencyLevel { | ||
OPAQUE, | ||
TRANSPARENT, | ||
TRANSLUCENT; | ||
|
||
/** | ||
* {@return whichever level has a higher ordinal, i.e. requires a better render pass} | ||
*/ | ||
public SpriteTransparencyLevel chooseNextLevel(SpriteTransparencyLevel level) { | ||
return level.ordinal() >= this.ordinal() ? level : this; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
.../java/org/embeddedt/embeddium/impl/render/chunk/sprite/SpriteTransparencyLevelHolder.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,11 @@ | ||
package org.embeddedt.embeddium.impl.render.chunk.sprite; | ||
|
||
import net.minecraft.client.renderer.texture.SpriteContents; | ||
|
||
public interface SpriteTransparencyLevelHolder { | ||
SpriteTransparencyLevel embeddium$getTransparencyLevel(); | ||
|
||
static SpriteTransparencyLevel getTransparencyLevel(SpriteContents contents) { | ||
return ((SpriteTransparencyLevelHolder)contents).embeddium$getTransparencyLevel(); | ||
} | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.