Jump to content

1.8.9 Generate a BakedQuad(no texture file)


UberAffe

Recommended Posts

I am planning something like this:

DraftableBakedModel implements IFlexibleBakedModel{

   private List<BakedQuad> quads = new ArrayList<BakedQuad>();

   public DraftableBakedModel(IDraftable draft){
      HashMap<String, IPartType> parts = draft.getParts();
      for(int i = x; x < 16; x++)
         for(int y = 0; y < 16; y++)
            for(int z = 0; z < 16; z++)
               if(parts.contain(x + "," + y + "," z))
                  quads.addAll(getQuadFrom(parts.get(x + "," + y + "," z), x, y, z);

   }

   //x, y, z specify the relative top, left, front, for the part to base it's vertices from.
   private List<BakedQuad> getQuadFrom(IPartType part,int x, int y, int z){
      // part has relative vertex information and RGBA for the color and transparency
      // that this part should render with.
      // each part can be thought of as a semi transparent, single color cube
      // although they may not actually be cubes
   }
   
}

 

1. is this the correct place to be specifying a color to render with?

2. it seems like each vertex of Baked Quad only has 1 variable for color, so how do I store the color?

3. if this isn't the way to generate a texture how should I be doing it?

Current Project: Armerger 

Planned mods: Light Drafter  | Ore Swords

Looking for help getting a mod off the ground? Coding  | Textures

Link to comment
Share on other sites

1. What do you mean? If you are doing everything according to vanilla code (you use model system) then you don't color stuff on your own. You colorize Quads.

2. Well, without looking at internals (can't now) - if that "one variable" is "int" then I don't understand your problem. int =(bits)= 0xRRGGBBAA (I am unsure as to the color ordering). BakedQuad can have texture and color, texture can be applied as u,v coords and use e.g grayscale image, while colorization is one value (to my understanding).

3. What way do you mean? You are doing nothing that actually generates any image OR quads. Also - are you sure about what you are asking - "to generate a texture". From what I understand you want to make 16x16x16 cubical model that can be rendered from ItemStack, e.g:

 

width=204 height=248https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcRbr6VYHu1JTJXVLEB93D_6j1I3DwnU0HetRlou4Wp9BRnXBbGq[/img]

 

You want to (based on ItemStack) make those cubes (like on img) and colorize them (also based on ItemStack). Is this correct?

 

Well, you can either make 4096 grayscale model files that cover every mini-cube, name them cube_x_y_z and then in your smart item combine them. But that we all know is stupid.

 

What you want is generate them on your own - which is simple. Without learning BakedQuad format you can't do shit. You need to create 6 BakedQuads for evey cubical. and place them in proper position of model. Which you probably alredy know - yet still, I have no idea what you are asking of us.

 

Side note: (optimization) When you generate your ItemStack's model for the 1st time - while 4096 (considering worst case) of BakedQUads can be handled, you can easily track and remove some of Quads that are not visible (remove each side of mini-box that contancs other).

 

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

That was actually helpful, this is what I have come up with since then:

IFlexibleBakedModel

 

public class DraftableBakedModel implements IFlexibleBakedModel{

 private List<BakedQuad> quads = new ArrayList<BakedQuad>();

 public DraftableBakedModel(IDraftable draft){
	 DraftableMap parts = draft.GetPartArray();
	 for(int xPos = 0; xPos < 16; xPos++){
		 for(int yPos = 0; yPos < 16; yPos++){
            for(int zPos = 0; zPos < 16; zPos++){
               if(parts.GetPart(xPos + "," + yPos + "," + zPos) != null)
                  quads.addAll(getQuadFrom(parts.GetPart(xPos + "," + yPos + "," + zPos), xPos, yPos, zPos));
            }
         }
      }
   }

private List<BakedQuad> getQuadFrom(IPartType getPart, int x, int y, int z) {
	List<BakedQuad> list = new ArrayList<BakedQuad>();
	BakedQuad quad;
	//North
	quad = new BakedQuad(applyOffset(getPart.GetVertices(EnumFacing.NORTH),x,y,z), 0, EnumFacing.NORTH);
	list.add(quad);
	//Up
	quad = new BakedQuad(getPart.GetVertices(EnumFacing.UP), z, EnumFacing.UP);
	list.add(quad);
	//East
	quad = new BakedQuad(getPart.GetVertices(EnumFacing.EAST), z, EnumFacing.EAST);
	list.add(quad);
	//South
	quad = new BakedQuad(getPart.GetVertices(EnumFacing.SOUTH), z, EnumFacing.SOUTH);
	list.add(quad);
	//Down
	quad = new BakedQuad(getPart.GetVertices(EnumFacing.DOWN), z, EnumFacing.DOWN);
	list.add(quad);
	//West
	quad = new BakedQuad(getPart.GetVertices(EnumFacing.WEST), z, EnumFacing.WEST);
	list.add(quad);
	return list;
}

private int[] applyOffset(int[] vertices, int x, int y, int z) {
	for(int i = 0; i < 7; i++)//7 elements per vertex
	{
		for(int j = 1; j < 5; j++)// 4 vertices
		{
			switch(i){
			case 0: vertices[i*j] = vertices[i*j] + (x*Refs.OFFSET);//xpos
				break;
			case 1: vertices[i*j] = vertices[i*j] + (y*Refs.OFFSET);//ypos
				break;
			case 2: vertices[i*j] = vertices[i*j] + (z*Refs.OFFSET);//zpos
				break;
			default:
				break;
			}
		}
	}
	return vertices;
}
}

 

Vertices

 

        public int[] GetVertices(EnumFacing face) {
	switch(face){
	case NORTH:
		return north();
	case EAST:
		return east();
	case WEST:
		return west();
	case SOUTH:
		return south();
	case UP:
		return up();
	case DOWN:
		return down();
	default:
		return null;
	}
}

private int[] north() {
	int[] vertices = new int[28];
	//top left
	vertices[0] = 0; //x
	vertices[1] = 0; //y
	vertices[2] = 0; //z
	vertices[3] = asInt(luxin.GetColor()); // rrggbbaa
	vertices[4] = 0; //u 
	vertices[5] = 0; //v
	vertices[6] = 0; //unused
	//top right
	vertices[7] = 1; //x
	vertices[8] = 0; //y
	vertices[9] = 0; //z
	vertices[10] = asInt(luxin.GetColor()); // rrggbbaa
	vertices[11] = 0; //u 
	vertices[12] = 0; //v
	vertices[13] = 0; //unused
	//bottom right
	vertices[14] = 1; //x
	vertices[15] = 0; //y
	vertices[16] = 1; //z
	vertices[17] = asInt(luxin.GetColor()); // rrggbbaa
	vertices[18] = 0; //u 
	vertices[19] = 0; //v
	vertices[20] = 0; //unused
	//bottom left
	vertices[21] = 0; //x
	vertices[22] = 0; //y
	vertices[23] = 1; //z
	vertices[24] = asInt(luxin.GetColor()); // rrggbbaa
	vertices[25] = 0; //u 
	vertices[26] = 0; //v
	vertices[27] = 0; //unused
	return vertices;
}

        private int asInt(int[] color) {
	return (color[0]&0x0ff)<<24|(color[1]&0x0ff)<<16|(color[2]&0x0ff)<<8|(color[3]&0x0ff);//0 is r, 1 is g, 2 is b, 3 is a, &0x0ff limits each to 1 byte
}

with similar code for the other faces

 

 

 

I know this would still generate every quad, even unnecessary ones but I'll optimize that after I get it working.

 

1. Is it ok to leave u,v as 0 since I don't need anything from an actual texture file?

2. What is the scale of a block? Will 16 quads like I have reach up to a full block height?

Current Project: Armerger 

Planned mods: Light Drafter  | Ore Swords

Looking for help getting a mod off the ground? Coding  | Textures

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • For crash 1, set max-tick-time to -1 in your server.properties Crash 2 shows a conflict or incompatibility between LuckPerms and the mod boh-0.0.6.1-forge-1.20.1_2.jar
    • Add the crash-report or latest.log (logs-folder) with sites like https://mclo.gs/ and paste the link to it here  
    • so my minecraft crashes when opening my world, i played without any troubles for about 5 days and today it started tweaking.. pls help me
    • Hi guys! I am having some issues with the server crashing over and over and I was hoping to get some guidance.  Thanks in advance! Crash 1: java.lang.Error: ServerHangWatchdog detected that a single server tick took 60.00 seconds (should be max 0.05)     at net.minecraft.server.dedicated.ServerWatchdog.run(ServerWatchdog.java:43) ~[server-1.20.1-20230612.114412-srg.jar%23217!/:?] {re:classloading}     at java.lang.Thread.run(Thread.java:840) ~[?:?] { Crash 2: java.lang.IllegalStateException: Capability missing for eeb7f026-34b4-42f5-9164-e7736461df83     at me.lucko.luckperms.forge.capabilities.UserCapabilityImpl.lambda$get$0(UserCapabilityImpl.java:66) ~[?:?] {re:classloading,re:classloading,re:classloading}     at net.minecraftforge.common.util.LazyOptional.orElseThrow(LazyOptional.java:261) ~[forge-1.20.1-47.3.10-universal.jar%23222!/:?] {re:mixin,re:classloading}     at me.lucko.luckperms.forge.capabilities.UserCapabilityImpl.get(UserCapabilityImpl.java:66) ~[?:?] {re:classloading,re:classloading,re:classloading}     at me.lucko.luckperms.forge.util.BrigadierInjector$InjectedPermissionRequirement.test(BrigadierInjector.java:143) ~[?:?] {}     at me.lucko.luckperms.forge.util.BrigadierInjector$InjectedPermissionRequirement.test(BrigadierInjector.java:129) ~[?:?] {}     at com.mojang.brigadier.tree.CommandNode.canUse(CommandNode.java:65) ~[brigadier-1.1.8.jar%2376!/:?] {}     at com.mojang.brigadier.CommandDispatcher.parseNodes(CommandDispatcher.java:359) ~[brigadier-1.1.8.jar%2376!/:?] {}     at com.mojang.brigadier.CommandDispatcher.parse(CommandDispatcher.java:349) ~[brigadier-1.1.8.jar%2376!/:?] {}     at com.mojang.brigadier.CommandDispatcher.parse(CommandDispatcher.java:317) ~[brigadier-1.1.8.jar%2376!/:?] {}     at net.minecraft.commands.Commands.m_230957_(Commands.java:237) ~[server-1.20.1-20230612.114412-srg.jar%23217!/:?] {re:classloading}     at net.mcreator.boh.procedures.TeleportbenProcedure.lambda$execute$2(TeleportbenProcedure.java:65) ~[boh-0.0.6.1-forge-1.20.1_2.jar%23165!/:?] {re:classloading}     at net.mcreator.boh.BohMod.lambda$tick$2(BohMod.java:96) ~[boh-0.0.6.1-forge-1.20.1_2.jar%23165!/:?] {re:classloading}     at java.util.ArrayList.forEach(ArrayList.java:1511) ~[?:?] {re:mixin}     at net.mcreator.boh.BohMod.tick(BohMod.java:96) ~[boh-0.0.6.1-forge-1.20.1_2.jar%23165!/:?] {re:classloading}     at net.mcreator.boh.__BohMod_tick_ServerTickEvent.invoke(.dynamic) ~[boh-0.0.6.1-forge-1.20.1_2.jar%23165!/:?] {re:classloading,pl:eventbus:B}     at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.event.ForgeEventFactory.onPostServerTick(ForgeEventFactory.java:950) ~[forge-1.20.1-47.3.10-universal.jar%23222!/:?] {re:classloading}     at net.minecraft.server.MinecraftServer.m_5705_(MinecraftServer.java:835) ~[server-1.20.1-20230612.114412-srg.jar%23217!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaerominimap:xaero_minecraftserver,re:classloading,pl:accesstransformer:B,xf:fml:xaerominimap:xaero_minecraftserver,pl:mixin:A}     at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:661) ~[server-1.20.1-20230612.114412-srg.jar%23217!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaerominimap:xaero_minecraftserver,re:classloading,pl:accesstransformer:B,xf:fml:xaerominimap:xaero_minecraftserver,pl:mixin:A}     at net.minecraft.server.MinecraftServer.m_206580_(MinecraftServer.java:251) ~[server-1.20.1-20230612.114412-srg.jar%23217!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaerominimap:xaero_minecraftserver,re:classloading,pl:accesstransformer:B,xf:fml:xaerominimap:xaero_minecraftserver,pl:mixin:A}     at java.lang.Thread.run(Thread.java:840) ~[?:?] {}
    • Hello there! I am trying to make custom dimensions for a modpack I am making in an older minecraft version, 1.16.5. I like that version and it has a few other mods that have not been updated that I would still like to use. Anyway, I am having a terrible time with getting my dimension to work and have tried using code from other peoples projects to at least figure out what I'm supposed to be doing but it has not been as helpful as I would have liked. If anyone could help that would be greatly appreciated! Here is my github with all the code as I am using it: https://github.com/BladeColdsteel/InvigoratedDimensionsMod I have also included the last log, https://pastebin.com/zX9vsDSq, I had when I tried to load up a world, let me know if there is anything else I should send though, thank you!
  • Topics

×
×
  • Create New...

Important Information

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