-
Notifications
You must be signed in to change notification settings - Fork 6
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
d1b2a12
commit 382e90c
Showing
43 changed files
with
1,145 additions
and
8 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
12 changes: 12 additions & 0 deletions
12
src/main/java/me/hankung/legacyenhance/mixin/batchdrawing/BufferBuilderAccessor.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,12 @@ | ||
package me.hankung.legacyenhance.mixin.batchdrawing; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
import net.minecraft.client.render.BufferBuilder; | ||
|
||
@Mixin(BufferBuilder.class) | ||
public interface BufferBuilderAccessor { | ||
@Accessor("building") | ||
boolean isDrawing(); | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/me/hankung/legacyenhance/mixin/batchdrawing/ModelPartMixin.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,44 @@ | ||
package me.hankung.legacyenhance.mixin.batchdrawing; | ||
|
||
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 me.hankung.legacyenhance.LegacyEnhance; | ||
import net.minecraft.client.render.Tessellator; | ||
import net.minecraft.client.render.VertexFormats; | ||
import net.minecraft.client.render.model.ModelPart; | ||
|
||
@Mixin(ModelPart.class) | ||
public class ModelPartMixin { | ||
|
||
@Shadow | ||
private boolean compiledList; | ||
|
||
private boolean legacy$compiledState; | ||
|
||
@Inject(method = "render", at = @At("HEAD")) | ||
private void legacy$resetCompiled(float j, CallbackInfo ci) { | ||
if (legacy$compiledState != LegacyEnhance.CONFIG.performanceBatchModel.get()) { | ||
this.compiledList = false; | ||
} | ||
} | ||
|
||
@Inject(method = "compileList", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/client/render/Tessellator;getBuffer()Lnet/minecraft/client/render/BufferBuilder;")) | ||
private void legacy$beginRendering(CallbackInfo ci) { | ||
this.legacy$compiledState = LegacyEnhance.CONFIG.performanceBatchModel.get(); | ||
if (LegacyEnhance.CONFIG.performanceBatchModel.get()) { | ||
Tessellator.getInstance().getBuffer().begin(7, VertexFormats.ENTITY); | ||
} | ||
} | ||
|
||
@Inject(method = "compileList", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glEndList()V", remap = false)) | ||
private void legacy$draw(CallbackInfo ci) { | ||
if (LegacyEnhance.CONFIG.performanceBatchModel.get()) { | ||
Tessellator.getInstance().draw(); | ||
} | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/me/hankung/legacyenhance/mixin/batchdrawing/TexturedQuadMixin.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,36 @@ | ||
package me.hankung.legacyenhance.mixin.batchdrawing; | ||
|
||
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.Redirect; | ||
|
||
import me.hankung.legacyenhance.LegacyEnhance; | ||
import net.minecraft.client.render.BufferBuilder; | ||
import net.minecraft.client.render.Tessellator; | ||
import net.minecraft.client.render.VertexFormat; | ||
import net.minecraft.client.render.VertexFormats; | ||
import net.minecraft.client.util.TexturedQuad; | ||
|
||
@Mixin(TexturedQuad.class) | ||
public class TexturedQuadMixin { | ||
|
||
@Unique | ||
private boolean legacy$drawOnSelf; | ||
|
||
@Redirect(method = "draw", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/BufferBuilder;begin(ILnet/minecraft/client/render/VertexFormat;)V")) | ||
private void legacy$beginDraw(BufferBuilder renderer, int glMode, VertexFormat format) { | ||
this.legacy$drawOnSelf = !((BufferBuilderAccessor) renderer).isDrawing(); | ||
if (this.legacy$drawOnSelf || !LegacyEnhance.CONFIG.performanceBatchModel.get()) { | ||
renderer.begin(glMode, VertexFormats.POSITION_TEXTURE_NORMAL); | ||
} | ||
} | ||
|
||
@Redirect(method = "draw", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Tessellator;draw()V")) | ||
private void legacy$endDraw(Tessellator tessellator) { | ||
if (this.legacy$drawOnSelf || !LegacyEnhance.CONFIG.performanceBatchModel.get()) { | ||
tessellator.draw(); | ||
} | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/me/hankung/legacyenhance/mixin/cachedisplayname/EntityMixin.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,48 @@ | ||
package me.hankung.legacyenhance.mixin.cachedisplayname; | ||
|
||
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.CallbackInfoReturnable; | ||
|
||
import net.minecraft.entity.Entity; | ||
import net.minecraft.text.HoverEvent; | ||
import net.minecraft.text.Style; | ||
import net.minecraft.text.Text; | ||
|
||
@Mixin(Entity.class) | ||
public abstract class EntityMixin { | ||
|
||
@Shadow | ||
protected abstract HoverEvent getHoverEvent(); | ||
|
||
private long legacy$displayNameCachedAt; | ||
|
||
private Text legacy$cachedDisplayName; | ||
|
||
@Inject(method = "getName", at = @At("RETURN")) | ||
protected void legacy$cacheDisplayName(CallbackInfoReturnable<Text> cir) { | ||
legacy$cachedDisplayName = cir.getReturnValue(); | ||
legacy$displayNameCachedAt = System.currentTimeMillis(); | ||
} | ||
|
||
@Inject(method = "getName", at = @At("HEAD"), cancellable = true) | ||
protected void legacy$returnCachedDisplayName(CallbackInfoReturnable<Text> cir) { | ||
if (System.currentTimeMillis() - legacy$displayNameCachedAt < 50L) { | ||
cir.setReturnValue(legacy$cachedDisplayName); | ||
} | ||
} | ||
|
||
@Redirect(method = "getName", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getHoverEvent()Lnet/minecraft/text/HoverEvent;")) | ||
private HoverEvent legacy$doNotGetHoverEvent(Entity instance) { | ||
return null; | ||
} | ||
|
||
@Redirect(method = "getName", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/Style;setHoverEvent(Lnet/minecraft/text/HoverEvent;)Lnet/minecraft/text/Style;")) | ||
private Style legacy$doNotSetHoverEvent(Style instance, HoverEvent event) { | ||
return null; | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/me/hankung/legacyenhance/mixin/cachedisplayname/ItemStackMixin.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,32 @@ | ||
package me.hankung.legacyenhance.mixin.cachedisplayname; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import net.minecraft.item.ItemStack; | ||
|
||
@Mixin(ItemStack.class) | ||
public class ItemStackMixin { | ||
|
||
private String legacy$cachedDisplayName; | ||
|
||
@Inject(method = "getCustomName", at = @At("HEAD"), cancellable = true) | ||
private void legacy$returnCachedDisplayName(CallbackInfoReturnable<String> cir) { | ||
if (legacy$cachedDisplayName != null) { | ||
cir.setReturnValue(legacy$cachedDisplayName); | ||
} | ||
} | ||
|
||
@Inject(method = "getCustomName", at = @At("RETURN")) | ||
private void legacy$cacheDisplayName(CallbackInfoReturnable<String> cir) { | ||
legacy$cachedDisplayName = cir.getReturnValue(); | ||
} | ||
|
||
@Inject(method = "setCustomName", at = @At("HEAD")) | ||
private void legacy$resetCachedDisplayName(String displayName, CallbackInfoReturnable<ItemStack> cir) { | ||
legacy$cachedDisplayName = null; | ||
} | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/me/hankung/legacyenhance/mixin/cachedisplayname/PlayerEntityMixin.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.hankung.legacyenhance.mixin.cachedisplayname; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
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.CallbackInfoReturnable; | ||
|
||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.text.HoverEvent; | ||
import net.minecraft.text.Style; | ||
import net.minecraft.text.Text; | ||
|
||
@Mixin(PlayerEntity.class) | ||
public abstract class PlayerEntityMixin extends EntityMixin { | ||
|
||
@Inject(method = "getName", at = @At("RETURN")) | ||
private void legacy$cachePlayerDisplayName(CallbackInfoReturnable<Text> cir) { | ||
super.legacy$cacheDisplayName(cir); | ||
} | ||
|
||
@Inject(method = "getName", at = @At("HEAD"), cancellable = true) | ||
private void legacy$returnCachedPlayerDisplayName(CallbackInfoReturnable<Text> cir) { | ||
super.legacy$returnCachedDisplayName(cir); | ||
} | ||
|
||
@Redirect(method = "getName", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;getHoverEvent()Lnet/minecraft/text/HoverEvent;")) | ||
private HoverEvent legacy$onlyGetHoverEventInSinglePlayer(PlayerEntity instance) { | ||
// Only needed in single player | ||
return MinecraftClient.getInstance().isIntegratedServerRunning() | ||
? ((PlayerEntityMixin) (Object) instance).getHoverEvent() | ||
: null; | ||
} | ||
|
||
@Redirect(method = "getName", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/Style;setHoverEvent(Lnet/minecraft/text/HoverEvent;)Lnet/minecraft/text/Style;")) | ||
private Style legacy$onlySetHoverEventInSinglePlayer(Style instance, HoverEvent event) { | ||
return MinecraftClient.getInstance().isIntegratedServerRunning() | ||
? instance.setHoverEvent(event) | ||
: null; | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/me/hankung/legacyenhance/mixin/cancellightmap/GameRendererMixin.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,30 @@ | ||
package me.hankung.legacyenhance.mixin.cancellightmap; | ||
|
||
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 me.hankung.legacyenhance.LegacyEnhance; | ||
import net.minecraft.client.render.GameRenderer; | ||
|
||
@Mixin(GameRenderer.class) | ||
public class GameRendererMixin { | ||
|
||
@Unique | ||
private boolean legacy$createdLightmap; | ||
|
||
@Inject(method = "updateLightmap", at = @At("HEAD"), cancellable = true) | ||
private void legacy$cancelLightmapBuild(CallbackInfo ci) { | ||
if (LegacyEnhance.CONFIG.generalFullBright.get() && this.legacy$createdLightmap) { | ||
ci.cancel(); | ||
} | ||
} | ||
|
||
@Inject(method = "updateLightmap", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;pop()V")) | ||
private void legacy$setCreatedLightmap(CallbackInfo ci) { | ||
this.legacy$createdLightmap = true; | ||
} | ||
|
||
} |
Oops, something went wrong.