-
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
530e674
commit a02b3a9
Showing
46 changed files
with
1,235 additions
and
664 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
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
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
...java/me/flashyreese/mods/sodiumextra/mixin/profiler/MixinBlockEntityRenderDispatcher.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 me.flashyreese.mods.sodiumextra.mixin.profiler; | ||
|
||
import net.minecraft.block.entity.BlockEntity; | ||
import net.minecraft.client.render.VertexConsumerProvider; | ||
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher; | ||
import net.minecraft.client.render.block.entity.BlockEntityRenderer; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.world.World; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import java.util.WeakHashMap; | ||
|
||
@Mixin(BlockEntityRenderDispatcher.class) | ||
public class MixinBlockEntityRenderDispatcher { | ||
@Unique | ||
private static final WeakHashMap<Class<?>, String> names = new WeakHashMap<>(); | ||
|
||
@Inject(at = @At("HEAD"), method = "render(Lnet/minecraft/client/render/block/entity/BlockEntityRenderer;Lnet/minecraft/block/entity/BlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;)V") | ||
private static <T extends BlockEntity> void onRender(BlockEntityRenderer<T> renderer, T blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, CallbackInfo info) { | ||
World world = blockEntity.getWorld(); | ||
if (world != null) { | ||
String name = names.computeIfAbsent(renderer.getClass(), Class::getSimpleName); | ||
if (!name.isEmpty()) { | ||
world.getProfiler().push(name); | ||
} | ||
} | ||
} | ||
|
||
@Inject(at = @At("TAIL"), method = "render(Lnet/minecraft/client/render/block/entity/BlockEntityRenderer;Lnet/minecraft/block/entity/BlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;)V") | ||
private static <T extends BlockEntity> void afterRender(BlockEntityRenderer<T> renderer, T blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, CallbackInfo info) { | ||
World world = blockEntity.getWorld(); | ||
if (world != null) { | ||
String name = names.computeIfAbsent(renderer.getClass(), Class::getSimpleName); | ||
if (!name.isEmpty()) { | ||
world.getProfiler().pop(); | ||
} | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...main/java/me/flashyreese/mods/sodiumextra/mixin/profiler/MixinEntityRenderDispatcher.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,45 @@ | ||
package me.flashyreese.mods.sodiumextra.mixin.profiler; | ||
|
||
import net.minecraft.client.render.VertexConsumerProvider; | ||
import net.minecraft.client.render.entity.EntityRenderDispatcher; | ||
import net.minecraft.client.render.entity.EntityRenderer; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.world.World; | ||
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.callback.CallbackInfo; | ||
|
||
import java.util.WeakHashMap; | ||
|
||
@Mixin(EntityRenderDispatcher.class) | ||
public abstract class MixinEntityRenderDispatcher { | ||
@Shadow | ||
public abstract <T extends Entity> EntityRenderer<? super T> getRenderer(T entity); | ||
|
||
private static final WeakHashMap<Class<?>, String> names = new WeakHashMap<>(); | ||
|
||
@Inject(at = @At("HEAD"), method = "render") | ||
private <E extends Entity> void onRender(E entity, double x, double y, double z, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { | ||
World world = entity.getWorld(); | ||
if (world != null) { | ||
String name = names.computeIfAbsent(this.getRenderer(entity).getClass(), Class::getSimpleName); | ||
if (!name.isEmpty()) { | ||
world.getProfiler().push(name); | ||
} | ||
} | ||
} | ||
|
||
@Inject(at = @At("TAIL"), method = "render") | ||
private <E extends Entity> void afterRender(E entity, double x, double y, double z, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { | ||
World world = entity.getWorld(); | ||
if (world != null) { | ||
String name = names.computeIfAbsent(this.getRenderer(entity).getClass(), Class::getSimpleName); | ||
if (!name.isEmpty()) { | ||
world.getProfiler().pop(); | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.