Jump to content

[1.15.2] Dynamic Item texture creation


BeardlessBrady

Recommended Posts

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

 

 

 

  • Thanks 1
Link to comment
Share on other sites

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;
}

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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 by BeardlessBrady
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.