Skip to content

Commit

Permalink
fix crash on startup, close #2 , close #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Kasualix committed Aug 7, 2023
1 parent aaf5d98 commit ba3c148
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/main/java/fi/dy/masa/tweakeroo/mixin/MixinWorld.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package fi.dy.masa.tweakeroo.mixin;

import java.util.HashSet;
import java.util.List;
import java.util.function.Consumer;
import fi.dy.masa.tweakeroo.config.Configs;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;
import fi.dy.masa.tweakeroo.config.Configs;

import java.util.HashSet;
import java.util.List;
import java.util.function.Consumer;

@Mixin(World.class)
public abstract class MixinWorld
Expand Down Expand Up @@ -53,15 +54,14 @@ private boolean preventTileEntityTicking(BlockEntity te)
}

@Inject(method = "tickBlockEntities",
at = @At(value = "FIELD", target = "Lnet/minecraft/world/World;unloadedBlockEntities:Ljava/util/List;", ordinal = 0))
at = @At(value = "FIELD", target = "Lnet/minecraft/world/World;unloadedBlockEntities:Ljava/util/Set;", ordinal = 0))
private void optimizedTileEntityRemoval(CallbackInfo ci)
{
if (Configs.Fixes.TILE_UNLOAD_OPTIMIZATION.getBooleanValue())
{
if (!this.unloadedBlockEntities.isEmpty())
{
HashSet<BlockEntity> remove = new HashSet<>();
remove.addAll(this.unloadedBlockEntities);
HashSet<BlockEntity> remove = new HashSet<>(this.unloadedBlockEntities);

this.tickingBlockEntities.removeAll(remove);
this.blockEntities.removeAll(remove);
Expand Down

0 comments on commit ba3c148

Please sign in to comment.