mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-16 08:53:43 +01:00
Timewarp
- Added user view mode for editors to hide coordinates - Ponder now pauses the game in SP - Ponder elements now use a separate timer and separate partial ticks - Fixed virtual funnels not flapping - Fixed ponder buttons having hover highlights when not clickable - Fixed ponder button mouse hitbox - Addressed strange render state bleed with identify mode highlighting
This commit is contained in:
parent
ea90196250
commit
d1e96c3b4b
26 changed files with 209 additions and 123 deletions
|
@ -58,7 +58,7 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer<KineticTil
|
|||
}
|
||||
|
||||
public static float getAngleForTe(KineticTileEntity te, final BlockPos pos, Axis axis) {
|
||||
float time = AnimationTickHolder.getRenderTime();
|
||||
float time = AnimationTickHolder.getRenderTime(te.getWorld());
|
||||
float offset = getRotationOffsetForPosition(te, pos, axis);
|
||||
float angle = ((time * te.getSpeed() * 3f / 10 + offset) % 360) / 180 * (float) Math.PI;
|
||||
return angle;
|
||||
|
|
|
@ -24,6 +24,7 @@ import net.minecraft.util.Direction;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.LightType;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class HarvesterRenderer extends SafeTileEntityRenderer<HarvesterTileEntity> {
|
||||
|
||||
|
@ -36,7 +37,8 @@ public class HarvesterRenderer extends SafeTileEntityRenderer<HarvesterTileEntit
|
|||
int light, int overlay) {
|
||||
BlockState blockState = te.getBlockState();
|
||||
SuperByteBuffer superBuffer = AllBlockPartials.HARVESTER_BLADE.renderOn(blockState);
|
||||
transform(blockState.get(HarvesterBlock.HORIZONTAL_FACING), superBuffer, te.manuallyAnimatedSpeed);
|
||||
transform(te.getWorld(), blockState.get(HarvesterBlock.HORIZONTAL_FACING), superBuffer,
|
||||
te.manuallyAnimatedSpeed);
|
||||
superBuffer.light(light)
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.getCutoutMipped()));
|
||||
}
|
||||
|
@ -70,17 +72,17 @@ public class HarvesterRenderer extends SafeTileEntityRenderer<HarvesterTileEntit
|
|||
if (context.contraption.stalled)
|
||||
speed = 0;
|
||||
|
||||
transform(facing, superBuffer, speed);
|
||||
transform(context.world, facing, superBuffer, speed);
|
||||
|
||||
superBuffer.light(msLocal.peek()
|
||||
.getModel(), ContraptionRenderDispatcher.getLightOnContraption(context))
|
||||
.renderInto(ms, buffers.getBuffer(RenderType.getCutoutMipped()));
|
||||
}
|
||||
|
||||
public static void transform(Direction facing, SuperByteBuffer superBuffer, float speed) {
|
||||
public static void transform(World world, Direction facing, SuperByteBuffer superBuffer, float speed) {
|
||||
float originOffset = 1 / 16f;
|
||||
Vec3d rotOffset = new Vec3d(0, -2 * originOffset, originOffset).add(VecHelper.getCenterOf(BlockPos.ZERO));
|
||||
float time = AnimationTickHolder.getRenderTime() / 20;
|
||||
float time = AnimationTickHolder.getRenderTime(world) / 20;
|
||||
float angle = (time * speed) % 360;
|
||||
|
||||
superBuffer.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(facing)))
|
||||
|
|
|
@ -89,7 +89,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
|
|||
ms.translate(0, isBlockItem ? 9 / 16f : 11 / 16f, 0);
|
||||
ms.scale(scale, scale, scale);
|
||||
transform = TransformType.GROUND;
|
||||
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(AnimationTickHolder.getRenderTime()));
|
||||
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(AnimationTickHolder.getRenderTime(te.getWorld())));
|
||||
|
||||
} else {
|
||||
float scale = punching ? .75f : isBlockItem ? .75f - 1 / 64f : .5f;
|
||||
|
|
|
@ -41,7 +41,7 @@ public class EncasedFanRenderer extends KineticTileEntityRenderer {
|
|||
SuperByteBuffer fanInner =
|
||||
AllBlockPartials.ENCASED_FAN_INNER.renderOnDirectionalSouth(te.getBlockState(), direction.getOpposite());
|
||||
|
||||
float time = AnimationTickHolder.getRenderTime();
|
||||
float time = AnimationTickHolder.getRenderTime(te.getWorld());
|
||||
float speed = te.getSpeed() * 5;
|
||||
if (speed > 0)
|
||||
speed = MathHelper.clamp(speed, 80, 64 * 20);
|
||||
|
|
|
@ -46,7 +46,7 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer {
|
|||
int packedLightmapCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, pos);
|
||||
float renderedHeadOffset = mixer.getRenderedHeadOffset(partialTicks);
|
||||
float speed = mixer.getRenderedHeadRotationSpeed(partialTicks);
|
||||
float time = AnimationTickHolder.getRenderTime();
|
||||
float time = AnimationTickHolder.getRenderTime(te.getWorld());
|
||||
float angle = ((time * speed * 6 / 10f) % 360) / 180 * (float) Math.PI;
|
||||
|
||||
SuperByteBuffer poleRender = AllBlockPartials.MECHANICAL_MIXER_POLE.renderOn(blockState);
|
||||
|
|
|
@ -72,7 +72,7 @@ public class GantryCarriageRenderer extends KineticTileEntityRenderer {
|
|||
}
|
||||
|
||||
public static float getAngleForTe(KineticTileEntity te, final BlockPos pos, Axis axis) {
|
||||
float time = AnimationTickHolder.getRenderTime();
|
||||
float time = AnimationTickHolder.getRenderTime(te.getWorld());
|
||||
float offset = getRotationOffsetForPosition(te, pos, axis);
|
||||
return ((time * te.getSpeed() * 3f / 20 + offset) % 360) / 180 * (float) Math.PI;
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public class RotationIndicatorParticle extends SimpleAnimatedParticle {
|
|||
}
|
||||
|
||||
public void move(double x, double y, double z) {
|
||||
float time = AnimationTickHolder.getTicks();
|
||||
float time = AnimationTickHolder.getTicks(world);
|
||||
float angle = (float) ((time * speed) % 360) - (speed / 2 * age * (((float) age) / maxAge));
|
||||
if (speed < 0 && axis.isVertical())
|
||||
angle += 180;
|
||||
|
|
|
@ -72,8 +72,9 @@ public class BasinRenderer extends SmartTileEntityRenderer<BasinTileEntity> {
|
|||
|
||||
if (fluidLevel > 0) {
|
||||
ms.translate(0,
|
||||
(MathHelper.sin(AnimationTickHolder.getRenderTime() / 12f + anglePartition * itemCount) + 1.5f) * 1
|
||||
/ 32f,
|
||||
(MathHelper.sin(
|
||||
AnimationTickHolder.getRenderTime(basin.getWorld()) / 12f + anglePartition * itemCount) + 1.5f)
|
||||
* 1 / 32f,
|
||||
0);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ public class BlazeBurnerRenderer extends SafeTileEntityRenderer<BlazeBurnerTileE
|
|||
if (heatLevel == HeatLevel.NONE)
|
||||
return;
|
||||
|
||||
float renderTick = AnimationTickHolder.getRenderTime() + (te.hashCode() % 13) * 16f;
|
||||
float renderTick = AnimationTickHolder.getRenderTime(te.getWorld()) + (te.hashCode() % 13) * 16f;
|
||||
float offset = (MathHelper.sin((float) ((renderTick / 16f) % (2 * Math.PI))) + .5f) / 16f;
|
||||
|
||||
AllBlockPartials blazeModel = AllBlockPartials.BLAZES.get(heatLevel);
|
||||
|
|
|
@ -74,7 +74,7 @@ public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> {
|
|||
MatrixStack localTransforms = new MatrixStack();
|
||||
MatrixStacker msr = MatrixStacker.of(localTransforms);
|
||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||
float renderTick = AnimationTickHolder.getRenderTime();
|
||||
float renderTick = AnimationTickHolder.getRenderTime(te.getWorld());
|
||||
|
||||
msr.centre();
|
||||
msr.rotateY(AngleHelper.horizontalAngle(facing) + (upward ? 180 : 0) + (sideways ? 270 : 0));
|
||||
|
|
|
@ -32,7 +32,7 @@ public class SplitShaftRenderer extends KineticTileEntityRenderer {
|
|||
Block block = te.getBlockState().getBlock();
|
||||
final Axis boxAxis = ((IRotate) block).getRotationAxis(te.getBlockState());
|
||||
final BlockPos pos = te.getPos();
|
||||
float time = AnimationTickHolder.getRenderTime();
|
||||
float time = AnimationTickHolder.getRenderTime(te.getWorld());
|
||||
|
||||
for (Direction direction : Iterate.directions) {
|
||||
Axis axis = direction.getAxis();
|
||||
|
|
|
@ -30,7 +30,7 @@ public class GearboxRenderer extends KineticTileEntityRenderer {
|
|||
|
||||
final Axis boxAxis = te.getBlockState().get(BlockStateProperties.AXIS);
|
||||
final BlockPos pos = te.getPos();
|
||||
float time = AnimationTickHolder.getRenderTime();
|
||||
float time = AnimationTickHolder.getRenderTime(te.getWorld());
|
||||
|
||||
for (Direction direction : Iterate.directions) {
|
||||
final Axis axis = direction.getAxis();
|
||||
|
|
|
@ -95,7 +95,7 @@ public class ArmInstance extends SingleRotatingInstance implements ITickableInst
|
|||
float headAngle = arm.headAngle.get(pt);
|
||||
|
||||
if (rave) {
|
||||
float renderTick = AnimationTickHolder.getRenderTime() + (tile.hashCode() % 64);
|
||||
float renderTick = AnimationTickHolder.getRenderTime(arm.getWorld()) + (tile.hashCode() % 64);
|
||||
baseAngle = (renderTick * 10) % 360;
|
||||
lowerArmAngle = MathHelper.lerp((MathHelper.sin(renderTick / 4) + 1) / 2, -45, 15);
|
||||
upperArmAngle = MathHelper.lerp((MathHelper.sin(renderTick / 8) + 1) / 4, -45, 95);
|
||||
|
|
|
@ -69,7 +69,7 @@ public class ArmRenderer extends KineticTileEntityRenderer {
|
|||
float headAngle = arm.headAngle.get(pt);
|
||||
|
||||
boolean rave = arm.phase == Phase.DANCING;
|
||||
float renderTick = AnimationTickHolder.getRenderTime() + (te.hashCode() % 64);
|
||||
float renderTick = AnimationTickHolder.getRenderTime(te.getWorld()) + (te.hashCode() % 64);
|
||||
if (rave) {
|
||||
baseAngle = (renderTick * 10) % 360;
|
||||
lowerArmAngle = MathHelper.lerp((MathHelper.sin(renderTick / 4) + 1) / 2, -45, 15);
|
||||
|
|
|
@ -122,7 +122,8 @@ public class AllIcons implements IScreenRenderable {
|
|||
I_MTD_CLOSE = next(),
|
||||
I_MTD_RIGHT = next(),
|
||||
I_MTD_SCAN = next(),
|
||||
I_MTD_REPLAY = next();
|
||||
I_MTD_REPLAY = next(),
|
||||
I_MTD_USER_MODE = next();
|
||||
|
||||
public AllIcons(int x, int y) {
|
||||
iconX = x * 16;
|
||||
|
|
|
@ -95,7 +95,8 @@ public class PonderTooltipHandler {
|
|||
}
|
||||
|
||||
public static void addToTooltip(List<ITextComponent> toolTip, ItemStack stack) {
|
||||
float renderPartialTicks = AnimationTickHolder.getPartialTicks();
|
||||
float renderPartialTicks = Minecraft.getInstance()
|
||||
.getRenderPartialTicks();
|
||||
if (lastHoveredStack != stack)
|
||||
return;
|
||||
ITextComponent component = subject ? Lang.createTranslationTextComponent(SUBJECT)
|
||||
|
|
|
@ -38,6 +38,7 @@ import net.minecraft.client.GameSettings;
|
|||
import net.minecraft.client.MainWindow;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Direction;
|
||||
|
@ -55,6 +56,9 @@ import net.minecraftforge.registries.ForgeRegistries;
|
|||
|
||||
public class PonderUI extends AbstractSimiScreen {
|
||||
|
||||
public static int ponderTicks;
|
||||
public static float ponderPartialTicksPaused;
|
||||
|
||||
public static final String PONDERING = PonderLocalization.LANG_PREFIX + "pondering";
|
||||
public static final String IDENTIFY_MODE = PonderLocalization.LANG_PREFIX + "identify_mode";
|
||||
public static final String IN_CHAPTER = PonderLocalization.LANG_PREFIX + "in_chapter";
|
||||
|
@ -68,6 +72,7 @@ public class PonderUI extends AbstractSimiScreen {
|
|||
ItemStack stack;
|
||||
PonderChapter chapter = null;
|
||||
|
||||
private boolean userViewMode;
|
||||
private boolean identifyMode;
|
||||
private ItemStack hoveredTooltipItem;
|
||||
private BlockPos hoveredBlockPos;
|
||||
|
@ -79,7 +84,7 @@ public class PonderUI extends AbstractSimiScreen {
|
|||
private int index = 0;
|
||||
private PonderTag referredToByTag;
|
||||
|
||||
private PonderButton left, right, scan, chap;
|
||||
private PonderButton left, right, scan, chap, userMode;
|
||||
|
||||
public static PonderUI of(ItemStack item) {
|
||||
return new PonderUI(PonderRegistry.compile(item.getItem()
|
||||
|
@ -165,10 +170,19 @@ public class PonderUI extends AbstractSimiScreen {
|
|||
if (!identifyMode)
|
||||
scenes.get(index)
|
||||
.deselect();
|
||||
else
|
||||
ponderPartialTicksPaused = minecraft.getRenderPartialTicks();
|
||||
}).showing(AllIcons.I_MTD_SCAN)
|
||||
.shortcut(bindings.keyBindDrop)
|
||||
.fade(0, -1));
|
||||
|
||||
if (PonderIndex.EDITOR_MODE) {
|
||||
widgets.add(userMode = new PonderButton(31, bY, () -> {
|
||||
userViewMode = !userViewMode;
|
||||
}).showing(AllIcons.I_MTD_USER_MODE)
|
||||
.fade(0, -1));
|
||||
}
|
||||
|
||||
bX += 50 + spacing;
|
||||
widgets.add(left = new PonderButton(bX, bY, () -> this.scroll(false)).showing(AllIcons.I_MTD_LEFT)
|
||||
.shortcut(bindings.keyBindLeft)
|
||||
|
@ -215,8 +229,10 @@ public class PonderUI extends AbstractSimiScreen {
|
|||
}
|
||||
|
||||
PonderScene activeScene = scenes.get(index);
|
||||
if (!identifyMode)
|
||||
if (!identifyMode) {
|
||||
ponderTicks++;
|
||||
activeScene.tick();
|
||||
}
|
||||
sceneProgress.chase(activeScene.getSceneProgress(), .5f, Chaser.EXP);
|
||||
lazyIndex.tickChaser();
|
||||
fadeIn.tickChaser();
|
||||
|
@ -295,8 +311,8 @@ public class PonderUI extends AbstractSimiScreen {
|
|||
@Override
|
||||
protected void renderWindow(int mouseX, int mouseY, float partialTicks) {
|
||||
RenderSystem.enableBlend();
|
||||
renderVisibleScenes(mouseX, mouseY, identifyMode ? 0 : partialTicks);
|
||||
renderWidgets(mouseX, mouseY, identifyMode ? 0 : partialTicks);
|
||||
renderVisibleScenes(mouseX, mouseY, identifyMode ? ponderPartialTicksPaused : partialTicks);
|
||||
renderWidgets(mouseX, mouseY, identifyMode ? ponderPartialTicksPaused : partialTicks);
|
||||
}
|
||||
|
||||
protected void renderVisibleScenes(int mouseX, int mouseY, float partialTicks) {
|
||||
|
@ -310,7 +326,7 @@ public class PonderUI extends AbstractSimiScreen {
|
|||
SuperRenderTypeBuffer buffer = SuperRenderTypeBuffer.getInstance();
|
||||
PonderScene story = scenes.get(i);
|
||||
MatrixStack ms = new MatrixStack();
|
||||
double value = lazyIndex.getValue(AnimationTickHolder.getPartialTicks());
|
||||
double value = lazyIndex.getValue(AnimationTickHolder.getPartialTicks(story.world));
|
||||
double diff = i - value;
|
||||
double slide = MathHelper.lerp(diff * diff, 200, 600) * diff;
|
||||
|
||||
|
@ -326,7 +342,7 @@ public class PonderUI extends AbstractSimiScreen {
|
|||
buffer.draw();
|
||||
|
||||
// coords for debug
|
||||
if (PonderIndex.EDITOR_MODE) {
|
||||
if (PonderIndex.EDITOR_MODE && !userViewMode) {
|
||||
MutableBoundingBox bounds = story.getBounds();
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
|
@ -388,6 +404,10 @@ public class PonderUI extends AbstractSimiScreen {
|
|||
PonderScene activeScene = scenes.get(index);
|
||||
int textColor = 0xeeeeee;
|
||||
|
||||
boolean noWidgetsHovered = true;
|
||||
for (Widget widget : widgets)
|
||||
noWidgetsHovered &= !widget.isMouseOver(mouseX, mouseY);
|
||||
|
||||
{
|
||||
// Chapter title
|
||||
RenderSystem.pushMatrix();
|
||||
|
@ -433,34 +453,43 @@ public class PonderUI extends AbstractSimiScreen {
|
|||
}
|
||||
|
||||
if (identifyMode) {
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translated(mouseX, mouseY, 100);
|
||||
if (hoveredTooltipItem.isEmpty()) {
|
||||
String tooltip = Lang
|
||||
.createTranslationTextComponent(IDENTIFY_MODE,
|
||||
new StringTextComponent(minecraft.gameSettings.keyBindDrop.getKeyBinding()
|
||||
.getLocalizedName()).applyTextStyle(TextFormatting.WHITE))
|
||||
.applyTextStyle(TextFormatting.GRAY)
|
||||
.getFormattedText();
|
||||
renderTooltip(font.listFormattedStringToWidth(tooltip, width / 3), 0, 0);
|
||||
} else
|
||||
renderTooltip(hoveredTooltipItem, 0, 0);
|
||||
if (hoveredBlockPos != null && PonderIndex.EDITOR_MODE) {
|
||||
RenderSystem.translated(0, -15, 0);
|
||||
boolean copied = copiedBlockPos != null && hoveredBlockPos.equals(copiedBlockPos);
|
||||
String coords = new StringTextComponent(
|
||||
hoveredBlockPos.getX() + ", " + hoveredBlockPos.getY() + ", " + hoveredBlockPos.getZ())
|
||||
.applyTextStyles(copied ? TextFormatting.GREEN : TextFormatting.GOLD)
|
||||
if (noWidgetsHovered) {
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translated(mouseX, mouseY, 100);
|
||||
if (hoveredTooltipItem.isEmpty()) {
|
||||
String tooltip = Lang
|
||||
.createTranslationTextComponent(IDENTIFY_MODE,
|
||||
new StringTextComponent(minecraft.gameSettings.keyBindDrop.getKeyBinding()
|
||||
.getLocalizedName()).applyTextStyle(TextFormatting.WHITE))
|
||||
.applyTextStyle(TextFormatting.GRAY)
|
||||
.getFormattedText();
|
||||
renderTooltip(coords, 0, 0);
|
||||
renderTooltip(font.listFormattedStringToWidth(tooltip, width / 3), 0, 0);
|
||||
} else
|
||||
renderTooltip(hoveredTooltipItem, 0, 0);
|
||||
if (hoveredBlockPos != null && PonderIndex.EDITOR_MODE && !userViewMode) {
|
||||
RenderSystem.translated(0, -15, 0);
|
||||
boolean copied = copiedBlockPos != null && hoveredBlockPos.equals(copiedBlockPos);
|
||||
String coords = new StringTextComponent(
|
||||
hoveredBlockPos.getX() + ", " + hoveredBlockPos.getY() + ", " + hoveredBlockPos.getZ())
|
||||
.applyTextStyles(copied ? TextFormatting.GREEN : TextFormatting.GOLD)
|
||||
.getFormattedText();
|
||||
renderTooltip(coords, 0, 0);
|
||||
}
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
RenderSystem.popMatrix();
|
||||
|
||||
scan.flash();
|
||||
} else {
|
||||
scan.dim();
|
||||
}
|
||||
|
||||
if (PonderIndex.EDITOR_MODE) {
|
||||
if (userViewMode)
|
||||
userMode.flash();
|
||||
else
|
||||
userMode.dim();
|
||||
}
|
||||
|
||||
{
|
||||
// Scene overlay
|
||||
RenderSystem.pushMatrix();
|
||||
|
@ -777,8 +806,25 @@ public class PonderUI extends AbstractSimiScreen {
|
|||
|
||||
@Override
|
||||
public void shareContextWith(AbstractSimiScreen other) {
|
||||
if (other instanceof PonderUI)
|
||||
((PonderUI) other).referredToByTag = referredToByTag;
|
||||
if (other instanceof PonderUI) {
|
||||
PonderUI ponderUI = (PonderUI) other;
|
||||
ponderUI.referredToByTag = referredToByTag;
|
||||
}
|
||||
}
|
||||
|
||||
public static float getPartialTicks() {
|
||||
if (Minecraft.getInstance().currentScreen instanceof PonderUI) {
|
||||
PonderUI ui = (PonderUI) Minecraft.getInstance().currentScreen;
|
||||
if (ui.identifyMode)
|
||||
return ponderPartialTicksPaused;
|
||||
}
|
||||
return Minecraft.getInstance()
|
||||
.getRenderPartialTicks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPauseScreen() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -525,7 +525,7 @@ public class SceneBuilder {
|
|||
return;
|
||||
behaviour.handleInsertion(stack, insertionSide.getOpposite(), false);
|
||||
});
|
||||
flapFunnels(scene.getSceneBuildingUtil().select.position(location.up()), true);
|
||||
flapFunnel(location.up(), true);
|
||||
}
|
||||
|
||||
public ElementLink<BeltItemElement> createItemOnBelt(BlockPos beltLocation, Direction insertionSide,
|
||||
|
@ -553,9 +553,8 @@ public class SceneBuilder {
|
|||
scene.linkElement(tracker, link);
|
||||
return TransportedResult.doNothing();
|
||||
});
|
||||
|
||||
});
|
||||
flapFunnels(scene.getSceneBuildingUtil().select.position(beltLocation.up()), true);
|
||||
flapFunnel(beltLocation.up(), true);
|
||||
return link;
|
||||
}
|
||||
|
||||
|
@ -633,11 +632,8 @@ public class SceneBuilder {
|
|||
}, reDrawBlocks));
|
||||
}
|
||||
|
||||
public void flapFunnels(Selection selection, boolean outward) {
|
||||
addInstruction(new TileEntityDataInstruction(selection, FunnelTileEntity.class, nbt -> {
|
||||
nbt.putInt("Flap", outward ? -1 : 1);
|
||||
return nbt;
|
||||
}, false));
|
||||
public void flapFunnel(BlockPos position, boolean outward) {
|
||||
modifyTileEntity(position, FunnelTileEntity.class, funnel -> funnel.flap(!outward));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -52,12 +52,11 @@ public class FunnelScenes {
|
|||
BlockPos entryBeltPos = util.grid.at(3, 1, 2);
|
||||
BlockPos exitBeltPos = util.grid.at(1, 1, 2);
|
||||
ItemStack itemStack = AllBlocks.BRASS_BLOCK.asStack();
|
||||
Selection exitFunnel = util.select.position(exitBeltPos.up());
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
scene.idle(8);
|
||||
scene.world.removeItemsFromBelt(exitBeltPos);
|
||||
scene.world.flapFunnels(exitFunnel, false);
|
||||
scene.world.flapFunnel(exitBeltPos.up(), false);
|
||||
if (i == 2)
|
||||
scene.rotateCameraY(70);
|
||||
if (i < 6)
|
||||
|
@ -94,7 +93,7 @@ public class FunnelScenes {
|
|||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
scene.idle(8);
|
||||
scene.world.flapFunnels(outputFunnel, false);
|
||||
scene.world.flapFunnel(util.grid.at(1, 2, 4), false);
|
||||
scene.world.createItemEntity(sideItemSpawn, util.vector.of(-.05, 0, 0), itemStack);
|
||||
}
|
||||
|
||||
|
@ -198,7 +197,7 @@ public class FunnelScenes {
|
|||
|
||||
scene.idle(20);
|
||||
|
||||
scene.world.flapFunnels(sideFunnelSelection, true);
|
||||
scene.world.flapFunnel(sideFunnel, true);
|
||||
itemLink = scene.world.createItemEntity(sideCenter.subtract(0, .45, 0), util.vector.of(0, 0, -0.1), itemStack);
|
||||
scene.idle(60);
|
||||
scene.world.hideSection(sideFunnelSelection, Direction.UP);
|
||||
|
@ -233,7 +232,7 @@ public class FunnelScenes {
|
|||
scene.idle(35);
|
||||
|
||||
scene.world.removeItemsFromBelt(beltPos);
|
||||
scene.world.flapFunnels(beltFunnelSetup, false);
|
||||
scene.world.flapFunnel(util.grid.at(2, 2, 2), false);
|
||||
|
||||
if (i == 0) {
|
||||
scene.idle(50);
|
||||
|
@ -374,7 +373,7 @@ public class FunnelScenes {
|
|||
scene.idle(10);
|
||||
scene.world.createItemOnBeltLike(andesiteFunnel.down()
|
||||
.north(), Direction.SOUTH, itemStack);
|
||||
scene.world.flapFunnels(util.select.position(andesiteFunnel), true);
|
||||
scene.world.flapFunnel(andesiteFunnel, true);
|
||||
scene.idle(60);
|
||||
|
||||
scene.overlay.showText(60)
|
||||
|
@ -384,7 +383,7 @@ public class FunnelScenes {
|
|||
scene.idle(10);
|
||||
scene.world.createItemOnBeltLike(brassFunnel.down()
|
||||
.north(), Direction.SOUTH, ItemHandlerHelper.copyStackWithSize(itemStack, 64));
|
||||
scene.world.flapFunnels(util.select.position(brassFunnel), true);
|
||||
scene.world.flapFunnel(brassFunnel, true);
|
||||
scene.idle(60);
|
||||
|
||||
AxisAlignedBB filterSlot = new AxisAlignedBB(brassFunnel).grow(-.35, -.35, -.35)
|
||||
|
@ -421,7 +420,7 @@ public class FunnelScenes {
|
|||
|
||||
if (i > 0 && (i < 3 || i % 3 == 0)) {
|
||||
scene.world.removeItemsFromBelt(brassFunnel.down());
|
||||
scene.world.flapFunnels(util.select.position(brassFunnel), false);
|
||||
scene.world.flapFunnel(brassFunnel, false);
|
||||
}
|
||||
|
||||
scene.world.modifyEntities(ItemEntity.class, e -> {
|
||||
|
|
|
@ -49,43 +49,39 @@ public class PonderIndexScreen extends AbstractSimiScreen {
|
|||
protected void init() {
|
||||
super.init();
|
||||
|
||||
//populate lists
|
||||
// populate lists
|
||||
widgets.clear();
|
||||
|
||||
chapters.clear();
|
||||
//chapters.addAll(PonderRegistry.chapters.getAllChapters());
|
||||
// chapters.addAll(PonderRegistry.chapters.getAllChapters());
|
||||
|
||||
items.clear();
|
||||
PonderRegistry.all.keySet()
|
||||
.stream()
|
||||
.map(key -> {
|
||||
Item item = ForgeRegistries.ITEMS.getValue(key);
|
||||
if (item == null) {
|
||||
Block b = ForgeRegistries.BLOCKS.getValue(key);
|
||||
if (b != null)
|
||||
item = b.asItem();
|
||||
}
|
||||
return item;
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.filter(PonderIndexScreen::exclusions)
|
||||
.forEach(items::add);
|
||||
.stream()
|
||||
.map(key -> {
|
||||
Item item = ForgeRegistries.ITEMS.getValue(key);
|
||||
if (item == null) {
|
||||
Block b = ForgeRegistries.BLOCKS.getValue(key);
|
||||
if (b != null)
|
||||
item = b.asItem();
|
||||
}
|
||||
return item;
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.filter(PonderIndexScreen::exclusions)
|
||||
.forEach(items::add);
|
||||
|
||||
boolean hasChapters = !chapters.isEmpty();
|
||||
|
||||
//setup chapters
|
||||
LayoutHelper layout = LayoutHelper.centeredHorizontal(
|
||||
chapters.size(),
|
||||
MathHelper.clamp((int) Math.ceil(chapters.size() / 4f), 1, 4),
|
||||
200,
|
||||
38,
|
||||
16
|
||||
);
|
||||
// setup chapters
|
||||
LayoutHelper layout = LayoutHelper.centeredHorizontal(chapters.size(),
|
||||
MathHelper.clamp((int) Math.ceil(chapters.size() / 4f), 1, 4), 200, 38, 16);
|
||||
chapterArea = layout.getArea();
|
||||
int chapterCenterX = (int) (width * chapterXmult);
|
||||
int chapterCenterY = (int) (height * chapterYmult);
|
||||
|
||||
//todo at some point pagination or horizontal scrolling may be needed for chapters/items
|
||||
// todo at some point pagination or horizontal scrolling may be needed for
|
||||
// chapters/items
|
||||
for (PonderChapter chapter : chapters) {
|
||||
ChapterLabel label = new ChapterLabel(chapter, chapterCenterX + layout.getX(),
|
||||
chapterCenterY + layout.getY(), (mouseX, mouseY) -> {
|
||||
|
@ -97,44 +93,40 @@ public class PonderIndexScreen extends AbstractSimiScreen {
|
|||
layout.next();
|
||||
}
|
||||
|
||||
//setup items
|
||||
// setup items
|
||||
if (!hasChapters) {
|
||||
itemYmult = 0.5;
|
||||
}
|
||||
|
||||
int maxItemRows = hasChapters ? 4 : 7;
|
||||
layout = LayoutHelper.centeredHorizontal(
|
||||
items.size(),
|
||||
MathHelper.clamp((int) Math.ceil(items.size() / 11f), 1, maxItemRows),
|
||||
28,
|
||||
28,
|
||||
8
|
||||
);
|
||||
layout = LayoutHelper.centeredHorizontal(items.size(),
|
||||
MathHelper.clamp((int) Math.ceil(items.size() / 11f), 1, maxItemRows), 28, 28, 8);
|
||||
itemArea = layout.getArea();
|
||||
int itemCenterX = (int) (width * itemXmult);
|
||||
int itemCenterY = (int) (height * itemYmult);
|
||||
|
||||
for (Item item : items) {
|
||||
PonderButton button = new PonderButton(itemCenterX + layout.getX() + 4, itemCenterY + layout.getY() + 4, (x, y) -> {
|
||||
if (!PonderRegistry.all.containsKey(item.getRegistryName()))
|
||||
return;
|
||||
PonderButton button =
|
||||
new PonderButton(itemCenterX + layout.getX() + 4, itemCenterY + layout.getY() + 4, (x, y) -> {
|
||||
if (!PonderRegistry.all.containsKey(item.getRegistryName()))
|
||||
return;
|
||||
|
||||
centerScalingOn(x, y);
|
||||
ScreenOpener.transitionTo(PonderUI.of(new ItemStack(item)));
|
||||
}).showing(new ItemStack(item));
|
||||
centerScalingOn(x, y);
|
||||
ScreenOpener.transitionTo(PonderUI.of(new ItemStack(item)));
|
||||
}).showing(new ItemStack(item));
|
||||
|
||||
button.fade(1);
|
||||
widgets.add(button);
|
||||
layout.next();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static boolean exclusions(Item item) {
|
||||
if (item instanceof BlockItem) {
|
||||
Block block = ((BlockItem) item).getBlock();
|
||||
if (block instanceof ValveHandleBlock && !AllBlocks.COPPER_VALVE_HANDLE.is(item)) return false;
|
||||
if (block instanceof ValveHandleBlock && !AllBlocks.COPPER_VALVE_HANDLE.is(item))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -143,6 +135,7 @@ public class PonderIndexScreen extends AbstractSimiScreen {
|
|||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
PonderUI.ponderTicks++;
|
||||
|
||||
hoveredItem = ItemStack.EMPTY;
|
||||
MainWindow w = minecraft.getWindow();
|
||||
|
@ -224,4 +217,9 @@ public class PonderIndexScreen extends AbstractSimiScreen {
|
|||
public ItemStack getHoveredTooltipItem() {
|
||||
return hoveredItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPauseScreen() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,13 +77,16 @@ public class PonderTagScreen extends AbstractSimiScreen {
|
|||
int itemCenterY = getItemsY();
|
||||
|
||||
for (Item i : items) {
|
||||
final boolean canClick = PonderRegistry.all.containsKey(i.getRegistryName());
|
||||
PonderButton button =
|
||||
new PonderButton(itemCenterX + layout.getX() + 4, itemCenterY + layout.getY() + 4, (mouseX, mouseY) -> {
|
||||
if (!PonderRegistry.all.containsKey(i.getRegistryName()))
|
||||
if (!canClick)
|
||||
return;
|
||||
centerScalingOn(mouseX, mouseY);
|
||||
ScreenOpener.transitionTo(PonderUI.of(new ItemStack(i), tag));
|
||||
}).showing(new ItemStack(i));
|
||||
if (!canClick)
|
||||
button.noClickEvent();
|
||||
|
||||
button.fade(1);
|
||||
widgets.add(button);
|
||||
|
@ -92,18 +95,20 @@ public class PonderTagScreen extends AbstractSimiScreen {
|
|||
|
||||
if (!tag.getMainItem()
|
||||
.isEmpty()) {
|
||||
final boolean canClick = PonderRegistry.all.containsKey(tag.getMainItem()
|
||||
.getItem()
|
||||
.getRegistryName());
|
||||
PonderButton button =
|
||||
new PonderButton(itemCenterX - layout.getTotalWidth() / 2 - 42, itemCenterY - 10, (mouseX, mouseY) -> {
|
||||
if (!PonderRegistry.all.containsKey(tag.getMainItem()
|
||||
.getItem()
|
||||
.getRegistryName()))
|
||||
if (!canClick)
|
||||
return;
|
||||
centerScalingOn(mouseX, mouseY);
|
||||
ScreenOpener.transitionTo(PonderUI.of(tag.getMainItem(), tag));
|
||||
}).showing(tag.getMainItem());
|
||||
if (!canClick)
|
||||
button.noClickEvent();
|
||||
|
||||
button.fade(1);
|
||||
// button.flash();
|
||||
widgets.add(button);
|
||||
}
|
||||
|
||||
|
@ -133,6 +138,7 @@ public class PonderTagScreen extends AbstractSimiScreen {
|
|||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
PonderUI.ponderTicks++;
|
||||
|
||||
hoveredItem = ItemStack.EMPTY;
|
||||
MainWindow w = minecraft.getWindow();
|
||||
|
@ -292,4 +298,9 @@ public class PonderTagScreen extends AbstractSimiScreen {
|
|||
return super.isEquivalentTo(other);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPauseScreen() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
|||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.foundation.ponder.PonderScene;
|
||||
import com.simibubi.create.foundation.ponder.PonderUI;
|
||||
import com.simibubi.create.foundation.ponder.PonderWorld;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
|
||||
import net.minecraft.client.MainWindow;
|
||||
|
@ -170,7 +170,7 @@ public class ParrotElement extends AnimatedSceneElement {
|
|||
.length();
|
||||
entity.onGround = false;
|
||||
double phase = Math.min(length * 15, 8);
|
||||
float f = (float) ((AnimationTickHolder.getTicks() % 100) * phase);
|
||||
float f = (float) ((PonderUI.ponderTicks % 100) * phase);
|
||||
entity.flapSpeed = MathHelper.sin(f) + 1;
|
||||
if (length == 0)
|
||||
entity.flapSpeed = 0;
|
||||
|
|
|
@ -313,10 +313,9 @@ public class WorldSectionElement extends AnimatedSceneElement {
|
|||
transformMS(ms, pt);
|
||||
RenderSystem.disableTexture();
|
||||
WorldRenderer.drawBox(ms, buffer.getBuffer(RenderType.getLines()), shape.getBoundingBox()
|
||||
.offset(selectedBlock), 1, 1, 1, 1);
|
||||
if (buffer instanceof SuperRenderTypeBuffer)
|
||||
((SuperRenderTypeBuffer) buffer).draw(RenderType.getLines());
|
||||
RenderSystem.enableTexture();
|
||||
.offset(selectedBlock), 1, 1, 1, 0.6f);
|
||||
// if (buffer instanceof SuperRenderTypeBuffer)
|
||||
// ((SuperRenderTypeBuffer) buffer).draw(RenderType.getLines());
|
||||
ms.pop();
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import com.simibubi.create.foundation.gui.GuiGameElement;
|
|||
import com.simibubi.create.foundation.gui.IScreenRenderable;
|
||||
import com.simibubi.create.foundation.gui.widgets.AbstractSimiWidget;
|
||||
import com.simibubi.create.foundation.ponder.PonderUI;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.ColorHelper;
|
||||
import com.simibubi.create.foundation.utility.LerpedFloat;
|
||||
|
||||
|
@ -26,6 +25,7 @@ public class PonderButton extends AbstractSimiWidget {
|
|||
private float fade;
|
||||
private KeyBinding shortcut;
|
||||
private LerpedFloat flash;
|
||||
private boolean noClickEvent;
|
||||
|
||||
public static final int SIZE = 20;
|
||||
|
||||
|
@ -54,6 +54,11 @@ public class PonderButton extends AbstractSimiWidget {
|
|||
return this;
|
||||
}
|
||||
|
||||
public PonderButton noClickEvent() {
|
||||
this.noClickEvent = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PonderButton shortcut(KeyBinding key) {
|
||||
this.shortcut = key;
|
||||
return this;
|
||||
|
@ -86,7 +91,7 @@ public class PonderButton extends AbstractSimiWidget {
|
|||
if (fade < .1f)
|
||||
return;
|
||||
|
||||
isHovered = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height && fade > .75f;
|
||||
isHovered = isMouseOver(mouseX, mouseY) && fade > .75f;
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.disableDepthTest();
|
||||
|
@ -95,11 +100,13 @@ public class PonderButton extends AbstractSimiWidget {
|
|||
|
||||
float flashValue = flash.getValue(partialTicks);
|
||||
if (flashValue > .1f)
|
||||
fade *= 3 * flashValue + Math.sin((AnimationTickHolder.getTicks() + partialTicks) / 6);
|
||||
fade *= 3 * flashValue + Math.sin((PonderUI.ponderTicks + partialTicks) / 6);
|
||||
|
||||
int backgroundColor = ColorHelper.applyAlpha(0xdd000000, fade);
|
||||
int borderColorStart = ColorHelper.applyAlpha(isHovered ? 0x70ffffff : 0x40aa9999, fade);
|
||||
int borderColorEnd = ColorHelper.applyAlpha(isHovered ? 0x30ffffff : 0x20aa9999, fade);
|
||||
int borderColorStart =
|
||||
ColorHelper.applyAlpha(noClickEvent ? 0x70984500 : isHovered ? 0x70ffffff : 0x40aa9999, fade);
|
||||
int borderColorEnd =
|
||||
ColorHelper.applyAlpha(noClickEvent ? 0x70692400 : isHovered ? 0x30ffffff : 0x20aa9999, fade);
|
||||
|
||||
PonderUI.renderBox(x, y, width, height, backgroundColor, borderColorStart, borderColorEnd);
|
||||
RenderSystem.translated(0, 0, 800);
|
||||
|
@ -153,4 +160,13 @@ public class PonderButton extends AbstractSimiWidget {
|
|||
public ItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMouseOver(double x, double y) {
|
||||
double m = 4;
|
||||
x = Math.floor(x);
|
||||
y = Math.floor(y);
|
||||
return active && visible
|
||||
&& !(x < this.x - m || x > this.x + width + m - 1 || y < this.y - m || y > this.y + height + m - 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package com.simibubi.create.foundation.utility;
|
||||
|
||||
import com.simibubi.create.foundation.ponder.PonderUI;
|
||||
import com.simibubi.create.foundation.ponder.PonderWorld;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.world.IWorld;
|
||||
|
||||
public class AnimationTickHolder {
|
||||
|
||||
|
@ -16,6 +20,10 @@ public class AnimationTickHolder {
|
|||
}
|
||||
}
|
||||
|
||||
public static int getTicks() {
|
||||
return ticks;
|
||||
}
|
||||
|
||||
public static float getRenderTime() {
|
||||
return getTicks() + getPartialTicks();
|
||||
}
|
||||
|
@ -25,7 +33,15 @@ public class AnimationTickHolder {
|
|||
return (mc.isGamePaused() ? mc.renderPartialTicksPaused : mc.getRenderPartialTicks());
|
||||
}
|
||||
|
||||
public static int getTicks() {
|
||||
return ticks;
|
||||
public static int getTicks(IWorld world) {
|
||||
return world instanceof PonderWorld ? PonderUI.ponderTicks : getTicks();
|
||||
}
|
||||
|
||||
public static float getRenderTime(IWorld world) {
|
||||
return getTicks(world) + getPartialTicks(world);
|
||||
}
|
||||
|
||||
public static float getPartialTicks(IWorld world) {
|
||||
return world instanceof PonderWorld ? PonderUI.getPartialTicks() : getPartialTicks();
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Loading…
Reference in a new issue