generated from kappa-maintainer/1.12.2-FG6-Template
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from ZZZank/extu2-cme
properly patch ExtraUtils2 client-side CME
- Loading branch information
Showing
3 changed files
with
62 additions
and
25 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
src/main/java/com/cleanroommc/fugue/mixin/extrautils2/XUBlockStatic$3Mixin.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,61 @@ | ||
package com.cleanroommc.fugue.mixin.extrautils2; | ||
|
||
import com.rwtema.extrautils2.backend.XUBlock; | ||
import com.rwtema.extrautils2.backend.XUBlockStatic; | ||
import com.rwtema.extrautils2.backend.model.MutableModel; | ||
import com.rwtema.extrautils2.backend.model.PassthruModelBlock; | ||
import com.rwtema.extrautils2.backend.model.Transforms; | ||
import net.minecraft.block.state.IBlockState; | ||
import net.minecraft.client.renderer.block.model.BakedQuad; | ||
import net.minecraft.client.renderer.block.model.ModelResourceLocation; | ||
import net.minecraft.util.BlockRenderLayer; | ||
import net.minecraft.util.EnumFacing; | ||
import net.minecraftforge.client.MinecraftForgeClient; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
import org.spongepowered.asm.mixin.*; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
/** | ||
* @author ZZZank | ||
*/ | ||
@Mixin(targets = "com.rwtema.extrautils2.backend.XUBlockStatic$3", remap = false) | ||
public abstract class XUBlockStatic$3Mixin extends PassthruModelBlock { | ||
@Shadow | ||
@Final | ||
XUBlockStatic this$0; | ||
|
||
@Shadow | ||
HashMap<IBlockState, HashMap<EnumFacing, HashMap<BlockRenderLayer, List<BakedQuad>>>> cachedLists; | ||
|
||
@Unique | ||
private final Object fugue$lock = new Object(); | ||
|
||
private XUBlockStatic$3Mixin(XUBlock block, IBlockState key, ModelResourceLocation modelResourceLocation) { | ||
super(block, key, modelResourceLocation); | ||
} | ||
|
||
/** | ||
* @author ZZZank | ||
* @reason original implementation forces the usage of {@link HashMap}, which is NOT concurrency-safe | ||
*/ | ||
@Overwrite | ||
@Nonnull | ||
@SideOnly(Side.CLIENT) | ||
@Override | ||
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) { | ||
synchronized (fugue$lock) { | ||
return cachedLists | ||
.computeIfAbsent(state, XUBlockStatic::dummyCreateHash) | ||
.computeIfAbsent(side, XUBlockStatic::dummyCreateHash) | ||
.computeIfAbsent(MinecraftForgeClient.getRenderLayer(), (layer) -> { | ||
MutableModel model = new MutableModel(Transforms.blockTransforms); | ||
this$0.cachedModels.get(state).loadIntoMutable(model, layer); | ||
return model.getQuads(state, side, rand); | ||
}); | ||
} | ||
} | ||
} |
24 changes: 0 additions & 24 deletions
24
src/main/java/com/cleanroommc/fugue/mixin/extrautils2/XUBlockStaticMixin.java
This file was deleted.
Oops, something went wrong.
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