Update TextureStitchEvent.Pre to give access to the list of ResourceLocations that will be loaded as textures. (#5870)

This commit is contained in:
primetoxinz authored and LexManos committed 2019-07-03 12:26:51 -07:00
1 parent bc23c1ddb2
commit 765efc3c72
3 files changed
+35 -17

No files matched your search

@@ -31,6 +31,7 @@ import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.Map;
import java.util.Optional;
import java.util.Random;
@@ -178,9 +179,9 @@ public class ForgeHooksClient
return MinecraftForge.EVENT_BUS.post(new RenderSpecificHandEvent(hand, partialTicks, interpPitch, swingProgress, equipProgress, stack));
}
public static void onTextureStitchedPre(AtlasTexture map)
public static void onTextureStitchedPre(AtlasTexture map, Set<ResourceLocation> resourceLocations)
{
ModLoader.get().postEvent(new TextureStitchEvent.Pre(map));
ModLoader.get().postEvent(new TextureStitchEvent.Pre(map, resourceLocations));
// ModelLoader.White.INSTANCE.register(map); // TODO Custom TAS
ModelDynBucket.LoaderDynBucket.INSTANCE.register(map);
}
@@ -19,9 +19,12 @@
package net.minecraftforge.client.event;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.eventbus.api.Event;
import net.minecraft.client.renderer.texture.AtlasTexture;
import java.util.Set;
public class TextureStitchEvent extends Event
{
@@ -38,17 +41,29 @@ public class TextureStitchEvent extends Event
}
/**
* Fired when the TextureMap is told to refresh it's stitched texture.
* Called after the Stitched list is cleared, but before any blocks or items
* add themselves to the list.
* Fired when the TextureMap is told to refresh it's stitched texture.
* Called before the {@link net.minecraft.client.renderer.texture.TextureAtlasSprite} are loaded.
*/
public static class Pre extends TextureStitchEvent
{
public Pre(AtlasTexture map){ super(map); }
private final Set<ResourceLocation> sprites;
public Pre(AtlasTexture map, Set<ResourceLocation> sprites)
{
super(map);
this.sprites = sprites;
}
/**
* Add a sprite to be stitched into the Texture Atlas.
*/
public boolean addSprite(ResourceLocation sprite) {
return this.sprites.add(sprite);
}
}
/**
* This event is fired once the texture map has loaded all textures and
* This event is fired once the texture map has loaded all textures and
* stitched them together. All Icons should have there locations defined
* by the time this is fired.
*/