Show targeted multipart in debug HUD
This commit is contained in:
parent
53b0db1cc4
commit
4498feaee1
|
@ -0,0 +1,58 @@
|
|||
package net.shadowfacts.simplemultipart.mixin.client;
|
||||
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.hud.DebugHud;
|
||||
import net.minecraft.state.property.Property;
|
||||
import net.minecraft.util.HitResult;
|
||||
import net.shadowfacts.simplemultipart.SimpleMultipart;
|
||||
import net.shadowfacts.simplemultipart.container.MultipartContainer;
|
||||
import net.shadowfacts.simplemultipart.multipart.Multipart;
|
||||
import net.shadowfacts.simplemultipart.multipart.MultipartState;
|
||||
import net.shadowfacts.simplemultipart.util.MultipartHelper;
|
||||
import net.shadowfacts.simplemultipart.util.MultipartHitResult;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
@Mixin(DebugHud.class)
|
||||
public abstract class MixinDebugHud {
|
||||
|
||||
@Shadow
|
||||
private MinecraftClient client;
|
||||
@Shadow
|
||||
private HitResult blockHit;
|
||||
|
||||
@Shadow
|
||||
public abstract String method_1845(Map.Entry<Property<?>, Comparable<?>> map$Entry_1);
|
||||
|
||||
@Inject(method = "method_1839", at = @At("RETURN"))
|
||||
public void method_1839(CallbackInfoReturnable<List<String>> info) {
|
||||
if (!client.hasReducedDebugInfo() && blockHit != null && blockHit.type == HitResult.Type.BLOCK) {
|
||||
BlockEntity entity = client.world.getBlockEntity(blockHit.getBlockPos());
|
||||
if (entity instanceof MultipartContainer) {
|
||||
MultipartContainer container = (MultipartContainer)entity;
|
||||
MultipartHitResult result = MultipartHelper.rayTrace(container, client.world, blockHit.getBlockPos(), client.player);
|
||||
if (result != null && result.view != null) {
|
||||
info.getReturnValue().add("");
|
||||
info.getReturnValue().add("Targeted Multipart");
|
||||
MultipartState state = result.view.getState();
|
||||
Multipart part = state.getMultipart();
|
||||
info.getReturnValue().add(String.valueOf(SimpleMultipart.MULTIPART.getId(part)));
|
||||
for (Map.Entry<Property<?>, Comparable<?>> e : state.getEntries().entrySet()) {
|
||||
info.getReturnValue().add(method_1845(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"MixinBlockRenderManager",
|
||||
"MixinDebugHud",
|
||||
"MixinModelLoader"
|
||||
],
|
||||
"injectors": {
|
||||
|
|
Loading…
Reference in New Issue