Posted June 24, 20205 yr Hello, Is it possible to create an image through code and texture an item with it in game?
June 24, 20205 yr Howdy Yes it is Here's a working example of texturing an item with a custom quad https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe15_item_dynamic_item_model DynamicTexture is suitable for creating an image in code. If you search this forum for DynamicTexture you'll find some recents posts about dynamic textures (Elytra, wolves) -TGG
June 25, 20205 yr Author It seems that AtlasTexture and ModelLoader.instance().getSpriteMap... is no longer the same as your guide. Do you know how accessing those things have changed?
June 25, 20205 yr 7 minutes ago, BeardlessBrady said: It seems that AtlasTexture and ModelLoader.instance().getSpriteMap... is no longer the same as your guide. Do you know how accessing those things have changed? It seems to still be correct for me // we have previously registered digitsTexture in StartupClientOnly::onTextureStitchEvent AtlasTexture blocksStitchedTextures = ModelLoader.instance().getSpriteMap().getAtlasTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE); TextureAtlasSprite digitsTextures = blocksStitchedTextures.getSprite(digitsTextureRL); These compile fine Check you build.gradle? mappings channel: 'snapshot', version: '20200514-1.15.1' minecraft 'net.minecraftforge:forge:1.15.2-31.2.0' @OnlyIn(Dist.CLIENT) public class AtlasTexture extends Texture implements ITickable { private static final Logger LOGGER = LogManager.getLogger(); @Deprecated public static final ResourceLocation LOCATION_BLOCKS_TEXTURE = PlayerContainer.LOCATION_BLOCKS_TEXTURE; @Deprecated public static final ResourceLocation LOCATION_PARTICLES_TEXTURE = new ResourceLocation("textures/atlas/particles.png"); private final List<TextureAtlasSprite> listAnimatedSprites = Lists.newArrayList(); private final Set<ResourceLocation> sprites = Sets.newHashSet(); private final Map<ResourceLocation, TextureAtlasSprite> mapUploadedSprites = Maps.newHashMap(); private final ResourceLocation textureLocation; private final int maximumTextureSize; public AtlasTexture(ResourceLocation textureLocationIn) { this.textureLocation = textureLocationIn; this.maximumTextureSize = RenderSystem.maxSupportedTextureSize(); } and ModelBakery:: public SpriteMap getSpriteMap() { return this.spriteMap; }
June 25, 20205 yr Author One last thing... I am having trouble properly coloring the quads: https://github.com/TheGreyGhost/MinecraftByExample/blob/master/src/main/java/minecraftbyexample/mbe15_item_dynamic_item_model/ChessboardFinalisedModel.java#L287-L290 On these specific lines you can set a parameter to a color, if I change any of them from white to anything else it just turns teal, any ideas?
June 25, 20205 yr Author Also I just want to make sure I'm doing this efficiently. I'm trying to dynamically create a texture in game. Is the best way to do it like your example where instead of filling a chess board with diamond blocks (I'll use a blank texture), the blocks will represent each individual pixel. If you get what I mean would adding these many quads cause any lag or am I doing this wrong/not efficiently? Edited June 25, 20205 yr by BeardlessBrady
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.