-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix CME in StructureTemplate.Palette
The cache needs to be a CHM to prevent CMEs. Since the only usage is compute() on static data, this is all we need to fix the threading issues here.
- Loading branch information
1 parent
959fc80
commit 1d60cdb
Showing
3 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/main/java/ca/spottedleaf/moonrise/mixin/chunk_system/StructureTemplate$PaletteMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package ca.spottedleaf.moonrise.mixin.chunk_system; | ||
|
||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; | ||
import org.objectweb.asm.Opcodes; | ||
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 java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
@Mixin(StructureTemplate.Palette.class) | ||
public abstract class StructureTemplate$PaletteMixin { | ||
|
||
@Shadow | ||
private Map<Block, List<StructureTemplate.StructureBlockInfo>> cache; | ||
|
||
/** | ||
* @reason Make cache CHM to prevent CME | ||
* @author Spottedleaf | ||
*/ | ||
@Inject( | ||
method = "<init>", | ||
at = @At( | ||
value = "RETURN" | ||
) | ||
) | ||
private <K, V> void makeCacheCHM(final CallbackInfo ci) { | ||
this.cache = new ConcurrentHashMap<>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters