-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
8 changed files
with
78 additions
and
3 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
45 changes: 45 additions & 0 deletions
45
src/client/java/net/mcbrawls/blueprint/mixin/client/EntityRendererMixin.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 net.mcbrawls.blueprint.mixin.client; | ||
|
||
import com.llamalad7.mixinextras.sugar.Local; | ||
import eu.pb4.polymer.core.api.client.ClientPolymerEntityType; | ||
import eu.pb4.polymer.core.api.client.PolymerClientUtils; | ||
import net.mcbrawls.blueprint.entity.BlueprintEntityTypes; | ||
import net.mcbrawls.blueprint.key.BlueprintKeyBindings; | ||
import net.minecraft.client.render.VertexConsumerProvider; | ||
import net.minecraft.client.render.entity.EntityRenderDispatcher; | ||
import net.minecraft.client.render.entity.EntityRenderer; | ||
import net.minecraft.client.render.entity.state.EntityRenderState; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.math.Vec3d; | ||
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; | ||
|
||
@Mixin(EntityRenderDispatcher.class) | ||
public class EntityRendererMixin { | ||
@Inject( | ||
method = "render(Lnet/minecraft/entity/Entity;DDDFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/render/entity/EntityRenderer;)V", | ||
at = @At( | ||
value = "FIELD", | ||
target = "Lnet/minecraft/client/render/entity/EntityRenderDispatcher;renderHitboxes:Z", | ||
shift = At.Shift.BEFORE | ||
) | ||
) | ||
private <E extends Entity, S extends EntityRenderState> void onRender(E entity, double x, double y, double z, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertices, int light, EntityRenderer<? super E, S> renderer, CallbackInfo ci, @Local S state) { | ||
if (BlueprintKeyBindings.INSTANCE.getTOGGLE_ANCHOR_VISUALISATION().isPressed()) { | ||
ClientPolymerEntityType trueType = PolymerClientUtils.getEntityType(entity); | ||
if (trueType != null && trueType.registryEntry() == BlueprintEntityTypes.INSTANCE.getANCHOR()) { | ||
float scale = 1.5f; | ||
matrices.scale(scale, scale, scale); | ||
|
||
state.nameLabelPos = Vec3d.ZERO; | ||
renderer.renderLabelIfPresent(state, Text.literal(String.valueOf(entity.getId())), matrices, vertices, light); | ||
|
||
matrices.scale(1 / scale, 1 / scale, 1 / scale); | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package net.mcbrawls.blueprint | ||
|
||
import net.fabricmc.api.ClientModInitializer | ||
import net.mcbrawls.blueprint.key.BlueprintKeyBindings | ||
|
||
object BlueprintClient : ClientModInitializer { | ||
override fun onInitializeClient() { | ||
BlueprintKeyBindings | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/client/kotlin/net/mcbrawls/blueprint/key/BlueprintKeyBindings.kt
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,19 @@ | ||
package net.mcbrawls.blueprint.key | ||
|
||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper | ||
import net.mcbrawls.blueprint.BlueprintMod | ||
import net.minecraft.client.option.KeyBinding | ||
import net.minecraft.client.util.InputUtil | ||
import org.lwjgl.glfw.GLFW | ||
|
||
object BlueprintKeyBindings { | ||
val TOGGLE_ANCHOR_VISUALISATION = registerKey("toggle_anchor_visualisation", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_N,) | ||
|
||
private fun registerKey(id: String, type: InputUtil.Type, key: Int): KeyBinding { | ||
val modId = BlueprintMod.MOD_ID | ||
val translationKey = "$modId.key.$id" | ||
val category = "$modId.key_category" | ||
val keyBinding = KeyBinding(translationKey, type, key, category) | ||
return KeyBindingHelper.registerKeyBinding(keyBinding) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"entity.blueprint.anchor": "Anchor", | ||
"block.blueprint.point_region": "Region (Point)", | ||
"item.blueprint.anchor": "Anchor", | ||
"blueprint.key_category": "Blueprint", | ||
"blueprint.key.toggle_anchor_visualisation": "Toggle Anchor Visualisation" | ||
} |
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