Skip to content

Instantly share code, notes, and snippets.

@marchermans
Created February 26, 2016 22:57
Show Gist options
  • Save marchermans/c730ce31afcafc331f72 to your computer and use it in GitHub Desktop.
Save marchermans/c730ce31afcafc331f72 to your computer and use it in GitHub Desktop.
Anvil getExtendedState
/**
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
* metadata, such as fence connections.
*
* @param state
* @param world
* @param pos
*/
@Override
public IBlockState getExtendedState (IBlockState state, IBlockAccess world, BlockPos pos) {
if (world.getTileEntity(pos) == null) return this.state.getBaseState();
OBJModel.OBJState objState = ((IExtendedBlockState) state).getValue(OBJModel.OBJProperty.instance);
if (objState == null)
{
ArrayList<String> parts = new ArrayList<>();
parts.add(OBJModel.Group.ALL);
objState = new OBJModel.OBJState(parts, true);
}
objState.parent = new TRSRTransformation(state.getValue(FACING));
return ((IExtendedBlockState)state).withProperty(PROPERTY_ANVIL_MATERIAL, (( BlackSmithsAnvilState) ((TileEntityBlackSmithsAnvil) world.getTileEntity(pos)).getState()).getMaterial().getID()).withProperty(OBJModel.OBJProperty.instance, objState);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment