Jump to content

Recommended Posts

Posted

Hello there lovely people! Been messing with multiblock structures and had a few questions.

 

1: Is having a crazy amount of if statements "bad" (server-wise) when dealing with multiblocks? (i have 26x4 if statements checking, 26 for each direction the block is facing.)

 

2: How I have it now is if(multiblock == true) it makes right clicking the furnace block open the gui. Is it possible to extend it so when any of the 3x3x3 blocks are right clicked it opens the gui? Make block hitbox into 3x3x3 or something?

 

3: As image below shows, when putting a model with a texture over blocks like that, is there a way to either hide the blocks (setting them to Blocks.air?) under or make model texture dominant over block textures there somehow? At first I made the model 1 pixel longer on each side so it just got above the redstone block texture, but then the model take up half a pixel more on all sides and it looked bad.

 

Any help or tips are appriciated!

 

 

M6vDtQd.png

Posted

1. As long as they are not in per-tick calls - yes. Whenever you go into ticking stuff - always: The less, the better and if you can't - you don't do it per-tick, but per few sec at least - in critical cases ofc.

 

2. if(multiblock == true) - I hope this si pseudocode, you don't need "==" in boolean statements - meaning: if(multiblock) - is correct.

No, do not extend hitbox (which I think is impossible in "good" terms). What I'd do is make clicking other blocks (around) search for parent furnace and open it remotely by passing arguments from onBlockRightClick or whatever (just idea).

 

3. I don't get the pictured example. I probably know what you want, but still not sure, explain. You will probably want to make custom renederer, not an expert.

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

Posted

1. As long as they are not in per-tick calls - yes. Whenever you go into ticking stuff - always: The less, the better and if you can't - you don't do it per-tick, but per few sec at least - in critical cases ofc.

 

Technically speaking, more code is not slower code.  If there's a fast way to check that something may be true (i.e. if the fast check returns a statement that provides false positives, but not false negatives, or vice versa), then if that's false, you can skip a more expensive check, its better than if you didn't check.

 

For multiblock, you shouldn't be doing checks in onUpdate anyway: the world didn't change unless you got a neighbor block update check.  Which you can then fast-check the changed block (not one of the multiblock items? No need to check for the whole structure).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

3. I don't get the pictured example. I probably know what you want, but still not sure, explain. You will probably want to make custom renederer, not an expert.

 

Basically when I add the model directly over the redstone blocks, the texture flickers as you move around looking at it. I'm assuming this is because there are now 2 textures fighting ontop of eachother. Trying to figure out what the best way is to only show the model texture, and hide/remove the 3x3x3 blocks under it. I can make the model bigger and 1 pixel into the sourrounding blocks, but that doesn't look right.

Posted

I had the same issue, and I solved it by overriding the

shouldSideBeRendered

method. In that method, you get the side as a parameter. Get the according ForgeDirection from it, and get the opposite from it, as we undo the offset they did, so we can get the right coordinates. Now get the TileEntity from the world, adding the opposite to the coordinates, so you should get something like this:

TileEntity tile = world.getTileEntity(x+opposite.x, y+opposite.y, z+opposite.z);

Now return false if the multiblock is formed, and true if the multiblock isn't formed.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

Basically when I add the model directly over the redstone blocks, the texture flickers as you move around looking at it. I'm assuming this is because there are now 2 textures fighting ontop of eachother. Trying to figure out what the best way is to only show the model texture, and hide/remove the 3x3x3 blocks under it. I can make the model bigger and 1 pixel into the sourrounding blocks, but that doesn't look right.

 

That is precisely what's happening.  It's called z-fighting.

 

Most mods avoid this problem by not using vanilla blocks in their structures.  Your best bet is to create an invisible (but solid) block that replaces the redstone (or whatever) so that the original block doesn't render.  But when broken, it drops the original and kills the multiblock.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Basically when I add the model directly over the redstone blocks, the texture flickers as you move around looking at it. I'm assuming this is because there are now 2 textures fighting ontop of eachother. Trying to figure out what the best way is to only show the model texture, and hide/remove the 3x3x3 blocks under it. I can make the model bigger and 1 pixel into the sourrounding blocks, but that doesn't look right.

 

That is precisely what's happening.  It's called z-fighting.

 

