Jump to content

Custom model broken texture for hit and destroy particles [SOLVED] [1.7.10]


TheEpicTekkit

Recommended Posts

Hello everyone.

 

I have several models in my mod, and I have been ignoring this for a while now, but I would like to know how I can fix the hit effects and destroy effects for my models. Currently, they are just the purple and black broken textures. I do know about the addDestroyEffects and addHitEffects methods, but don't know how to use them properly.

 

I couldn't find any tutorials, so I have looked at the source code for Buildcraft on github, and figured it out to an extent, but it still isn't working.

 

This is my texture and hit/break effects code so far:

        public IIcon[] icon = new IIcon[8]; //I have 8 metadata subtypes for my block, so 8 icons, and this was the neatest way to save them.

        //...Irrelevant code here...

        //Only registering icons for the particle effect when hit or broken, the actual block texture is in the renderer class.
public IIcon getIcon(int side, int meta) {
	System.out.println(icon[meta]);
	if (icon[meta] != null) return icon[meta];
	else return blockIcon;
}

@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister icon) { //These resource locations are the exact same textures that the renderer uses
	this.blockIcon = icon.registerIcon(modid + ":" + "");
	this.icon[0] = icon.registerIcon(modid + ":" + "textures/models/cables/Cable_LV");
	this.icon[1] = icon.registerIcon(modid + ":" + "textures/models/cables/Cable_LV_Uninsulated");
	this.icon[2] = icon.registerIcon(modid + ":" + "textures/models/cables/Cable_MV");
	this.icon[3] = icon.registerIcon(modid + ":" + "textures/models/cables/Cable_MV_Uninsulated");
	this.icon[4] = icon.registerIcon(modid + ":" + "textures/models/cables/Cable_HV");
	this.icon[5] = icon.registerIcon(modid + ":" + "textures/models/cables/Cable_HV_Uninsulated");
	this.icon[6] = icon.registerIcon(modid + ":" + "textures/models/cables/Cable_UV");
	this.icon[7] = icon.registerIcon(modid + ":" + "textures/models/cables/Cable_UV_Uninsulated");
}

        //... More irrelevant code here...

        @Override
@SideOnly(Side.CLIENT)
public boolean addHitEffects(World world, MovingObjectPosition pos, EffectRenderer renderer) {

	int x = pos.blockX, y = pos.blockY, z = pos.blockZ;
	int meta = world.getBlockMetadata(x, y, z);

	Block block = world.getBlock(x, y, z);
	if (block == null) {
		return false;
	}

	int side = pos.sideHit;

	float i = 0.1F;
	double posX = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - (i * 2.0F)) + i + block.getBlockBoundsMinX();
	double posY = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - (i * 2.0F)) + i + block.getBlockBoundsMinY();
	double posZ = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - (i * 2.0F)) + i + block.getBlockBoundsMinZ();

	if (side == 4) posX = x + block.getBlockBoundsMinX() - i;
	if (side == 5) posX = x + block.getBlockBoundsMaxX() + i;
	if (side == 0) posY = y + block.getBlockBoundsMinY() - i;
	if (side == 1) posY = y + block.getBlockBoundsMaxY() + i;
	if (side == 2) posZ = z + block.getBlockBoundsMinZ() - i;
	if (side == 3) posZ = z + block.getBlockBoundsMaxZ() + i;

	EntityDiggingFX digFX = new EntityDiggingFX(world, posX, posY, posZ, 0.0D, 0.0D, 0.0D, block, side, world.getBlockMetadata(x, y, z));
	digFX.setParticleIcon(icon[meta]);
	renderer.addEffect(digFX.applyColourMultiplier(x, y, z).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F));
	return true;
}

@Override
@SideOnly(Side.CLIENT)
public boolean addDestroyEffects(World world, int x, int y, int z, int meta, EffectRenderer renderer) {

	Block block = world.getBlock(x, y, z);
	if (block == null) {
		return false;
	}

	byte b0 = 4;
	for (int i = 0; i < b0; ++i) {
		for (int j = 0; j < b0; ++j) {
			for (int k = 0; k < b0; ++k) {
				double px = x + (i + 0.5D) / b0;
				double py = y + (j + 0.5D) / b0;
				double pz = z + (k + 0.5D) / b0;

				int random = rand.nextInt(6);

				EntityDiggingFX fx = new EntityDiggingFX(world, px, py, pz, px - x - 0.5D, py - y - 0.5D, pz - z - 0.5D, this, random, meta);
				fx.setParticleIcon(icon[meta]);
				renderer.addEffect(fx.applyColourMultiplier(x, y, z));
			}
		}
	}
	return true;
}

 

Thanks.

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

Link to comment
Share on other sites

The render type is -1. I'm not sure, but maybe having renderAsNormalBlock and isOpaqueCube as false might be causing problems?

 

My textures are 16x16 well, four of them are, and even they still don't work, they have that aspect ratio and the size is always a power of 2, so the same as vanilla texture rules, e.g some are 128x128 but I don't see that being a problem, it still isn't working though. Do I need to create a new texture sheet specifically for the particles then?

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

Link to comment
Share on other sites

Hi

 

The "flying fragments of block" are generated using an EntityDiggingFX, which takes its texture from

 

        this.setParticleIcon(block.getIcon(side, metadata));

 

So I'm not sure why your

public IIcon getIcon(int side, int meta) {

isn't working.  (add @Override before it just in case?)

 

Does your System.out.println(icon[meta]); print something when you smash the block?

 

Does your console say "Using missing texture, unable to load" for these textures?

 

I really don't think it's anything to do with render type, isOpaqueCube, etc.

 

Try using a 16x16 texture like DieSieben and EternalDoom say and see if that solves the problem (very easy to test!) ?

 

-TGG

Link to comment
Share on other sites

Okay, so that "System.out.println(icon[meta]);" is printing out the resource location for the icons. Strangely, it only does this when I hit the block (probably because that is when it is getting called) and it is only printing out the resource for meta[0], but nevertheless, it is still a resourcelocation, and so should be working.

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

Link to comment
Share on other sites

Solved it.

 

TGG, you mentioned the console, so I loaded up the game and watched the console, and it did say missing texture. Now, my textures were in modid:textures\models\cables\texture.png and I imediatly knew the problem when I saw the console saying "Unable to load texture: modid:textures\blocks\textures\models\cables\texture.png" It was thinking the resource was in the blocks textures. So I have moved my textures and changed the resource location slightly, and it is fixed.

 

Thanks for the help guys.

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

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.