Jump to content

Recommended Posts

Posted

Im not sure what's going on here, I set the blockState for a position and it doesn't change the state. worldObj.setBlockState() returns true though, so it should be going through.

 

int heat = nextHeatValues.get(pos);
			if(heat>40){
				IBlockState temp = FlyingFortressBase.hotAir.getStateFromMeta(heat);
				worldObj.setBlockState(pos, temp);
				System.out.print("Ideal:"+heat+" :  Actual:"+FlyingFortressBase.hotAir.getMetaFromState(worldObj.getBlockState(pos)));
			}else{
				worldObj.setBlockToAir(pos);
			}

 

And my BlockHotAir code

 

public class BlockHotAir extends Block{

public static final PropertyInteger heatValue = PropertyInteger.create("heatValue", 0, 1024);

public BlockHotAir(Material materialIn) {
	super(materialIn);
}

@Override
    public void updateTick(World worldIn,BlockPos pos,IBlockState state,Random rand){

}

@Override
    public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state){

}

@Override
    public int tickRate(World worldIn){
        return 1;
    }

@Override
public String getHarvestTool(IBlockState state){
        return null;
    }

@Override protected BlockState createBlockState() { 
	return new BlockState(this, new IProperty[] {heatValue}); 
}

@Override
public IBlockState getStateFromMeta(int meta){
    return getDefaultState().withProperty(heatValue, meta);
}

@Override
public int getMetaFromState(IBlockState state){
    int i =  (Integer) state.getValue(heatValue);
    return i;
}

}

 

The getStateFromMeta and getMetaFromState are working properly, yet the values on

 

IBlockState temp = FlyingFortressBase.hotAir.getStateFromMeta(heat);

worldObj.setBlockState(pos, temp);

System.out.print("Ideal:"+heat+"Actual:"+FlyingFortressBase.hotAir.getMetaFromState(worldObj.getBlockState(pos)))

 

don't match. I have no idea how to get around the game not setting the blockstate properly D:

 

 

Also I've tried doing worldObj.setBlockToAir(pos) and then setting the state, and it's still wrong

"you seem to be THE best modder I've seen imo."

~spynathan

 

ლ(́◉◞౪◟◉‵ლ

Posted

You can store more than 16 combinations of property values if you store values in a

TileEntity

and override

Block#getActualState

to return the values from the

TileEntity

, but this is mainly useful if the block's model depends on data in the

TileEntity

. You can't use

World#setBlockState

to set the values of properties that aren't stored in the metadata.

 

In this case, you should just store the heat value in a

TileEntity

and forget about the blockstate.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Do you really need 1024 distinct states, and do you need to store them in the world? Won't your blockstates file then have 1024 cases?  :(

 

Can you get away with having 16 cases? If you're doing some physics, can you translate 16 states into 16 representative int values?

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

No this is for simulating gas spread inside of blimp balloons. If there really isnt a way to store more than 16 states then I'll just program my own storage system.

"you seem to be THE best modder I've seen imo."

~spynathan

 

ლ(́◉◞౪◟◉‵ლ

Posted

No this is for simulating gas spread inside of blimp balloons. If there really isnt a way to store more than 16 states then I'll just program my own storage system.

 

Have fun with that. Having done chunk-level saved data myself, there are a lot of pitfalls.

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.