generated from Polyfrost/OneConfigExampleMod
-
Notifications
You must be signed in to change notification settings - Fork 2
Add 1.21.5 Support & Rework Code Structure #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d8a99b3
Add 1.21.5 Support & Rework Code Structure
lowercasebtw f3d95d2
Fixup requested changes
lowercasebtw 895d997
Forgot a spot
lowercasebtw 01789b0
Cleanup import stuff
lowercasebtw 5546db0
Omnicore v1
lowercasebtw 172d700
Remove Hitbox State
lowercasebtw 13c9968
Fixes, Config Changes & OneConfig alpha.152
lowercasebtw 55797d4
Forgot, Fixed TODO
lowercasebtw ee15ebe
Compiles and runs down to 1.16.5!
lowercasebtw 61da2d3
All compiles and runs!
lowercasebtw 464ee50
Small cleanup
lowercasebtw 02c4bf3
Small changes
lowercasebtw 66b196a
It does exist!
lowercasebtw 65c2818
Fix version range mistake
lowercasebtw e5d7a36
Fix 1.8
lowercasebtw 835fa8e
Fix spelling of line stipple
lowercasebtw a6cfd3a
OmniCore beta 10, OneConfig 153
lowercasebtw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
122 changes: 122 additions & 0 deletions
122
src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java
This file contains hidden or 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,122 @@ | ||
| package org.polyfrost.polyhitbox.mixin; | ||
|
|
||
| import dev.deftu.omnicore.api.client.OmniClient; | ||
| import dev.deftu.omnicore.api.client.render.stack.OmniMatrixStack; | ||
| import dev.deftu.omnicore.api.client.render.stack.OmniMatrixStacks; | ||
| import dev.deftu.omnicore.api.data.vec.OmniVec3d; | ||
| import dev.deftu.omnicore.api.entity.OmniEntities; | ||
| import net.minecraft.client.render.entity.EntityRenderDispatcher; | ||
| import net.minecraft.entity.Entity; | ||
| import net.minecraft.entity.LivingEntity; | ||
| import org.polyfrost.polyhitbox.HitboxRendererKt; | ||
| 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.CallbackInfo; | ||
|
|
||
| //#if MC >=1.21.5 | ||
| import net.minecraft.client.render.entity.state.EntityHitbox; | ||
| //#endif | ||
|
|
||
| //#if MC >=1.16.5 | ||
| import net.minecraft.client.util.math.MatrixStack; | ||
| import net.minecraft.client.render.VertexConsumer; | ||
| import net.minecraft.client.render.VertexConsumerProvider; | ||
| import org.spongepowered.asm.mixin.Unique; | ||
| //#endif | ||
|
|
||
| @Mixin(EntityRenderDispatcher.class) | ||
| public abstract class MixinRenderManager { | ||
| //#if MC >=1.21.5 | ||
| @Unique | ||
| private static ThreadLocal<Entity> polyhitbox$entity = ThreadLocal.withInitial(() -> null); | ||
| //#endif | ||
|
|
||
| @Inject( | ||
| //#if MC >=1.16.5 | ||
| method = "renderHitbox", | ||
| //#else | ||
| //$$ method = "renderDebugBoundingBox", | ||
| //#endif | ||
| at = @At("HEAD"), | ||
| cancellable = true | ||
| ) | ||
| //#if MC >=1.16.5 | ||
| private | ||
| //#if MC >=1.20.1 | ||
| static | ||
| //#endif | ||
| void polyhitbox$customRendering( | ||
| MatrixStack matrixStack, | ||
| VertexConsumer vertexConsumer, | ||
| //#if MC >=1.21.5 | ||
| EntityHitbox entityHitbox, | ||
| //#else | ||
| //$$ Entity entity, | ||
| //$$ float tickDelta, | ||
| //#if MC >=1.21.1 | ||
| //$$ float offsetX, float offsetY, float offsetZ, | ||
| //#endif | ||
| //#endif | ||
| CallbackInfo ci | ||
| ) { | ||
| //#else | ||
| //$$ private void polyhitbox$customRendering(Entity entity, double offsetX, double offsetY, double offsetZ, float yaw, float tickDelta, CallbackInfo ci) { | ||
| //#endif | ||
| ci.cancel(); | ||
| OmniMatrixStack stack = OmniMatrixStacks.vanilla( | ||
| //#if MC >=1.16.5 | ||
| matrixStack | ||
| //#endif | ||
| ); | ||
|
|
||
| //#if MC >=1.21.5 | ||
| Entity entity = polyhitbox$entity.get(); | ||
| OmniVec3d offset = new OmniVec3d(entityHitbox.comp_3855(), entityHitbox.comp_3856(), entityHitbox.comp_3857()); | ||
| //#else | ||
| //$$ OmniVec3d offset = OmniVec3d.ZERO; | ||
| //#endif | ||
|
|
||
| HitboxRendererKt.renderHitbox( | ||
| stack, | ||
| offset, | ||
| OmniEntities.getCurrentPos(entity), | ||
| new OmniVec3d(entity.getRotationVector()), | ||
| entity.getStandingEyeHeight(), | ||
| entity instanceof LivingEntity, | ||
| entity == OmniClient.get().targetedEntity, | ||
| //#if MC >=1.16.5 | ||
| entity.getWidth(), | ||
| //#else | ||
| //$$ entity.width, | ||
| //#endif | ||
| entity.getTargetingMargin(), | ||
| OmniEntities.getRenderBoundingBox(entity) | ||
| ); | ||
| } | ||
|
|
||
| //#if MC >=1.21.5 | ||
| @com.llamalad7.mixinextras.injector.v2.WrapWithCondition(method = "renderHitboxes(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/entity/state/EntityHitboxAndView;Lnet/minecraft/client/render/VertexConsumer;F)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/VertexRendering;drawVector(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;Lorg/joml/Vector3f;Lnet/minecraft/util/math/Vec3d;I)V")) | ||
| private static boolean polyhitbox$removeViewRay( | ||
| net.minecraft.client.util.math.MatrixStack matrixStack, | ||
| net.minecraft.client.render.VertexConsumer vertexConsumer, | ||
| org.joml.Vector3f vector3f, | ||
| net.minecraft.util.math.Vec3d vec3d, | ||
| int i | ||
| ) { | ||
| return false; | ||
| } | ||
|
|
||
| @Inject(method = "render(Lnet/minecraft/entity/Entity;DDDFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD")) | ||
| private static void polyhitbox$storeEntity( | ||
| Entity entity, | ||
| double x, double y, double z, float tickDelta, | ||
| MatrixStack matrixStack, | ||
| VertexConsumerProvider vertexConsumerProvider, | ||
| int i, | ||
| CallbackInfo ci | ||
| ) { | ||
| polyhitbox$entity.set(entity); | ||
| } | ||
| //#endif | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overwrite