mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-05 20:06:30 +01:00
Entry point
This commit is contained in:
parent
d35bdab51a
commit
9d7ddbc326
3 changed files with 184 additions and 4 deletions
|
@ -1,5 +1,8 @@
|
||||||
package com.simibubi.create.events;
|
package com.simibubi.create.events;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllFluids;
|
import com.simibubi.create.AllFluids;
|
||||||
import com.simibubi.create.Create;
|
import com.simibubi.create.Create;
|
||||||
|
@ -22,6 +25,7 @@ import com.simibubi.create.content.logistics.block.mechanicalArm.ArmInteractionP
|
||||||
import com.simibubi.create.foundation.config.AllConfigs;
|
import com.simibubi.create.foundation.config.AllConfigs;
|
||||||
import com.simibubi.create.foundation.gui.ScreenOpener;
|
import com.simibubi.create.foundation.gui.ScreenOpener;
|
||||||
import com.simibubi.create.foundation.item.TooltipHelper;
|
import com.simibubi.create.foundation.item.TooltipHelper;
|
||||||
|
import com.simibubi.create.foundation.metadoc.MetaDocHandler;
|
||||||
import com.simibubi.create.foundation.networking.AllPackets;
|
import com.simibubi.create.foundation.networking.AllPackets;
|
||||||
import com.simibubi.create.foundation.networking.LeftClickPacket;
|
import com.simibubi.create.foundation.networking.LeftClickPacket;
|
||||||
import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer;
|
import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer;
|
||||||
|
@ -32,6 +36,7 @@ import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollVal
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
import com.simibubi.create.foundation.utility.ServerSpeedProvider;
|
import com.simibubi.create.foundation.utility.ServerSpeedProvider;
|
||||||
import com.simibubi.create.foundation.utility.placement.PlacementHelpers;
|
import com.simibubi.create.foundation.utility.placement.PlacementHelpers;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
|
@ -46,6 +51,7 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.client.event.EntityViewRenderEvent;
|
import net.minecraftforge.client.event.EntityViewRenderEvent;
|
||||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
|
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
|
||||||
|
import net.minecraftforge.client.event.RenderTooltipEvent;
|
||||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||||
import net.minecraftforge.event.TickEvent.ClientTickEvent;
|
import net.minecraftforge.event.TickEvent.ClientTickEvent;
|
||||||
import net.minecraftforge.event.TickEvent.Phase;
|
import net.minecraftforge.event.TickEvent.Phase;
|
||||||
|
@ -56,9 +62,6 @@ import net.minecraftforge.event.world.WorldEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@EventBusSubscriber(value = Dist.CLIENT)
|
@EventBusSubscriber(value = Dist.CLIENT)
|
||||||
public class ClientEvents {
|
public class ClientEvents {
|
||||||
|
|
||||||
|
@ -84,6 +87,7 @@ public class ClientEvents {
|
||||||
CapabilityMinecartController.tick(world);
|
CapabilityMinecartController.tick(world);
|
||||||
CouplingPhysics.tick(world);
|
CouplingPhysics.tick(world);
|
||||||
|
|
||||||
|
MetaDocHandler.tick();
|
||||||
ScreenOpener.tick();
|
ScreenOpener.tick();
|
||||||
ServerSpeedProvider.clientTick();
|
ServerSpeedProvider.clientTick();
|
||||||
BeltConnectorHandler.tick();
|
BeltConnectorHandler.tick();
|
||||||
|
@ -142,6 +146,11 @@ public class ClientEvents {
|
||||||
CreateClient.schematicHandler.renderOverlay(ms, buffer, light, overlay);
|
CreateClient.schematicHandler.renderOverlay(ms, buffer, light, overlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void getItemTooltipColor(RenderTooltipEvent.Color event) {
|
||||||
|
MetaDocHandler.handleTooltipColor(event);
|
||||||
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void addToItemTooltip(ItemTooltipEvent event) {
|
public static void addToItemTooltip(ItemTooltipEvent event) {
|
||||||
if (!AllConfigs.CLIENT.tooltips.get())
|
if (!AllConfigs.CLIENT.tooltips.get())
|
||||||
|
@ -163,7 +172,8 @@ public class ClientEvents {
|
||||||
.addInformation(toolTip);
|
.addInformation(toolTip);
|
||||||
itemTooltip.addAll(0, toolTip);
|
itemTooltip.addAll(0, toolTip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MetaDocHandler.addToTooltip(event.getToolTip(), stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|
|
@ -0,0 +1,114 @@
|
||||||
|
package com.simibubi.create.foundation.metadoc;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
import com.simibubi.create.foundation.gui.ScreenOpener;
|
||||||
|
import com.simibubi.create.foundation.utility.ColorHelper;
|
||||||
|
import com.simibubi.create.foundation.utility.LerpedFloat;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
|
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||||
|
import net.minecraft.client.util.InputMappings;
|
||||||
|
import net.minecraft.inventory.container.Slot;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
import net.minecraftforge.client.event.RenderTooltipEvent;
|
||||||
|
|
||||||
|
public class MetaDocHandler {
|
||||||
|
|
||||||
|
static LerpedFloat holdWProgress = LerpedFloat.linear()
|
||||||
|
.startWithValue(0);
|
||||||
|
static ItemStack lastHoveredStack = null;
|
||||||
|
|
||||||
|
public static void tick() {
|
||||||
|
Minecraft instance = Minecraft.getInstance();
|
||||||
|
Screen currentScreen = instance.currentScreen;
|
||||||
|
if (!(currentScreen instanceof ContainerScreen))
|
||||||
|
return;
|
||||||
|
ContainerScreen<?> cs = (ContainerScreen<?>) currentScreen;
|
||||||
|
|
||||||
|
ItemStack prevStack = lastHoveredStack;
|
||||||
|
lastHoveredStack = null;
|
||||||
|
Slot slotUnderMouse = cs.getSlotUnderMouse();
|
||||||
|
if (slotUnderMouse == null || !slotUnderMouse.getHasStack())
|
||||||
|
return;
|
||||||
|
|
||||||
|
ItemStack stack = slotUnderMouse.getStack();
|
||||||
|
if (prevStack != stack)
|
||||||
|
holdWProgress.startWithValue(0);
|
||||||
|
|
||||||
|
float value = holdWProgress.getValue();
|
||||||
|
if (InputMappings.isKeyDown(instance.getWindow()
|
||||||
|
.getHandle(),
|
||||||
|
instance.gameSettings.keyBindForward.getKey()
|
||||||
|
.getKeyCode())) {
|
||||||
|
// if (AllKeys.altDown()) {
|
||||||
|
if (value >= 1)
|
||||||
|
ScreenOpener.open(new MetaDocScreen());
|
||||||
|
holdWProgress.setValue(Math.min(1, value + Math.max(.25f, value) * .25f));
|
||||||
|
} else {
|
||||||
|
holdWProgress.setValue(Math.max(0, value - .05f));
|
||||||
|
}
|
||||||
|
|
||||||
|
lastHoveredStack = stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addToTooltip(List<ITextComponent> toolTip, ItemStack stack) {
|
||||||
|
if (lastHoveredStack != stack)
|
||||||
|
return;
|
||||||
|
float renderPartialTicks = Minecraft.getInstance()
|
||||||
|
.getRenderPartialTicks();
|
||||||
|
toolTip.add(makeProgressBar(Math.min(1, holdWProgress.getValue(renderPartialTicks) * 8 / 7f)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void handleTooltipColor(RenderTooltipEvent.Color event) {
|
||||||
|
if (lastHoveredStack != event.getStack())
|
||||||
|
return;
|
||||||
|
if (holdWProgress.getValue() == 0)
|
||||||
|
return;
|
||||||
|
float renderPartialTicks = Minecraft.getInstance()
|
||||||
|
.getRenderPartialTicks();
|
||||||
|
int start = event.getOriginalBorderStart();
|
||||||
|
int end = event.getOriginalBorderEnd();
|
||||||
|
float progress = Math.min(1, holdWProgress.getValue(renderPartialTicks) * 8 / 7f);
|
||||||
|
|
||||||
|
start = getSmoothColorForProgress(progress);
|
||||||
|
end = getSmoothColorForProgress((progress));
|
||||||
|
|
||||||
|
event.setBorderStart(start | 0xa0000000);
|
||||||
|
event.setBorderEnd(end | 0xa0000000);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getSmoothColorForProgress(float progress) {
|
||||||
|
if (progress < .5f)
|
||||||
|
return ColorHelper.mixColors(0x5000FF, 5592575, progress * 2);
|
||||||
|
// if (progress < .75f)
|
||||||
|
// return ColorHelper.mixColors(16733695, 5636095, (progress - .5f) * 4);
|
||||||
|
return ColorHelper.mixColors(5592575, 5636095, (progress - .5f) * 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ITextComponent makeProgressBar(float progress) {
|
||||||
|
String bar = "";
|
||||||
|
int filledLength = (int) (12 * progress);
|
||||||
|
bar += Strings.repeat("\u2588", filledLength);
|
||||||
|
if (progress < 1)
|
||||||
|
bar += Strings.repeat("\u2592", 12 - filledLength);
|
||||||
|
|
||||||
|
TextFormatting color = TextFormatting.GRAY;
|
||||||
|
if (progress > 0)
|
||||||
|
color = TextFormatting.BLUE;
|
||||||
|
if (progress == 1f)
|
||||||
|
color = TextFormatting.AQUA;
|
||||||
|
|
||||||
|
ITextComponent leftBr = new StringTextComponent("").applyTextStyle(TextFormatting.WHITE);
|
||||||
|
ITextComponent rightBr = new StringTextComponent("").applyTextStyle(TextFormatting.WHITE);
|
||||||
|
ITextComponent barComponent = new StringTextComponent(bar).applyTextStyle(color);
|
||||||
|
return leftBr.appendSibling(barComponent)
|
||||||
|
.appendSibling(rightBr);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
package com.simibubi.create.foundation.metadoc;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.simibubi.create.foundation.gui.AbstractSimiScreen;
|
||||||
|
import com.simibubi.create.foundation.gui.GuiGameElement;
|
||||||
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
|
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||||
|
|
||||||
|
public class MetaDocScreen extends AbstractSimiScreen {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void renderWindow(int mouseX, int mouseY, float partialTicks) {
|
||||||
|
|
||||||
|
int tooltipX = 50;
|
||||||
|
int tooltipY = 50;
|
||||||
|
int tooltipTextWidth = width - 100;
|
||||||
|
int backgroundColor = GuiUtils.DEFAULT_BACKGROUND_COLOR;
|
||||||
|
int borderColorStart = GuiUtils.DEFAULT_BORDER_COLOR_START;
|
||||||
|
int borderColorEnd = GuiUtils.DEFAULT_BORDER_COLOR_END;
|
||||||
|
int zLevel = 100;
|
||||||
|
int tooltipHeight = height - 100;
|
||||||
|
|
||||||
|
drawString(font, "MetaDoc Experimental 0", tooltipX, tooltipY - 16, 0xffffff);
|
||||||
|
|
||||||
|
GuiUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY - 4, tooltipX + tooltipTextWidth + 3, tooltipY - 3,
|
||||||
|
backgroundColor, backgroundColor);
|
||||||
|
GuiUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY + tooltipHeight + 3, tooltipX + tooltipTextWidth + 3,
|
||||||
|
tooltipY + tooltipHeight + 4, backgroundColor, backgroundColor);
|
||||||
|
GuiUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3,
|
||||||
|
tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
|
||||||
|
GuiUtils.drawGradientRect(zLevel, tooltipX - 4, tooltipY - 3, tooltipX - 3, tooltipY + tooltipHeight + 3,
|
||||||
|
backgroundColor, backgroundColor);
|
||||||
|
GuiUtils.drawGradientRect(zLevel, tooltipX + tooltipTextWidth + 3, tooltipY - 3,
|
||||||
|
tooltipX + tooltipTextWidth + 4, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
|
||||||
|
GuiUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3 + 1, tooltipX - 3 + 1,
|
||||||
|
tooltipY + tooltipHeight + 3 - 1, borderColorStart, borderColorEnd);
|
||||||
|
GuiUtils.drawGradientRect(zLevel, tooltipX + tooltipTextWidth + 2, tooltipY - 3 + 1,
|
||||||
|
tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3 - 1, borderColorStart, borderColorEnd);
|
||||||
|
GuiUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY - 3 + 1,
|
||||||
|
borderColorStart, borderColorStart);
|
||||||
|
GuiUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY + tooltipHeight + 2, tooltipX + tooltipTextWidth + 3,
|
||||||
|
tooltipY + tooltipHeight + 3, borderColorEnd, borderColorEnd);
|
||||||
|
|
||||||
|
RenderSystem.pushMatrix();
|
||||||
|
RenderSystem.translated(width/2, height/2, 200);
|
||||||
|
GuiGameElement.of(Blocks.DIAMOND_BLOCK.getDefaultState())
|
||||||
|
.rotate(22.5, AnimationTickHolder.getRenderTick() % 360f, 0)
|
||||||
|
.scale(50)
|
||||||
|
.render();
|
||||||
|
RenderSystem.popMatrix();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue