-
Notifications
You must be signed in to change notification settings - Fork 83
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
1 parent
3fe7a74
commit 23dbade
Showing
75 changed files
with
1,072 additions
and
1,229 deletions.
There are no files selected for viewing
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
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
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
16 changes: 16 additions & 0 deletions
16
src/main/java/me/pepperbell/continuity/api/client/CachingPredicates.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,16 @@ | ||
package me.pepperbell.continuity.api.client; | ||
|
||
import net.minecraft.block.BlockState; | ||
import net.minecraft.client.texture.Sprite; | ||
|
||
public interface CachingPredicates { | ||
boolean affectsSprites(); | ||
|
||
boolean affectsSprite(Sprite sprite); | ||
|
||
boolean affectsBlockStates(); | ||
|
||
boolean affectsBlockState(BlockState state); | ||
|
||
boolean isValidForMultipass(); | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/me/pepperbell/continuity/api/client/CachingPredicatesFactory.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,10 @@ | ||
package me.pepperbell.continuity.api.client; | ||
|
||
import java.util.function.Function; | ||
|
||
import net.minecraft.client.texture.Sprite; | ||
import net.minecraft.client.util.SpriteIdentifier; | ||
|
||
public interface CachingPredicatesFactory<T extends CTMProperties> { | ||
CachingPredicates createPredicates(T properties, Function<SpriteIdentifier, Sprite> textureGetter); | ||
} |
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
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
87 changes: 87 additions & 0 deletions
87
src/main/java/me/pepperbell/continuity/client/mixin/AtlasLoaderMixin.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,87 @@ | ||
package me.pepperbell.continuity.client.mixin; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
import java.util.function.Supplier; | ||
|
||
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.ModifyVariable; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture; | ||
|
||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; | ||
import it.unimi.dsi.fastutil.objects.ObjectArrayList; | ||
import me.pepperbell.continuity.client.resource.AtlasLoaderInitContext; | ||
import me.pepperbell.continuity.client.resource.AtlasLoaderLoadContext; | ||
import me.pepperbell.continuity.client.resource.EmissiveSuffixLoader; | ||
import net.minecraft.client.texture.SpriteContents; | ||
import net.minecraft.client.texture.SpriteLoader; | ||
import net.minecraft.client.texture.atlas.AtlasLoader; | ||
import net.minecraft.client.texture.atlas.AtlasSource; | ||
import net.minecraft.client.texture.atlas.SingleAtlasSource; | ||
import net.minecraft.resource.Resource; | ||
import net.minecraft.resource.ResourceManager; | ||
import net.minecraft.util.Identifier; | ||
|
||
@Mixin(AtlasLoader.class) | ||
public class AtlasLoaderMixin { | ||
@ModifyVariable(method = "<init>(Ljava/util/List;)V", at = @At(value = "LOAD", ordinal = 0), argsOnly = true, ordinal = 0) | ||
private List<AtlasSource> continuity$modifySources(List<AtlasSource> sources) { | ||
AtlasLoaderInitContext context = AtlasLoaderInitContext.THREAD_LOCAL.get(); | ||
if (context != null) { | ||
Set<Identifier> extraIds = context.getExtraIdsFuture().join(); | ||
if (extraIds != null && !extraIds.isEmpty()) { | ||
List<AtlasSource> extraSources = new ObjectArrayList<>(); | ||
for (Identifier extraId : extraIds) { | ||
extraSources.add(new SingleAtlasSource(extraId, Optional.empty())); | ||
} | ||
|
||
if (sources instanceof ArrayList) { | ||
sources.addAll(0, extraSources); | ||
} else { | ||
List<AtlasSource> mutableSources = new ArrayList<>(extraSources); | ||
mutableSources.addAll(sources); | ||
return mutableSources; | ||
} | ||
} | ||
} | ||
return sources; | ||
} | ||
|
||
@Inject(method = "loadSources(Lnet/minecraft/resource/ResourceManager;)Ljava/util/List;", at = @At(value = "INVOKE", target = "Lcom/google/common/collect/ImmutableList;builder()Lcom/google/common/collect/ImmutableList$Builder;", remap = false), locals = LocalCapture.CAPTURE_FAILHARD) | ||
private void continuity$afterLoadSources(ResourceManager resourceManager, CallbackInfoReturnable<List<Supplier<SpriteContents>>> cir, Map<Identifier, AtlasSource.SpriteRegion> suppliers) { | ||
AtlasLoaderLoadContext context = AtlasLoaderLoadContext.THREAD_LOCAL.get(); | ||
if (context != null) { | ||
String emissiveSuffix = EmissiveSuffixLoader.getEmissiveSuffix(); | ||
if (emissiveSuffix != null) { | ||
Map<Identifier, AtlasSource.SpriteRegion> extraSuppliers = new Object2ObjectOpenHashMap<>(); | ||
Map<Identifier, Identifier> emissiveIdMap = new Object2ObjectOpenHashMap<>(); | ||
suppliers.forEach((id, supplier) -> { | ||
if (!id.getPath().endsWith(emissiveSuffix)) { | ||
Identifier emissiveId = new Identifier(id.getNamespace(), id.getPath() + emissiveSuffix); | ||
if (!suppliers.containsKey(emissiveId)) { | ||
Identifier emissiveLocation = emissiveId.withPath("textures/" + emissiveId.getPath() + ".png"); | ||
Optional<Resource> optionalResource = resourceManager.getResource(emissiveLocation); | ||
if (optionalResource.isPresent()) { | ||
Resource resource = optionalResource.get(); | ||
extraSuppliers.put(emissiveId, () -> SpriteLoader.load(emissiveId, resource)); | ||
emissiveIdMap.put(id, emissiveId); | ||
} | ||
} else { | ||
emissiveIdMap.put(id, emissiveId); | ||
} | ||
} | ||
}); | ||
suppliers.putAll(extraSuppliers); | ||
if (!emissiveIdMap.isEmpty()) { | ||
context.setEmissiveIdMap(emissiveIdMap); | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.