Jump to content

Recommended Posts

Posted

I am trying to change a block's texture depending on the block in the inventory of the block. What I have right now is setting the block to the texture of the block I put in the inventory, however it is also changing the block in the creative menu and not just the block i have placed in the world. I am using if statements in the getIcon method.

 

this is what I have:

 

  Reveal hidden contents

 

 

and before anyone says anything about updating to 1.10 this mod is being used in a 1.7.10 pack, so updating to 1.10 will not help me at all. thanks in advance.

-Elrol

Posted

@SideOnly(Side.CLIENT)
   public IIcon getIcon(int side, int meta){
      if(this.isAdv && this.block != null){
         return this.block.getIcon(side,meta); //why not this?
      }
   }

 

?

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

it will change to have a different texture overlay, like using the same block and adding the overlay to it, the else will be for the other 5 sides

 

when ever I add a block to the Inventory all the elevators change to that including the one in the creative menu

 

im looking for a way so that the texture is changed only on the block with the inventory and the block. so that the other blocks can have different textures, like the draw bridges from TMechworks

 

@SideOnly(Side.CLIENT)

  public IIcon getIcon(int side, int meta){

      if(this.isAdv && this.block != null){

        if(side == meta){

//this will be the texture of the block with the face overlay so the players know where it is facing

            return this.block.getBlockTextureFromSide(side);

        }else{

            return this.block.getBlockTextureFromSide(side);

        }

       

      }else{

//This is the Elevator and Advanced Elevator (if it has no block to set the texture) textures

        if(side == meta){

//This sets a side to be the face of the block, so the players can tell where the elevator is facing

            return this.side;

        }else{

            return this.blockIcon;

        }

      }

  }

Posted

Mmm. You've posted the same code again along with a bunch of words. It doesn't help me figure out why you're not using

this.block.getIcon(side,meta);

 

Yes, I skipped the "else" statement, but whatever.

 

I still don't know what the "problem" you're having even is.

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

as i have stated TWICE my issue is not about the block having the textures, it is that the change is to EVERY elevator not just the one which has the block in the invnetory. the block in the creative menu that doesnt have an inventory yet also changes. the elevator is rendering the texture of the block, but all of the other ones are too.

Posted

You need to show more of the class, then.  Post the whole thing.

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

Here it is:

 

Elevator.class

 

  Reveal hidden contents

 

 

TileEntityElevator.class

 

  Reveal hidden contents

 

 

if you need any other files, like from the GUI or what not, I will also post them. But these are the ones that deal with the textures.

 

Posted

See all this stuff?

 

	private boolean isAdv = false;
private Block block;

private TileEntityElevator tile;

 

You can't do that.  Blocks are singleton classes.  You must store this information in the TE.  You should never ever be storing a reference to the TileEntity in your block class either, that already tells you you have no idea WTF you're doing.

 

Also, don't use BlockContainer.  Override

hasTileEntity

and

createNewTileEntity

instead.

 

Also...

 

	public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
	try{
		return new TileEntityElevator();	
	}catch (Exception var3){
		throw new RuntimeException(var3);
	}

}

 

WHY ARE YOU DOING THIS.  You catch an exception for the sole purpose of throwing it again?  Why?  Not to mention that creating a new TE can't even throw an exception!

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

I am trying to learn java and how to code mods for minecraft, sadly there is no school that teaches this to a person who has no money, at least none that I know of. I have some idea of how java works, but yes I am not perfect, If I was I would not need assistance.

 

How would I get Information from the TileEntity inside the Block class for rendering the Texture Differently, I had looked through methods and didnt see any. Any help is welcomed.

Posted

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

I would store the block inside the TileEntity and then get the TileEntity from world.getTileEntityAt

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

Override

public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)

Get the TileEntity

Get the block stored in the TE

Ask it what it's icon is

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
  On 7/14/2016 at 11:18 PM, Draco18s said:

world.getTileEntityAt

 

?

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

how exactly would I get the world in the Block to get the textures from the tile entity. I know about:

 

return ((TileEntityElevator)world.getTileEntity(x, y, z)).getBlock().getIcon(side, meta);

 

but how do you get the world?

 

 

I wasnt aware about this IBlockAccess being the world. I will try it.

 

 

 

Posted

Now im just having an issue with the block updating to show the texture, im using this:

 

@Override

public void closeInventory() {

this.worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord), 1);

}

 

but it doesnt seem to work

Posted
  On 7/15/2016 at 4:07 AM, Elrol_Arrowsend said:
I wasnt aware about this IBlockAccess being the world. I will try it.

 

IBlockAccess is "world-lite" or "read-only World." 

World implements IBlockAcess

and IBlockAccess provides access to blocks (every single getter).

 

  Quote

Now im just having an issue with the block updating to show the texture, im using this:

 

@Override

public void closeInventory() {

this.worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord), 1);

}

 

but it doesnt seem to work

 

Please look at world#setBlock to know what that last parameter does.  1 is not the right value to pass.

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.

You should be passing a 3.

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.

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.