Most mods avoid this problem by not using vanilla blocks in their structures.  Your best bet is to create an invisible (but solid) block that replaces the redstone (or whatever) so that the original block doesn't render.  But when broken, it drops the original and kills the multiblock.

 

Thanks for the help to all of you, appriciate it.

 

So the code below is what I got so far, it's a complete mess. I want to have a multiblock that I can set to any size with different blocks everywhere, but checking that will require thousands of if statements.

 

So how I understand it is if isMultiBlock is true set the blocks to their invisible state. But then it has to know which of the blocks the player breaks and set the invisible blocks back to the solid textured ones. Also if the player breaks the main block, how do you then set the blocks from invisible to solid textured? BreakEvents?

 

I just started school learning java so that and some tips here will hopefully get me where I want. :)

 

Edit: A friend told me about an api called beefcore for making multiblocks, might try it: https://github.com/erogenousbeef/BeefCore

public boolean isMultiBlockStructure(World world, int x, int y, int z) {

	if (checkMulti(world, x, y, z)){
		world.setBlock(x + 1, y + 0, z + 0, ModBlocks.blockInvBedrock);
		world.setBlock(x + 2, y + 0, z + 0, ModBlocks.blockInvCoal);
		world.setBlock(x + 3, y + 0, z + 0, ModBlocks.blockInvDiamond);
		world.setBlock(x + 4, y + 0, z + 0, ModBlocks.blockInvGravel);
		world.setBlock(x + 5, y + 0, z + 0, ModBlocks.blockInvMelon);
		/* North */ return true;
	}    

	if (checkIfMelonIsAir(world, x, y, z)){
		world.setBlock(x + 1, y + 0, z + 0, Blocks.bedrock);
		world.setBlock(x + 2, y + 0, z + 0, Blocks.coal_block);
		world.setBlock(x + 3, y + 0, z + 0, Blocks.diamond_block);
		world.setBlock(x + 4, y + 0, z + 0, Blocks.gravel);
	//	world.setBlock(x + 5, y + 0, z + 0, Blocks.melon_block);
		/* North */ return true;
	}    

	if (checkIfGravelIsAir(world, x, y, z)){
		world.setBlock(x + 1, y + 0, z + 0, Blocks.bedrock);
		world.setBlock(x + 2, y + 0, z + 0, Blocks.coal_block);
		world.setBlock(x + 3, y + 0, z + 0, Blocks.diamond_block);
	//	world.setBlock(x + 4, y + 0, z + 0, Blocks.gravel);
		world.setBlock(x + 5, y + 0, z + 0, Blocks.melon_block);
		/* North */ return true;
	}   

	if (checkIfDiamondIsAir(world, x, y, z)){
		world.setBlock(x + 1, y + 0, z + 0, Blocks.bedrock);
		world.setBlock(x + 2, y + 0, z + 0, Blocks.coal_block);
//		world.setBlock(x + 3, y + 0, z + 0, Blocks.diamond_block);
		world.setBlock(x + 4, y + 0, z + 0, Blocks.gravel);
		world.setBlock(x + 5, y + 0, z + 0, Blocks.melon_block);
		/* North */ return true;
	}   

	if (checkIfCoalIsAir(world, x, y, z)){
		world.setBlock(x + 1, y + 0, z + 0, Blocks.bedrock);
	//	world.setBlock(x + 2, y + 0, z + 0, Blocks.coal_block);
		world.setBlock(x + 3, y + 0, z + 0, Blocks.diamond_block);
		world.setBlock(x + 4, y + 0, z + 0, Blocks.gravel);
		world.setBlock(x + 5, y + 0, z + 0, Blocks.melon_block);
		/* North */ return true;
	}   

	if (checkIfBedrockIsAir(world, x, y, z)){
	//	world.setBlock(x + 1, y + 0, z + 0, Blocks.bedrock);
		world.setBlock(x + 2, y + 0, z + 0, Blocks.coal_block);
		world.setBlock(x + 3, y + 0, z + 0, Blocks.diamond_block);
		world.setBlock(x + 4, y + 0, z + 0, Blocks.gravel);
		world.setBlock(x + 5, y + 0, z + 0, Blocks.melon_block);
		/* North */ return true;
	}  

   return false;	
}

