-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
223 additions
and
99 deletions.
There are no files selected for viewing
24 changes: 0 additions & 24 deletions
24
src/main/java/ladysnake/satin/api/experimental/BlockRenderLayerRegistry.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
47 changes: 47 additions & 0 deletions
47
src/main/java/ladysnake/satin/impl/BlockRenderLayerRegistry.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,47 @@ | ||
/* | ||
* Satin | ||
* Copyright (C) 2019-2020 Ladysnake | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; If not, see <https://www.gnu.org/licenses>. | ||
*/ | ||
package ladysnake.satin.impl; | ||
|
||
import it.unimi.dsi.fastutil.objects.ObjectArraySet; | ||
import net.minecraft.client.render.RenderLayer; | ||
|
||
import java.util.Set; | ||
|
||
public final class BlockRenderLayerRegistry { | ||
public static final BlockRenderLayerRegistry INSTANCE = new BlockRenderLayerRegistry(); | ||
private final Set<RenderLayer> renderLayers = new ObjectArraySet<>(); // ArraySet for faster iteration | ||
private volatile boolean registryLocked = false; | ||
|
||
private BlockRenderLayerRegistry(){} | ||
|
||
public void registerRenderLayer(RenderLayer layer) { | ||
if(registryLocked){ | ||
throw new IllegalStateException(String.format( | ||
"RenderLayer %s was added too late.", | ||
layer.toString() | ||
)); | ||
} | ||
|
||
renderLayers.add(layer); | ||
} | ||
|
||
public Set<RenderLayer> getLayers() { | ||
registryLocked = true; | ||
return renderLayers; | ||
} | ||
} |
32 changes: 0 additions & 32 deletions
32
src/main/java/ladysnake/satin/impl/BlockRenderLayerRegistryImpl.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Satin | ||
* Copyright (C) 2019-2020 Ladysnake | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; If not, see <https://www.gnu.org/licenses>. | ||
*/ | ||
package ladysnake.satin.mixin; | ||
|
||
import ladysnake.satin.Satin; | ||
import net.fabricmc.loader.api.FabricLoader; | ||
import org.objectweb.asm.tree.ClassNode; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public final class SatinMixinPlugin implements IMixinConfigPlugin { | ||
private static final boolean ALLOW_RENDER_LAYER_MIXINS; | ||
|
||
static { | ||
FabricLoader loader = FabricLoader.getInstance(); | ||
if (loader.isModLoaded("canvas")) { | ||
Satin.LOGGER.warn("[Satin] Canvas is present, custom block renders will not work"); | ||
ALLOW_RENDER_LAYER_MIXINS = false; | ||
} else { | ||
if (loader.isModLoaded("sodium")) { | ||
Satin.LOGGER.warn("[Satin] Sodium is present, custom block renders may not work"); | ||
} | ||
ALLOW_RENDER_LAYER_MIXINS = true; | ||
} | ||
} | ||
|
||
@Override | ||
public void onLoad(String mixinPackage) { | ||
// NO-OP | ||
} | ||
|
||
@Override | ||
public String getRefMapperConfig() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { | ||
if (targetClassName.startsWith("blockrenderlayer")) { | ||
return ALLOW_RENDER_LAYER_MIXINS; | ||
} | ||
return true; | ||
} | ||
|
||
@Override | ||
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) { | ||
// NO-OP | ||
} | ||
|
||
@Override | ||
public List<String> getMixins() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { | ||
// NO-OP | ||
} | ||
|
||
@Override | ||
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { | ||
// NO-OP | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/ladysnake/satin/mixin/client/blockrenderlayer/RenderLayerMixin.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,47 @@ | ||
/* | ||
* Satin | ||
* Copyright (C) 2019-2020 Ladysnake | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; If not, see <https://www.gnu.org/licenses>. | ||
*/ | ||
package ladysnake.satin.mixin.client.blockrenderlayer; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import ladysnake.satin.impl.BlockRenderLayerRegistry; | ||
import net.minecraft.client.render.RenderLayer; | ||
import net.minecraft.client.render.RenderPhase; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(RenderLayer.class) | ||
public abstract class RenderLayerMixin extends RenderPhase { | ||
private RenderLayerMixin() { | ||
super(null, null, null); | ||
} | ||
|
||
@Inject( | ||
method = "getBlockLayers", | ||
at = @At("RETURN"), | ||
cancellable = true | ||
) | ||
private static void getBlockLayers(CallbackInfoReturnable<ImmutableList<Object>> info) { | ||
info.setReturnValue( | ||
ImmutableList.builder() | ||
.addAll(info.getReturnValue()) | ||
.addAll(BlockRenderLayerRegistry.INSTANCE.getLayers() | ||
).build()); | ||
} | ||
} |
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
30 changes: 0 additions & 30 deletions
30
src/main/java/ladysnake/satin/mixin/client/render/RenderLayerMixin.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
Oops, something went wrong.