Setup
Go into creative mode and have a workstation (tested with stonecutter and cartography table) and a villager spawn egg in your inventory. Place workstation first and then spawn villager (or vice versa) and wait for it to change its texture (meaning it has taken a job) and immediately thereafter destroy the block.
All my tests had the villager within a one-block radius of the workstation.
Expectation
The game doesn't crash, but instead causes the villager to stop working at that station as it no longer exists.
Observation
The game crashes with a ticking entity crash described as java.util.NoSuchElementException
.
Crash log (attached as well -
[media])
19w13a: crash-2019-03-28_15.32.10-server.txt
---- Minecraft Crash Report ----
// Daisy, daisy...
Time: 13-3-19 17:23
Description: Ticking entity
java.util.NoSuchElementException: No value present
at java.util.Optional.get(Optional.java:135)
at akn.c(SourceFile:54)
at akn.g(SourceFile:17)
at ajk.e(SourceFile:43)
at ajk$$Lambda$2795/893830713.test(Unknown Source)
at java.util.stream.MatchOps$1MatchSink.accept(MatchOps.java:90)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1351)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:529)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:516)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:502)
at java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:230)
at java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:196)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.anyMatch(ReferencePipeline.java:449)
at ajk.g(SourceFile:43)
at ajf.c(SourceFile:52)
at aiu.b(SourceFile:185)
at aiu$$Lambda$2793/540347566.accept(Unknown Source)
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
at java.util.Iterator.forEachRemaining(Iterator.java:116)
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:270)
at java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1612)
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:270)
at java.util.TreeMap$ValueSpliterator.forEachRemaining(TreeMap.java:2893)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:512)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:502)
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
at aiu.a(SourceFile:185)
at atz.K(SourceFile:229)
at aig.cW(SourceFile:622)
at aif.k(SourceFile:2202)
at aig.k(SourceFile:478)
at ahu.k(SourceFile:141)
at aif.h(SourceFile:2051)
at aig.h(SourceFile:292)
at vc.a(SourceFile:579)
at vc$$Lambda$2634/1560289409.accept(Unknown Source)
at bfy.a(SourceFile:668)
at vc.a(SourceFile:382)
at net.minecraft.server.MinecraftServer.b(SourceFile:814)
at net.minecraft.server.MinecraftServer.a(SourceFile:753)
at dwc.a(SourceFile:128)
at net.minecraft.server.MinecraftServer.run(SourceFile:628)
at java.lang.Thread.run(Thread.java:745)
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- Head --
Thread: Server thread
Stacktrace:
at java.util.Optional.get(Optional.java:135)
at akn.c(SourceFile:54)
at akn.g(SourceFile:17)
at ajk.e(SourceFile:43)
at ajk$$Lambda$2795/893830713.test(Unknown Source)
at java.util.stream.MatchOps$1MatchSink.accept(MatchOps.java:90)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1351)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:529)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:516)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:502)
at java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:230)
at java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:196)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.anyMatch(ReferencePipeline.java:449)
at ajk.g(SourceFile:43)
at ajf.c(SourceFile:52)
at aiu.b(SourceFile:185)
at aiu$$Lambda$2793/540347566.accept(Unknown Source)
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
at java.util.Iterator.forEachRemaining(Iterator.java:116)
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:270)
at java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1612)
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:270)
at java.util.TreeMap$ValueSpliterator.forEachRemaining(TreeMap.java:2893)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:512)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:502)
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
at aiu.a(SourceFile:185)
at atz.K(SourceFile:229)
at aig.cW(SourceFile:622)
at aif.k(SourceFile:2202)
at aig.k(SourceFile:478)
at ahu.k(SourceFile:141)
at aif.h(SourceFile:2051)
at aig.h(SourceFile:292)
at vc.a(SourceFile:579)
at vc$$Lambda$2634/1560289409.accept(Unknown Source)
-- Entity being ticked --
Details:
Entity Type: minecraft:villager (atz)
Entity ID: 165834
Entity Name: Dorpeling
Entity's Exact location: -90.50, 56.00, -87.50
Entity's Block location: World: (-91,56,-88), Chunk: (at 5,3,8 in -6,-6; contains blocks -96,0,-96 to -81,255,-81), Region: (-1,-1; contains chunks -32,-32 to -1,-1, blocks -512,0,-512 to -1,255,-1)
Entity's Momentum: 0.00, -0.08, 0.00
Entity's Passengers: []
Entity's Vehicle: ~~ERROR~~ NullPointerException: null
Stacktrace:
at bfy.a(SourceFile:668)
at vc.a(SourceFile:382)
-- Affected level --
Details:
Level name: Testing
All players: 1 total; [vd['DarkShadow_TNT'/3, l='Testing', x=-90.54, y=57.42, z=-85.66]]
Chunk stats: ServerChunkCache: 2535
Level seed: 2253500656129032334
Level generator: ID 01 - flat, ver 0. Features enabled: true
Level generator options: {biome:"minecraft:desert",layers:[{block:"minecraft:bedrock",height:1b},{block:"minecraft:stone",height:3b},{block:"minecraft:sandstone",height:52b}],structures:{}}
Level spawn location: World: (8,55,8), Chunk: (at 8,3,8 in 0,0; contains blocks 0,0,0 to 15,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Level time: 151541 game time, 6000 day time
Level dimension: 0
Level storage version: 0x04ABD - Anvil
Level weather: Rain time: 17599 (now: false), thunder time: 8364 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
Stacktrace:
at net.minecraft.server.MinecraftServer.b(SourceFile:814)
at net.minecraft.server.MinecraftServer.a(SourceFile:753)
at dwc.a(SourceFile:128)
at net.minecraft.server.MinecraftServer.run(SourceFile:628)
at java.lang.Thread.run(Thread.java:745)
-- System Details --
Details:
Minecraft Version: 19w11a
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_51, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 989206528 bytes (943 MB) / 1946157056 bytes (1856 MB) up to 2147483648 bytes (2048 MB)
JVM Flags: 9 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xss1M -Xmx2G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M
Player Count: 1 / 8; [vd['DarkShadow_TNT'/3, l='Testing', x=-90.54, y=57.42, z=-85.66]]
Data Packs: vanilla
Type: Integrated Server (map_client.txt)
Is Modded: Probably not. Jar signature remains and both client + server brands are untouched.
Log (anonimised and attached as well -
[media])
19w13a: 2019-03-28-4.log
[15:32:10] [Server thread/ERROR]: Encountered an unexpected exception
m: Ticking entity
at net.minecraft.server.MinecraftServer.b(SourceFile:820) ~[19w13a.jar:?]
at net.minecraft.server.MinecraftServer.a(SourceFile:755) ~[19w13a.jar:?]
at dwo.a(SourceFile:128) ~[19w13a.jar:?]
at net.minecraft.server.MinecraftServer.run(SourceFile:630) [19w13a.jar:?]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_51]
Caused by: java.util.NoSuchElementException: No value present
at java.util.Optional.get(Optional.java:135) ~[?:1.8.0_51]
at alj.c(SourceFile:72) ~[19w13a.jar:?]
at alj.g(SourceFile:22) ~[19w13a.jar:?]
at ajq.c(SourceFile:45) ~[19w13a.jar:?]
at ajq$$Lambda$2871/903543169.test(Unknown Source) ~[?:?]
at java.util.stream.MatchOps$1MatchSink.accept(MatchOps.java:90) ~[?:1.8.0_51]
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) ~[?:1.8.0_51]
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:1.8.0_51]
at java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1351) ~[?:1.8.0_51]
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126) ~[?:1.8.0_51]
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:529) ~[?:1.8.0_51]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:516) ~[?:1.8.0_51]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:502) ~[?:1.8.0_51]
at java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:230) ~[?:1.8.0_51]
at java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:196) ~[?:1.8.0_51]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_51]
at java.util.stream.ReferencePipeline.anyMatch(ReferencePipeline.java:449) ~[?:1.8.0_51]
at ajq.g(SourceFile:45) ~[19w13a.jar:?]
at ajj.c(SourceFile:61) ~[19w13a.jar:?]
at aix.a(SourceFile:285) ~[19w13a.jar:?]
at aix$$Lambda$2869/1951457415.accept(Unknown Source) ~[?:?]
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) ~[?:1.8.0_51]
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) ~[?:1.8.0_51]
at java.util.Iterator.forEachRemaining(Iterator.java:116) ~[?:1.8.0_51]
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) ~[?:1.8.0_51]
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580) ~[?:1.8.0_51]
at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:270) ~[?:1.8.0_51]
at java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1612) ~[?:1.8.0_51]
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580) ~[?:1.8.0_51]
at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:270) ~[?:1.8.0_51]
at java.util.TreeMap$ValueSpliterator.forEachRemaining(TreeMap.java:2893) ~[?:1.8.0_51]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:512) ~[?:1.8.0_51]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:502) ~[?:1.8.0_51]
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) ~[?:1.8.0_51]
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) ~[?:1.8.0_51]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_51]
at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) ~[?:1.8.0_51]
at aix.e(SourceFile:285) ~[19w13a.jar:?]
at aix.a(SourceFile:233) ~[19w13a.jar:?]
at auz.K(SourceFile:254) ~[19w13a.jar:?]
at aij.cX(SourceFile:623) ~[19w13a.jar:?]
at aii.k(SourceFile:2206) ~[19w13a.jar:?]
at aij.k(SourceFile:479) ~[19w13a.jar:?]
at ahx.k(SourceFile:141) ~[19w13a.jar:?]
at aii.h(SourceFile:2051) ~[19w13a.jar:?]
at aij.h(SourceFile:293) ~[19w13a.jar:?]
at ve.a(SourceFile:581) ~[19w13a.jar:?]
at ve$$Lambda$2709/1546971920.accept(Unknown Source) ~[?:?]
at bgv.a(SourceFile:668) ~[19w13a.jar:?]
at ve.a(SourceFile:384) ~[19w13a.jar:?]
at net.minecraft.server.MinecraftServer.b(SourceFile:816) ~[19w13a.jar:?]
... 4 more
Linked issues
is duplicated by
Attachments
Comments