private static boolean checkMulti(World world, int x, int y, int z) {
	if (world.getBlock(x + 1, y + 0, z + 0) == Blocks.bedrock || world.getBlock(x + 1, y + 0, z + 0) == ModBlocks.blockInvBedrock){
		if (world.getBlock(x + 2, y + 0, z + 0) == Blocks.coal_block || world.getBlock(x + 2, y + 0, z + 0) == ModBlocks.blockInvCoal) {
			if (world.getBlock(x + 3, y + 0, z + 0) == Blocks.diamond_block || world.getBlock(x + 3, y + 0, z + 0) == ModBlocks.blockInvDiamond) {
				if (world.getBlock(x + 4, y + 0, z + 0) == Blocks.gravel || world.getBlock(x + 4, y + 0, z + 0) == ModBlocks.blockInvGravel) {
					if (world.getBlock(x + 5, y + 0, z + 0) == Blocks.melon_block || world.getBlock(x + 5, y + 0, z + 0) == ModBlocks.blockInvMelon) {
                                                    return true;
					}
				}
			}
		}
	}
	return false;
}

private static boolean checkIfMelonIsAir(World world, int x, int y, int z) {
	if (world.getBlock(x + 1, y + 0, z + 0) == ModBlocks.blockInvBedock){
		if (world.getBlock(x + 2, y + 0, z + 0) == ModBlocks.blockInvCoal) {
			if (world.getBlock(x + 3, y + 0, z + 0) == ModBlocks.blockInvDiamond) {
				if (world.getBlock(x + 4, y + 0, z + 0) == ModBlocks.blockInvGravel) {
					if (world.getBlock(x + 5, y + 0, z + 0) == Blocks.air) {
                                                    return true;
					}
				}
			}
		}
	}
	return false;
}

private static boolean checkIfGravelIsAir(World world, int x, int y, int z) {
	if (world.getBlock(x + 1, y + 0, z + 0) == ModBlocks.blockInvBedrock){
		if (world.getBlock(x + 2, y + 0, z + 0) == ModBlocks.blockInvCoal) {
			if (world.getBlock(x + 3, y + 0, z + 0) == ModBlocks.blockInvDiamond) {
				if (world.getBlock(x + 4, y + 0, z + 0) == Blocks.air) {
					if (world.getBlock(x + 5, y + 0, z + 0) == ModBlocks.blockInvMelon) {
                                                    return true;
					}
				}
			}
		}
	}
	return false;
}

private static boolean checkIfDiamondIsAir(World world, int x, int y, int z) {
	if (world.getBlock(x + 1, y + 0, z + 0) == ModBlocks.blockInvbedrock){
		if (world.getBlock(x + 2, y + 0, z + 0) == ModBlocks.blockInvCoal) {
			if (world.getBlock(x + 3, y + 0, z + 0) == Blocks.air) {
				if (world.getBlock(x + 4, y + 0, z + 0) == ModBlocks.blockInvGravel) {
					if (world.getBlock(x + 5, y + 0, z + 0) == ModBlocks.blockInvMelon) {
                                                    return true;
					}
				}
			}
		}
	}
	return false;
}

private static boolean checkIfCoalIsAir(World world, int x, int y, int z) {
	if (world.getBlock(x + 1, y + 0, z + 0) == ModBlocks.blockInvbedrock){
		if (world.getBlock(x + 2, y + 0, z + 0) == Blocks.air) {
			if (world.getBlock(x + 3, y + 0, z + 0) == ModBlocks.blockInvDiamond) {
				if (world.getBlock(x + 4, y + 0, z + 0) == ModBlocks.blockInvGravel) {
					if (world.getBlock(x + 5, y + 0, z + 0) == ModBlocks.blockInvMelon) {
                                                    return true;
					}
				}
			}
		}
	}
	return false;
}

private static boolean checkIfBedrockIsAir(World world, int x, int y, int z) {
	if (world.getBlock(x + 1, y + 0, z + 0) == Blocks.air){
		if (world.getBlock(x + 2, y + 0, z + 0) == ModBlocks.blockInvCoal) {
			if (world.getBlock(x + 3, y + 0, z + 0) == ModBlocks.blockInvDiamond) {
				if (world.getBlock(x + 4, y + 0, z + 0) == ModBlocks.blockInvGravel) {
					if (world.getBlock(x + 5, y + 0, z + 0) == ModBlocks.blockInvMelon) {
                                                    return true;
					}
				}
			}
		}
	}
	return false;
}

 

 

 

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.