69 lines
3.1 KiB
Java
69 lines
3.1 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* org.jspecify.annotations.Nullable
|
|
*/
|
|
package net.minecraft.client.gui.components.debug;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Map;
|
|
import net.minecraft.ChatFormatting;
|
|
import net.minecraft.SharedConstants;
|
|
import net.minecraft.client.Minecraft;
|
|
import net.minecraft.client.gui.components.debug.DebugScreenDisplayer;
|
|
import net.minecraft.client.gui.components.debug.DebugScreenEntry;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.core.registries.BuiltInRegistries;
|
|
import net.minecraft.resources.Identifier;
|
|
import net.minecraft.util.Util;
|
|
import net.minecraft.world.entity.Entity;
|
|
import net.minecraft.world.level.Level;
|
|
import net.minecraft.world.level.block.state.properties.Property;
|
|
import net.minecraft.world.level.chunk.LevelChunk;
|
|
import net.minecraft.world.level.material.FluidState;
|
|
import net.minecraft.world.phys.BlockHitResult;
|
|
import net.minecraft.world.phys.HitResult;
|
|
import org.jspecify.annotations.Nullable;
|
|
|
|
public class DebugEntryLookingAtFluid
|
|
implements DebugScreenEntry {
|
|
private static final Identifier GROUP = Identifier.withDefaultNamespace("looking_at_fluid");
|
|
|
|
@Override
|
|
public void display(DebugScreenDisplayer displayer, @Nullable Level serverOrClientLevel, @Nullable LevelChunk clientChunk, @Nullable LevelChunk serverChunk) {
|
|
Level clientOrServerLevel;
|
|
Entity cameraEntity = Minecraft.getInstance().getCameraEntity();
|
|
Level level = clientOrServerLevel = SharedConstants.DEBUG_SHOW_SERVER_DEBUG_VALUES ? serverOrClientLevel : Minecraft.getInstance().level;
|
|
if (cameraEntity == null || clientOrServerLevel == null) {
|
|
return;
|
|
}
|
|
HitResult liquid = cameraEntity.pick(20.0, 0.0f, true);
|
|
ArrayList<String> result = new ArrayList<String>();
|
|
if (liquid.getType() == HitResult.Type.BLOCK) {
|
|
BlockPos pos = ((BlockHitResult)liquid).getBlockPos();
|
|
FluidState fluidState = clientOrServerLevel.getFluidState(pos);
|
|
result.add(String.valueOf(ChatFormatting.UNDERLINE) + "Targeted Fluid: " + pos.getX() + ", " + pos.getY() + ", " + pos.getZ());
|
|
result.add(String.valueOf(BuiltInRegistries.FLUID.getKey(fluidState.getType())));
|
|
for (Map.Entry<Property<?>, Comparable<?>> entry : fluidState.getValues().entrySet()) {
|
|
result.add(this.getPropertyValueString(entry));
|
|
}
|
|
fluidState.getTags().map(e -> "#" + String.valueOf(e.location())).forEach(result::add);
|
|
}
|
|
displayer.addToGroup(GROUP, result);
|
|
}
|
|
|
|
private String getPropertyValueString(Map.Entry<Property<?>, Comparable<?>> entry) {
|
|
Property<?> property = entry.getKey();
|
|
Comparable<?> value = entry.getValue();
|
|
Object valueString = Util.getPropertyName(property, value);
|
|
if (Boolean.TRUE.equals(value)) {
|
|
valueString = String.valueOf(ChatFormatting.GREEN) + (String)valueString;
|
|
} else if (Boolean.FALSE.equals(value)) {
|
|
valueString = String.valueOf(ChatFormatting.RED) + (String)valueString;
|
|
}
|
|
return property.getName() + ": " + (String)valueString;
|
|
}
|
|
}
|
|
|