made the environmental eye more visually pleasing

This commit is contained in:
Ellpeck 2018-12-02 18:33:04 +01:00
parent 2603c590b1
commit c571c95fec
2 changed files with 17 additions and 4 deletions

View file

@ -33,6 +33,7 @@ import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import org.apache.commons.lang3.mutable.MutableFloat;
import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.mutable.MutableInt;
import java.util.List; import java.util.List;
@ -45,6 +46,7 @@ public class ClientEvents {
@SubscribeEvent @SubscribeEvent
public void onDebugRender(RenderGameOverlayEvent.Text event) { public void onDebugRender(RenderGameOverlayEvent.Text event) {
Minecraft mc = Minecraft.getMinecraft(); Minecraft mc = Minecraft.getMinecraft();
mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":onDebugRender");
if (mc.gameSettings.showDebugInfo) { if (mc.gameSettings.showDebugInfo) {
String prefix = TextFormatting.GREEN + "[" + NaturesAura.MOD_NAME + "]" + TextFormatting.RESET + " "; String prefix = TextFormatting.GREEN + "[" + NaturesAura.MOD_NAME + "]" + TextFormatting.RESET + " ";
List<String> left = event.getLeft(); List<String> left = event.getLeft();
@ -52,10 +54,10 @@ public class ClientEvents {
left.add(prefix + "Particles: " + ParticleHandler.getParticleAmount()); left.add(prefix + "Particles: " + ParticleHandler.getParticleAmount());
if (mc.player.capabilities.isCreativeMode) { if (mc.player.capabilities.isCreativeMode) {
left.add(prefix + "Aura:"); left.add(prefix + "Aura (range 35)");
MutableInt amount = new MutableInt(IAuraChunk.DEFAULT_AURA); MutableInt amount = new MutableInt(IAuraChunk.DEFAULT_AURA);
MutableInt spots = new MutableInt(); MutableInt spots = new MutableInt();
IAuraChunk.getSpotsInArea(mc.world, mc.player.getPosition(), 15, ((blockPos, drainSpot) -> { IAuraChunk.getSpotsInArea(mc.world, mc.player.getPosition(), 35, ((blockPos, drainSpot) -> {
spots.increment(); spots.increment();
amount.add(drainSpot); amount.add(drainSpot);
if (mc.player.isSneaking()) if (mc.player.isSneaking())
@ -65,6 +67,7 @@ public class ClientEvents {
left.add(prefix + "Type: " + IAuraType.forWorld(mc.world).getName()); left.add(prefix + "Type: " + IAuraType.forWorld(mc.world).getName());
} }
} }
mc.profiler.endSection();
} }
@SubscribeEvent @SubscribeEvent
@ -93,6 +96,7 @@ public class ClientEvents {
@SubscribeEvent @SubscribeEvent
public void onOverlayRender(RenderGameOverlayEvent.Post event) { public void onOverlayRender(RenderGameOverlayEvent.Post event) {
Minecraft mc = Minecraft.getMinecraft(); Minecraft mc = Minecraft.getMinecraft();
mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":onOverlayRender");
if (event.getType() == ElementType.ALL) { if (event.getType() == ElementType.ALL) {
ScaledResolution res = event.getResolution(); ScaledResolution res = event.getResolution();
if (mc.player != null) { if (mc.player != null) {
@ -155,7 +159,14 @@ public class ClientEvents {
if (!mc.gameSettings.showDebugInfo) { if (!mc.gameSettings.showDebugInfo) {
GlStateManager.color(83 / 255F, 160 / 255F, 8 / 255F); GlStateManager.color(83 / 255F, 160 / 255F, 8 / 255F);
float totalPercentage = IAuraChunk.getAuraInArea(mc.world, mc.player.getPosition(), 15) / (IAuraChunk.DEFAULT_AURA * 2F);
MutableFloat totalAmount = new MutableFloat(IAuraChunk.DEFAULT_AURA);
IAuraChunk.getSpotsInArea(mc.world, mc.player.getPosition(), 35, (pos, spot) -> {
float percentage = 1F - (float) mc.player.getDistance(pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F) / 35F;
totalAmount.add(spot * percentage);
});
float totalPercentage = totalAmount.intValue() / (IAuraChunk.DEFAULT_AURA * 2F);
int tHeight = MathHelper.ceil(MathHelper.clamp(totalPercentage, 0F, 1F) * 50); int tHeight = MathHelper.ceil(MathHelper.clamp(totalPercentage, 0F, 1F) * 50);
if (tHeight < 50) if (tHeight < 50)
Gui.drawModalRectWithCustomSizedTexture(3, 10, 6, 12, 6, 50 - tHeight, 256, 256); Gui.drawModalRectWithCustomSizedTexture(3, 10, 6, 12, 6, 50 - tHeight, 256, 256);
@ -201,6 +212,7 @@ public class ClientEvents {
} }
} }
} }
mc.profiler.endSection();
} }
private void drawContainerInfo(IAuraContainer container, Minecraft mc, ScaledResolution res, int yOffset, String name) { private void drawContainerInfo(IAuraContainer container, Minecraft mc, ScaledResolution res, int yOffset, String name) {

View file

@ -3,6 +3,7 @@
"icon": "naturesaura:eye", "icon": "naturesaura:eye",
"category": "items", "category": "items",
"advancement": "naturesaura:wood_stand", "advancement": "naturesaura:wood_stand",
"priority": true,
"pages": [ "pages": [
{ {
"type": "text", "type": "text",
@ -10,7 +11,7 @@
}, },
{ {
"type": "text", "type": "text",
"text": "A bar will display the amount stored in $(aura)-bearing blocks, with a full bar meaning that the block has reached its storage capacity.$(br)An additional bar will display the saturation of $(aura) around one's current location, with the bar being half full meaning that the $(aura) is at its expected default level. The eye's limited power, however, means that, when $(aura) exceeds any end of the visible bar, it will not be able to tell you just how much there is." "text": "A bar will display the amount stored in $(aura)-bearing blocks, with a full bar meaning that the block has reached its storage capacity.$(br)An additional bar at the top left of one's field of view will display the saturation of $(aura) around one's current location, with the bar being half full meaning that the $(aura) is at its expected default level. The eye's limited power, however, means that, when $(aura) exceeds any end of the visible bar, it will not be able to tell you just how much there is."
}, },
{ {
"type": "naturesaura:tree_ritual", "type": "naturesaura:tree_ritual",