Is this still an issue in 19w13a? If it is, please provide reproduction steps.

I was unable to reproduce it so it seem to be fixed in 19w13a.

Not fixed in 19w13a. I'm assuming it wasn't fixed in 19w12a & b either, as I didn't test those versions, but based on this bug being in 19w11b, I don't think an attempt fix was done between 11b and 13a.
EDIT: Rewrote the title of this bug, as this one seems more fitting.
Can also confirm that this is still an issue in 19w13a.

Still an issue in 19w13b. Can reproduce over and over. I've been trying to grab a screen shot. This happens when the workstation is destroyed as the villager seems to focus on it.
EDIT: Here is a video of how I reproduce it (too big to upload here) : https://youtu.be/-tOcJH_LlGg
I've noticed after many crashes that there seems to be a ghost workstations left, since without any in the world a new villager takes the profession of what was previously there. Have to move several chunks away.

Another way to reproduce this is by moving the villager's composter just after the villager resets trades. https://youtu.be/fUUXfr0bXBw

Can confirm fixed for 19w14a. Villager now seems to prioritise looking at the player rather than working at a workplace and when removing its workstation using /fill
, the game doesn't crash either.

Still present in 1.14.2.
Since I can't reproduce it with "fill" commands...
The fastest way to cause the bug is "using another bug". I explain it:
Flat world
Spawn a villager in a 3x3 hole.
Equip yourself on the hotbar a Workstation, for example a lectern.
Now you can simply place and break a lectern until it happens, but the fastest way is as follows:
Change "Place block" action to key "F"
Change "Destroy block" action to key "E"
Place the lectern.
Now, close to it (to avoid placing more than one block), hold E (to destroy it) and then hold F (to place it). (In this order, so the game prioritizes placing blocks faster than it breaks them).
(This should make the "place-break-place-break" action very fast, making the bug appear with a few attempts) (It's easier this way thanks to this other bug -> MC-118107 , in which "the last key that is kept pressed, repeats the action very quickly).
(I use the keyboard with this configuration because I usually play like this, and that's how I discovered that the bug persists)
I hope that the steps, though confusing in theory, will be simple to reproduce for you in practice.

I can confirm that this bug does affect 1.14.2
How I do it: In creative mode spawn in a villager and set the time of day to 2000. Nearby, place a workstation without a gui such as a lectern. Get very close and target the side closest to you, then simply press and HOLD right then left mouse buttons to break and replace repeatedly. Eventually the game will crash.
Added: crash-2019-05-28_21.58.13-server.txt
Unlisted Video: https://youtu.be/M2QQ1SBwHGM

The crash you are currently experiencing is actually a tad bit different from this crash. While at first glance the crash report looks a lot like the ones of the original crash, the 1.14.2 (and, sadly, as far back as 19w14b⚠️ ) crash is actually caused by something in it.unimi.dsi.fastutil.longs.LongLinkedOpenHashSet.removeFirstLong (LongLinkedOpenHashSet.java:470)
.
What's also different about this crash, or at least as far as I know, is that a villager can have a job (or even must (didn't test for that)) to trigger this crash.
EDIT: I've opened MC-153355 to address this specific crash. Please comment there with your findings.
The "java.lang.IllegalStateException: POI never registered at eu{x=1, y=56, z=9}" crash has already been reported under MC-145756. I edited this ticket to focus on the missing optional crash.