Jump to content

Recommended Posts

Posted

Hello everyone.

 

So, I have another problem, I am making a machine class for my mod, this class will have all the generic methods that all my machines will have, one of which, being registering the textures. Now, unlike the vanilla furnace, which has 2 separate blocks for on/off state, I am using metadata to do this. Now my problem is that the front texture doesn't update when the machine is on, everything else except this works. And I have a theory as to why; The registerBlockIcons method is only called when the block is created, now this isn't a problem for the vanilla furnace, as it replaces the off block with the on block, and when it does this, it is technically creating a new block, and so is re registering the textures. With my block, in my updateMachineState method (my equivalent to updateFurnaceBlockState) I am adding 1 to the metadata to set the machines state to on, and this is working fine, even with the rotations, I made it print out the metadata, and it does what I need it to. Now I have also made it print out the resource location (in the updateMachineState method) and it does update the texture name properly. Now all I need to do and cant figure out is how to re call the registerBlockIcons method, if I can do that, then it should work.

 

Any ideas on how to recall this method?

 

Thanks.

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

Posted

Your best bet is to register all the textures at once, and then just switch between those. That way, you don't need to re-run the registerBlockIcons method.

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

Well, you can just do something like this:

public void registerBlockIcons(IIconRegister reg)
{
    this.icon0=reg.registerIcon("modid:icon0");
    this.icon1=reg.registerIcon("modid:icon1");
    this.icon2=reg.registerIcon("modid:icon2");
    //etc...
}

And then, where you return the icons, you need to return diffferent icons based on the metadata.

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

Okay, so I have updated my getIcon method to this:

 

        public IIcon getIcon(int side, int meta) {

	if (side == 0 || side == 1) {
		if (side == 0) return this.sideBottom;
		if (side == 1) return this.sideTop;
	} else {
		if (meta == 0 || meta == 1) {
			if (this.isActive) return side == 2 ? this.sideFrontOn : this.blockIcon;
			else return side == 2 ? this.sideFrontOff : this.blockIcon;
		} if (meta == 2 || meta == 3) {
			if (this.isActive) return side == 5 ? this.sideFrontOn : this.blockIcon;
			else return side == 5 ? this.sideFrontOff : this.blockIcon;
		} if (meta == 4 || meta == 5) {
			if (this.isActive) return side == 3 ? this.sideFrontOn : this.blockIcon;
			else return side == 3 ? this.sideFrontOff : this.blockIcon;
		} if (meta == 6 || meta == 7) {
			if (this.isActive) return side == 4 ? this.sideFrontOn : this.blockIcon;
			else return side == 4 ? this.sideFrontOff : this.blockIcon;
		}
	}
	return blockIcon;
}

 

just a note; I have 8 metadata values, 0, 2, 4, and 6 being the rotational values while off, and 1, 3, 5, and 7 being the rotational values while on. So to turn the machine on, one is added to the metadata.

 

Should this work? I am loading my game now to find out, but it takes a while to load as I have several other mods installed.

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

Posted

Okay, so the texture does now update, but with weird consequences... And this is weird because I have no static fields or methods anywhere in my tile or block. So what is happening is well, when one machine in the world is off, and another is placed, it is fine, but if a second machine is placed with the first one on, it rotates to face the direction of the first block, and both of them update to the off texture. also when I mouse over the block in the world, the texture on the block in my hand changes to the one I am looking at. Now the way I am rotating my block is just reordering the textures on the faces depending on what angle the player is at relative to the block when placed. This is actually the only way (I know of) to do this, because I dont think that the block can actually physically rotate.

 

Any help on this?

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

Posted

The thing is though, I really dont know where the problem is at all, so I will post my whole class (bare in mind, this class is designed to support all of my machines, it isnt just for this machine, but atm I only have this machine, I have no others)

 

Also, I have alot of custom methods. and it is a long class (about 300 lined)

 

  Reveal hidden contents

 

 

UPDATE: Sorry, but I forgot to include the tileentity(s). Warning; Also messy.

 

  Reveal hidden contents

 

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

Posted

At the beginning of your class, all of these declarations are shared between all blocks in the world. That means that all blocks of that type in the world, will emit the same light, are all active at the same time and they will all spawn particles in the world at the same time. You probably need to store those in the TileEntity.

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

Okay then... what about the vanilla furnace though? variables like these were stored in the block, not the tile... im confused now

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

Posted

So out of the variables I have in the block, which ones should I store in the tile? I know things like the modid I wouldn't, but what about things like the MachineType type variable? MachineType is an enum to store what machine this class belongs to (not needed yet, but will be useful when I have multiple machines sharing this class).

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

Posted

Also, aren't things only shared between all instances of a class if the variable has a static modifier?

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

Posted

Ohh, ok, now I understand, I was thinking that because when you register the block you register it as a new block, it creates a new instance for each... ok, i get it now.

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

Posted

Also, unrelated, but I have a question that I have been curious about for a while, what is the "private static final String __OBFID = "CL_000SomeNumberHere";" that I see in many vanilla classes?

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

Posted

Okay.

 

Update on my block; I Have moved the methods in the block class to the tileentity, as this class supports all my machines, I also have a tileentity that all my machines tileentitys extend, so I have moved them all to there, I have also moved the updateBlockState method to the tileentity too.

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

Posted

I would also like to know how to make the ItemBlock in the players inventory render the front icon, at the moment, it just renders the blockIcon icon on all sides, and in the players hand, it renders whatever face the player is mousing over.

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

Posted

<associatedBlock>getBlockTextureFromSide(1) {{ which calls getIcon(1, 0) }} returns that ItemBlock's texture; that is, unless you override the Icon or the getIconFromDamage(int dmg) method.

So, your block getIcon(side,meta) method should return the front icon when it sees side 1 and meta 0.

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.