Skip to content

Commit

Permalink
[1.19] Fixed skeleton spawn crash
Browse files Browse the repository at this point in the history
RandomSource can crash if used from multiple threads, switch to a normal Random
  • Loading branch information
The-Fireplace committed Nov 29, 2022
1 parent 8978b9b commit 556bda1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Fixed skeleton hitboxes
Fixed skeleton hitboxes
[1.19] Fixed skeleton spawn crash
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,23 @@
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.Random;

public final class SkeletonSpawnUtils
{
private final OverlordItems overlordItems;
private final Random random;

@Inject
public SkeletonSpawnUtils(OverlordItems overlordItems) {
this.overlordItems = overlordItems;
this.random = new Random();
}

public void addMask(LivingEntity entity) {
int daysSinceUndertaleReleased = (int) ChronoUnit.DAYS.between(LocalDate.parse("2015-09-15", DateTimeFormatter.ofPattern("y-M-d")), LocalDateTime.now());
int daysSince1710Released = (int) ChronoUnit.DAYS.between(LocalDate.parse("2014-06-26", DateTimeFormatter.ofPattern("y-M-d")), LocalDateTime.now());
if (entity.getCommandSenderWorld().getRandom().nextInt(daysSinceUndertaleReleased + daysSince1710Released) == 0
if (random.nextInt(daysSinceUndertaleReleased + daysSince1710Released) == 0
&& entity.getItemBySlot(EquipmentSlot.HEAD).isEmpty()
) {
entity.setItemSlot(EquipmentSlot.HEAD, new ItemStack(overlordItems.getSansMask()));
Expand Down

0 comments on commit 556bda1

Please sign in to comment.